babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * 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.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * 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).
  163. * 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.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @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.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = linear */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * 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.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. /**
  4784. * new Path3D(path, normal, raw)
  4785. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4786. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4787. * @param path an array of Vector3, the curve axis of the Path3D
  4788. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4789. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4790. */
  4791. constructor(
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4796. /**
  4797. * Returns the Path3D array of successive Vector3 designing its curve.
  4798. * @returns the Path3D array of successive Vector3 designing its curve.
  4799. */
  4800. getCurve(): Vector3[];
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4823. * @param path path which all values are copied into the curves points
  4824. * @param firstNormal which should be projected onto the curve
  4825. * @returns the same object updated.
  4826. */
  4827. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4828. private _compute;
  4829. private _getFirstNonNullVector;
  4830. private _getLastNonNullVector;
  4831. private _normalVector;
  4832. }
  4833. /**
  4834. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4835. * A Curve3 is designed from a series of successive Vector3.
  4836. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4837. */
  4838. export class Curve3 {
  4839. private _points;
  4840. private _length;
  4841. /**
  4842. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4843. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4844. * @param v1 (Vector3) the control point
  4845. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4846. * @param nbPoints (integer) the wanted number of points in the curve
  4847. * @returns the created Curve3
  4848. */
  4849. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4850. /**
  4851. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4852. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4853. * @param v1 (Vector3) the first control point
  4854. * @param v2 (Vector3) the second control point
  4855. * @param v3 (Vector3) the end point of the Cubic Bezier
  4856. * @param nbPoints (integer) the wanted number of points in the curve
  4857. * @returns the created Curve3
  4858. */
  4859. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4860. /**
  4861. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4862. * @param p1 (Vector3) the origin point of the Hermite Spline
  4863. * @param t1 (Vector3) the tangent vector at the origin point
  4864. * @param p2 (Vector3) the end point of the Hermite Spline
  4865. * @param t2 (Vector3) the tangent vector at the end point
  4866. * @param nbPoints (integer) the wanted number of points in the curve
  4867. * @returns the created Curve3
  4868. */
  4869. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4870. /**
  4871. * Returns a Curve3 object along a CatmullRom Spline curve :
  4872. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4873. * @param nbPoints (integer) the wanted number of points between each curve control points
  4874. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4875. * @returns the created Curve3
  4876. */
  4877. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4878. /**
  4879. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4880. * A Curve3 is designed from a series of successive Vector3.
  4881. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4882. * @param points points which make up the curve
  4883. */
  4884. constructor(points: Vector3[]);
  4885. /**
  4886. * @returns the Curve3 stored array of successive Vector3
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the curve.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4895. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4896. * curveA and curveB keep unchanged.
  4897. * @param curve the curve to continue from this curve
  4898. * @returns the newly constructed curve
  4899. */
  4900. continue(curve: DeepImmutable<Curve3>): Curve3;
  4901. private _computeLength;
  4902. }
  4903. }
  4904. declare module "babylonjs/Animations/easing" {
  4905. /**
  4906. * This represents the main contract an easing function should follow.
  4907. * Easing functions are used throughout the animation system.
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export interface IEasingFunction {
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4913. * of the easing function.
  4914. * The link below provides some of the most common examples of easing functions.
  4915. * @see https://easings.net/
  4916. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4917. * @returns the corresponding value on the curve defined by the easing function
  4918. */
  4919. ease(gradient: number): number;
  4920. }
  4921. /**
  4922. * Base class used for every default easing function.
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. export class EasingFunction implements IEasingFunction {
  4926. /**
  4927. * Interpolation follows the mathematical formula associated with the easing function.
  4928. */
  4929. static readonly EASINGMODE_EASEIN: number;
  4930. /**
  4931. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4932. */
  4933. static readonly EASINGMODE_EASEOUT: number;
  4934. /**
  4935. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4936. */
  4937. static readonly EASINGMODE_EASEINOUT: number;
  4938. private _easingMode;
  4939. /**
  4940. * Sets the easing mode of the current function.
  4941. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4942. */
  4943. setEasingMode(easingMode: number): void;
  4944. /**
  4945. * Gets the current easing mode.
  4946. * @returns the easing mode
  4947. */
  4948. getEasingMode(): number;
  4949. /**
  4950. * @hidden
  4951. */
  4952. easeInCore(gradient: number): number;
  4953. /**
  4954. * Given an input gradient between 0 and 1, this returns the corresponding value
  4955. * of the easing function.
  4956. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4957. * @returns the corresponding value on the curve defined by the easing function
  4958. */
  4959. ease(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a circle shape (see link below).
  4963. * @see https://easings.net/#easeInCirc
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. export class CircleEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a ease back shape (see link below).
  4972. * @see https://easings.net/#easeInBack
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. export class BackEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the amplitude of the function */
  4977. amplitude: number;
  4978. /**
  4979. * Instantiates a back ease easing
  4980. * @see https://easings.net/#easeInBack
  4981. * @param amplitude Defines the amplitude of the function
  4982. */
  4983. constructor(
  4984. /** Defines the amplitude of the function */
  4985. amplitude?: number);
  4986. /** @hidden */
  4987. easeInCore(gradient: number): number;
  4988. }
  4989. /**
  4990. * Easing function with a bouncing shape (see link below).
  4991. * @see https://easings.net/#easeInBounce
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export class BounceEase extends EasingFunction implements IEasingFunction {
  4995. /** Defines the number of bounces */
  4996. bounces: number;
  4997. /** Defines the amplitude of the bounce */
  4998. bounciness: number;
  4999. /**
  5000. * Instantiates a bounce easing
  5001. * @see https://easings.net/#easeInBounce
  5002. * @param bounces Defines the number of bounces
  5003. * @param bounciness Defines the amplitude of the bounce
  5004. */
  5005. constructor(
  5006. /** Defines the number of bounces */
  5007. bounces?: number,
  5008. /** Defines the amplitude of the bounce */
  5009. bounciness?: number);
  5010. /** @hidden */
  5011. easeInCore(gradient: number): number;
  5012. }
  5013. /**
  5014. * Easing function with a power of 3 shape (see link below).
  5015. * @see https://easings.net/#easeInCubic
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export class CubicEase extends EasingFunction implements IEasingFunction {
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. /**
  5023. * Easing function with an elastic shape (see link below).
  5024. * @see https://easings.net/#easeInElastic
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5028. /** Defines the number of oscillations*/
  5029. oscillations: number;
  5030. /** Defines the amplitude of the oscillations*/
  5031. springiness: number;
  5032. /**
  5033. * Instantiates an elastic easing function
  5034. * @see https://easings.net/#easeInElastic
  5035. * @param oscillations Defines the number of oscillations
  5036. * @param springiness Defines the amplitude of the oscillations
  5037. */
  5038. constructor(
  5039. /** Defines the number of oscillations*/
  5040. oscillations?: number,
  5041. /** Defines the amplitude of the oscillations*/
  5042. springiness?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with an exponential shape (see link below).
  5048. * @see https://easings.net/#easeInExpo
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the exponent of the function */
  5053. exponent: number;
  5054. /**
  5055. * Instantiates an exponential easing function
  5056. * @see https://easings.net/#easeInExpo
  5057. * @param exponent Defines the exponent of the function
  5058. */
  5059. constructor(
  5060. /** Defines the exponent of the function */
  5061. exponent?: number);
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. /**
  5066. * Easing function with a power shape (see link below).
  5067. * @see https://easings.net/#easeInQuad
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export class PowerEase extends EasingFunction implements IEasingFunction {
  5071. /** Defines the power of the function */
  5072. power: number;
  5073. /**
  5074. * Instantiates an power base easing function
  5075. * @see https://easings.net/#easeInQuad
  5076. * @param power Defines the power of the function
  5077. */
  5078. constructor(
  5079. /** Defines the power of the function */
  5080. power?: number);
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a power of 2 shape (see link below).
  5086. * @see https://easings.net/#easeInQuad
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5090. /** @hidden */
  5091. easeInCore(gradient: number): number;
  5092. }
  5093. /**
  5094. * Easing function with a power of 4 shape (see link below).
  5095. * @see https://easings.net/#easeInQuart
  5096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5097. */
  5098. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 5 shape (see link below).
  5104. * @see https://easings.net/#easeInQuint
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with a sin shape (see link below).
  5113. * @see https://easings.net/#easeInSine
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class SineEase extends EasingFunction implements IEasingFunction {
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a bezier shape (see link below).
  5122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5126. /** Defines the x component of the start tangent in the bezier curve */
  5127. x1: number;
  5128. /** Defines the y component of the start tangent in the bezier curve */
  5129. y1: number;
  5130. /** Defines the x component of the end tangent in the bezier curve */
  5131. x2: number;
  5132. /** Defines the y component of the end tangent in the bezier curve */
  5133. y2: number;
  5134. /**
  5135. * Instantiates a bezier function
  5136. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5137. * @param x1 Defines the x component of the start tangent in the bezier curve
  5138. * @param y1 Defines the y component of the start tangent in the bezier curve
  5139. * @param x2 Defines the x component of the end tangent in the bezier curve
  5140. * @param y2 Defines the y component of the end tangent in the bezier curve
  5141. */
  5142. constructor(
  5143. /** Defines the x component of the start tangent in the bezier curve */
  5144. x1?: number,
  5145. /** Defines the y component of the start tangent in the bezier curve */
  5146. y1?: number,
  5147. /** Defines the x component of the end tangent in the bezier curve */
  5148. x2?: number,
  5149. /** Defines the y component of the end tangent in the bezier curve */
  5150. y2?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. }
  5155. declare module "babylonjs/Maths/math.color" {
  5156. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5157. /**
  5158. * Class used to hold a RBG color
  5159. */
  5160. export class Color3 {
  5161. /**
  5162. * Defines the red component (between 0 and 1, default is 0)
  5163. */
  5164. r: number;
  5165. /**
  5166. * Defines the green component (between 0 and 1, default is 0)
  5167. */
  5168. g: number;
  5169. /**
  5170. * Defines the blue component (between 0 and 1, default is 0)
  5171. */
  5172. b: number;
  5173. /**
  5174. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5175. * @param r defines the red component (between 0 and 1, default is 0)
  5176. * @param g defines the green component (between 0 and 1, default is 0)
  5177. * @param b defines the blue component (between 0 and 1, default is 0)
  5178. */
  5179. constructor(
  5180. /**
  5181. * Defines the red component (between 0 and 1, default is 0)
  5182. */
  5183. r?: number,
  5184. /**
  5185. * Defines the green component (between 0 and 1, default is 0)
  5186. */
  5187. g?: number,
  5188. /**
  5189. * Defines the blue component (between 0 and 1, default is 0)
  5190. */
  5191. b?: number);
  5192. /**
  5193. * Creates a string with the Color3 current values
  5194. * @returns the string representation of the Color3 object
  5195. */
  5196. toString(): string;
  5197. /**
  5198. * Returns the string "Color3"
  5199. * @returns "Color3"
  5200. */
  5201. getClassName(): string;
  5202. /**
  5203. * Compute the Color3 hash code
  5204. * @returns an unique number that can be used to hash Color3 objects
  5205. */
  5206. getHashCode(): number;
  5207. /**
  5208. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5209. * @param array defines the array where to store the r,g,b components
  5210. * @param index defines an optional index in the target array to define where to start storing values
  5211. * @returns the current Color3 object
  5212. */
  5213. toArray(array: FloatArray, index?: number): Color3;
  5214. /**
  5215. * Returns a new Color4 object from the current Color3 and the given alpha
  5216. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5217. * @returns a new Color4 object
  5218. */
  5219. toColor4(alpha?: number): Color4;
  5220. /**
  5221. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5222. * @returns the new array
  5223. */
  5224. asArray(): number[];
  5225. /**
  5226. * Returns the luminance value
  5227. * @returns a float value
  5228. */
  5229. toLuminance(): number;
  5230. /**
  5231. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5232. * @param otherColor defines the second operand
  5233. * @returns the new Color3 object
  5234. */
  5235. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5236. /**
  5237. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5238. * @param otherColor defines the second operand
  5239. * @param result defines the Color3 object where to store the result
  5240. * @returns the current Color3
  5241. */
  5242. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5243. /**
  5244. * Determines equality between Color3 objects
  5245. * @param otherColor defines the second operand
  5246. * @returns true if the rgb values are equal to the given ones
  5247. */
  5248. equals(otherColor: DeepImmutable<Color3>): boolean;
  5249. /**
  5250. * Determines equality between the current Color3 object and a set of r,b,g values
  5251. * @param r defines the red component to check
  5252. * @param g defines the green component to check
  5253. * @param b defines the blue component to check
  5254. * @returns true if the rgb values are equal to the given ones
  5255. */
  5256. equalsFloats(r: number, g: number, b: number): boolean;
  5257. /**
  5258. * Multiplies in place each rgb value by scale
  5259. * @param scale defines the scaling factor
  5260. * @returns the updated Color3
  5261. */
  5262. scale(scale: number): Color3;
  5263. /**
  5264. * Multiplies the rgb values by scale and stores the result into "result"
  5265. * @param scale defines the scaling factor
  5266. * @param result defines the Color3 object where to store the result
  5267. * @returns the unmodified current Color3
  5268. */
  5269. scaleToRef(scale: number, result: Color3): Color3;
  5270. /**
  5271. * Scale the current Color3 values by a factor and add the result to a given Color3
  5272. * @param scale defines the scale factor
  5273. * @param result defines color to store the result into
  5274. * @returns the unmodified current Color3
  5275. */
  5276. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5277. /**
  5278. * Clamps the rgb values by the min and max values and stores the result into "result"
  5279. * @param min defines minimum clamping value (default is 0)
  5280. * @param max defines maximum clamping value (default is 1)
  5281. * @param result defines color to store the result into
  5282. * @returns the original Color3
  5283. */
  5284. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5285. /**
  5286. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5287. * @param otherColor defines the second operand
  5288. * @returns the new Color3
  5289. */
  5290. add(otherColor: DeepImmutable<Color3>): Color3;
  5291. /**
  5292. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5293. * @param otherColor defines the second operand
  5294. * @param result defines Color3 object to store the result into
  5295. * @returns the unmodified current Color3
  5296. */
  5297. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5298. /**
  5299. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5300. * @param otherColor defines the second operand
  5301. * @returns the new Color3
  5302. */
  5303. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5304. /**
  5305. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5306. * @param otherColor defines the second operand
  5307. * @param result defines Color3 object to store the result into
  5308. * @returns the unmodified current Color3
  5309. */
  5310. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5311. /**
  5312. * Copy the current object
  5313. * @returns a new Color3 copied the current one
  5314. */
  5315. clone(): Color3;
  5316. /**
  5317. * Copies the rgb values from the source in the current Color3
  5318. * @param source defines the source Color3 object
  5319. * @returns the updated Color3 object
  5320. */
  5321. copyFrom(source: DeepImmutable<Color3>): Color3;
  5322. /**
  5323. * Updates the Color3 rgb values from the given floats
  5324. * @param r defines the red component to read from
  5325. * @param g defines the green component to read from
  5326. * @param b defines the blue component to read from
  5327. * @returns the current Color3 object
  5328. */
  5329. copyFromFloats(r: number, g: number, b: number): Color3;
  5330. /**
  5331. * Updates the Color3 rgb values from the given floats
  5332. * @param r defines the red component to read from
  5333. * @param g defines the green component to read from
  5334. * @param b defines the blue component to read from
  5335. * @returns the current Color3 object
  5336. */
  5337. set(r: number, g: number, b: number): Color3;
  5338. /**
  5339. * Compute the Color3 hexadecimal code as a string
  5340. * @returns a string containing the hexadecimal representation of the Color3 object
  5341. */
  5342. toHexString(): string;
  5343. /**
  5344. * Computes a new Color3 converted from the current one to linear space
  5345. * @returns a new Color3 object
  5346. */
  5347. toLinearSpace(): Color3;
  5348. /**
  5349. * Converts current color in rgb space to HSV values
  5350. * @returns a new color3 representing the HSV values
  5351. */
  5352. toHSV(): Color3;
  5353. /**
  5354. * Converts current color in rgb space to HSV values
  5355. * @param result defines the Color3 where to store the HSV values
  5356. */
  5357. toHSVToRef(result: Color3): void;
  5358. /**
  5359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5360. * @param convertedColor defines the Color3 object where to store the linear space version
  5361. * @returns the unmodified Color3
  5362. */
  5363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5364. /**
  5365. * Computes a new Color3 converted from the current one to gamma space
  5366. * @returns a new Color3 object
  5367. */
  5368. toGammaSpace(): Color3;
  5369. /**
  5370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5371. * @param convertedColor defines the Color3 object where to store the gamma space version
  5372. * @returns the unmodified Color3
  5373. */
  5374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5375. private static _BlackReadOnly;
  5376. /**
  5377. * Convert Hue, saturation and value to a Color3 (RGB)
  5378. * @param hue defines the hue
  5379. * @param saturation defines the saturation
  5380. * @param value defines the value
  5381. * @param result defines the Color3 where to store the RGB values
  5382. */
  5383. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5384. /**
  5385. * Creates a new Color3 from the string containing valid hexadecimal values
  5386. * @param hex defines a string containing valid hexadecimal values
  5387. * @returns a new Color3 object
  5388. */
  5389. static FromHexString(hex: string): Color3;
  5390. /**
  5391. * Creates a new Color3 from the starting index of the given array
  5392. * @param array defines the source array
  5393. * @param offset defines an offset in the source array
  5394. * @returns a new Color3 object
  5395. */
  5396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5397. /**
  5398. * Creates a new Color3 from integer values (< 256)
  5399. * @param r defines the red component to read from (value between 0 and 255)
  5400. * @param g defines the green component to read from (value between 0 and 255)
  5401. * @param b defines the blue component to read from (value between 0 and 255)
  5402. * @returns a new Color3 object
  5403. */
  5404. static FromInts(r: number, g: number, b: number): Color3;
  5405. /**
  5406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5407. * @param start defines the start Color3 value
  5408. * @param end defines the end Color3 value
  5409. * @param amount defines the gradient value between start and end
  5410. * @returns a new Color3 object
  5411. */
  5412. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5413. /**
  5414. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5415. * @param left defines the start value
  5416. * @param right defines the end value
  5417. * @param amount defines the gradient factor
  5418. * @param result defines the Color3 object where to store the result
  5419. */
  5420. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5421. /**
  5422. * Returns a Color3 value containing a red color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Red(): Color3;
  5426. /**
  5427. * Returns a Color3 value containing a green color
  5428. * @returns a new Color3 object
  5429. */
  5430. static Green(): Color3;
  5431. /**
  5432. * Returns a Color3 value containing a blue color
  5433. * @returns a new Color3 object
  5434. */
  5435. static Blue(): Color3;
  5436. /**
  5437. * Returns a Color3 value containing a black color
  5438. * @returns a new Color3 object
  5439. */
  5440. static Black(): Color3;
  5441. /**
  5442. * Gets a Color3 value containing a black color that must not be updated
  5443. */
  5444. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5445. /**
  5446. * Returns a Color3 value containing a white color
  5447. * @returns a new Color3 object
  5448. */
  5449. static White(): Color3;
  5450. /**
  5451. * Returns a Color3 value containing a purple color
  5452. * @returns a new Color3 object
  5453. */
  5454. static Purple(): Color3;
  5455. /**
  5456. * Returns a Color3 value containing a magenta color
  5457. * @returns a new Color3 object
  5458. */
  5459. static Magenta(): Color3;
  5460. /**
  5461. * Returns a Color3 value containing a yellow color
  5462. * @returns a new Color3 object
  5463. */
  5464. static Yellow(): Color3;
  5465. /**
  5466. * Returns a Color3 value containing a gray color
  5467. * @returns a new Color3 object
  5468. */
  5469. static Gray(): Color3;
  5470. /**
  5471. * Returns a Color3 value containing a teal color
  5472. * @returns a new Color3 object
  5473. */
  5474. static Teal(): Color3;
  5475. /**
  5476. * Returns a Color3 value containing a random color
  5477. * @returns a new Color3 object
  5478. */
  5479. static Random(): Color3;
  5480. }
  5481. /**
  5482. * Class used to hold a RBGA color
  5483. */
  5484. export class Color4 {
  5485. /**
  5486. * Defines the red component (between 0 and 1, default is 0)
  5487. */
  5488. r: number;
  5489. /**
  5490. * Defines the green component (between 0 and 1, default is 0)
  5491. */
  5492. g: number;
  5493. /**
  5494. * Defines the blue component (between 0 and 1, default is 0)
  5495. */
  5496. b: number;
  5497. /**
  5498. * Defines the alpha component (between 0 and 1, default is 1)
  5499. */
  5500. a: number;
  5501. /**
  5502. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5503. * @param r defines the red component (between 0 and 1, default is 0)
  5504. * @param g defines the green component (between 0 and 1, default is 0)
  5505. * @param b defines the blue component (between 0 and 1, default is 0)
  5506. * @param a defines the alpha component (between 0 and 1, default is 1)
  5507. */
  5508. constructor(
  5509. /**
  5510. * Defines the red component (between 0 and 1, default is 0)
  5511. */
  5512. r?: number,
  5513. /**
  5514. * Defines the green component (between 0 and 1, default is 0)
  5515. */
  5516. g?: number,
  5517. /**
  5518. * Defines the blue component (between 0 and 1, default is 0)
  5519. */
  5520. b?: number,
  5521. /**
  5522. * Defines the alpha component (between 0 and 1, default is 1)
  5523. */
  5524. a?: number);
  5525. /**
  5526. * Adds in place the given Color4 values to the current Color4 object
  5527. * @param right defines the second operand
  5528. * @returns the current updated Color4 object
  5529. */
  5530. addInPlace(right: DeepImmutable<Color4>): Color4;
  5531. /**
  5532. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5533. * @returns the new array
  5534. */
  5535. asArray(): number[];
  5536. /**
  5537. * Stores from the starting index in the given array the Color4 successive values
  5538. * @param array defines the array where to store the r,g,b components
  5539. * @param index defines an optional index in the target array to define where to start storing values
  5540. * @returns the current Color4 object
  5541. */
  5542. toArray(array: number[], index?: number): Color4;
  5543. /**
  5544. * Determines equality between Color4 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgba values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color4>): boolean;
  5549. /**
  5550. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5551. * @param right defines the second operand
  5552. * @returns a new Color4 object
  5553. */
  5554. add(right: DeepImmutable<Color4>): Color4;
  5555. /**
  5556. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5557. * @param right defines the second operand
  5558. * @returns a new Color4 object
  5559. */
  5560. subtract(right: DeepImmutable<Color4>): Color4;
  5561. /**
  5562. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5563. * @param right defines the second operand
  5564. * @param result defines the Color4 object where to store the result
  5565. * @returns the current Color4 object
  5566. */
  5567. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5568. /**
  5569. * Creates a new Color4 with the current Color4 values multiplied by scale
  5570. * @param scale defines the scaling factor to apply
  5571. * @returns a new Color4 object
  5572. */
  5573. scale(scale: number): Color4;
  5574. /**
  5575. * Multiplies the current Color4 values by scale and stores the result in "result"
  5576. * @param scale defines the scaling factor to apply
  5577. * @param result defines the Color4 object where to store the result
  5578. * @returns the current unmodified Color4
  5579. */
  5580. scaleToRef(scale: number, result: Color4): Color4;
  5581. /**
  5582. * Scale the current Color4 values by a factor and add the result to a given Color4
  5583. * @param scale defines the scale factor
  5584. * @param result defines the Color4 object where to store the result
  5585. * @returns the unmodified current Color4
  5586. */
  5587. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5588. /**
  5589. * Clamps the rgb values by the min and max values and stores the result into "result"
  5590. * @param min defines minimum clamping value (default is 0)
  5591. * @param max defines maximum clamping value (default is 1)
  5592. * @param result defines color to store the result into.
  5593. * @returns the cuurent Color4
  5594. */
  5595. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5596. /**
  5597. * Multipy an Color4 value by another and return a new Color4 object
  5598. * @param color defines the Color4 value to multiply by
  5599. * @returns a new Color4 object
  5600. */
  5601. multiply(color: Color4): Color4;
  5602. /**
  5603. * Multipy a Color4 value by another and push the result in a reference value
  5604. * @param color defines the Color4 value to multiply by
  5605. * @param result defines the Color4 to fill the result in
  5606. * @returns the result Color4
  5607. */
  5608. multiplyToRef(color: Color4, result: Color4): Color4;
  5609. /**
  5610. * Creates a string with the Color4 current values
  5611. * @returns the string representation of the Color4 object
  5612. */
  5613. toString(): string;
  5614. /**
  5615. * Returns the string "Color4"
  5616. * @returns "Color4"
  5617. */
  5618. getClassName(): string;
  5619. /**
  5620. * Compute the Color4 hash code
  5621. * @returns an unique number that can be used to hash Color4 objects
  5622. */
  5623. getHashCode(): number;
  5624. /**
  5625. * Creates a new Color4 copied from the current one
  5626. * @returns a new Color4 object
  5627. */
  5628. clone(): Color4;
  5629. /**
  5630. * Copies the given Color4 values into the current one
  5631. * @param source defines the source Color4 object
  5632. * @returns the current updated Color4 object
  5633. */
  5634. copyFrom(source: Color4): Color4;
  5635. /**
  5636. * Copies the given float values into the current one
  5637. * @param r defines the red component to read from
  5638. * @param g defines the green component to read from
  5639. * @param b defines the blue component to read from
  5640. * @param a defines the alpha component to read from
  5641. * @returns the current updated Color4 object
  5642. */
  5643. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5644. /**
  5645. * Copies the given float values into the current one
  5646. * @param r defines the red component to read from
  5647. * @param g defines the green component to read from
  5648. * @param b defines the blue component to read from
  5649. * @param a defines the alpha component to read from
  5650. * @returns the current updated Color4 object
  5651. */
  5652. set(r: number, g: number, b: number, a: number): Color4;
  5653. /**
  5654. * Compute the Color4 hexadecimal code as a string
  5655. * @returns a string containing the hexadecimal representation of the Color4 object
  5656. */
  5657. toHexString(): string;
  5658. /**
  5659. * Computes a new Color4 converted from the current one to linear space
  5660. * @returns a new Color4 object
  5661. */
  5662. toLinearSpace(): Color4;
  5663. /**
  5664. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5665. * @param convertedColor defines the Color4 object where to store the linear space version
  5666. * @returns the unmodified Color4
  5667. */
  5668. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5669. /**
  5670. * Computes a new Color4 converted from the current one to gamma space
  5671. * @returns a new Color4 object
  5672. */
  5673. toGammaSpace(): Color4;
  5674. /**
  5675. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5676. * @param convertedColor defines the Color4 object where to store the gamma space version
  5677. * @returns the unmodified Color4
  5678. */
  5679. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5680. /**
  5681. * Creates a new Color4 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color4 object
  5684. */
  5685. static FromHexString(hex: string): Color4;
  5686. /**
  5687. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5688. * @param left defines the start value
  5689. * @param right defines the end value
  5690. * @param amount defines the gradient factor
  5691. * @returns a new Color4 object
  5692. */
  5693. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5694. /**
  5695. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color4 object where to store data
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5702. /**
  5703. * Creates a new Color4 from a Color3 and an alpha value
  5704. * @param color3 defines the source Color3 to read from
  5705. * @param alpha defines the alpha component (1.0 by default)
  5706. * @returns a new Color4 object
  5707. */
  5708. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5709. /**
  5710. * Creates a new Color4 from the starting index element of the given array
  5711. * @param array defines the source array to read from
  5712. * @param offset defines the offset in the source array
  5713. * @returns a new Color4 object
  5714. */
  5715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5716. /**
  5717. * Creates a new Color3 from integer values (< 256)
  5718. * @param r defines the red component to read from (value between 0 and 255)
  5719. * @param g defines the green component to read from (value between 0 and 255)
  5720. * @param b defines the blue component to read from (value between 0 and 255)
  5721. * @param a defines the alpha component to read from (value between 0 and 255)
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Check the content of a given array and convert it to an array containing RGBA data
  5727. * If the original array was already containing count * 4 values then it is returned directly
  5728. * @param colors defines the array to check
  5729. * @param count defines the number of RGBA data to expect
  5730. * @returns an array containing count * 4 values (RGBA)
  5731. */
  5732. static CheckColors4(colors: number[], count: number): number[];
  5733. }
  5734. /**
  5735. * @hidden
  5736. */
  5737. export class TmpColors {
  5738. static Color3: Color3[];
  5739. static Color4: Color4[];
  5740. }
  5741. }
  5742. declare module "babylonjs/Animations/animationKey" {
  5743. /**
  5744. * Defines an interface which represents an animation key frame
  5745. */
  5746. export interface IAnimationKey {
  5747. /**
  5748. * Frame of the key frame
  5749. */
  5750. frame: number;
  5751. /**
  5752. * Value at the specifies key frame
  5753. */
  5754. value: any;
  5755. /**
  5756. * The input tangent for the cubic hermite spline
  5757. */
  5758. inTangent?: any;
  5759. /**
  5760. * The output tangent for the cubic hermite spline
  5761. */
  5762. outTangent?: any;
  5763. /**
  5764. * The animation interpolation type
  5765. */
  5766. interpolation?: AnimationKeyInterpolation;
  5767. }
  5768. /**
  5769. * Enum for the animation key frame interpolation type
  5770. */
  5771. export enum AnimationKeyInterpolation {
  5772. /**
  5773. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5774. */
  5775. STEP = 1
  5776. }
  5777. }
  5778. declare module "babylonjs/Animations/animationRange" {
  5779. /**
  5780. * Represents the range of an animation
  5781. */
  5782. export class AnimationRange {
  5783. /**The name of the animation range**/
  5784. name: string;
  5785. /**The starting frame of the animation */
  5786. from: number;
  5787. /**The ending frame of the animation*/
  5788. to: number;
  5789. /**
  5790. * Initializes the range of an animation
  5791. * @param name The name of the animation range
  5792. * @param from The starting frame of the animation
  5793. * @param to The ending frame of the animation
  5794. */
  5795. constructor(
  5796. /**The name of the animation range**/
  5797. name: string,
  5798. /**The starting frame of the animation */
  5799. from: number,
  5800. /**The ending frame of the animation*/
  5801. to: number);
  5802. /**
  5803. * Makes a copy of the animation range
  5804. * @returns A copy of the animation range
  5805. */
  5806. clone(): AnimationRange;
  5807. }
  5808. }
  5809. declare module "babylonjs/Animations/animationEvent" {
  5810. /**
  5811. * Composed of a frame, and an action function
  5812. */
  5813. export class AnimationEvent {
  5814. /** The frame for which the event is triggered **/
  5815. frame: number;
  5816. /** The event to perform when triggered **/
  5817. action: (currentFrame: number) => void;
  5818. /** Specifies if the event should be triggered only once**/
  5819. onlyOnce?: boolean | undefined;
  5820. /**
  5821. * Specifies if the animation event is done
  5822. */
  5823. isDone: boolean;
  5824. /**
  5825. * Initializes the animation event
  5826. * @param frame The frame for which the event is triggered
  5827. * @param action The event to perform when triggered
  5828. * @param onlyOnce Specifies if the event should be triggered only once
  5829. */
  5830. constructor(
  5831. /** The frame for which the event is triggered **/
  5832. frame: number,
  5833. /** The event to perform when triggered **/
  5834. action: (currentFrame: number) => void,
  5835. /** Specifies if the event should be triggered only once**/
  5836. onlyOnce?: boolean | undefined);
  5837. /** @hidden */
  5838. _clone(): AnimationEvent;
  5839. }
  5840. }
  5841. declare module "babylonjs/Behaviors/behavior" {
  5842. import { Nullable } from "babylonjs/types";
  5843. /**
  5844. * Interface used to define a behavior
  5845. */
  5846. export interface Behavior<T> {
  5847. /** gets or sets behavior's name */
  5848. name: string;
  5849. /**
  5850. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5851. */
  5852. init(): void;
  5853. /**
  5854. * Called when the behavior is attached to a target
  5855. * @param target defines the target where the behavior is attached to
  5856. */
  5857. attach(target: T): void;
  5858. /**
  5859. * Called when the behavior is detached from its target
  5860. */
  5861. detach(): void;
  5862. }
  5863. /**
  5864. * Interface implemented by classes supporting behaviors
  5865. */
  5866. export interface IBehaviorAware<T> {
  5867. /**
  5868. * Attach a behavior
  5869. * @param behavior defines the behavior to attach
  5870. * @returns the current host
  5871. */
  5872. addBehavior(behavior: Behavior<T>): T;
  5873. /**
  5874. * Remove a behavior from the current object
  5875. * @param behavior defines the behavior to detach
  5876. * @returns the current host
  5877. */
  5878. removeBehavior(behavior: Behavior<T>): T;
  5879. /**
  5880. * Gets a behavior using its name to search
  5881. * @param name defines the name to search
  5882. * @returns the behavior or null if not found
  5883. */
  5884. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5885. }
  5886. }
  5887. declare module "babylonjs/Misc/smartArray" {
  5888. /**
  5889. * Defines an array and its length.
  5890. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5891. */
  5892. export interface ISmartArrayLike<T> {
  5893. /**
  5894. * The data of the array.
  5895. */
  5896. data: Array<T>;
  5897. /**
  5898. * The active length of the array.
  5899. */
  5900. length: number;
  5901. }
  5902. /**
  5903. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5904. */
  5905. export class SmartArray<T> implements ISmartArrayLike<T> {
  5906. /**
  5907. * The full set of data from the array.
  5908. */
  5909. data: Array<T>;
  5910. /**
  5911. * The active length of the array.
  5912. */
  5913. length: number;
  5914. protected _id: number;
  5915. /**
  5916. * Instantiates a Smart Array.
  5917. * @param capacity defines the default capacity of the array.
  5918. */
  5919. constructor(capacity: number);
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * @param value defines the object to push in the array.
  5923. */
  5924. push(value: T): void;
  5925. /**
  5926. * Iterates over the active data and apply the lambda to them.
  5927. * @param func defines the action to apply on each value.
  5928. */
  5929. forEach(func: (content: T) => void): void;
  5930. /**
  5931. * Sorts the full sets of data.
  5932. * @param compareFn defines the comparison function to apply.
  5933. */
  5934. sort(compareFn: (a: T, b: T) => number): void;
  5935. /**
  5936. * Resets the active data to an empty array.
  5937. */
  5938. reset(): void;
  5939. /**
  5940. * Releases all the data from the array as well as the array.
  5941. */
  5942. dispose(): void;
  5943. /**
  5944. * Concats the active data with a given array.
  5945. * @param array defines the data to concatenate with.
  5946. */
  5947. concat(array: any): void;
  5948. /**
  5949. * Returns the position of a value in the active data.
  5950. * @param value defines the value to find the index for
  5951. * @returns the index if found in the active data otherwise -1
  5952. */
  5953. indexOf(value: T): number;
  5954. /**
  5955. * Returns whether an element is part of the active data.
  5956. * @param value defines the value to look for
  5957. * @returns true if found in the active data otherwise false
  5958. */
  5959. contains(value: T): boolean;
  5960. private static _GlobalId;
  5961. }
  5962. /**
  5963. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5964. * The data in this array can only be present once
  5965. */
  5966. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5967. private _duplicateId;
  5968. /**
  5969. * Pushes a value at the end of the active data.
  5970. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5971. * @param value defines the object to push in the array.
  5972. */
  5973. push(value: T): void;
  5974. /**
  5975. * Pushes a value at the end of the active data.
  5976. * If the data is already present, it won t be added again
  5977. * @param value defines the object to push in the array.
  5978. * @returns true if added false if it was already present
  5979. */
  5980. pushNoDuplicate(value: T): boolean;
  5981. /**
  5982. * Resets the active data to an empty array.
  5983. */
  5984. reset(): void;
  5985. /**
  5986. * Concats the active data with a given array.
  5987. * This ensures no dupplicate will be present in the result.
  5988. * @param array defines the data to concatenate with.
  5989. */
  5990. concatWithNoDuplicate(array: any): void;
  5991. }
  5992. }
  5993. declare module "babylonjs/Cameras/cameraInputsManager" {
  5994. import { Nullable } from "babylonjs/types";
  5995. import { Camera } from "babylonjs/Cameras/camera";
  5996. /**
  5997. * @ignore
  5998. * This is a list of all the different input types that are available in the application.
  5999. * Fo instance: ArcRotateCameraGamepadInput...
  6000. */
  6001. export var CameraInputTypes: {};
  6002. /**
  6003. * This is the contract to implement in order to create a new input class.
  6004. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6005. */
  6006. export interface ICameraInput<TCamera extends Camera> {
  6007. /**
  6008. * Defines the camera the input is attached to.
  6009. */
  6010. camera: Nullable<TCamera>;
  6011. /**
  6012. * Gets the class name of the current intput.
  6013. * @returns the class name
  6014. */
  6015. getClassName(): string;
  6016. /**
  6017. * Get the friendly name associated with the input class.
  6018. * @returns the input friendly name
  6019. */
  6020. getSimpleName(): string;
  6021. /**
  6022. * Attach the input controls to a specific dom element to get the input from.
  6023. * @param element Defines the element the controls should be listened from
  6024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6025. */
  6026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6027. /**
  6028. * Detach the current controls from the specified dom element.
  6029. * @param element Defines the element to stop listening the inputs from
  6030. */
  6031. detachControl(element: Nullable<HTMLElement>): void;
  6032. /**
  6033. * Update the current camera state depending on the inputs that have been used this frame.
  6034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6035. */
  6036. checkInputs?: () => void;
  6037. }
  6038. /**
  6039. * Represents a map of input types to input instance or input index to input instance.
  6040. */
  6041. export interface CameraInputsMap<TCamera extends Camera> {
  6042. /**
  6043. * Accessor to the input by input type.
  6044. */
  6045. [name: string]: ICameraInput<TCamera>;
  6046. /**
  6047. * Accessor to the input by input index.
  6048. */
  6049. [idx: number]: ICameraInput<TCamera>;
  6050. }
  6051. /**
  6052. * This represents the input manager used within a camera.
  6053. * It helps dealing with all the different kind of input attached to a camera.
  6054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6055. */
  6056. export class CameraInputsManager<TCamera extends Camera> {
  6057. /**
  6058. * Defines the list of inputs attahed to the camera.
  6059. */
  6060. attached: CameraInputsMap<TCamera>;
  6061. /**
  6062. * Defines the dom element the camera is collecting inputs from.
  6063. * This is null if the controls have not been attached.
  6064. */
  6065. attachedElement: Nullable<HTMLElement>;
  6066. /**
  6067. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6068. */
  6069. noPreventDefault: boolean;
  6070. /**
  6071. * Defined the camera the input manager belongs to.
  6072. */
  6073. camera: TCamera;
  6074. /**
  6075. * Update the current camera state depending on the inputs that have been used this frame.
  6076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6077. */
  6078. checkInputs: () => void;
  6079. /**
  6080. * Instantiate a new Camera Input Manager.
  6081. * @param camera Defines the camera the input manager blongs to
  6082. */
  6083. constructor(camera: TCamera);
  6084. /**
  6085. * Add an input method to a camera
  6086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6087. * @param input camera input method
  6088. */
  6089. add(input: ICameraInput<TCamera>): void;
  6090. /**
  6091. * Remove a specific input method from a camera
  6092. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6093. * @param inputToRemove camera input method
  6094. */
  6095. remove(inputToRemove: ICameraInput<TCamera>): void;
  6096. /**
  6097. * Remove a specific input type from a camera
  6098. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6099. * @param inputType the type of the input to remove
  6100. */
  6101. removeByType(inputType: string): void;
  6102. private _addCheckInputs;
  6103. /**
  6104. * Attach the input controls to the currently attached dom element to listen the events from.
  6105. * @param input Defines the input to attach
  6106. */
  6107. attachInput(input: ICameraInput<TCamera>): void;
  6108. /**
  6109. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6110. * @param element Defines the dom element to collect the events from
  6111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6112. */
  6113. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6114. /**
  6115. * Detach the current manager inputs controls from a specific dom element.
  6116. * @param element Defines the dom element to collect the events from
  6117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6118. */
  6119. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6120. /**
  6121. * Rebuild the dynamic inputCheck function from the current list of
  6122. * defined inputs in the manager.
  6123. */
  6124. rebuildInputCheck(): void;
  6125. /**
  6126. * Remove all attached input methods from a camera
  6127. */
  6128. clear(): void;
  6129. /**
  6130. * Serialize the current input manager attached to a camera.
  6131. * This ensures than once parsed,
  6132. * the input associated to the camera will be identical to the current ones
  6133. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6134. */
  6135. serialize(serializedCamera: any): void;
  6136. /**
  6137. * Parses an input manager serialized JSON to restore the previous list of inputs
  6138. * and states associated to a camera.
  6139. * @param parsedCamera Defines the JSON to parse
  6140. */
  6141. parse(parsedCamera: any): void;
  6142. }
  6143. }
  6144. declare module "babylonjs/Meshes/buffer" {
  6145. import { Nullable, DataArray } from "babylonjs/types";
  6146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6147. /**
  6148. * Class used to store data that will be store in GPU memory
  6149. */
  6150. export class Buffer {
  6151. private _engine;
  6152. private _buffer;
  6153. /** @hidden */
  6154. _data: Nullable<DataArray>;
  6155. private _updatable;
  6156. private _instanced;
  6157. private _divisor;
  6158. /**
  6159. * Gets the byte stride.
  6160. */
  6161. readonly byteStride: number;
  6162. /**
  6163. * Constructor
  6164. * @param engine the engine
  6165. * @param data the data to use for this buffer
  6166. * @param updatable whether the data is updatable
  6167. * @param stride the stride (optional)
  6168. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6169. * @param instanced whether the buffer is instanced (optional)
  6170. * @param useBytes set to true if the stride in in bytes (optional)
  6171. * @param divisor sets an optional divisor for instances (1 by default)
  6172. */
  6173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6174. /**
  6175. * Create a new VertexBuffer based on the current buffer
  6176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6177. * @param offset defines offset in the buffer (0 by default)
  6178. * @param size defines the size in floats of attributes (position is 3 for instance)
  6179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6180. * @param instanced defines if the vertex buffer contains indexed data
  6181. * @param useBytes defines if the offset and stride are in bytes *
  6182. * @param divisor sets an optional divisor for instances (1 by default)
  6183. * @returns the new vertex buffer
  6184. */
  6185. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6186. /**
  6187. * Gets a boolean indicating if the Buffer is updatable?
  6188. * @returns true if the buffer is updatable
  6189. */
  6190. isUpdatable(): boolean;
  6191. /**
  6192. * Gets current buffer's data
  6193. * @returns a DataArray or null
  6194. */
  6195. getData(): Nullable<DataArray>;
  6196. /**
  6197. * Gets underlying native buffer
  6198. * @returns underlying native buffer
  6199. */
  6200. getBuffer(): Nullable<DataBuffer>;
  6201. /**
  6202. * Gets the stride in float32 units (i.e. byte stride / 4).
  6203. * May not be an integer if the byte stride is not divisible by 4.
  6204. * DEPRECATED. Use byteStride instead.
  6205. * @returns the stride in float32 units
  6206. */
  6207. getStrideSize(): number;
  6208. /**
  6209. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6210. * @param data defines the data to store
  6211. */
  6212. create(data?: Nullable<DataArray>): void;
  6213. /** @hidden */
  6214. _rebuild(): void;
  6215. /**
  6216. * Update current buffer data
  6217. * @param data defines the data to store
  6218. */
  6219. update(data: DataArray): void;
  6220. /**
  6221. * Updates the data directly.
  6222. * @param data the new data
  6223. * @param offset the new offset
  6224. * @param vertexCount the vertex count (optional)
  6225. * @param useBytes set to true if the offset is in bytes
  6226. */
  6227. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6228. /**
  6229. * Release all resources
  6230. */
  6231. dispose(): void;
  6232. }
  6233. /**
  6234. * Specialized buffer used to store vertex data
  6235. */
  6236. export class VertexBuffer {
  6237. /** @hidden */
  6238. _buffer: Buffer;
  6239. private _kind;
  6240. private _size;
  6241. private _ownsBuffer;
  6242. private _instanced;
  6243. private _instanceDivisor;
  6244. /**
  6245. * The byte type.
  6246. */
  6247. static readonly BYTE: number;
  6248. /**
  6249. * The unsigned byte type.
  6250. */
  6251. static readonly UNSIGNED_BYTE: number;
  6252. /**
  6253. * The short type.
  6254. */
  6255. static readonly SHORT: number;
  6256. /**
  6257. * The unsigned short type.
  6258. */
  6259. static readonly UNSIGNED_SHORT: number;
  6260. /**
  6261. * The integer type.
  6262. */
  6263. static readonly INT: number;
  6264. /**
  6265. * The unsigned integer type.
  6266. */
  6267. static readonly UNSIGNED_INT: number;
  6268. /**
  6269. * The float type.
  6270. */
  6271. static readonly FLOAT: number;
  6272. /**
  6273. * Gets or sets the instance divisor when in instanced mode
  6274. */
  6275. instanceDivisor: number;
  6276. /**
  6277. * Gets the byte stride.
  6278. */
  6279. readonly byteStride: number;
  6280. /**
  6281. * Gets the byte offset.
  6282. */
  6283. readonly byteOffset: number;
  6284. /**
  6285. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6286. */
  6287. readonly normalized: boolean;
  6288. /**
  6289. * Gets the data type of each component in the array.
  6290. */
  6291. readonly type: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this vertex buffer
  6296. * @param kind the vertex buffer kind
  6297. * @param updatable whether the data is updatable
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param stride the stride (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param offset the offset of the data (optional)
  6302. * @param size the number of components (optional)
  6303. * @param type the type of the component (optional)
  6304. * @param normalized whether the data contains normalized data (optional)
  6305. * @param useBytes set to true if stride and offset are in bytes (optional)
  6306. * @param divisor defines the instance divisor to use (1 by default)
  6307. */
  6308. 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, divisor?: number);
  6309. /** @hidden */
  6310. _rebuild(): void;
  6311. /**
  6312. * Returns the kind of the VertexBuffer (string)
  6313. * @returns a string
  6314. */
  6315. getKind(): string;
  6316. /**
  6317. * Gets a boolean indicating if the VertexBuffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * DEPRECATED. Use byteStride instead.
  6335. * @returns the stride in float32 units
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Returns the offset as a multiple of the type byte length.
  6340. * DEPRECATED. Use byteOffset instead.
  6341. * @returns the offset in bytes
  6342. */
  6343. getOffset(): number;
  6344. /**
  6345. * Returns the number of components per vertex attribute (integer)
  6346. * @returns the size in float
  6347. */
  6348. getSize(): number;
  6349. /**
  6350. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6351. * @returns true if this buffer is instanced
  6352. */
  6353. getIsInstanced(): boolean;
  6354. /**
  6355. * Returns the instancing divisor, zero for non-instanced (integer).
  6356. * @returns a number
  6357. */
  6358. getInstanceDivisor(): number;
  6359. /**
  6360. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6361. * @param data defines the data to store
  6362. */
  6363. create(data?: DataArray): void;
  6364. /**
  6365. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6366. * This function will create a new buffer if the current one is not updatable
  6367. * @param data defines the data to store
  6368. */
  6369. update(data: DataArray): void;
  6370. /**
  6371. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6372. * Returns the directly updated WebGLBuffer.
  6373. * @param data the new data
  6374. * @param offset the new offset
  6375. * @param useBytes set to true if the offset is in bytes
  6376. */
  6377. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6378. /**
  6379. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6380. */
  6381. dispose(): void;
  6382. /**
  6383. * Enumerates each value of this vertex buffer as numbers.
  6384. * @param count the number of values to enumerate
  6385. * @param callback the callback function called for each value
  6386. */
  6387. forEach(count: number, callback: (value: number, index: number) => void): void;
  6388. /**
  6389. * Positions
  6390. */
  6391. static readonly PositionKind: string;
  6392. /**
  6393. * Normals
  6394. */
  6395. static readonly NormalKind: string;
  6396. /**
  6397. * Tangents
  6398. */
  6399. static readonly TangentKind: string;
  6400. /**
  6401. * Texture coordinates
  6402. */
  6403. static readonly UVKind: string;
  6404. /**
  6405. * Texture coordinates 2
  6406. */
  6407. static readonly UV2Kind: string;
  6408. /**
  6409. * Texture coordinates 3
  6410. */
  6411. static readonly UV3Kind: string;
  6412. /**
  6413. * Texture coordinates 4
  6414. */
  6415. static readonly UV4Kind: string;
  6416. /**
  6417. * Texture coordinates 5
  6418. */
  6419. static readonly UV5Kind: string;
  6420. /**
  6421. * Texture coordinates 6
  6422. */
  6423. static readonly UV6Kind: string;
  6424. /**
  6425. * Colors
  6426. */
  6427. static readonly ColorKind: string;
  6428. /**
  6429. * Matrix indices (for bones)
  6430. */
  6431. static readonly MatricesIndicesKind: string;
  6432. /**
  6433. * Matrix weights (for bones)
  6434. */
  6435. static readonly MatricesWeightsKind: string;
  6436. /**
  6437. * Additional matrix indices (for bones)
  6438. */
  6439. static readonly MatricesIndicesExtraKind: string;
  6440. /**
  6441. * Additional matrix weights (for bones)
  6442. */
  6443. static readonly MatricesWeightsExtraKind: string;
  6444. /**
  6445. * Deduces the stride given a kind.
  6446. * @param kind The kind string to deduce
  6447. * @returns The deduced stride
  6448. */
  6449. static DeduceStride(kind: string): number;
  6450. /**
  6451. * Gets the byte length of the given type.
  6452. * @param type the type
  6453. * @returns the number of bytes
  6454. */
  6455. static GetTypeByteLength(type: number): number;
  6456. /**
  6457. * Enumerates each value of the given parameters as numbers.
  6458. * @param data the data to enumerate
  6459. * @param byteOffset the byte offset of the data
  6460. * @param byteStride the byte stride of the data
  6461. * @param componentCount the number of components per element
  6462. * @param componentType the type of the component
  6463. * @param count the number of values to enumerate
  6464. * @param normalized whether the data is normalized
  6465. * @param callback the callback function called for each value
  6466. */
  6467. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6468. private static _GetFloatValue;
  6469. }
  6470. }
  6471. declare module "babylonjs/Collisions/intersectionInfo" {
  6472. import { Nullable } from "babylonjs/types";
  6473. /**
  6474. * @hidden
  6475. */
  6476. export class IntersectionInfo {
  6477. bu: Nullable<number>;
  6478. bv: Nullable<number>;
  6479. distance: number;
  6480. faceId: number;
  6481. subMeshId: number;
  6482. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6483. }
  6484. }
  6485. declare module "babylonjs/Maths/math.plane" {
  6486. import { DeepImmutable } from "babylonjs/types";
  6487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6488. /**
  6489. * Represens a plane by the equation ax + by + cz + d = 0
  6490. */
  6491. export class Plane {
  6492. private static _TmpMatrix;
  6493. /**
  6494. * Normal of the plane (a,b,c)
  6495. */
  6496. normal: Vector3;
  6497. /**
  6498. * d component of the plane
  6499. */
  6500. d: number;
  6501. /**
  6502. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6503. * @param a a component of the plane
  6504. * @param b b component of the plane
  6505. * @param c c component of the plane
  6506. * @param d d component of the plane
  6507. */
  6508. constructor(a: number, b: number, c: number, d: number);
  6509. /**
  6510. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6511. */
  6512. asArray(): number[];
  6513. /**
  6514. * @returns a new plane copied from the current Plane.
  6515. */
  6516. clone(): Plane;
  6517. /**
  6518. * @returns the string "Plane".
  6519. */
  6520. getClassName(): string;
  6521. /**
  6522. * @returns the Plane hash code.
  6523. */
  6524. getHashCode(): number;
  6525. /**
  6526. * Normalize the current Plane in place.
  6527. * @returns the updated Plane.
  6528. */
  6529. normalize(): Plane;
  6530. /**
  6531. * Applies a transformation the plane and returns the result
  6532. * @param transformation the transformation matrix to be applied to the plane
  6533. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6534. */
  6535. transform(transformation: DeepImmutable<Matrix>): Plane;
  6536. /**
  6537. * Calcualtte the dot product between the point and the plane normal
  6538. * @param point point to calculate the dot product with
  6539. * @returns the dot product (float) of the point coordinates and the plane normal.
  6540. */
  6541. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6542. /**
  6543. * Updates the current Plane from the plane defined by the three given points.
  6544. * @param point1 one of the points used to contruct the plane
  6545. * @param point2 one of the points used to contruct the plane
  6546. * @param point3 one of the points used to contruct the plane
  6547. * @returns the updated Plane.
  6548. */
  6549. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6550. /**
  6551. * Checks if the plane is facing a given direction
  6552. * @param direction the direction to check if the plane is facing
  6553. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6554. * @returns True is the vector "direction" is the same side than the plane normal.
  6555. */
  6556. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6557. /**
  6558. * Calculates the distance to a point
  6559. * @param point point to calculate distance to
  6560. * @returns the signed distance (float) from the given point to the Plane.
  6561. */
  6562. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6563. /**
  6564. * Creates a plane from an array
  6565. * @param array the array to create a plane from
  6566. * @returns a new Plane from the given array.
  6567. */
  6568. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6569. /**
  6570. * Creates a plane from three points
  6571. * @param point1 point used to create the plane
  6572. * @param point2 point used to create the plane
  6573. * @param point3 point used to create the plane
  6574. * @returns a new Plane defined by the three given points.
  6575. */
  6576. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6577. /**
  6578. * Creates a plane from an origin point and a normal
  6579. * @param origin origin of the plane to be constructed
  6580. * @param normal normal of the plane to be constructed
  6581. * @returns a new Plane the normal vector to this plane at the given origin point.
  6582. * Note : the vector "normal" is updated because normalized.
  6583. */
  6584. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6585. /**
  6586. * Calculates the distance from a plane and a point
  6587. * @param origin origin of the plane to be constructed
  6588. * @param normal normal of the plane to be constructed
  6589. * @param point point to calculate distance to
  6590. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6591. */
  6592. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6593. }
  6594. }
  6595. declare module "babylonjs/Culling/boundingSphere" {
  6596. import { DeepImmutable } from "babylonjs/types";
  6597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6598. import { Plane } from "babylonjs/Maths/math.plane";
  6599. /**
  6600. * Class used to store bounding sphere information
  6601. */
  6602. export class BoundingSphere {
  6603. /**
  6604. * Gets the center of the bounding sphere in local space
  6605. */
  6606. readonly center: Vector3;
  6607. /**
  6608. * Radius of the bounding sphere in local space
  6609. */
  6610. radius: number;
  6611. /**
  6612. * Gets the center of the bounding sphere in world space
  6613. */
  6614. readonly centerWorld: Vector3;
  6615. /**
  6616. * Radius of the bounding sphere in world space
  6617. */
  6618. radiusWorld: number;
  6619. /**
  6620. * Gets the minimum vector in local space
  6621. */
  6622. readonly minimum: Vector3;
  6623. /**
  6624. * Gets the maximum vector in local space
  6625. */
  6626. readonly maximum: Vector3;
  6627. private _worldMatrix;
  6628. private static readonly TmpVector3;
  6629. /**
  6630. * Creates a new bounding sphere
  6631. * @param min defines the minimum vector (in local space)
  6632. * @param max defines the maximum vector (in local space)
  6633. * @param worldMatrix defines the new world matrix
  6634. */
  6635. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6636. /**
  6637. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. * @param worldMatrix defines the new world matrix
  6641. */
  6642. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6643. /**
  6644. * Scale the current bounding sphere by applying a scale factor
  6645. * @param factor defines the scale factor to apply
  6646. * @returns the current bounding box
  6647. */
  6648. scale(factor: number): BoundingSphere;
  6649. /**
  6650. * Gets the world matrix of the bounding box
  6651. * @returns a matrix
  6652. */
  6653. getWorldMatrix(): DeepImmutable<Matrix>;
  6654. /** @hidden */
  6655. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6656. /**
  6657. * Tests if the bounding sphere is intersecting the frustum planes
  6658. * @param frustumPlanes defines the frustum planes to test
  6659. * @returns true if there is an intersection
  6660. */
  6661. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6662. /**
  6663. * Tests if the bounding sphere center is in between the frustum planes.
  6664. * Used for optimistic fast inclusion.
  6665. * @param frustumPlanes defines the frustum planes to test
  6666. * @returns true if the sphere center is in between the frustum planes
  6667. */
  6668. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6669. /**
  6670. * Tests if a point is inside the bounding sphere
  6671. * @param point defines the point to test
  6672. * @returns true if the point is inside the bounding sphere
  6673. */
  6674. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6675. /**
  6676. * Checks if two sphere intersct
  6677. * @param sphere0 sphere 0
  6678. * @param sphere1 sphere 1
  6679. * @returns true if the speres intersect
  6680. */
  6681. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingBox" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6688. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding box information
  6692. */
  6693. export class BoundingBox implements ICullable {
  6694. /**
  6695. * Gets the 8 vectors representing the bounding box in local space
  6696. */
  6697. readonly vectors: Vector3[];
  6698. /**
  6699. * Gets the center of the bounding box in local space
  6700. */
  6701. readonly center: Vector3;
  6702. /**
  6703. * Gets the center of the bounding box in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Gets the extend size in local space
  6708. */
  6709. readonly extendSize: Vector3;
  6710. /**
  6711. * Gets the extend size in world space
  6712. */
  6713. readonly extendSizeWorld: Vector3;
  6714. /**
  6715. * Gets the OBB (object bounding box) directions
  6716. */
  6717. readonly directions: Vector3[];
  6718. /**
  6719. * Gets the 8 vectors representing the bounding box in world space
  6720. */
  6721. readonly vectorsWorld: Vector3[];
  6722. /**
  6723. * Gets the minimum vector in world space
  6724. */
  6725. readonly minimumWorld: Vector3;
  6726. /**
  6727. * Gets the maximum vector in world space
  6728. */
  6729. readonly maximumWorld: Vector3;
  6730. /**
  6731. * Gets the minimum vector in local space
  6732. */
  6733. readonly minimum: Vector3;
  6734. /**
  6735. * Gets the maximum vector in local space
  6736. */
  6737. readonly maximum: Vector3;
  6738. private _worldMatrix;
  6739. private static readonly TmpVector3;
  6740. /**
  6741. * @hidden
  6742. */
  6743. _tag: number;
  6744. /**
  6745. * Creates a new bounding box
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding box by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingBox;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(world: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding box is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding box is entirely inside the frustum planes
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if there is an inclusion
  6781. */
  6782. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding box
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding box
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Tests if the bounding box intersects with a bounding sphere
  6791. * @param sphere defines the sphere to test
  6792. * @returns true if there is an intersection
  6793. */
  6794. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6795. /**
  6796. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6797. * @param min defines the min vector to use
  6798. * @param max defines the max vector to use
  6799. * @returns true if there is an intersection
  6800. */
  6801. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6802. /**
  6803. * Tests if two bounding boxes are intersections
  6804. * @param box0 defines the first box to test
  6805. * @param box1 defines the second box to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6809. /**
  6810. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6811. * @param minPoint defines the minimum vector of the bounding box
  6812. * @param maxPoint defines the maximum vector of the bounding box
  6813. * @param sphereCenter defines the sphere center
  6814. * @param sphereRadius defines the sphere radius
  6815. * @returns true if there is an intersection
  6816. */
  6817. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6818. /**
  6819. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @return true if there is an inclusion
  6823. */
  6824. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6827. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6828. * @param frustumPlanes defines the frustum planes to test
  6829. * @return true if there is an intersection
  6830. */
  6831. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6832. }
  6833. }
  6834. declare module "babylonjs/Collisions/collider" {
  6835. import { Nullable, IndicesArray } from "babylonjs/types";
  6836. import { Vector3 } from "babylonjs/Maths/math.vector";
  6837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6838. import { Plane } from "babylonjs/Maths/math.plane";
  6839. /** @hidden */
  6840. export class Collider {
  6841. /** Define if a collision was found */
  6842. collisionFound: boolean;
  6843. /**
  6844. * Define last intersection point in local space
  6845. */
  6846. intersectionPoint: Vector3;
  6847. /**
  6848. * Define last collided mesh
  6849. */
  6850. collidedMesh: Nullable<AbstractMesh>;
  6851. private _collisionPoint;
  6852. private _planeIntersectionPoint;
  6853. private _tempVector;
  6854. private _tempVector2;
  6855. private _tempVector3;
  6856. private _tempVector4;
  6857. private _edge;
  6858. private _baseToVertex;
  6859. private _destinationPoint;
  6860. private _slidePlaneNormal;
  6861. private _displacementVector;
  6862. /** @hidden */
  6863. _radius: Vector3;
  6864. /** @hidden */
  6865. _retry: number;
  6866. private _velocity;
  6867. private _basePoint;
  6868. private _epsilon;
  6869. /** @hidden */
  6870. _velocityWorldLength: number;
  6871. /** @hidden */
  6872. _basePointWorld: Vector3;
  6873. private _velocityWorld;
  6874. private _normalizedVelocity;
  6875. /** @hidden */
  6876. _initialVelocity: Vector3;
  6877. /** @hidden */
  6878. _initialPosition: Vector3;
  6879. private _nearestDistance;
  6880. private _collisionMask;
  6881. collisionMask: number;
  6882. /**
  6883. * Gets the plane normal used to compute the sliding response (in local space)
  6884. */
  6885. readonly slidePlaneNormal: Vector3;
  6886. /** @hidden */
  6887. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6888. /** @hidden */
  6889. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6890. /** @hidden */
  6891. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6892. /** @hidden */
  6893. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6894. /** @hidden */
  6895. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6896. /** @hidden */
  6897. _getResponse(pos: Vector3, vel: Vector3): void;
  6898. }
  6899. }
  6900. declare module "babylonjs/Culling/boundingInfo" {
  6901. import { DeepImmutable } from "babylonjs/types";
  6902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6904. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6905. import { Plane } from "babylonjs/Maths/math.plane";
  6906. import { Collider } from "babylonjs/Collisions/collider";
  6907. /**
  6908. * Interface for cullable objects
  6909. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6910. */
  6911. export interface ICullable {
  6912. /**
  6913. * Checks if the object or part of the object is in the frustum
  6914. * @param frustumPlanes Camera near/planes
  6915. * @returns true if the object is in frustum otherwise false
  6916. */
  6917. isInFrustum(frustumPlanes: Plane[]): boolean;
  6918. /**
  6919. * Checks if a cullable object (mesh...) is in the camera frustum
  6920. * Unlike isInFrustum this cheks the full bounding box
  6921. * @param frustumPlanes Camera near/planes
  6922. * @returns true if the object is in frustum otherwise false
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6925. }
  6926. /**
  6927. * Info for a bounding data of a mesh
  6928. */
  6929. export class BoundingInfo implements ICullable {
  6930. /**
  6931. * Bounding box for the mesh
  6932. */
  6933. readonly boundingBox: BoundingBox;
  6934. /**
  6935. * Bounding sphere for the mesh
  6936. */
  6937. readonly boundingSphere: BoundingSphere;
  6938. private _isLocked;
  6939. private static readonly TmpVector3;
  6940. /**
  6941. * Constructs bounding info
  6942. * @param minimum min vector of the bounding box/sphere
  6943. * @param maximum max vector of the bounding box/sphere
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * min vector of the bounding box/sphere
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * max vector of the bounding box/sphere
  6960. */
  6961. readonly maximum: Vector3;
  6962. /**
  6963. * If the info is locked and won't be updated to avoid perf overhead
  6964. */
  6965. isLocked: boolean;
  6966. /**
  6967. * Updates the bounding sphere and box
  6968. * @param world world matrix to be used to update
  6969. */
  6970. update(world: DeepImmutable<Matrix>): void;
  6971. /**
  6972. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6973. * @param center New center of the bounding info
  6974. * @param extend New extend of the bounding info
  6975. * @returns the current bounding info
  6976. */
  6977. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6978. /**
  6979. * Scale the current bounding info by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding info
  6982. */
  6983. scale(factor: number): BoundingInfo;
  6984. /**
  6985. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6986. * @param frustumPlanes defines the frustum to test
  6987. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6988. * @returns true if the bounding info is in the frustum planes
  6989. */
  6990. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6991. /**
  6992. * Gets the world distance between the min and max points of the bounding box
  6993. */
  6994. readonly diagonalLength: number;
  6995. /**
  6996. * Checks if a cullable object (mesh...) is in the camera frustum
  6997. * Unlike isInFrustum this cheks the full bounding box
  6998. * @param frustumPlanes Camera near/planes
  6999. * @returns true if the object is in frustum otherwise false
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /** @hidden */
  7003. _checkCollision(collider: Collider): boolean;
  7004. /**
  7005. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7007. * @param point the point to check intersection with
  7008. * @returns if the point intersects
  7009. */
  7010. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7011. /**
  7012. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7013. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7014. * @param boundingInfo the bounding info to check intersection with
  7015. * @param precise if the intersection should be done using OBB
  7016. * @returns if the bounding info intersects
  7017. */
  7018. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7019. }
  7020. }
  7021. declare module "babylonjs/Maths/math.functions" {
  7022. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7023. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7024. /**
  7025. * Extracts minimum and maximum values from a list of indexed positions
  7026. * @param positions defines the positions to use
  7027. * @param indices defines the indices to the positions
  7028. * @param indexStart defines the start index
  7029. * @param indexCount defines the end index
  7030. * @param bias defines bias value to add to the result
  7031. * @return minimum and maximum values
  7032. */
  7033. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7034. minimum: Vector3;
  7035. maximum: Vector3;
  7036. };
  7037. /**
  7038. * Extracts minimum and maximum values from a list of positions
  7039. * @param positions defines the positions to use
  7040. * @param start defines the start index in the positions array
  7041. * @param count defines the number of positions to handle
  7042. * @param bias defines bias value to add to the result
  7043. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7044. * @return minimum and maximum values
  7045. */
  7046. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7047. minimum: Vector3;
  7048. maximum: Vector3;
  7049. };
  7050. }
  7051. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7052. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7053. /** @hidden */
  7054. export class WebGLDataBuffer extends DataBuffer {
  7055. private _buffer;
  7056. constructor(resource: WebGLBuffer);
  7057. readonly underlyingResource: any;
  7058. }
  7059. }
  7060. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7062. import { Nullable } from "babylonjs/types";
  7063. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7064. /** @hidden */
  7065. export class WebGLPipelineContext implements IPipelineContext {
  7066. engine: ThinEngine;
  7067. program: Nullable<WebGLProgram>;
  7068. context?: WebGLRenderingContext;
  7069. vertexShader?: WebGLShader;
  7070. fragmentShader?: WebGLShader;
  7071. isParallelCompiled: boolean;
  7072. onCompiled?: () => void;
  7073. transformFeedback?: WebGLTransformFeedback | null;
  7074. readonly isAsync: boolean;
  7075. readonly isReady: boolean;
  7076. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7077. }
  7078. }
  7079. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7080. import { FloatArray, Nullable } from "babylonjs/types";
  7081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7082. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7083. module "babylonjs/Engines/thinEngine" {
  7084. interface ThinEngine {
  7085. /**
  7086. * Create an uniform buffer
  7087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7088. * @param elements defines the content of the uniform buffer
  7089. * @returns the webGL uniform buffer
  7090. */
  7091. createUniformBuffer(elements: FloatArray): DataBuffer;
  7092. /**
  7093. * Create a dynamic uniform buffer
  7094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7095. * @param elements defines the content of the uniform buffer
  7096. * @returns the webGL uniform buffer
  7097. */
  7098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7099. /**
  7100. * Update an existing uniform buffer
  7101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7102. * @param uniformBuffer defines the target uniform buffer
  7103. * @param elements defines the content to update
  7104. * @param offset defines the offset in the uniform buffer where update should start
  7105. * @param count defines the size of the data to update
  7106. */
  7107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7108. /**
  7109. * Bind an uniform buffer to the current webGL context
  7110. * @param buffer defines the buffer to bind
  7111. */
  7112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7113. /**
  7114. * Bind a buffer to the current webGL context at a given location
  7115. * @param buffer defines the buffer to bind
  7116. * @param location defines the index where to bind the buffer
  7117. */
  7118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7119. /**
  7120. * Bind a specific block at a given index in a specific shader program
  7121. * @param pipelineContext defines the pipeline context to use
  7122. * @param blockName defines the block name
  7123. * @param index defines the index where to bind the block
  7124. */
  7125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7126. }
  7127. }
  7128. }
  7129. declare module "babylonjs/Materials/uniformBuffer" {
  7130. import { Nullable, FloatArray } from "babylonjs/types";
  7131. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7132. import { Engine } from "babylonjs/Engines/engine";
  7133. import { Effect } from "babylonjs/Materials/effect";
  7134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7135. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7136. import { Color3 } from "babylonjs/Maths/math.color";
  7137. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7138. /**
  7139. * Uniform buffer objects.
  7140. *
  7141. * Handles blocks of uniform on the GPU.
  7142. *
  7143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7144. *
  7145. * For more information, please refer to :
  7146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7147. */
  7148. export class UniformBuffer {
  7149. private _engine;
  7150. private _buffer;
  7151. private _data;
  7152. private _bufferData;
  7153. private _dynamic?;
  7154. private _uniformLocations;
  7155. private _uniformSizes;
  7156. private _uniformLocationPointer;
  7157. private _needSync;
  7158. private _noUBO;
  7159. private _currentEffect;
  7160. /** @hidden */
  7161. _alreadyBound: boolean;
  7162. private static _MAX_UNIFORM_SIZE;
  7163. private static _tempBuffer;
  7164. /**
  7165. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7170. /**
  7171. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7172. * This is dynamic to allow compat with webgl 1 and 2.
  7173. * You will need to pass the name of the uniform as well as the value.
  7174. */
  7175. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7176. /**
  7177. * Lambda to Update a single float in a uniform buffer.
  7178. * This is dynamic to allow compat with webgl 1 and 2.
  7179. * You will need to pass the name of the uniform as well as the value.
  7180. */
  7181. updateFloat: (name: string, x: number) => void;
  7182. /**
  7183. * Lambda to Update a vec2 of float in a uniform buffer.
  7184. * This is dynamic to allow compat with webgl 1 and 2.
  7185. * You will need to pass the name of the uniform as well as the value.
  7186. */
  7187. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7188. /**
  7189. * Lambda to Update a vec3 of float in a uniform buffer.
  7190. * This is dynamic to allow compat with webgl 1 and 2.
  7191. * You will need to pass the name of the uniform as well as the value.
  7192. */
  7193. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7194. /**
  7195. * Lambda to Update a vec4 of float in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7200. /**
  7201. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix: (name: string, mat: Matrix) => void;
  7206. /**
  7207. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateVector3: (name: string, vector: Vector3) => void;
  7212. /**
  7213. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateVector4: (name: string, vector: Vector4) => void;
  7218. /**
  7219. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7230. /**
  7231. * Instantiates a new Uniform buffer objects.
  7232. *
  7233. * Handles blocks of uniform on the GPU.
  7234. *
  7235. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7236. *
  7237. * For more information, please refer to :
  7238. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7239. * @param engine Define the engine the buffer is associated with
  7240. * @param data Define the data contained in the buffer
  7241. * @param dynamic Define if the buffer is updatable
  7242. */
  7243. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7244. /**
  7245. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7246. * or just falling back on setUniformXXX calls.
  7247. */
  7248. readonly useUbo: boolean;
  7249. /**
  7250. * Indicates if the WebGL underlying uniform buffer is in sync
  7251. * with the javascript cache data.
  7252. */
  7253. readonly isSync: boolean;
  7254. /**
  7255. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7256. * Also, a dynamic UniformBuffer will disable cache verification and always
  7257. * update the underlying WebGL uniform buffer to the GPU.
  7258. * @returns if Dynamic, otherwise false
  7259. */
  7260. isDynamic(): boolean;
  7261. /**
  7262. * The data cache on JS side.
  7263. * @returns the underlying data as a float array
  7264. */
  7265. getData(): Float32Array;
  7266. /**
  7267. * The underlying WebGL Uniform buffer.
  7268. * @returns the webgl buffer
  7269. */
  7270. getBuffer(): Nullable<DataBuffer>;
  7271. /**
  7272. * std140 layout specifies how to align data within an UBO structure.
  7273. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7274. * for specs.
  7275. */
  7276. private _fillAlignment;
  7277. /**
  7278. * Adds an uniform in the buffer.
  7279. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7280. * for the layout to be correct !
  7281. * @param name Name of the uniform, as used in the uniform block in the shader.
  7282. * @param size Data size, or data directly.
  7283. */
  7284. addUniform(name: string, size: number | number[]): void;
  7285. /**
  7286. * Adds a Matrix 4x4 to the uniform buffer.
  7287. * @param name Name of the uniform, as used in the uniform block in the shader.
  7288. * @param mat A 4x4 matrix.
  7289. */
  7290. addMatrix(name: string, mat: Matrix): void;
  7291. /**
  7292. * Adds a vec2 to the uniform buffer.
  7293. * @param name Name of the uniform, as used in the uniform block in the shader.
  7294. * @param x Define the x component value of the vec2
  7295. * @param y Define the y component value of the vec2
  7296. */
  7297. addFloat2(name: string, x: number, y: number): void;
  7298. /**
  7299. * Adds a vec3 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param x Define the x component value of the vec3
  7302. * @param y Define the y component value of the vec3
  7303. * @param z Define the z component value of the vec3
  7304. */
  7305. addFloat3(name: string, x: number, y: number, z: number): void;
  7306. /**
  7307. * Adds a vec3 to the uniform buffer.
  7308. * @param name Name of the uniform, as used in the uniform block in the shader.
  7309. * @param color Define the vec3 from a Color
  7310. */
  7311. addColor3(name: string, color: Color3): void;
  7312. /**
  7313. * Adds a vec4 to the uniform buffer.
  7314. * @param name Name of the uniform, as used in the uniform block in the shader.
  7315. * @param color Define the rgb components from a Color
  7316. * @param alpha Define the a component of the vec4
  7317. */
  7318. addColor4(name: string, color: Color3, alpha: number): void;
  7319. /**
  7320. * Adds a vec3 to the uniform buffer.
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. * @param vector Define the vec3 components from a Vector
  7323. */
  7324. addVector3(name: string, vector: Vector3): void;
  7325. /**
  7326. * Adds a Matrix 3x3 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. */
  7329. addMatrix3x3(name: string): void;
  7330. /**
  7331. * Adds a Matrix 2x2 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. */
  7334. addMatrix2x2(name: string): void;
  7335. /**
  7336. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7337. */
  7338. create(): void;
  7339. /** @hidden */
  7340. _rebuild(): void;
  7341. /**
  7342. * Updates the WebGL Uniform Buffer on the GPU.
  7343. * If the `dynamic` flag is set to true, no cache comparison is done.
  7344. * Otherwise, the buffer will be updated only if the cache differs.
  7345. */
  7346. update(): void;
  7347. /**
  7348. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7349. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7350. * @param data Define the flattened data
  7351. * @param size Define the size of the data.
  7352. */
  7353. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7354. private _valueCache;
  7355. private _cacheMatrix;
  7356. private _updateMatrix3x3ForUniform;
  7357. private _updateMatrix3x3ForEffect;
  7358. private _updateMatrix2x2ForEffect;
  7359. private _updateMatrix2x2ForUniform;
  7360. private _updateFloatForEffect;
  7361. private _updateFloatForUniform;
  7362. private _updateFloat2ForEffect;
  7363. private _updateFloat2ForUniform;
  7364. private _updateFloat3ForEffect;
  7365. private _updateFloat3ForUniform;
  7366. private _updateFloat4ForEffect;
  7367. private _updateFloat4ForUniform;
  7368. private _updateMatrixForEffect;
  7369. private _updateMatrixForUniform;
  7370. private _updateVector3ForEffect;
  7371. private _updateVector3ForUniform;
  7372. private _updateVector4ForEffect;
  7373. private _updateVector4ForUniform;
  7374. private _updateColor3ForEffect;
  7375. private _updateColor3ForUniform;
  7376. private _updateColor4ForEffect;
  7377. private _updateColor4ForUniform;
  7378. /**
  7379. * Sets a sampler uniform on the effect.
  7380. * @param name Define the name of the sampler.
  7381. * @param texture Define the texture to set in the sampler
  7382. */
  7383. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7384. /**
  7385. * Directly updates the value of the uniform in the cache AND on the GPU.
  7386. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7387. * @param data Define the flattened data
  7388. */
  7389. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7390. /**
  7391. * Binds this uniform buffer to an effect.
  7392. * @param effect Define the effect to bind the buffer to
  7393. * @param name Name of the uniform block in the shader.
  7394. */
  7395. bindToEffect(effect: Effect, name: string): void;
  7396. /**
  7397. * Disposes the uniform buffer.
  7398. */
  7399. dispose(): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/iInspectable" {
  7403. /**
  7404. * Enum that determines the text-wrapping mode to use.
  7405. */
  7406. export enum InspectableType {
  7407. /**
  7408. * Checkbox for booleans
  7409. */
  7410. Checkbox = 0,
  7411. /**
  7412. * Sliders for numbers
  7413. */
  7414. Slider = 1,
  7415. /**
  7416. * Vector3
  7417. */
  7418. Vector3 = 2,
  7419. /**
  7420. * Quaternions
  7421. */
  7422. Quaternion = 3,
  7423. /**
  7424. * Color3
  7425. */
  7426. Color3 = 4,
  7427. /**
  7428. * String
  7429. */
  7430. String = 5
  7431. }
  7432. /**
  7433. * Interface used to define custom inspectable properties.
  7434. * This interface is used by the inspector to display custom property grids
  7435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7436. */
  7437. export interface IInspectable {
  7438. /**
  7439. * Gets the label to display
  7440. */
  7441. label: string;
  7442. /**
  7443. * Gets the name of the property to edit
  7444. */
  7445. propertyName: string;
  7446. /**
  7447. * Gets the type of the editor to use
  7448. */
  7449. type: InspectableType;
  7450. /**
  7451. * Gets the minimum value of the property when using in "slider" mode
  7452. */
  7453. min?: number;
  7454. /**
  7455. * Gets the maximum value of the property when using in "slider" mode
  7456. */
  7457. max?: number;
  7458. /**
  7459. * Gets the setp to use when using in "slider" mode
  7460. */
  7461. step?: number;
  7462. }
  7463. }
  7464. declare module "babylonjs/Misc/timingTools" {
  7465. /**
  7466. * Class used to provide helper for timing
  7467. */
  7468. export class TimingTools {
  7469. /**
  7470. * Polyfill for setImmediate
  7471. * @param action defines the action to execute after the current execution block
  7472. */
  7473. static SetImmediate(action: () => void): void;
  7474. }
  7475. }
  7476. declare module "babylonjs/Misc/instantiationTools" {
  7477. /**
  7478. * Class used to enable instatition of objects by class name
  7479. */
  7480. export class InstantiationTools {
  7481. /**
  7482. * Use this object to register external classes like custom textures or material
  7483. * to allow the laoders to instantiate them
  7484. */
  7485. static RegisteredExternalClasses: {
  7486. [key: string]: Object;
  7487. };
  7488. /**
  7489. * Tries to instantiate a new object from a given class name
  7490. * @param className defines the class name to instantiate
  7491. * @returns the new object or null if the system was not able to do the instantiation
  7492. */
  7493. static Instantiate(className: string): any;
  7494. }
  7495. }
  7496. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7497. /**
  7498. * Define options used to create a depth texture
  7499. */
  7500. export class DepthTextureCreationOptions {
  7501. /** Specifies whether or not a stencil should be allocated in the texture */
  7502. generateStencil?: boolean;
  7503. /** Specifies whether or not bilinear filtering is enable on the texture */
  7504. bilinearFiltering?: boolean;
  7505. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7506. comparisonFunction?: number;
  7507. /** Specifies if the created texture is a cube texture */
  7508. isCube?: boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7513. import { Nullable } from "babylonjs/types";
  7514. import { Scene } from "babylonjs/scene";
  7515. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7516. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7517. module "babylonjs/Engines/thinEngine" {
  7518. interface ThinEngine {
  7519. /**
  7520. * Creates a depth stencil cube texture.
  7521. * This is only available in WebGL 2.
  7522. * @param size The size of face edge in the cube texture.
  7523. * @param options The options defining the cube texture.
  7524. * @returns The cube texture
  7525. */
  7526. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7527. /**
  7528. * Creates a cube texture
  7529. * @param rootUrl defines the url where the files to load is located
  7530. * @param scene defines the current scene
  7531. * @param files defines the list of files to load (1 per face)
  7532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7533. * @param onLoad defines an optional callback raised when the texture is loaded
  7534. * @param onError defines an optional callback raised if there is an issue to load the texture
  7535. * @param format defines the format of the data
  7536. * @param forcedExtension defines the extension to use to pick the right loader
  7537. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7540. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7541. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7542. * @returns the cube texture as an InternalTexture
  7543. */
  7544. 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;
  7545. /**
  7546. * Creates a cube texture
  7547. * @param rootUrl defines the url where the files to load is located
  7548. * @param scene defines the current scene
  7549. * @param files defines the list of files to load (1 per face)
  7550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7551. * @param onLoad defines an optional callback raised when the texture is loaded
  7552. * @param onError defines an optional callback raised if there is an issue to load the texture
  7553. * @param format defines the format of the data
  7554. * @param forcedExtension defines the extension to use to pick the right loader
  7555. * @returns the cube texture as an InternalTexture
  7556. */
  7557. 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;
  7558. /**
  7559. * Creates a cube texture
  7560. * @param rootUrl defines the url where the files to load is located
  7561. * @param scene defines the current scene
  7562. * @param files defines the list of files to load (1 per face)
  7563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7564. * @param onLoad defines an optional callback raised when the texture is loaded
  7565. * @param onError defines an optional callback raised if there is an issue to load the texture
  7566. * @param format defines the format of the data
  7567. * @param forcedExtension defines the extension to use to pick the right loader
  7568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7571. * @returns the cube texture as an InternalTexture
  7572. */
  7573. 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;
  7574. /** @hidden */
  7575. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7576. /** @hidden */
  7577. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7578. /** @hidden */
  7579. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7580. /** @hidden */
  7581. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7582. /**
  7583. * @hidden
  7584. */
  7585. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7586. }
  7587. }
  7588. }
  7589. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7590. import { Nullable } from "babylonjs/types";
  7591. import { Scene } from "babylonjs/scene";
  7592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7594. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7595. /**
  7596. * Class for creating a cube texture
  7597. */
  7598. export class CubeTexture extends BaseTexture {
  7599. private _delayedOnLoad;
  7600. /**
  7601. * The url of the texture
  7602. */
  7603. url: string;
  7604. /**
  7605. * Gets or sets the center of the bounding box associated with the cube texture.
  7606. * It must define where the camera used to render the texture was set
  7607. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7608. */
  7609. boundingBoxPosition: Vector3;
  7610. private _boundingBoxSize;
  7611. /**
  7612. * Gets or sets the size of the bounding box associated with the cube texture
  7613. * When defined, the cubemap will switch to local mode
  7614. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7615. * @example https://www.babylonjs-playground.com/#RNASML
  7616. */
  7617. /**
  7618. * Returns the bounding box size
  7619. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7620. */
  7621. boundingBoxSize: Vector3;
  7622. protected _rotationY: number;
  7623. /**
  7624. * Sets texture matrix rotation angle around Y axis in radians.
  7625. */
  7626. /**
  7627. * Gets texture matrix rotation angle around Y axis radians.
  7628. */
  7629. rotationY: number;
  7630. /**
  7631. * Are mip maps generated for this texture or not.
  7632. */
  7633. readonly noMipmap: boolean;
  7634. private _noMipmap;
  7635. private _files;
  7636. protected _forcedExtension: Nullable<string>;
  7637. private _extensions;
  7638. private _textureMatrix;
  7639. private _format;
  7640. private _createPolynomials;
  7641. /** @hidden */
  7642. _prefiltered: boolean;
  7643. /**
  7644. * Creates a cube texture from an array of image urls
  7645. * @param files defines an array of image urls
  7646. * @param scene defines the hosting scene
  7647. * @param noMipmap specifies if mip maps are not used
  7648. * @returns a cube texture
  7649. */
  7650. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7651. /**
  7652. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7653. * @param url defines the url of the prefiltered texture
  7654. * @param scene defines the scene the texture is attached to
  7655. * @param forcedExtension defines the extension of the file if different from the url
  7656. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7657. * @return the prefiltered texture
  7658. */
  7659. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7660. /**
  7661. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7662. * as prefiltered data.
  7663. * @param rootUrl defines the url of the texture or the root name of the six images
  7664. * @param scene defines the scene the texture is attached to
  7665. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7666. * @param noMipmap defines if mipmaps should be created or not
  7667. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7668. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7669. * @param onError defines a callback triggered in case of error during load
  7670. * @param format defines the internal format to use for the texture once loaded
  7671. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7672. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7673. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7674. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7675. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7676. * @return the cube texture
  7677. */
  7678. 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);
  7679. /**
  7680. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7681. */
  7682. readonly isPrefiltered: boolean;
  7683. /**
  7684. * Get the current class name of the texture useful for serialization or dynamic coding.
  7685. * @returns "CubeTexture"
  7686. */
  7687. getClassName(): string;
  7688. /**
  7689. * Update the url (and optional buffer) of this texture if url was null during construction.
  7690. * @param url the url of the texture
  7691. * @param forcedExtension defines the extension to use
  7692. * @param onLoad callback called when the texture is loaded (defaults to null)
  7693. */
  7694. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7695. /**
  7696. * Delays loading of the cube texture
  7697. * @param forcedExtension defines the extension to use
  7698. */
  7699. delayLoad(forcedExtension?: string): void;
  7700. /**
  7701. * Returns the reflection texture matrix
  7702. * @returns the reflection texture matrix
  7703. */
  7704. getReflectionTextureMatrix(): Matrix;
  7705. /**
  7706. * Sets the reflection texture matrix
  7707. * @param value Reflection texture matrix
  7708. */
  7709. setReflectionTextureMatrix(value: Matrix): void;
  7710. /**
  7711. * Parses text to create a cube texture
  7712. * @param parsedTexture define the serialized text to read from
  7713. * @param scene defines the hosting scene
  7714. * @param rootUrl defines the root url of the cube texture
  7715. * @returns a cube texture
  7716. */
  7717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7718. /**
  7719. * Makes a clone, or deep copy, of the cube texture
  7720. * @returns a new cube texture
  7721. */
  7722. clone(): CubeTexture;
  7723. }
  7724. }
  7725. declare module "babylonjs/Materials/materialDefines" {
  7726. /**
  7727. * Manages the defines for the Material
  7728. */
  7729. export class MaterialDefines {
  7730. /** @hidden */
  7731. protected _keys: string[];
  7732. private _isDirty;
  7733. /** @hidden */
  7734. _renderId: number;
  7735. /** @hidden */
  7736. _areLightsDirty: boolean;
  7737. /** @hidden */
  7738. _areLightsDisposed: boolean;
  7739. /** @hidden */
  7740. _areAttributesDirty: boolean;
  7741. /** @hidden */
  7742. _areTexturesDirty: boolean;
  7743. /** @hidden */
  7744. _areFresnelDirty: boolean;
  7745. /** @hidden */
  7746. _areMiscDirty: boolean;
  7747. /** @hidden */
  7748. _areImageProcessingDirty: boolean;
  7749. /** @hidden */
  7750. _normals: boolean;
  7751. /** @hidden */
  7752. _uvs: boolean;
  7753. /** @hidden */
  7754. _needNormals: boolean;
  7755. /** @hidden */
  7756. _needUVs: boolean;
  7757. [id: string]: any;
  7758. /**
  7759. * Specifies if the material needs to be re-calculated
  7760. */
  7761. readonly isDirty: boolean;
  7762. /**
  7763. * Marks the material to indicate that it has been re-calculated
  7764. */
  7765. markAsProcessed(): void;
  7766. /**
  7767. * Marks the material to indicate that it needs to be re-calculated
  7768. */
  7769. markAsUnprocessed(): void;
  7770. /**
  7771. * Marks the material to indicate all of its defines need to be re-calculated
  7772. */
  7773. markAllAsDirty(): void;
  7774. /**
  7775. * Marks the material to indicate that image processing needs to be re-calculated
  7776. */
  7777. markAsImageProcessingDirty(): void;
  7778. /**
  7779. * Marks the material to indicate the lights need to be re-calculated
  7780. * @param disposed Defines whether the light is dirty due to dispose or not
  7781. */
  7782. markAsLightDirty(disposed?: boolean): void;
  7783. /**
  7784. * Marks the attribute state as changed
  7785. */
  7786. markAsAttributesDirty(): void;
  7787. /**
  7788. * Marks the texture state as changed
  7789. */
  7790. markAsTexturesDirty(): void;
  7791. /**
  7792. * Marks the fresnel state as changed
  7793. */
  7794. markAsFresnelDirty(): void;
  7795. /**
  7796. * Marks the misc state as changed
  7797. */
  7798. markAsMiscDirty(): void;
  7799. /**
  7800. * Rebuilds the material defines
  7801. */
  7802. rebuild(): void;
  7803. /**
  7804. * Specifies if two material defines are equal
  7805. * @param other - A material define instance to compare to
  7806. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7807. */
  7808. isEqual(other: MaterialDefines): boolean;
  7809. /**
  7810. * Clones this instance's defines to another instance
  7811. * @param other - material defines to clone values to
  7812. */
  7813. cloneTo(other: MaterialDefines): void;
  7814. /**
  7815. * Resets the material define values
  7816. */
  7817. reset(): void;
  7818. /**
  7819. * Converts the material define values to a string
  7820. * @returns - String of material define information
  7821. */
  7822. toString(): string;
  7823. }
  7824. }
  7825. declare module "babylonjs/Materials/colorCurves" {
  7826. import { Effect } from "babylonjs/Materials/effect";
  7827. /**
  7828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7830. * 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;
  7831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7832. */
  7833. export class ColorCurves {
  7834. private _dirty;
  7835. private _tempColor;
  7836. private _globalCurve;
  7837. private _highlightsCurve;
  7838. private _midtonesCurve;
  7839. private _shadowsCurve;
  7840. private _positiveCurve;
  7841. private _negativeCurve;
  7842. private _globalHue;
  7843. private _globalDensity;
  7844. private _globalSaturation;
  7845. private _globalExposure;
  7846. /**
  7847. * Gets the global Hue value.
  7848. * 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).
  7849. */
  7850. /**
  7851. * Sets the global Hue value.
  7852. * 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).
  7853. */
  7854. globalHue: number;
  7855. /**
  7856. * Gets the global Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the global Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. globalDensity: number;
  7866. /**
  7867. * Gets the global Saturation value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the global Saturation value.
  7872. * 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.
  7873. */
  7874. globalSaturation: number;
  7875. /**
  7876. * Gets the global Exposure value.
  7877. * 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.
  7878. */
  7879. /**
  7880. * Sets the global Exposure value.
  7881. * 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.
  7882. */
  7883. globalExposure: number;
  7884. private _highlightsHue;
  7885. private _highlightsDensity;
  7886. private _highlightsSaturation;
  7887. private _highlightsExposure;
  7888. /**
  7889. * Gets the highlights Hue value.
  7890. * 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).
  7891. */
  7892. /**
  7893. * Sets the highlights Hue value.
  7894. * 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).
  7895. */
  7896. highlightsHue: number;
  7897. /**
  7898. * Gets the highlights Density value.
  7899. * 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.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the highlights Density value.
  7904. * 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.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. highlightsDensity: number;
  7908. /**
  7909. * Gets the highlights Saturation value.
  7910. * 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.
  7911. */
  7912. /**
  7913. * Sets the highlights Saturation value.
  7914. * 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.
  7915. */
  7916. highlightsSaturation: number;
  7917. /**
  7918. * Gets the highlights Exposure value.
  7919. * 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.
  7920. */
  7921. /**
  7922. * Sets the highlights Exposure value.
  7923. * 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.
  7924. */
  7925. highlightsExposure: number;
  7926. private _midtonesHue;
  7927. private _midtonesDensity;
  7928. private _midtonesSaturation;
  7929. private _midtonesExposure;
  7930. /**
  7931. * Gets the midtones Hue value.
  7932. * 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).
  7933. */
  7934. /**
  7935. * Sets the midtones Hue value.
  7936. * 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).
  7937. */
  7938. midtonesHue: number;
  7939. /**
  7940. * Gets the midtones Density value.
  7941. * 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.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the midtones Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. midtonesDensity: number;
  7950. /**
  7951. * Gets the midtones Saturation value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the midtones Saturation value.
  7956. * 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.
  7957. */
  7958. midtonesSaturation: number;
  7959. /**
  7960. * Gets the midtones Exposure value.
  7961. * 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.
  7962. */
  7963. /**
  7964. * Sets the midtones Exposure value.
  7965. * 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.
  7966. */
  7967. midtonesExposure: number;
  7968. private _shadowsHue;
  7969. private _shadowsDensity;
  7970. private _shadowsSaturation;
  7971. private _shadowsExposure;
  7972. /**
  7973. * Gets the shadows Hue value.
  7974. * 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).
  7975. */
  7976. /**
  7977. * Sets the shadows Hue value.
  7978. * 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).
  7979. */
  7980. shadowsHue: number;
  7981. /**
  7982. * Gets the shadows Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. /**
  7987. * Sets the shadows Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. shadowsDensity: number;
  7992. /**
  7993. * Gets the shadows Saturation value.
  7994. * 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.
  7995. */
  7996. /**
  7997. * Sets the shadows Saturation value.
  7998. * 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.
  7999. */
  8000. shadowsSaturation: number;
  8001. /**
  8002. * Gets the shadows Exposure value.
  8003. * 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.
  8004. */
  8005. /**
  8006. * Sets the shadows Exposure value.
  8007. * 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.
  8008. */
  8009. shadowsExposure: number;
  8010. /**
  8011. * Returns the class name
  8012. * @returns The class name
  8013. */
  8014. getClassName(): string;
  8015. /**
  8016. * Binds the color curves to the shader.
  8017. * @param colorCurves The color curve to bind
  8018. * @param effect The effect to bind to
  8019. * @param positiveUniform The positive uniform shader parameter
  8020. * @param neutralUniform The neutral uniform shader parameter
  8021. * @param negativeUniform The negative uniform shader parameter
  8022. */
  8023. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8024. /**
  8025. * Prepare the list of uniforms associated with the ColorCurves effects.
  8026. * @param uniformsList The list of uniforms used in the effect
  8027. */
  8028. static PrepareUniforms(uniformsList: string[]): void;
  8029. /**
  8030. * Returns color grading data based on a hue, density, saturation and exposure value.
  8031. * @param filterHue The hue of the color filter.
  8032. * @param filterDensity The density of the color filter.
  8033. * @param saturation The saturation.
  8034. * @param exposure The exposure.
  8035. * @param result The result data container.
  8036. */
  8037. private getColorGradingDataToRef;
  8038. /**
  8039. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8040. * @param value The input slider value in range [-100,100].
  8041. * @returns Adjusted value.
  8042. */
  8043. private static applyColorGradingSliderNonlinear;
  8044. /**
  8045. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8046. * @param hue The hue (H) input.
  8047. * @param saturation The saturation (S) input.
  8048. * @param brightness The brightness (B) input.
  8049. * @result An RGBA color represented as Vector4.
  8050. */
  8051. private static fromHSBToRef;
  8052. /**
  8053. * Returns a value clamped between min and max
  8054. * @param value The value to clamp
  8055. * @param min The minimum of value
  8056. * @param max The maximum of value
  8057. * @returns The clamped value.
  8058. */
  8059. private static clamp;
  8060. /**
  8061. * Clones the current color curve instance.
  8062. * @return The cloned curves
  8063. */
  8064. clone(): ColorCurves;
  8065. /**
  8066. * Serializes the current color curve instance to a json representation.
  8067. * @return a JSON representation
  8068. */
  8069. serialize(): any;
  8070. /**
  8071. * Parses the color curve from a json representation.
  8072. * @param source the JSON source to parse
  8073. * @return The parsed curves
  8074. */
  8075. static Parse(source: any): ColorCurves;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8079. import { Observable } from "babylonjs/Misc/observable";
  8080. import { Nullable } from "babylonjs/types";
  8081. import { Color4 } from "babylonjs/Maths/math.color";
  8082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8083. import { Effect } from "babylonjs/Materials/effect";
  8084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8085. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8086. /**
  8087. * Interface to follow in your material defines to integrate easily the
  8088. * Image proccessing functions.
  8089. * @hidden
  8090. */
  8091. export interface IImageProcessingConfigurationDefines {
  8092. IMAGEPROCESSING: boolean;
  8093. VIGNETTE: boolean;
  8094. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8095. VIGNETTEBLENDMODEOPAQUE: boolean;
  8096. TONEMAPPING: boolean;
  8097. TONEMAPPING_ACES: boolean;
  8098. CONTRAST: boolean;
  8099. EXPOSURE: boolean;
  8100. COLORCURVES: boolean;
  8101. COLORGRADING: boolean;
  8102. COLORGRADING3D: boolean;
  8103. SAMPLER3DGREENDEPTH: boolean;
  8104. SAMPLER3DBGRMAP: boolean;
  8105. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8106. }
  8107. /**
  8108. * @hidden
  8109. */
  8110. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8111. IMAGEPROCESSING: boolean;
  8112. VIGNETTE: boolean;
  8113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8114. VIGNETTEBLENDMODEOPAQUE: boolean;
  8115. TONEMAPPING: boolean;
  8116. TONEMAPPING_ACES: boolean;
  8117. CONTRAST: boolean;
  8118. COLORCURVES: boolean;
  8119. COLORGRADING: boolean;
  8120. COLORGRADING3D: boolean;
  8121. SAMPLER3DGREENDEPTH: boolean;
  8122. SAMPLER3DBGRMAP: boolean;
  8123. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8124. EXPOSURE: boolean;
  8125. constructor();
  8126. }
  8127. /**
  8128. * This groups together the common properties used for image processing either in direct forward pass
  8129. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8130. * or not.
  8131. */
  8132. export class ImageProcessingConfiguration {
  8133. /**
  8134. * Default tone mapping applied in BabylonJS.
  8135. */
  8136. static readonly TONEMAPPING_STANDARD: number;
  8137. /**
  8138. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8139. * to other engines rendering to increase portability.
  8140. */
  8141. static readonly TONEMAPPING_ACES: number;
  8142. /**
  8143. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8144. */
  8145. colorCurves: Nullable<ColorCurves>;
  8146. private _colorCurvesEnabled;
  8147. /**
  8148. * Gets wether the color curves effect is enabled.
  8149. */
  8150. /**
  8151. * Sets wether the color curves effect is enabled.
  8152. */
  8153. colorCurvesEnabled: boolean;
  8154. private _colorGradingTexture;
  8155. /**
  8156. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8157. */
  8158. /**
  8159. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8160. */
  8161. colorGradingTexture: Nullable<BaseTexture>;
  8162. private _colorGradingEnabled;
  8163. /**
  8164. * Gets wether the color grading effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color grading effect is enabled.
  8168. */
  8169. colorGradingEnabled: boolean;
  8170. private _colorGradingWithGreenDepth;
  8171. /**
  8172. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8173. */
  8174. /**
  8175. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8176. */
  8177. colorGradingWithGreenDepth: boolean;
  8178. private _colorGradingBGR;
  8179. /**
  8180. * Gets wether the color grading texture contains BGR values.
  8181. */
  8182. /**
  8183. * Sets wether the color grading texture contains BGR values.
  8184. */
  8185. colorGradingBGR: boolean;
  8186. /** @hidden */
  8187. _exposure: number;
  8188. /**
  8189. * Gets the Exposure used in the effect.
  8190. */
  8191. /**
  8192. * Sets the Exposure used in the effect.
  8193. */
  8194. exposure: number;
  8195. private _toneMappingEnabled;
  8196. /**
  8197. * Gets wether the tone mapping effect is enabled.
  8198. */
  8199. /**
  8200. * Sets wether the tone mapping effect is enabled.
  8201. */
  8202. toneMappingEnabled: boolean;
  8203. private _toneMappingType;
  8204. /**
  8205. * Gets the type of tone mapping effect.
  8206. */
  8207. /**
  8208. * Sets the type of tone mapping effect used in BabylonJS.
  8209. */
  8210. toneMappingType: number;
  8211. protected _contrast: number;
  8212. /**
  8213. * Gets the contrast used in the effect.
  8214. */
  8215. /**
  8216. * Sets the contrast used in the effect.
  8217. */
  8218. contrast: number;
  8219. /**
  8220. * Vignette stretch size.
  8221. */
  8222. vignetteStretch: number;
  8223. /**
  8224. * Vignette centre X Offset.
  8225. */
  8226. vignetteCentreX: number;
  8227. /**
  8228. * Vignette centre Y Offset.
  8229. */
  8230. vignetteCentreY: number;
  8231. /**
  8232. * Vignette weight or intensity of the vignette effect.
  8233. */
  8234. vignetteWeight: number;
  8235. /**
  8236. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8237. * if vignetteEnabled is set to true.
  8238. */
  8239. vignetteColor: Color4;
  8240. /**
  8241. * Camera field of view used by the Vignette effect.
  8242. */
  8243. vignetteCameraFov: number;
  8244. private _vignetteBlendMode;
  8245. /**
  8246. * Gets the vignette blend mode allowing different kind of effect.
  8247. */
  8248. /**
  8249. * Sets the vignette blend mode allowing different kind of effect.
  8250. */
  8251. vignetteBlendMode: number;
  8252. private _vignetteEnabled;
  8253. /**
  8254. * Gets wether the vignette effect is enabled.
  8255. */
  8256. /**
  8257. * Sets wether the vignette effect is enabled.
  8258. */
  8259. vignetteEnabled: boolean;
  8260. private _applyByPostProcess;
  8261. /**
  8262. * Gets wether the image processing is applied through a post process or not.
  8263. */
  8264. /**
  8265. * Sets wether the image processing is applied through a post process or not.
  8266. */
  8267. applyByPostProcess: boolean;
  8268. private _isEnabled;
  8269. /**
  8270. * Gets wether the image processing is enabled or not.
  8271. */
  8272. /**
  8273. * Sets wether the image processing is enabled or not.
  8274. */
  8275. isEnabled: boolean;
  8276. /**
  8277. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8278. */
  8279. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8280. /**
  8281. * Method called each time the image processing information changes requires to recompile the effect.
  8282. */
  8283. protected _updateParameters(): void;
  8284. /**
  8285. * Gets the current class name.
  8286. * @return "ImageProcessingConfiguration"
  8287. */
  8288. getClassName(): string;
  8289. /**
  8290. * Prepare the list of uniforms associated with the Image Processing effects.
  8291. * @param uniforms The list of uniforms used in the effect
  8292. * @param defines the list of defines currently in use
  8293. */
  8294. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8295. /**
  8296. * Prepare the list of samplers associated with the Image Processing effects.
  8297. * @param samplersList The list of uniforms used in the effect
  8298. * @param defines the list of defines currently in use
  8299. */
  8300. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8301. /**
  8302. * Prepare the list of defines associated to the shader.
  8303. * @param defines the list of defines to complete
  8304. * @param forPostProcess Define if we are currently in post process mode or not
  8305. */
  8306. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8307. /**
  8308. * Returns true if all the image processing information are ready.
  8309. * @returns True if ready, otherwise, false
  8310. */
  8311. isReady(): boolean;
  8312. /**
  8313. * Binds the image processing to the shader.
  8314. * @param effect The effect to bind to
  8315. * @param overrideAspectRatio Override the aspect ratio of the effect
  8316. */
  8317. bind(effect: Effect, overrideAspectRatio?: number): void;
  8318. /**
  8319. * Clones the current image processing instance.
  8320. * @return The cloned image processing
  8321. */
  8322. clone(): ImageProcessingConfiguration;
  8323. /**
  8324. * Serializes the current image processing instance to a json representation.
  8325. * @return a JSON representation
  8326. */
  8327. serialize(): any;
  8328. /**
  8329. * Parses the image processing from a json representation.
  8330. * @param source the JSON source to parse
  8331. * @return The parsed image processing
  8332. */
  8333. static Parse(source: any): ImageProcessingConfiguration;
  8334. private static _VIGNETTEMODE_MULTIPLY;
  8335. private static _VIGNETTEMODE_OPAQUE;
  8336. /**
  8337. * Used to apply the vignette as a mix with the pixel color.
  8338. */
  8339. static readonly VIGNETTEMODE_MULTIPLY: number;
  8340. /**
  8341. * Used to apply the vignette as a replacement of the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_OPAQUE: number;
  8344. }
  8345. }
  8346. declare module "babylonjs/Shaders/postprocess.vertex" {
  8347. /** @hidden */
  8348. export var postprocessVertexShader: {
  8349. name: string;
  8350. shader: string;
  8351. };
  8352. }
  8353. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8354. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8356. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8357. module "babylonjs/Engines/thinEngine" {
  8358. interface ThinEngine {
  8359. /**
  8360. * Creates a new render target texture
  8361. * @param size defines the size of the texture
  8362. * @param options defines the options used to create the texture
  8363. * @returns a new render target texture stored in an InternalTexture
  8364. */
  8365. createRenderTargetTexture(size: number | {
  8366. width: number;
  8367. height: number;
  8368. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8369. /**
  8370. * Creates a depth stencil texture.
  8371. * This is only available in WebGL 2 or with the depth texture extension available.
  8372. * @param size The size of face edge in the texture.
  8373. * @param options The options defining the texture.
  8374. * @returns The texture
  8375. */
  8376. createDepthStencilTexture(size: number | {
  8377. width: number;
  8378. height: number;
  8379. }, options: DepthTextureCreationOptions): InternalTexture;
  8380. /** @hidden */
  8381. _createDepthStencilTexture(size: number | {
  8382. width: number;
  8383. height: number;
  8384. }, options: DepthTextureCreationOptions): InternalTexture;
  8385. }
  8386. }
  8387. }
  8388. declare module "babylonjs/Maths/math.axis" {
  8389. import { Vector3 } from "babylonjs/Maths/math.vector";
  8390. /** Defines supported spaces */
  8391. export enum Space {
  8392. /** Local (object) space */
  8393. LOCAL = 0,
  8394. /** World space */
  8395. WORLD = 1,
  8396. /** Bone space */
  8397. BONE = 2
  8398. }
  8399. /** Defines the 3 main axes */
  8400. export class Axis {
  8401. /** X axis */
  8402. static X: Vector3;
  8403. /** Y axis */
  8404. static Y: Vector3;
  8405. /** Z axis */
  8406. static Z: Vector3;
  8407. }
  8408. }
  8409. declare module "babylonjs/Cameras/targetCamera" {
  8410. import { Nullable } from "babylonjs/types";
  8411. import { Camera } from "babylonjs/Cameras/camera";
  8412. import { Scene } from "babylonjs/scene";
  8413. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8414. /**
  8415. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8416. * This is the base of the follow, arc rotate cameras and Free camera
  8417. * @see http://doc.babylonjs.com/features/cameras
  8418. */
  8419. export class TargetCamera extends Camera {
  8420. private static _RigCamTransformMatrix;
  8421. private static _TargetTransformMatrix;
  8422. private static _TargetFocalPoint;
  8423. /**
  8424. * Define the current direction the camera is moving to
  8425. */
  8426. cameraDirection: Vector3;
  8427. /**
  8428. * Define the current rotation the camera is rotating to
  8429. */
  8430. cameraRotation: Vector2;
  8431. /**
  8432. * When set, the up vector of the camera will be updated by the rotation of the camera
  8433. */
  8434. updateUpVectorFromRotation: boolean;
  8435. private _tmpQuaternion;
  8436. /**
  8437. * Define the current rotation of the camera
  8438. */
  8439. rotation: Vector3;
  8440. /**
  8441. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8442. */
  8443. rotationQuaternion: Quaternion;
  8444. /**
  8445. * Define the current speed of the camera
  8446. */
  8447. speed: number;
  8448. /**
  8449. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8450. * around all axis.
  8451. */
  8452. noRotationConstraint: boolean;
  8453. /**
  8454. * Define the current target of the camera as an object or a position.
  8455. */
  8456. lockedTarget: any;
  8457. /** @hidden */
  8458. _currentTarget: Vector3;
  8459. /** @hidden */
  8460. _initialFocalDistance: number;
  8461. /** @hidden */
  8462. _viewMatrix: Matrix;
  8463. /** @hidden */
  8464. _camMatrix: Matrix;
  8465. /** @hidden */
  8466. _cameraTransformMatrix: Matrix;
  8467. /** @hidden */
  8468. _cameraRotationMatrix: Matrix;
  8469. /** @hidden */
  8470. _referencePoint: Vector3;
  8471. /** @hidden */
  8472. _transformedReferencePoint: Vector3;
  8473. protected _globalCurrentTarget: Vector3;
  8474. protected _globalCurrentUpVector: Vector3;
  8475. /** @hidden */
  8476. _reset: () => void;
  8477. private _defaultUp;
  8478. /**
  8479. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8480. * This is the base of the follow, arc rotate cameras and Free camera
  8481. * @see http://doc.babylonjs.com/features/cameras
  8482. * @param name Defines the name of the camera in the scene
  8483. * @param position Defines the start position of the camera in the scene
  8484. * @param scene Defines the scene the camera belongs to
  8485. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8488. /**
  8489. * Gets the position in front of the camera at a given distance.
  8490. * @param distance The distance from the camera we want the position to be
  8491. * @returns the position
  8492. */
  8493. getFrontPosition(distance: number): Vector3;
  8494. /** @hidden */
  8495. _getLockedTargetPosition(): Nullable<Vector3>;
  8496. private _storedPosition;
  8497. private _storedRotation;
  8498. private _storedRotationQuaternion;
  8499. /**
  8500. * Store current camera state of the camera (fov, position, rotation, etc..)
  8501. * @returns the camera
  8502. */
  8503. storeState(): Camera;
  8504. /**
  8505. * Restored camera state. You must call storeState() first
  8506. * @returns whether it was successful or not
  8507. * @hidden
  8508. */
  8509. _restoreStateValues(): boolean;
  8510. /** @hidden */
  8511. _initCache(): void;
  8512. /** @hidden */
  8513. _updateCache(ignoreParentClass?: boolean): void;
  8514. /** @hidden */
  8515. _isSynchronizedViewMatrix(): boolean;
  8516. /** @hidden */
  8517. _computeLocalCameraSpeed(): number;
  8518. /**
  8519. * Defines the target the camera should look at.
  8520. * @param target Defines the new target as a Vector or a mesh
  8521. */
  8522. setTarget(target: Vector3): void;
  8523. /**
  8524. * Return the current target position of the camera. This value is expressed in local space.
  8525. * @returns the target position
  8526. */
  8527. getTarget(): Vector3;
  8528. /** @hidden */
  8529. _decideIfNeedsToMove(): boolean;
  8530. /** @hidden */
  8531. _updatePosition(): void;
  8532. /** @hidden */
  8533. _checkInputs(): void;
  8534. protected _updateCameraRotationMatrix(): void;
  8535. /**
  8536. * 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)
  8537. * @returns the current camera
  8538. */
  8539. private _rotateUpVectorWithCameraRotationMatrix;
  8540. private _cachedRotationZ;
  8541. private _cachedQuaternionRotationZ;
  8542. /** @hidden */
  8543. _getViewMatrix(): Matrix;
  8544. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8545. /**
  8546. * @hidden
  8547. */
  8548. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8549. /**
  8550. * @hidden
  8551. */
  8552. _updateRigCameras(): void;
  8553. private _getRigCamPositionAndTarget;
  8554. /**
  8555. * Gets the current object class name.
  8556. * @return the class name
  8557. */
  8558. getClassName(): string;
  8559. }
  8560. }
  8561. declare module "babylonjs/Events/keyboardEvents" {
  8562. /**
  8563. * Gather the list of keyboard event types as constants.
  8564. */
  8565. export class KeyboardEventTypes {
  8566. /**
  8567. * The keydown event is fired when a key becomes active (pressed).
  8568. */
  8569. static readonly KEYDOWN: number;
  8570. /**
  8571. * The keyup event is fired when a key has been released.
  8572. */
  8573. static readonly KEYUP: number;
  8574. }
  8575. /**
  8576. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8577. */
  8578. export class KeyboardInfo {
  8579. /**
  8580. * Defines the type of event (KeyboardEventTypes)
  8581. */
  8582. type: number;
  8583. /**
  8584. * Defines the related dom event
  8585. */
  8586. event: KeyboardEvent;
  8587. /**
  8588. * Instantiates a new keyboard info.
  8589. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8590. * @param type Defines the type of event (KeyboardEventTypes)
  8591. * @param event Defines the related dom event
  8592. */
  8593. constructor(
  8594. /**
  8595. * Defines the type of event (KeyboardEventTypes)
  8596. */
  8597. type: number,
  8598. /**
  8599. * Defines the related dom event
  8600. */
  8601. event: KeyboardEvent);
  8602. }
  8603. /**
  8604. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8605. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8606. */
  8607. export class KeyboardInfoPre extends KeyboardInfo {
  8608. /**
  8609. * Defines the type of event (KeyboardEventTypes)
  8610. */
  8611. type: number;
  8612. /**
  8613. * Defines the related dom event
  8614. */
  8615. event: KeyboardEvent;
  8616. /**
  8617. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8618. */
  8619. skipOnPointerObservable: boolean;
  8620. /**
  8621. * Instantiates a new keyboard pre info.
  8622. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8623. * @param type Defines the type of event (KeyboardEventTypes)
  8624. * @param event Defines the related dom event
  8625. */
  8626. constructor(
  8627. /**
  8628. * Defines the type of event (KeyboardEventTypes)
  8629. */
  8630. type: number,
  8631. /**
  8632. * Defines the related dom event
  8633. */
  8634. event: KeyboardEvent);
  8635. }
  8636. }
  8637. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8638. import { Nullable } from "babylonjs/types";
  8639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8641. /**
  8642. * Manage the keyboard inputs to control the movement of a free camera.
  8643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8644. */
  8645. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8646. /**
  8647. * Defines the camera the input is attached to.
  8648. */
  8649. camera: FreeCamera;
  8650. /**
  8651. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8652. */
  8653. keysUp: number[];
  8654. /**
  8655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8656. */
  8657. keysDown: number[];
  8658. /**
  8659. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8660. */
  8661. keysLeft: number[];
  8662. /**
  8663. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8664. */
  8665. keysRight: number[];
  8666. private _keys;
  8667. private _onCanvasBlurObserver;
  8668. private _onKeyboardObserver;
  8669. private _engine;
  8670. private _scene;
  8671. /**
  8672. * Attach the input controls to a specific dom element to get the input from.
  8673. * @param element Defines the element the controls should be listened from
  8674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8675. */
  8676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8677. /**
  8678. * Detach the current controls from the specified dom element.
  8679. * @param element Defines the element to stop listening the inputs from
  8680. */
  8681. detachControl(element: Nullable<HTMLElement>): void;
  8682. /**
  8683. * Update the current camera state depending on the inputs that have been used this frame.
  8684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8685. */
  8686. checkInputs(): void;
  8687. /**
  8688. * Gets the class name of the current intput.
  8689. * @returns the class name
  8690. */
  8691. getClassName(): string;
  8692. /** @hidden */
  8693. _onLostFocus(): void;
  8694. /**
  8695. * Get the friendly name associated with the input class.
  8696. * @returns the input friendly name
  8697. */
  8698. getSimpleName(): string;
  8699. }
  8700. }
  8701. declare module "babylonjs/Lights/shadowLight" {
  8702. import { Camera } from "babylonjs/Cameras/camera";
  8703. import { Scene } from "babylonjs/scene";
  8704. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8706. import { Light } from "babylonjs/Lights/light";
  8707. /**
  8708. * Interface describing all the common properties and methods a shadow light needs to implement.
  8709. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8710. * as well as binding the different shadow properties to the effects.
  8711. */
  8712. export interface IShadowLight extends Light {
  8713. /**
  8714. * The light id in the scene (used in scene.findLighById for instance)
  8715. */
  8716. id: string;
  8717. /**
  8718. * The position the shdow will be casted from.
  8719. */
  8720. position: Vector3;
  8721. /**
  8722. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8723. */
  8724. direction: Vector3;
  8725. /**
  8726. * The transformed position. Position of the light in world space taking parenting in account.
  8727. */
  8728. transformedPosition: Vector3;
  8729. /**
  8730. * The transformed direction. Direction of the light in world space taking parenting in account.
  8731. */
  8732. transformedDirection: Vector3;
  8733. /**
  8734. * The friendly name of the light in the scene.
  8735. */
  8736. name: string;
  8737. /**
  8738. * Defines the shadow projection clipping minimum z value.
  8739. */
  8740. shadowMinZ: number;
  8741. /**
  8742. * Defines the shadow projection clipping maximum z value.
  8743. */
  8744. shadowMaxZ: number;
  8745. /**
  8746. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8747. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8748. */
  8749. computeTransformedInformation(): boolean;
  8750. /**
  8751. * Gets the scene the light belongs to.
  8752. * @returns The scene
  8753. */
  8754. getScene(): Scene;
  8755. /**
  8756. * Callback defining a custom Projection Matrix Builder.
  8757. * This can be used to override the default projection matrix computation.
  8758. */
  8759. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8760. /**
  8761. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8762. * @param matrix The materix to updated with the projection information
  8763. * @param viewMatrix The transform matrix of the light
  8764. * @param renderList The list of mesh to render in the map
  8765. * @returns The current light
  8766. */
  8767. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8768. /**
  8769. * Gets the current depth scale used in ESM.
  8770. * @returns The scale
  8771. */
  8772. getDepthScale(): number;
  8773. /**
  8774. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8775. * @returns true if a cube texture needs to be use
  8776. */
  8777. needCube(): boolean;
  8778. /**
  8779. * Detects if the projection matrix requires to be recomputed this frame.
  8780. * @returns true if it requires to be recomputed otherwise, false.
  8781. */
  8782. needProjectionMatrixCompute(): boolean;
  8783. /**
  8784. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8785. */
  8786. forceProjectionMatrixCompute(): void;
  8787. /**
  8788. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8789. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8790. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8791. */
  8792. getShadowDirection(faceIndex?: number): Vector3;
  8793. /**
  8794. * Gets the minZ used for shadow according to both the scene and the light.
  8795. * @param activeCamera The camera we are returning the min for
  8796. * @returns the depth min z
  8797. */
  8798. getDepthMinZ(activeCamera: Camera): number;
  8799. /**
  8800. * Gets the maxZ used for shadow according to both the scene and the light.
  8801. * @param activeCamera The camera we are returning the max for
  8802. * @returns the depth max z
  8803. */
  8804. getDepthMaxZ(activeCamera: Camera): number;
  8805. }
  8806. /**
  8807. * Base implementation IShadowLight
  8808. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8809. */
  8810. export abstract class ShadowLight extends Light implements IShadowLight {
  8811. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8812. protected _position: Vector3;
  8813. protected _setPosition(value: Vector3): void;
  8814. /**
  8815. * Sets the position the shadow will be casted from. Also use as the light position for both
  8816. * point and spot lights.
  8817. */
  8818. /**
  8819. * Sets the position the shadow will be casted from. Also use as the light position for both
  8820. * point and spot lights.
  8821. */
  8822. position: Vector3;
  8823. protected _direction: Vector3;
  8824. protected _setDirection(value: Vector3): void;
  8825. /**
  8826. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8827. * Also use as the light direction on spot and directional lights.
  8828. */
  8829. /**
  8830. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8831. * Also use as the light direction on spot and directional lights.
  8832. */
  8833. direction: Vector3;
  8834. private _shadowMinZ;
  8835. /**
  8836. * Gets the shadow projection clipping minimum z value.
  8837. */
  8838. /**
  8839. * Sets the shadow projection clipping minimum z value.
  8840. */
  8841. shadowMinZ: number;
  8842. private _shadowMaxZ;
  8843. /**
  8844. * Sets the shadow projection clipping maximum z value.
  8845. */
  8846. /**
  8847. * Gets the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Callback defining a custom Projection Matrix Builder.
  8852. * This can be used to override the default projection matrix computation.
  8853. */
  8854. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8855. /**
  8856. * The transformed position. Position of the light in world space taking parenting in account.
  8857. */
  8858. transformedPosition: Vector3;
  8859. /**
  8860. * The transformed direction. Direction of the light in world space taking parenting in account.
  8861. */
  8862. transformedDirection: Vector3;
  8863. private _needProjectionMatrixCompute;
  8864. /**
  8865. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8866. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8867. */
  8868. computeTransformedInformation(): boolean;
  8869. /**
  8870. * Return the depth scale used for the shadow map.
  8871. * @returns the depth scale.
  8872. */
  8873. getDepthScale(): number;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Returns the ShadowLight absolute position in the World.
  8882. * @returns the position vector in world space
  8883. */
  8884. getAbsolutePosition(): Vector3;
  8885. /**
  8886. * Sets the ShadowLight direction toward the passed target.
  8887. * @param target The point to target in local space
  8888. * @returns the updated ShadowLight direction
  8889. */
  8890. setDirectionToTarget(target: Vector3): Vector3;
  8891. /**
  8892. * Returns the light rotation in euler definition.
  8893. * @returns the x y z rotation in local space.
  8894. */
  8895. getRotation(): Vector3;
  8896. /**
  8897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8898. * @returns true if a cube texture needs to be use
  8899. */
  8900. needCube(): boolean;
  8901. /**
  8902. * Detects if the projection matrix requires to be recomputed this frame.
  8903. * @returns true if it requires to be recomputed otherwise, false.
  8904. */
  8905. needProjectionMatrixCompute(): boolean;
  8906. /**
  8907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8908. */
  8909. forceProjectionMatrixCompute(): void;
  8910. /** @hidden */
  8911. _initCache(): void;
  8912. /** @hidden */
  8913. _isSynchronized(): boolean;
  8914. /**
  8915. * Computes the world matrix of the node
  8916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8917. * @returns the world matrix
  8918. */
  8919. computeWorldMatrix(force?: boolean): Matrix;
  8920. /**
  8921. * Gets the minZ used for shadow according to both the scene and the light.
  8922. * @param activeCamera The camera we are returning the min for
  8923. * @returns the depth min z
  8924. */
  8925. getDepthMinZ(activeCamera: Camera): number;
  8926. /**
  8927. * Gets the maxZ used for shadow according to both the scene and the light.
  8928. * @param activeCamera The camera we are returning the max for
  8929. * @returns the depth max z
  8930. */
  8931. getDepthMaxZ(activeCamera: Camera): number;
  8932. /**
  8933. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8934. * @param matrix The materix to updated with the projection information
  8935. * @param viewMatrix The transform matrix of the light
  8936. * @param renderList The list of mesh to render in the map
  8937. * @returns The current light
  8938. */
  8939. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8940. }
  8941. }
  8942. declare module "babylonjs/Materials/effectFallbacks" {
  8943. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8944. import { Effect } from "babylonjs/Materials/effect";
  8945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8946. /**
  8947. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8948. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8949. */
  8950. export class EffectFallbacks implements IEffectFallbacks {
  8951. private _defines;
  8952. private _currentRank;
  8953. private _maxRank;
  8954. private _mesh;
  8955. /**
  8956. * Removes the fallback from the bound mesh.
  8957. */
  8958. unBindMesh(): void;
  8959. /**
  8960. * Adds a fallback on the specified property.
  8961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8962. * @param define The name of the define in the shader
  8963. */
  8964. addFallback(rank: number, define: string): void;
  8965. /**
  8966. * Sets the mesh to use CPU skinning when needing to fallback.
  8967. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8968. * @param mesh The mesh to use the fallbacks.
  8969. */
  8970. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8971. /**
  8972. * Checks to see if more fallbacks are still availible.
  8973. */
  8974. readonly hasMoreFallbacks: boolean;
  8975. /**
  8976. * Removes the defines that should be removed when falling back.
  8977. * @param currentDefines defines the current define statements for the shader.
  8978. * @param effect defines the current effect we try to compile
  8979. * @returns The resulting defines with defines of the current rank removed.
  8980. */
  8981. reduce(currentDefines: string, effect: Effect): string;
  8982. }
  8983. }
  8984. declare module "babylonjs/Materials/materialHelper" {
  8985. import { Nullable } from "babylonjs/types";
  8986. import { Scene } from "babylonjs/scene";
  8987. import { Engine } from "babylonjs/Engines/engine";
  8988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8989. import { Light } from "babylonjs/Lights/light";
  8990. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8991. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8995. /**
  8996. * "Static Class" containing the most commonly used helper while dealing with material for
  8997. * rendering purpose.
  8998. *
  8999. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9000. *
  9001. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9002. */
  9003. export class MaterialHelper {
  9004. /**
  9005. * Bind the current view position to an effect.
  9006. * @param effect The effect to be bound
  9007. * @param scene The scene the eyes position is used from
  9008. */
  9009. static BindEyePosition(effect: Effect, scene: Scene): void;
  9010. /**
  9011. * Helps preparing the defines values about the UVs in used in the effect.
  9012. * UVs are shared as much as we can accross channels in the shaders.
  9013. * @param texture The texture we are preparing the UVs for
  9014. * @param defines The defines to update
  9015. * @param key The channel key "diffuse", "specular"... used in the shader
  9016. */
  9017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9018. /**
  9019. * Binds a texture matrix value to its corrsponding uniform
  9020. * @param texture The texture to bind the matrix for
  9021. * @param uniformBuffer The uniform buffer receivin the data
  9022. * @param key The channel key "diffuse", "specular"... used in the shader
  9023. */
  9024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9025. /**
  9026. * Gets the current status of the fog (should it be enabled?)
  9027. * @param mesh defines the mesh to evaluate for fog support
  9028. * @param scene defines the hosting scene
  9029. * @returns true if fog must be enabled
  9030. */
  9031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9032. /**
  9033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9034. * @param mesh defines the current mesh
  9035. * @param scene defines the current scene
  9036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9037. * @param pointsCloud defines if point cloud rendering has to be turned on
  9038. * @param fogEnabled defines if fog has to be turned on
  9039. * @param alphaTest defines if alpha testing has to be turned on
  9040. * @param defines defines the current list of defines
  9041. */
  9042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9043. /**
  9044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9045. * @param scene defines the current scene
  9046. * @param engine defines the current engine
  9047. * @param defines specifies the list of active defines
  9048. * @param useInstances defines if instances have to be turned on
  9049. * @param useClipPlane defines if clip plane have to be turned on
  9050. */
  9051. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9052. /**
  9053. * Prepares the defines for bones
  9054. * @param mesh The mesh containing the geometry data we will draw
  9055. * @param defines The defines to update
  9056. */
  9057. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9058. /**
  9059. * Prepares the defines for morph targets
  9060. * @param mesh The mesh containing the geometry data we will draw
  9061. * @param defines The defines to update
  9062. */
  9063. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9064. /**
  9065. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9066. * @param mesh The mesh containing the geometry data we will draw
  9067. * @param defines The defines to update
  9068. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9069. * @param useBones Precise whether bones should be used or not (override mesh info)
  9070. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9071. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9072. * @returns false if defines are considered not dirty and have not been checked
  9073. */
  9074. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9075. /**
  9076. * Prepares the defines related to multiview
  9077. * @param scene The scene we are intending to draw
  9078. * @param defines The defines to update
  9079. */
  9080. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9081. /**
  9082. * Prepares the defines related to the light information passed in parameter
  9083. * @param scene The scene we are intending to draw
  9084. * @param mesh The mesh the effect is compiling for
  9085. * @param light The light the effect is compiling for
  9086. * @param lightIndex The index of the light
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param state Defines the current state regarding what is needed (normals, etc...)
  9090. */
  9091. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9092. needNormals: boolean;
  9093. needRebuild: boolean;
  9094. shadowEnabled: boolean;
  9095. specularEnabled: boolean;
  9096. lightmapMode: boolean;
  9097. }): void;
  9098. /**
  9099. * Prepares the defines related to the light information passed in parameter
  9100. * @param scene The scene we are intending to draw
  9101. * @param mesh The mesh the effect is compiling for
  9102. * @param defines The defines to update
  9103. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9104. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9105. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9106. * @returns true if normals will be required for the rest of the effect
  9107. */
  9108. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9109. /**
  9110. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9111. * @param lightIndex defines the light index
  9112. * @param uniformsList The uniform list
  9113. * @param samplersList The sampler list
  9114. * @param projectedLightTexture defines if projected texture must be used
  9115. * @param uniformBuffersList defines an optional list of uniform buffers
  9116. */
  9117. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9118. /**
  9119. * Prepares the uniforms and samplers list to be used in the effect
  9120. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9121. * @param samplersList The sampler list
  9122. * @param defines The defines helping in the list generation
  9123. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9124. */
  9125. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9126. /**
  9127. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9128. * @param defines The defines to update while falling back
  9129. * @param fallbacks The authorized effect fallbacks
  9130. * @param maxSimultaneousLights The maximum number of lights allowed
  9131. * @param rank the current rank of the Effect
  9132. * @returns The newly affected rank
  9133. */
  9134. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9135. private static _TmpMorphInfluencers;
  9136. /**
  9137. * Prepares the list of attributes required for morph targets according to the effect defines.
  9138. * @param attribs The current list of supported attribs
  9139. * @param mesh The mesh to prepare the morph targets attributes for
  9140. * @param influencers The number of influencers
  9141. */
  9142. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9143. /**
  9144. * Prepares the list of attributes required for morph targets according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param mesh The mesh to prepare the morph targets attributes for
  9147. * @param defines The current Defines of the effect
  9148. */
  9149. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9150. /**
  9151. * Prepares the list of attributes required for bones according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the bones attributes for
  9154. * @param defines The current Defines of the effect
  9155. * @param fallbacks The current efffect fallback strategy
  9156. */
  9157. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9158. /**
  9159. * Check and prepare the list of attributes required for instances according to the effect defines.
  9160. * @param attribs The current list of supported attribs
  9161. * @param defines The current MaterialDefines of the effect
  9162. */
  9163. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9164. /**
  9165. * Add the list of attributes required for instances to the attribs array.
  9166. * @param attribs The current list of supported attribs
  9167. */
  9168. static PushAttributesForInstances(attribs: string[]): void;
  9169. /**
  9170. * Binds the light information to the effect.
  9171. * @param light The light containing the generator
  9172. * @param effect The effect we are binding the data to
  9173. * @param lightIndex The light index in the effect used to render
  9174. */
  9175. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9176. /**
  9177. * Binds the lights information from the scene to the effect for the given mesh.
  9178. * @param light Light to bind
  9179. * @param lightIndex Light index
  9180. * @param scene The scene where the light belongs to
  9181. * @param effect The effect we are binding the data to
  9182. * @param useSpecular Defines if specular is supported
  9183. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9184. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9185. */
  9186. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9196. */
  9197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9198. private static _tempFogColor;
  9199. /**
  9200. * Binds the fog information from the scene to the effect for the given mesh.
  9201. * @param scene The scene the lights belongs to
  9202. * @param mesh The mesh we are binding the information to render
  9203. * @param effect The effect we are binding the data to
  9204. * @param linearSpace Defines if the fog effect is applied in linear space
  9205. */
  9206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9207. /**
  9208. * Binds the bones information from the mesh to the effect.
  9209. * @param mesh The mesh we are binding the information to render
  9210. * @param effect The effect we are binding the data to
  9211. */
  9212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9213. /**
  9214. * Binds the morph targets information from the mesh to the effect.
  9215. * @param abstractMesh The mesh we are binding the information to render
  9216. * @param effect The effect we are binding the data to
  9217. */
  9218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9219. /**
  9220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9221. * @param defines The generated defines used in the effect
  9222. * @param effect The effect we are binding the data to
  9223. * @param scene The scene we are willing to render with logarithmic scale for
  9224. */
  9225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9226. /**
  9227. * Binds the clip plane information from the scene to the effect.
  9228. * @param scene The scene the clip plane information are extracted from
  9229. * @param effect The effect we are binding the data to
  9230. */
  9231. static BindClipPlane(effect: Effect, scene: Scene): void;
  9232. }
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9235. /** @hidden */
  9236. export var packingFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. /** @hidden */
  9244. export var shadowMapPixelShader: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9250. /** @hidden */
  9251. export var bonesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9257. /** @hidden */
  9258. export var morphTargetsVertexGlobalDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9264. /** @hidden */
  9265. export var morphTargetsVertexDeclaration: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9271. /** @hidden */
  9272. export var instancesDeclaration: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9278. /** @hidden */
  9279. export var helperFunctions: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9285. /** @hidden */
  9286. export var morphTargetsVertex: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9292. /** @hidden */
  9293. export var instancesVertex: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9299. /** @hidden */
  9300. export var bonesVertex: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9306. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9312. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9313. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9314. /** @hidden */
  9315. export var shadowMapVertexShader: {
  9316. name: string;
  9317. shader: string;
  9318. };
  9319. }
  9320. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9321. /** @hidden */
  9322. export var depthBoxBlurPixelShader: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9328. import { Nullable } from "babylonjs/types";
  9329. import { Scene } from "babylonjs/scene";
  9330. import { Matrix } from "babylonjs/Maths/math.vector";
  9331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9333. import { Mesh } from "babylonjs/Meshes/mesh";
  9334. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9335. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9336. import { Effect } from "babylonjs/Materials/effect";
  9337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9338. import "babylonjs/Shaders/shadowMap.fragment";
  9339. import "babylonjs/Shaders/shadowMap.vertex";
  9340. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9341. import { Observable } from "babylonjs/Misc/observable";
  9342. /**
  9343. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9344. */
  9345. export interface ICustomShaderOptions {
  9346. /**
  9347. * Gets or sets the custom shader name to use
  9348. */
  9349. shaderName: string;
  9350. /**
  9351. * The list of attribute names used in the shader
  9352. */
  9353. attributes?: string[];
  9354. /**
  9355. * The list of unifrom names used in the shader
  9356. */
  9357. uniforms?: string[];
  9358. /**
  9359. * The list of sampler names used in the shader
  9360. */
  9361. samplers?: string[];
  9362. /**
  9363. * The list of defines used in the shader
  9364. */
  9365. defines?: string[];
  9366. }
  9367. /**
  9368. * Interface to implement to create a shadow generator compatible with BJS.
  9369. */
  9370. export interface IShadowGenerator {
  9371. /**
  9372. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9373. * @returns The render target texture if present otherwise, null
  9374. */
  9375. getShadowMap(): Nullable<RenderTargetTexture>;
  9376. /**
  9377. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9378. * @returns The render target texture if the shadow map is present otherwise, null
  9379. */
  9380. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9381. /**
  9382. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9383. * @param subMesh The submesh we want to render in the shadow map
  9384. * @param useInstances Defines wether will draw in the map using instances
  9385. * @returns true if ready otherwise, false
  9386. */
  9387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9388. /**
  9389. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9390. * @param defines Defines of the material we want to update
  9391. * @param lightIndex Index of the light in the enabled light list of the material
  9392. */
  9393. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9394. /**
  9395. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9396. * defined in the generator but impacting the effect).
  9397. * It implies the unifroms available on the materials are the standard BJS ones.
  9398. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9399. * @param effect The effect we are binfing the information for
  9400. */
  9401. bindShadowLight(lightIndex: string, effect: Effect): void;
  9402. /**
  9403. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9404. * (eq to shadow prjection matrix * light transform matrix)
  9405. * @returns The transform matrix used to create the shadow map
  9406. */
  9407. getTransformMatrix(): Matrix;
  9408. /**
  9409. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9410. * Cube and 2D textures for instance.
  9411. */
  9412. recreateShadowMap(): void;
  9413. /**
  9414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9415. * @param onCompiled Callback triggered at the and of the effects compilation
  9416. * @param options Sets of optional options forcing the compilation with different modes
  9417. */
  9418. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9419. useInstances: boolean;
  9420. }>): void;
  9421. /**
  9422. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9423. * @param options Sets of optional options forcing the compilation with different modes
  9424. * @returns A promise that resolves when the compilation completes
  9425. */
  9426. forceCompilationAsync(options?: Partial<{
  9427. useInstances: boolean;
  9428. }>): Promise<void>;
  9429. /**
  9430. * Serializes the shadow generator setup to a json object.
  9431. * @returns The serialized JSON object
  9432. */
  9433. serialize(): any;
  9434. /**
  9435. * Disposes the Shadow map and related Textures and effects.
  9436. */
  9437. dispose(): void;
  9438. }
  9439. /**
  9440. * Default implementation IShadowGenerator.
  9441. * This is the main object responsible of generating shadows in the framework.
  9442. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9443. */
  9444. export class ShadowGenerator implements IShadowGenerator {
  9445. /**
  9446. * Shadow generator mode None: no filtering applied.
  9447. */
  9448. static readonly FILTER_NONE: number;
  9449. /**
  9450. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9452. */
  9453. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9454. /**
  9455. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9456. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9457. */
  9458. static readonly FILTER_POISSONSAMPLING: number;
  9459. /**
  9460. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9462. */
  9463. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9464. /**
  9465. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9466. * edge artifacts on steep falloff.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode PCF: Percentage Closer Filtering
  9478. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9479. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9480. */
  9481. static readonly FILTER_PCF: number;
  9482. /**
  9483. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * Contact Hardening
  9486. */
  9487. static readonly FILTER_PCSS: number;
  9488. /**
  9489. * Reserved for PCF and PCSS
  9490. * Highest Quality.
  9491. *
  9492. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9493. *
  9494. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9495. */
  9496. static readonly QUALITY_HIGH: number;
  9497. /**
  9498. * Reserved for PCF and PCSS
  9499. * Good tradeoff for quality/perf cross devices
  9500. *
  9501. * Execute PCF on a 3*3 kernel.
  9502. *
  9503. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9504. */
  9505. static readonly QUALITY_MEDIUM: number;
  9506. /**
  9507. * Reserved for PCF and PCSS
  9508. * The lowest quality but the fastest.
  9509. *
  9510. * Execute PCF on a 1*1 kernel.
  9511. *
  9512. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9513. */
  9514. static readonly QUALITY_LOW: number;
  9515. /** Gets or sets the custom shader name to use */
  9516. customShaderOptions: ICustomShaderOptions;
  9517. /**
  9518. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9519. */
  9520. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9521. /**
  9522. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9523. */
  9524. onAfterShadowMapRenderObservable: Observable<Effect>;
  9525. /**
  9526. * Observable triggered before a mesh is rendered in the shadow map.
  9527. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9528. */
  9529. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9530. /**
  9531. * Observable triggered after a mesh is rendered in the shadow map.
  9532. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9533. */
  9534. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9535. private _bias;
  9536. /**
  9537. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9538. */
  9539. /**
  9540. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9541. */
  9542. bias: number;
  9543. private _normalBias;
  9544. /**
  9545. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9546. */
  9547. /**
  9548. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9549. */
  9550. normalBias: number;
  9551. private _blurBoxOffset;
  9552. /**
  9553. * Gets the blur box offset: offset applied during the blur pass.
  9554. * Only useful if useKernelBlur = false
  9555. */
  9556. /**
  9557. * Sets the blur box offset: offset applied during the blur pass.
  9558. * Only useful if useKernelBlur = false
  9559. */
  9560. blurBoxOffset: number;
  9561. private _blurScale;
  9562. /**
  9563. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9564. * 2 means half of the size.
  9565. */
  9566. /**
  9567. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9568. * 2 means half of the size.
  9569. */
  9570. blurScale: number;
  9571. private _blurKernel;
  9572. /**
  9573. * Gets the blur kernel: kernel size of the blur pass.
  9574. * Only useful if useKernelBlur = true
  9575. */
  9576. /**
  9577. * Sets the blur kernel: kernel size of the blur pass.
  9578. * Only useful if useKernelBlur = true
  9579. */
  9580. blurKernel: number;
  9581. private _useKernelBlur;
  9582. /**
  9583. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9584. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9585. */
  9586. /**
  9587. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9588. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9589. */
  9590. useKernelBlur: boolean;
  9591. private _depthScale;
  9592. /**
  9593. * Gets the depth scale used in ESM mode.
  9594. */
  9595. /**
  9596. * Sets the depth scale used in ESM mode.
  9597. * This can override the scale stored on the light.
  9598. */
  9599. depthScale: number;
  9600. private _filter;
  9601. /**
  9602. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9603. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9604. */
  9605. /**
  9606. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9607. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9608. */
  9609. filter: number;
  9610. /**
  9611. * Gets if the current filter is set to Poisson Sampling.
  9612. */
  9613. /**
  9614. * Sets the current filter to Poisson Sampling.
  9615. */
  9616. usePoissonSampling: boolean;
  9617. /**
  9618. * Gets if the current filter is set to ESM.
  9619. */
  9620. /**
  9621. * Sets the current filter is to ESM.
  9622. */
  9623. useExponentialShadowMap: boolean;
  9624. /**
  9625. * Gets if the current filter is set to filtered ESM.
  9626. */
  9627. /**
  9628. * Gets if the current filter is set to filtered ESM.
  9629. */
  9630. useBlurExponentialShadowMap: boolean;
  9631. /**
  9632. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9633. * exponential to prevent steep falloff artifacts).
  9634. */
  9635. /**
  9636. * Sets the current filter to "close ESM" (using the inverse of the
  9637. * exponential to prevent steep falloff artifacts).
  9638. */
  9639. useCloseExponentialShadowMap: boolean;
  9640. /**
  9641. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9642. * exponential to prevent steep falloff artifacts).
  9643. */
  9644. /**
  9645. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9646. * exponential to prevent steep falloff artifacts).
  9647. */
  9648. useBlurCloseExponentialShadowMap: boolean;
  9649. /**
  9650. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9651. */
  9652. /**
  9653. * Sets the current filter to "PCF" (percentage closer filtering).
  9654. */
  9655. usePercentageCloserFiltering: boolean;
  9656. private _filteringQuality;
  9657. /**
  9658. * Gets the PCF or PCSS Quality.
  9659. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9660. */
  9661. /**
  9662. * Sets the PCF or PCSS Quality.
  9663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9664. */
  9665. filteringQuality: number;
  9666. /**
  9667. * Gets if the current filter is set to "PCSS" (contact hardening).
  9668. */
  9669. /**
  9670. * Sets the current filter to "PCSS" (contact hardening).
  9671. */
  9672. useContactHardeningShadow: boolean;
  9673. private _contactHardeningLightSizeUVRatio;
  9674. /**
  9675. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9676. * Using a ratio helps keeping shape stability independently of the map size.
  9677. *
  9678. * It does not account for the light projection as it was having too much
  9679. * instability during the light setup or during light position changes.
  9680. *
  9681. * Only valid if useContactHardeningShadow is true.
  9682. */
  9683. /**
  9684. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9685. * Using a ratio helps keeping shape stability independently of the map size.
  9686. *
  9687. * It does not account for the light projection as it was having too much
  9688. * instability during the light setup or during light position changes.
  9689. *
  9690. * Only valid if useContactHardeningShadow is true.
  9691. */
  9692. contactHardeningLightSizeUVRatio: number;
  9693. private _darkness;
  9694. /** Gets or sets the actual darkness of a shadow */
  9695. darkness: number;
  9696. /**
  9697. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9698. * 0 means strongest and 1 would means no shadow.
  9699. * @returns the darkness.
  9700. */
  9701. getDarkness(): number;
  9702. /**
  9703. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9704. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9705. * @returns the shadow generator allowing fluent coding.
  9706. */
  9707. setDarkness(darkness: number): ShadowGenerator;
  9708. private _transparencyShadow;
  9709. /** Gets or sets the ability to have transparent shadow */
  9710. transparencyShadow: boolean;
  9711. /**
  9712. * Sets the ability to have transparent shadow (boolean).
  9713. * @param transparent True if transparent else False
  9714. * @returns the shadow generator allowing fluent coding
  9715. */
  9716. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9717. private _shadowMap;
  9718. private _shadowMap2;
  9719. /**
  9720. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9721. * @returns The render target texture if present otherwise, null
  9722. */
  9723. getShadowMap(): Nullable<RenderTargetTexture>;
  9724. /**
  9725. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9726. * @returns The render target texture if the shadow map is present otherwise, null
  9727. */
  9728. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9729. /**
  9730. * Gets the class name of that object
  9731. * @returns "ShadowGenerator"
  9732. */
  9733. getClassName(): string;
  9734. /**
  9735. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9736. * @param mesh Mesh to add
  9737. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9738. * @returns the Shadow Generator itself
  9739. */
  9740. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9741. /**
  9742. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9743. * @param mesh Mesh to remove
  9744. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9745. * @returns the Shadow Generator itself
  9746. */
  9747. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9748. /**
  9749. * Controls the extent to which the shadows fade out at the edge of the frustum
  9750. * Used only by directionals and spots
  9751. */
  9752. frustumEdgeFalloff: number;
  9753. private _light;
  9754. /**
  9755. * Returns the associated light object.
  9756. * @returns the light generating the shadow
  9757. */
  9758. getLight(): IShadowLight;
  9759. /**
  9760. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9761. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9762. * It might on the other hand introduce peter panning.
  9763. */
  9764. forceBackFacesOnly: boolean;
  9765. private _scene;
  9766. private _lightDirection;
  9767. private _effect;
  9768. private _viewMatrix;
  9769. private _projectionMatrix;
  9770. private _transformMatrix;
  9771. private _cachedPosition;
  9772. private _cachedDirection;
  9773. private _cachedDefines;
  9774. private _currentRenderID;
  9775. private _boxBlurPostprocess;
  9776. private _kernelBlurXPostprocess;
  9777. private _kernelBlurYPostprocess;
  9778. private _blurPostProcesses;
  9779. private _mapSize;
  9780. private _currentFaceIndex;
  9781. private _currentFaceIndexCache;
  9782. private _textureType;
  9783. private _defaultTextureMatrix;
  9784. private _storedUniqueId;
  9785. /** @hidden */
  9786. static _SceneComponentInitialization: (scene: Scene) => void;
  9787. /**
  9788. * Creates a ShadowGenerator object.
  9789. * A ShadowGenerator is the required tool to use the shadows.
  9790. * Each light casting shadows needs to use its own ShadowGenerator.
  9791. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9792. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9793. * @param light The light object generating the shadows.
  9794. * @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.
  9795. */
  9796. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9797. private _initializeGenerator;
  9798. private _initializeShadowMap;
  9799. private _initializeBlurRTTAndPostProcesses;
  9800. private _renderForShadowMap;
  9801. private _renderSubMeshForShadowMap;
  9802. private _applyFilterValues;
  9803. /**
  9804. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9805. * @param onCompiled Callback triggered at the and of the effects compilation
  9806. * @param options Sets of optional options forcing the compilation with different modes
  9807. */
  9808. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9809. useInstances: boolean;
  9810. }>): void;
  9811. /**
  9812. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9813. * @param options Sets of optional options forcing the compilation with different modes
  9814. * @returns A promise that resolves when the compilation completes
  9815. */
  9816. forceCompilationAsync(options?: Partial<{
  9817. useInstances: boolean;
  9818. }>): Promise<void>;
  9819. /**
  9820. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9821. * @param subMesh The submesh we want to render in the shadow map
  9822. * @param useInstances Defines wether will draw in the map using instances
  9823. * @returns true if ready otherwise, false
  9824. */
  9825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9826. /**
  9827. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9828. * @param defines Defines of the material we want to update
  9829. * @param lightIndex Index of the light in the enabled light list of the material
  9830. */
  9831. prepareDefines(defines: any, lightIndex: number): void;
  9832. /**
  9833. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9834. * defined in the generator but impacting the effect).
  9835. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9836. * @param effect The effect we are binfing the information for
  9837. */
  9838. bindShadowLight(lightIndex: string, effect: Effect): void;
  9839. /**
  9840. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9841. * (eq to shadow prjection matrix * light transform matrix)
  9842. * @returns The transform matrix used to create the shadow map
  9843. */
  9844. getTransformMatrix(): Matrix;
  9845. /**
  9846. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9847. * Cube and 2D textures for instance.
  9848. */
  9849. recreateShadowMap(): void;
  9850. private _disposeBlurPostProcesses;
  9851. private _disposeRTTandPostProcesses;
  9852. /**
  9853. * Disposes the ShadowGenerator.
  9854. * Returns nothing.
  9855. */
  9856. dispose(): void;
  9857. /**
  9858. * Serializes the shadow generator setup to a json object.
  9859. * @returns The serialized JSON object
  9860. */
  9861. serialize(): any;
  9862. /**
  9863. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9864. * @param parsedShadowGenerator The JSON object to parse
  9865. * @param scene The scene to create the shadow map for
  9866. * @returns The parsed shadow generator
  9867. */
  9868. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9869. }
  9870. }
  9871. declare module "babylonjs/Lights/light" {
  9872. import { Nullable } from "babylonjs/types";
  9873. import { Scene } from "babylonjs/scene";
  9874. import { Vector3 } from "babylonjs/Maths/math.vector";
  9875. import { Color3 } from "babylonjs/Maths/math.color";
  9876. import { Node } from "babylonjs/node";
  9877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9878. import { Effect } from "babylonjs/Materials/effect";
  9879. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9881. /**
  9882. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9883. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9884. * 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.
  9885. */
  9886. export abstract class Light extends Node {
  9887. /**
  9888. * Falloff Default: light is falling off following the material specification:
  9889. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9890. */
  9891. static readonly FALLOFF_DEFAULT: number;
  9892. /**
  9893. * Falloff Physical: light is falling off following the inverse squared distance law.
  9894. */
  9895. static readonly FALLOFF_PHYSICAL: number;
  9896. /**
  9897. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9898. * to enhance interoperability with other engines.
  9899. */
  9900. static readonly FALLOFF_GLTF: number;
  9901. /**
  9902. * Falloff Standard: light is falling off like in the standard material
  9903. * to enhance interoperability with other materials.
  9904. */
  9905. static readonly FALLOFF_STANDARD: number;
  9906. /**
  9907. * If every light affecting the material is in this lightmapMode,
  9908. * material.lightmapTexture adds or multiplies
  9909. * (depends on material.useLightmapAsShadowmap)
  9910. * after every other light calculations.
  9911. */
  9912. static readonly LIGHTMAP_DEFAULT: number;
  9913. /**
  9914. * material.lightmapTexture as only diffuse lighting from this light
  9915. * adds only specular lighting from this light
  9916. * adds dynamic shadows
  9917. */
  9918. static readonly LIGHTMAP_SPECULAR: number;
  9919. /**
  9920. * material.lightmapTexture as only lighting
  9921. * no light calculation from this light
  9922. * only adds dynamic shadows from this light
  9923. */
  9924. static readonly LIGHTMAP_SHADOWSONLY: number;
  9925. /**
  9926. * Each light type uses the default quantity according to its type:
  9927. * point/spot lights use luminous intensity
  9928. * directional lights use illuminance
  9929. */
  9930. static readonly INTENSITYMODE_AUTOMATIC: number;
  9931. /**
  9932. * lumen (lm)
  9933. */
  9934. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9935. /**
  9936. * candela (lm/sr)
  9937. */
  9938. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9939. /**
  9940. * lux (lm/m^2)
  9941. */
  9942. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9943. /**
  9944. * nit (cd/m^2)
  9945. */
  9946. static readonly INTENSITYMODE_LUMINANCE: number;
  9947. /**
  9948. * Light type const id of the point light.
  9949. */
  9950. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9951. /**
  9952. * Light type const id of the directional light.
  9953. */
  9954. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9955. /**
  9956. * Light type const id of the spot light.
  9957. */
  9958. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9959. /**
  9960. * Light type const id of the hemispheric light.
  9961. */
  9962. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9963. /**
  9964. * Diffuse gives the basic color to an object.
  9965. */
  9966. diffuse: Color3;
  9967. /**
  9968. * Specular produces a highlight color on an object.
  9969. * Note: This is note affecting PBR materials.
  9970. */
  9971. specular: Color3;
  9972. /**
  9973. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9974. * falling off base on range or angle.
  9975. * This can be set to any values in Light.FALLOFF_x.
  9976. *
  9977. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9978. * other types of materials.
  9979. */
  9980. falloffType: number;
  9981. /**
  9982. * Strength of the light.
  9983. * Note: By default it is define in the framework own unit.
  9984. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9985. */
  9986. intensity: number;
  9987. private _range;
  9988. protected _inverseSquaredRange: number;
  9989. /**
  9990. * Defines how far from the source the light is impacting in scene units.
  9991. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9992. */
  9993. /**
  9994. * Defines how far from the source the light is impacting in scene units.
  9995. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9996. */
  9997. range: number;
  9998. /**
  9999. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10000. * of light.
  10001. */
  10002. private _photometricScale;
  10003. private _intensityMode;
  10004. /**
  10005. * Gets the photometric scale used to interpret the intensity.
  10006. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10007. */
  10008. /**
  10009. * Sets the photometric scale used to interpret the intensity.
  10010. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10011. */
  10012. intensityMode: number;
  10013. private _radius;
  10014. /**
  10015. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10016. */
  10017. /**
  10018. * sets the light radius used by PBR Materials to simulate soft area lights.
  10019. */
  10020. radius: number;
  10021. private _renderPriority;
  10022. /**
  10023. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10024. * exceeding the number allowed of the materials.
  10025. */
  10026. renderPriority: number;
  10027. private _shadowEnabled;
  10028. /**
  10029. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10030. * the current shadow generator.
  10031. */
  10032. /**
  10033. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10034. * the current shadow generator.
  10035. */
  10036. shadowEnabled: boolean;
  10037. private _includedOnlyMeshes;
  10038. /**
  10039. * Gets the only meshes impacted by this light.
  10040. */
  10041. /**
  10042. * Sets the only meshes impacted by this light.
  10043. */
  10044. includedOnlyMeshes: AbstractMesh[];
  10045. private _excludedMeshes;
  10046. /**
  10047. * Gets the meshes not impacted by this light.
  10048. */
  10049. /**
  10050. * Sets the meshes not impacted by this light.
  10051. */
  10052. excludedMeshes: AbstractMesh[];
  10053. private _excludeWithLayerMask;
  10054. /**
  10055. * Gets the layer id use to find what meshes are not impacted by the light.
  10056. * Inactive if 0
  10057. */
  10058. /**
  10059. * Sets the layer id use to find what meshes are not impacted by the light.
  10060. * Inactive if 0
  10061. */
  10062. excludeWithLayerMask: number;
  10063. private _includeOnlyWithLayerMask;
  10064. /**
  10065. * Gets the layer id use to find what meshes are impacted by the light.
  10066. * Inactive if 0
  10067. */
  10068. /**
  10069. * Sets the layer id use to find what meshes are impacted by the light.
  10070. * Inactive if 0
  10071. */
  10072. includeOnlyWithLayerMask: number;
  10073. private _lightmapMode;
  10074. /**
  10075. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10076. */
  10077. /**
  10078. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10079. */
  10080. lightmapMode: number;
  10081. /**
  10082. * Shadow generator associted to the light.
  10083. * @hidden Internal use only.
  10084. */
  10085. _shadowGenerator: Nullable<IShadowGenerator>;
  10086. /**
  10087. * @hidden Internal use only.
  10088. */
  10089. _excludedMeshesIds: string[];
  10090. /**
  10091. * @hidden Internal use only.
  10092. */
  10093. _includedOnlyMeshesIds: string[];
  10094. /**
  10095. * The current light unifom buffer.
  10096. * @hidden Internal use only.
  10097. */
  10098. _uniformBuffer: UniformBuffer;
  10099. /** @hidden */
  10100. _renderId: number;
  10101. /**
  10102. * Creates a Light object in the scene.
  10103. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10104. * @param name The firendly name of the light
  10105. * @param scene The scene the light belongs too
  10106. */
  10107. constructor(name: string, scene: Scene);
  10108. protected abstract _buildUniformLayout(): void;
  10109. /**
  10110. * Sets the passed Effect "effect" with the Light information.
  10111. * @param effect The effect to update
  10112. * @param lightIndex The index of the light in the effect to update
  10113. * @returns The light
  10114. */
  10115. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10116. /**
  10117. * Sets the passed Effect "effect" with the Light information.
  10118. * @param effect The effect to update
  10119. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10120. * @returns The light
  10121. */
  10122. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10123. /**
  10124. * Returns the string "Light".
  10125. * @returns the class name
  10126. */
  10127. getClassName(): string;
  10128. /** @hidden */
  10129. readonly _isLight: boolean;
  10130. /**
  10131. * Converts the light information to a readable string for debug purpose.
  10132. * @param fullDetails Supports for multiple levels of logging within scene loading
  10133. * @returns the human readable light info
  10134. */
  10135. toString(fullDetails?: boolean): string;
  10136. /** @hidden */
  10137. protected _syncParentEnabledState(): void;
  10138. /**
  10139. * Set the enabled state of this node.
  10140. * @param value - the new enabled state
  10141. */
  10142. setEnabled(value: boolean): void;
  10143. /**
  10144. * Returns the Light associated shadow generator if any.
  10145. * @return the associated shadow generator.
  10146. */
  10147. getShadowGenerator(): Nullable<IShadowGenerator>;
  10148. /**
  10149. * Returns a Vector3, the absolute light position in the World.
  10150. * @returns the world space position of the light
  10151. */
  10152. getAbsolutePosition(): Vector3;
  10153. /**
  10154. * Specifies if the light will affect the passed mesh.
  10155. * @param mesh The mesh to test against the light
  10156. * @return true the mesh is affected otherwise, false.
  10157. */
  10158. canAffectMesh(mesh: AbstractMesh): boolean;
  10159. /**
  10160. * Sort function to order lights for rendering.
  10161. * @param a First Light object to compare to second.
  10162. * @param b Second Light object to compare first.
  10163. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10164. */
  10165. static CompareLightsPriority(a: Light, b: Light): number;
  10166. /**
  10167. * Releases resources associated with this node.
  10168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10170. */
  10171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10172. /**
  10173. * Returns the light type ID (integer).
  10174. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10175. */
  10176. getTypeID(): number;
  10177. /**
  10178. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10179. * @returns the scaled intensity in intensity mode unit
  10180. */
  10181. getScaledIntensity(): number;
  10182. /**
  10183. * Returns a new Light object, named "name", from the current one.
  10184. * @param name The name of the cloned light
  10185. * @returns the new created light
  10186. */
  10187. clone(name: string): Nullable<Light>;
  10188. /**
  10189. * Serializes the current light into a Serialization object.
  10190. * @returns the serialized object.
  10191. */
  10192. serialize(): any;
  10193. /**
  10194. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10195. * This new light is named "name" and added to the passed scene.
  10196. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10197. * @param name The friendly name of the light
  10198. * @param scene The scene the new light will belong to
  10199. * @returns the constructor function
  10200. */
  10201. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10202. /**
  10203. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10204. * @param parsedLight The JSON representation of the light
  10205. * @param scene The scene to create the parsed light in
  10206. * @returns the created light after parsing
  10207. */
  10208. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10209. private _hookArrayForExcluded;
  10210. private _hookArrayForIncludedOnly;
  10211. private _resyncMeshes;
  10212. /**
  10213. * Forces the meshes to update their light related information in their rendering used effects
  10214. * @hidden Internal Use Only
  10215. */
  10216. _markMeshesAsLightDirty(): void;
  10217. /**
  10218. * Recomputes the cached photometric scale if needed.
  10219. */
  10220. private _computePhotometricScale;
  10221. /**
  10222. * Returns the Photometric Scale according to the light type and intensity mode.
  10223. */
  10224. private _getPhotometricScale;
  10225. /**
  10226. * Reorder the light in the scene according to their defined priority.
  10227. * @hidden Internal Use Only
  10228. */
  10229. _reorderLightsInScene(): void;
  10230. /**
  10231. * Prepares the list of defines specific to the light type.
  10232. * @param defines the list of defines
  10233. * @param lightIndex defines the index of the light for the effect
  10234. */
  10235. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10236. }
  10237. }
  10238. declare module "babylonjs/Actions/action" {
  10239. import { Observable } from "babylonjs/Misc/observable";
  10240. import { Condition } from "babylonjs/Actions/condition";
  10241. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10242. import { ActionManager } from "babylonjs/Actions/actionManager";
  10243. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10244. /**
  10245. * Interface used to define Action
  10246. */
  10247. export interface IAction {
  10248. /**
  10249. * Trigger for the action
  10250. */
  10251. trigger: number;
  10252. /** Options of the trigger */
  10253. triggerOptions: any;
  10254. /**
  10255. * Gets the trigger parameters
  10256. * @returns the trigger parameters
  10257. */
  10258. getTriggerParameter(): any;
  10259. /**
  10260. * Internal only - executes current action event
  10261. * @hidden
  10262. */
  10263. _executeCurrent(evt?: ActionEvent): void;
  10264. /**
  10265. * Serialize placeholder for child classes
  10266. * @param parent of child
  10267. * @returns the serialized object
  10268. */
  10269. serialize(parent: any): any;
  10270. /**
  10271. * Internal only
  10272. * @hidden
  10273. */
  10274. _prepare(): void;
  10275. /**
  10276. * Internal only - manager for action
  10277. * @hidden
  10278. */
  10279. _actionManager: AbstractActionManager;
  10280. /**
  10281. * Adds action to chain of actions, may be a DoNothingAction
  10282. * @param action defines the next action to execute
  10283. * @returns The action passed in
  10284. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10285. */
  10286. then(action: IAction): IAction;
  10287. }
  10288. /**
  10289. * The action to be carried out following a trigger
  10290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10291. */
  10292. export class Action implements IAction {
  10293. /** the trigger, with or without parameters, for the action */
  10294. triggerOptions: any;
  10295. /**
  10296. * Trigger for the action
  10297. */
  10298. trigger: number;
  10299. /**
  10300. * Internal only - manager for action
  10301. * @hidden
  10302. */
  10303. _actionManager: ActionManager;
  10304. private _nextActiveAction;
  10305. private _child;
  10306. private _condition?;
  10307. private _triggerParameter;
  10308. /**
  10309. * An event triggered prior to action being executed.
  10310. */
  10311. onBeforeExecuteObservable: Observable<Action>;
  10312. /**
  10313. * Creates a new Action
  10314. * @param triggerOptions the trigger, with or without parameters, for the action
  10315. * @param condition an optional determinant of action
  10316. */
  10317. constructor(
  10318. /** the trigger, with or without parameters, for the action */
  10319. triggerOptions: any, condition?: Condition);
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _prepare(): void;
  10325. /**
  10326. * Gets the trigger parameters
  10327. * @returns the trigger parameters
  10328. */
  10329. getTriggerParameter(): any;
  10330. /**
  10331. * Internal only - executes current action event
  10332. * @hidden
  10333. */
  10334. _executeCurrent(evt?: ActionEvent): void;
  10335. /**
  10336. * Execute placeholder for child classes
  10337. * @param evt optional action event
  10338. */
  10339. execute(evt?: ActionEvent): void;
  10340. /**
  10341. * Skips to next active action
  10342. */
  10343. skipToNextActiveAction(): void;
  10344. /**
  10345. * Adds action to chain of actions, may be a DoNothingAction
  10346. * @param action defines the next action to execute
  10347. * @returns The action passed in
  10348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10349. */
  10350. then(action: Action): Action;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _getProperty(propertyPath: string): string;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. _getEffectiveTarget(target: any, propertyPath: string): any;
  10361. /**
  10362. * Serialize placeholder for child classes
  10363. * @param parent of child
  10364. * @returns the serialized object
  10365. */
  10366. serialize(parent: any): any;
  10367. /**
  10368. * Internal only called by serialize
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedAction: any, parent?: any): any;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. static _SerializeValueAsString: (value: any) => string;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10382. name: string;
  10383. targetType: string;
  10384. value: string;
  10385. };
  10386. }
  10387. }
  10388. declare module "babylonjs/Actions/condition" {
  10389. import { ActionManager } from "babylonjs/Actions/actionManager";
  10390. /**
  10391. * A Condition applied to an Action
  10392. */
  10393. export class Condition {
  10394. /**
  10395. * Internal only - manager for action
  10396. * @hidden
  10397. */
  10398. _actionManager: ActionManager;
  10399. /**
  10400. * Internal only
  10401. * @hidden
  10402. */
  10403. _evaluationId: number;
  10404. /**
  10405. * Internal only
  10406. * @hidden
  10407. */
  10408. _currentResult: boolean;
  10409. /**
  10410. * Creates a new Condition
  10411. * @param actionManager the manager of the action the condition is applied to
  10412. */
  10413. constructor(actionManager: ActionManager);
  10414. /**
  10415. * Check if the current condition is valid
  10416. * @returns a boolean
  10417. */
  10418. isValid(): boolean;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. _getProperty(propertyPath: string): string;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /**
  10430. * Serialize placeholder for child classes
  10431. * @returns the serialized object
  10432. */
  10433. serialize(): any;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. protected _serialize(serializedCondition: any): any;
  10439. }
  10440. /**
  10441. * Defines specific conditional operators as extensions of Condition
  10442. */
  10443. export class ValueCondition extends Condition {
  10444. /** path to specify the property of the target the conditional operator uses */
  10445. propertyPath: string;
  10446. /** the value compared by the conditional operator against the current value of the property */
  10447. value: any;
  10448. /** the conditional operator, default ValueCondition.IsEqual */
  10449. operator: number;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private static _IsEqual;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private static _IsDifferent;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private static _IsGreater;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private static _IsLesser;
  10470. /**
  10471. * returns the number for IsEqual
  10472. */
  10473. static readonly IsEqual: number;
  10474. /**
  10475. * Returns the number for IsDifferent
  10476. */
  10477. static readonly IsDifferent: number;
  10478. /**
  10479. * Returns the number for IsGreater
  10480. */
  10481. static readonly IsGreater: number;
  10482. /**
  10483. * Returns the number for IsLesser
  10484. */
  10485. static readonly IsLesser: number;
  10486. /**
  10487. * Internal only The action manager for the condition
  10488. * @hidden
  10489. */
  10490. _actionManager: ActionManager;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private _target;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private _effectiveTarget;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private _property;
  10506. /**
  10507. * Creates a new ValueCondition
  10508. * @param actionManager manager for the action the condition applies to
  10509. * @param target for the action
  10510. * @param propertyPath path to specify the property of the target the conditional operator uses
  10511. * @param value the value compared by the conditional operator against the current value of the property
  10512. * @param operator the conditional operator, default ValueCondition.IsEqual
  10513. */
  10514. constructor(actionManager: ActionManager, target: any,
  10515. /** path to specify the property of the target the conditional operator uses */
  10516. propertyPath: string,
  10517. /** the value compared by the conditional operator against the current value of the property */
  10518. value: any,
  10519. /** the conditional operator, default ValueCondition.IsEqual */
  10520. operator?: number);
  10521. /**
  10522. * Compares the given value with the property value for the specified conditional operator
  10523. * @returns the result of the comparison
  10524. */
  10525. isValid(): boolean;
  10526. /**
  10527. * Serialize the ValueCondition into a JSON compatible object
  10528. * @returns serialization object
  10529. */
  10530. serialize(): any;
  10531. /**
  10532. * Gets the name of the conditional operator for the ValueCondition
  10533. * @param operator the conditional operator
  10534. * @returns the name
  10535. */
  10536. static GetOperatorName(operator: number): string;
  10537. }
  10538. /**
  10539. * Defines a predicate condition as an extension of Condition
  10540. */
  10541. export class PredicateCondition extends Condition {
  10542. /** defines the predicate function used to validate the condition */
  10543. predicate: () => boolean;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. /**
  10550. * Creates a new PredicateCondition
  10551. * @param actionManager manager for the action the condition applies to
  10552. * @param predicate defines the predicate function used to validate the condition
  10553. */
  10554. constructor(actionManager: ActionManager,
  10555. /** defines the predicate function used to validate the condition */
  10556. predicate: () => boolean);
  10557. /**
  10558. * @returns the validity of the predicate condition
  10559. */
  10560. isValid(): boolean;
  10561. }
  10562. /**
  10563. * Defines a state condition as an extension of Condition
  10564. */
  10565. export class StateCondition extends Condition {
  10566. /** Value to compare with target state */
  10567. value: string;
  10568. /**
  10569. * Internal only - manager for action
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _target;
  10578. /**
  10579. * Creates a new StateCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target of the condition
  10582. * @param value to compare with target state
  10583. */
  10584. constructor(actionManager: ActionManager, target: any,
  10585. /** Value to compare with target state */
  10586. value: string);
  10587. /**
  10588. * Gets a boolean indicating if the current condition is met
  10589. * @returns the validity of the state
  10590. */
  10591. isValid(): boolean;
  10592. /**
  10593. * Serialize the StateCondition into a JSON compatible object
  10594. * @returns serialization object
  10595. */
  10596. serialize(): any;
  10597. }
  10598. }
  10599. declare module "babylonjs/Actions/directActions" {
  10600. import { Action } from "babylonjs/Actions/action";
  10601. import { Condition } from "babylonjs/Actions/condition";
  10602. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10603. /**
  10604. * This defines an action responsible to toggle a boolean once triggered.
  10605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10606. */
  10607. export class SwitchBooleanAction extends Action {
  10608. /**
  10609. * The path to the boolean property in the target object
  10610. */
  10611. propertyPath: string;
  10612. private _target;
  10613. private _effectiveTarget;
  10614. private _property;
  10615. /**
  10616. * Instantiate the action
  10617. * @param triggerOptions defines the trigger options
  10618. * @param target defines the object containing the boolean
  10619. * @param propertyPath defines the path to the boolean property in the target object
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10623. /** @hidden */
  10624. _prepare(): void;
  10625. /**
  10626. * Execute the action toggle the boolean value.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to set a the state field of the target
  10638. * to a desired value once triggered.
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10640. */
  10641. export class SetStateAction extends Action {
  10642. /**
  10643. * The value to store in the state field.
  10644. */
  10645. value: string;
  10646. private _target;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the state property
  10651. * @param value defines the value to store in the state field
  10652. * @param condition defines the trigger related conditions
  10653. */
  10654. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10655. /**
  10656. * Execute the action and store the value on the target state property.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to set a property of the target
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SetValueAction extends Action {
  10672. /**
  10673. * The path of the property to set in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value to set in the property
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to set in the target
  10688. * @param value defines the value to set in the property
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and set the targetted property to the desired value.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to increment the target value
  10707. * to a desired value once triggered.
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10709. */
  10710. export class IncrementValueAction extends Action {
  10711. /**
  10712. * The path of the property to increment in the target.
  10713. */
  10714. propertyPath: string;
  10715. /**
  10716. * The value we should increment the property by.
  10717. */
  10718. value: any;
  10719. private _target;
  10720. private _effectiveTarget;
  10721. private _property;
  10722. /**
  10723. * Instantiate the action
  10724. * @param triggerOptions defines the trigger options
  10725. * @param target defines the object containing the property
  10726. * @param propertyPath defines the path of the property to increment in the target
  10727. * @param value defines the value value we should increment the property by
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and increment the target of the value amount.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible to start an animation once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class PlayAnimationAction extends Action {
  10749. /**
  10750. * Where the animation should start (animation frame)
  10751. */
  10752. from: number;
  10753. /**
  10754. * Where the animation should stop (animation frame)
  10755. */
  10756. to: number;
  10757. /**
  10758. * Define if the animation should loop or stop after the first play.
  10759. */
  10760. loop?: boolean;
  10761. private _target;
  10762. /**
  10763. * Instantiate the action
  10764. * @param triggerOptions defines the trigger options
  10765. * @param target defines the target animation or animation name
  10766. * @param from defines from where the animation should start (animation frame)
  10767. * @param end defines where the animation should stop (animation frame)
  10768. * @param loop defines if the animation should loop or stop after the first play
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10772. /** @hidden */
  10773. _prepare(): void;
  10774. /**
  10775. * Execute the action and play the animation.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible to stop an animation once triggered.
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class StopAnimationAction extends Action {
  10790. private _target;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the target animation or animation name
  10795. * @param condition defines the trigger related conditions
  10796. */
  10797. constructor(triggerOptions: any, target: any, condition?: Condition);
  10798. /** @hidden */
  10799. _prepare(): void;
  10800. /**
  10801. * Execute the action and stop the animation.
  10802. */
  10803. execute(): void;
  10804. /**
  10805. * Serializes the actions and its related information.
  10806. * @param parent defines the object to serialize in
  10807. * @returns the serialized object
  10808. */
  10809. serialize(parent: any): any;
  10810. }
  10811. /**
  10812. * This defines an action responsible that does nothing once triggered.
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10814. */
  10815. export class DoNothingAction extends Action {
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param condition defines the trigger related conditions
  10820. */
  10821. constructor(triggerOptions?: any, condition?: Condition);
  10822. /**
  10823. * Execute the action and do nothing.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to trigger several actions once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class CombineAction extends Action {
  10838. /**
  10839. * The list of aggregated animations to run.
  10840. */
  10841. children: Action[];
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param children defines the list of aggregated animations to run
  10846. * @param condition defines the trigger related conditions
  10847. */
  10848. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10849. /** @hidden */
  10850. _prepare(): void;
  10851. /**
  10852. * Execute the action and executes all the aggregated actions.
  10853. */
  10854. execute(evt: ActionEvent): void;
  10855. /**
  10856. * Serializes the actions and its related information.
  10857. * @param parent defines the object to serialize in
  10858. * @returns the serialized object
  10859. */
  10860. serialize(parent: any): any;
  10861. }
  10862. /**
  10863. * This defines an action responsible to run code (external event) once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class ExecuteCodeAction extends Action {
  10867. /**
  10868. * The callback function to run.
  10869. */
  10870. func: (evt: ActionEvent) => void;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param func defines the callback function to run
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10878. /**
  10879. * Execute the action and run the attached code.
  10880. */
  10881. execute(evt: ActionEvent): void;
  10882. }
  10883. /**
  10884. * This defines an action responsible to set the parent property of the target once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class SetParentAction extends Action {
  10888. private _parent;
  10889. private _target;
  10890. /**
  10891. * Instantiate the action
  10892. * @param triggerOptions defines the trigger options
  10893. * @param target defines the target containing the parent property
  10894. * @param parent defines from where the animation should start (animation frame)
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and set the parent property.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. }
  10912. declare module "babylonjs/Actions/actionManager" {
  10913. import { Nullable } from "babylonjs/types";
  10914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10915. import { Scene } from "babylonjs/scene";
  10916. import { IAction } from "babylonjs/Actions/action";
  10917. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10918. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10919. /**
  10920. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10921. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class ActionManager extends AbstractActionManager {
  10925. /**
  10926. * Nothing
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10928. */
  10929. static readonly NothingTrigger: number;
  10930. /**
  10931. * On pick
  10932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10933. */
  10934. static readonly OnPickTrigger: number;
  10935. /**
  10936. * On left pick
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10938. */
  10939. static readonly OnLeftPickTrigger: number;
  10940. /**
  10941. * On right pick
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10943. */
  10944. static readonly OnRightPickTrigger: number;
  10945. /**
  10946. * On center pick
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnCenterPickTrigger: number;
  10950. /**
  10951. * On pick down
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnPickDownTrigger: number;
  10955. /**
  10956. * On double pick
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnDoublePickTrigger: number;
  10960. /**
  10961. * On pick up
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnPickUpTrigger: number;
  10965. /**
  10966. * On pick out.
  10967. * This trigger will only be raised if you also declared a OnPickDown
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10969. */
  10970. static readonly OnPickOutTrigger: number;
  10971. /**
  10972. * On long press
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10974. */
  10975. static readonly OnLongPressTrigger: number;
  10976. /**
  10977. * On pointer over
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10979. */
  10980. static readonly OnPointerOverTrigger: number;
  10981. /**
  10982. * On pointer out
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly OnPointerOutTrigger: number;
  10986. /**
  10987. * On every frame
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnEveryFrameTrigger: number;
  10991. /**
  10992. * On intersection enter
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnIntersectionEnterTrigger: number;
  10996. /**
  10997. * On intersection exit
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnIntersectionExitTrigger: number;
  11001. /**
  11002. * On key down
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnKeyDownTrigger: number;
  11006. /**
  11007. * On key up
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnKeyUpTrigger: number;
  11011. private _scene;
  11012. /**
  11013. * Creates a new action manager
  11014. * @param scene defines the hosting scene
  11015. */
  11016. constructor(scene: Scene);
  11017. /**
  11018. * Releases all associated resources
  11019. */
  11020. dispose(): void;
  11021. /**
  11022. * Gets hosting scene
  11023. * @returns the hosting scene
  11024. */
  11025. getScene(): Scene;
  11026. /**
  11027. * Does this action manager handles actions of any of the given triggers
  11028. * @param triggers defines the triggers to be tested
  11029. * @return a boolean indicating whether one (or more) of the triggers is handled
  11030. */
  11031. hasSpecificTriggers(triggers: number[]): boolean;
  11032. /**
  11033. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11034. * speed.
  11035. * @param triggerA defines the trigger to be tested
  11036. * @param triggerB defines the trigger to be tested
  11037. * @return a boolean indicating whether one (or more) of the triggers is handled
  11038. */
  11039. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11040. /**
  11041. * Does this action manager handles actions of a given trigger
  11042. * @param trigger defines the trigger to be tested
  11043. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11044. * @return whether the trigger is handled
  11045. */
  11046. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11047. /**
  11048. * Does this action manager has pointer triggers
  11049. */
  11050. readonly hasPointerTriggers: boolean;
  11051. /**
  11052. * Does this action manager has pick triggers
  11053. */
  11054. readonly hasPickTriggers: boolean;
  11055. /**
  11056. * Registers an action to this action manager
  11057. * @param action defines the action to be registered
  11058. * @return the action amended (prepared) after registration
  11059. */
  11060. registerAction(action: IAction): Nullable<IAction>;
  11061. /**
  11062. * Unregisters an action to this action manager
  11063. * @param action defines the action to be unregistered
  11064. * @return a boolean indicating whether the action has been unregistered
  11065. */
  11066. unregisterAction(action: IAction): Boolean;
  11067. /**
  11068. * Process a specific trigger
  11069. * @param trigger defines the trigger to process
  11070. * @param evt defines the event details to be processed
  11071. */
  11072. processTrigger(trigger: number, evt?: IActionEvent): void;
  11073. /** @hidden */
  11074. _getEffectiveTarget(target: any, propertyPath: string): any;
  11075. /** @hidden */
  11076. _getProperty(propertyPath: string): string;
  11077. /**
  11078. * Serialize this manager to a JSON object
  11079. * @param name defines the property name to store this manager
  11080. * @returns a JSON representation of this manager
  11081. */
  11082. serialize(name: string): any;
  11083. /**
  11084. * Creates a new ActionManager from a JSON data
  11085. * @param parsedActions defines the JSON data to read from
  11086. * @param object defines the hosting mesh
  11087. * @param scene defines the hosting scene
  11088. */
  11089. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11090. /**
  11091. * Get a trigger name by index
  11092. * @param trigger defines the trigger index
  11093. * @returns a trigger name
  11094. */
  11095. static GetTriggerName(trigger: number): string;
  11096. }
  11097. }
  11098. declare module "babylonjs/Culling/ray" {
  11099. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11100. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11104. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11105. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11106. import { Plane } from "babylonjs/Maths/math.plane";
  11107. /**
  11108. * Class representing a ray with position and direction
  11109. */
  11110. export class Ray {
  11111. /** origin point */
  11112. origin: Vector3;
  11113. /** direction */
  11114. direction: Vector3;
  11115. /** length of the ray */
  11116. length: number;
  11117. private static readonly TmpVector3;
  11118. private _tmpRay;
  11119. /**
  11120. * Creates a new ray
  11121. * @param origin origin point
  11122. * @param direction direction
  11123. * @param length length of the ray
  11124. */
  11125. constructor(
  11126. /** origin point */
  11127. origin: Vector3,
  11128. /** direction */
  11129. direction: Vector3,
  11130. /** length of the ray */
  11131. length?: number);
  11132. /**
  11133. * Checks if the ray intersects a box
  11134. * @param minimum bound of the box
  11135. * @param maximum bound of the box
  11136. * @param intersectionTreshold extra extend to be added to the box in all direction
  11137. * @returns if the box was hit
  11138. */
  11139. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11140. /**
  11141. * Checks if the ray intersects a box
  11142. * @param box the bounding box to check
  11143. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11144. * @returns if the box was hit
  11145. */
  11146. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11147. /**
  11148. * If the ray hits a sphere
  11149. * @param sphere the bounding sphere to check
  11150. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11151. * @returns true if it hits the sphere
  11152. */
  11153. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11154. /**
  11155. * If the ray hits a triange
  11156. * @param vertex0 triangle vertex
  11157. * @param vertex1 triangle vertex
  11158. * @param vertex2 triangle vertex
  11159. * @returns intersection information if hit
  11160. */
  11161. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11162. /**
  11163. * Checks if ray intersects a plane
  11164. * @param plane the plane to check
  11165. * @returns the distance away it was hit
  11166. */
  11167. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11168. /**
  11169. * Calculate the intercept of a ray on a given axis
  11170. * @param axis to check 'x' | 'y' | 'z'
  11171. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11172. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11173. */
  11174. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11175. /**
  11176. * Checks if ray intersects a mesh
  11177. * @param mesh the mesh to check
  11178. * @param fastCheck if only the bounding box should checked
  11179. * @returns picking info of the intersecton
  11180. */
  11181. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11182. /**
  11183. * Checks if ray intersects a mesh
  11184. * @param meshes the meshes to check
  11185. * @param fastCheck if only the bounding box should checked
  11186. * @param results array to store result in
  11187. * @returns Array of picking infos
  11188. */
  11189. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11190. private _comparePickingInfo;
  11191. private static smallnum;
  11192. private static rayl;
  11193. /**
  11194. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11195. * @param sega the first point of the segment to test the intersection against
  11196. * @param segb the second point of the segment to test the intersection against
  11197. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11198. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11199. */
  11200. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11201. /**
  11202. * Update the ray from viewport position
  11203. * @param x position
  11204. * @param y y position
  11205. * @param viewportWidth viewport width
  11206. * @param viewportHeight viewport height
  11207. * @param world world matrix
  11208. * @param view view matrix
  11209. * @param projection projection matrix
  11210. * @returns this ray updated
  11211. */
  11212. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11213. /**
  11214. * Creates a ray with origin and direction of 0,0,0
  11215. * @returns the new ray
  11216. */
  11217. static Zero(): Ray;
  11218. /**
  11219. * Creates a new ray from screen space and viewport
  11220. * @param x position
  11221. * @param y y position
  11222. * @param viewportWidth viewport width
  11223. * @param viewportHeight viewport height
  11224. * @param world world matrix
  11225. * @param view view matrix
  11226. * @param projection projection matrix
  11227. * @returns new ray
  11228. */
  11229. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11230. /**
  11231. * 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
  11232. * transformed to the given world matrix.
  11233. * @param origin The origin point
  11234. * @param end The end point
  11235. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11236. * @returns the new ray
  11237. */
  11238. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11239. /**
  11240. * Transforms a ray by a matrix
  11241. * @param ray ray to transform
  11242. * @param matrix matrix to apply
  11243. * @returns the resulting new ray
  11244. */
  11245. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11246. /**
  11247. * Transforms a ray by a matrix
  11248. * @param ray ray to transform
  11249. * @param matrix matrix to apply
  11250. * @param result ray to store result in
  11251. */
  11252. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11253. /**
  11254. * Unproject a ray from screen space to object space
  11255. * @param sourceX defines the screen space x coordinate to use
  11256. * @param sourceY defines the screen space y coordinate to use
  11257. * @param viewportWidth defines the current width of the viewport
  11258. * @param viewportHeight defines the current height of the viewport
  11259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11260. * @param view defines the view matrix to use
  11261. * @param projection defines the projection matrix to use
  11262. */
  11263. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11264. }
  11265. /**
  11266. * Type used to define predicate used to select faces when a mesh intersection is detected
  11267. */
  11268. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11269. module "babylonjs/scene" {
  11270. interface Scene {
  11271. /** @hidden */
  11272. _tempPickingRay: Nullable<Ray>;
  11273. /** @hidden */
  11274. _cachedRayForTransform: Ray;
  11275. /** @hidden */
  11276. _pickWithRayInverseMatrix: Matrix;
  11277. /** @hidden */
  11278. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11279. /** @hidden */
  11280. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11281. }
  11282. }
  11283. }
  11284. declare module "babylonjs/sceneComponent" {
  11285. import { Scene } from "babylonjs/scene";
  11286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11288. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11289. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11290. import { Nullable } from "babylonjs/types";
  11291. import { Camera } from "babylonjs/Cameras/camera";
  11292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11293. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11294. import { AbstractScene } from "babylonjs/abstractScene";
  11295. import { Mesh } from "babylonjs/Meshes/mesh";
  11296. /**
  11297. * Groups all the scene component constants in one place to ease maintenance.
  11298. * @hidden
  11299. */
  11300. export class SceneComponentConstants {
  11301. static readonly NAME_EFFECTLAYER: string;
  11302. static readonly NAME_LAYER: string;
  11303. static readonly NAME_LENSFLARESYSTEM: string;
  11304. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11305. static readonly NAME_PARTICLESYSTEM: string;
  11306. static readonly NAME_GAMEPAD: string;
  11307. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11308. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11309. static readonly NAME_DEPTHRENDERER: string;
  11310. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11311. static readonly NAME_SPRITE: string;
  11312. static readonly NAME_OUTLINERENDERER: string;
  11313. static readonly NAME_PROCEDURALTEXTURE: string;
  11314. static readonly NAME_SHADOWGENERATOR: string;
  11315. static readonly NAME_OCTREE: string;
  11316. static readonly NAME_PHYSICSENGINE: string;
  11317. static readonly NAME_AUDIO: string;
  11318. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11319. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11320. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11321. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11322. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11323. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11324. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11325. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11326. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11327. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11328. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11329. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11330. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11331. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11332. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11333. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11334. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11335. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11336. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11337. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11338. static readonly STEP_AFTERRENDER_AUDIO: number;
  11339. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11340. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11341. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11342. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11343. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11344. static readonly STEP_POINTERMOVE_SPRITE: number;
  11345. static readonly STEP_POINTERDOWN_SPRITE: number;
  11346. static readonly STEP_POINTERUP_SPRITE: number;
  11347. }
  11348. /**
  11349. * This represents a scene component.
  11350. *
  11351. * This is used to decouple the dependency the scene is having on the different workloads like
  11352. * layers, post processes...
  11353. */
  11354. export interface ISceneComponent {
  11355. /**
  11356. * The name of the component. Each component must have a unique name.
  11357. */
  11358. name: string;
  11359. /**
  11360. * The scene the component belongs to.
  11361. */
  11362. scene: Scene;
  11363. /**
  11364. * Register the component to one instance of a scene.
  11365. */
  11366. register(): void;
  11367. /**
  11368. * Rebuilds the elements related to this component in case of
  11369. * context lost for instance.
  11370. */
  11371. rebuild(): void;
  11372. /**
  11373. * Disposes the component and the associated ressources.
  11374. */
  11375. dispose(): void;
  11376. }
  11377. /**
  11378. * This represents a SERIALIZABLE scene component.
  11379. *
  11380. * This extends Scene Component to add Serialization methods on top.
  11381. */
  11382. export interface ISceneSerializableComponent extends ISceneComponent {
  11383. /**
  11384. * Adds all the elements from the container to the scene
  11385. * @param container the container holding the elements
  11386. */
  11387. addFromContainer(container: AbstractScene): void;
  11388. /**
  11389. * Removes all the elements in the container from the scene
  11390. * @param container contains the elements to remove
  11391. * @param dispose if the removed element should be disposed (default: false)
  11392. */
  11393. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11394. /**
  11395. * Serializes the component data to the specified json object
  11396. * @param serializationObject The object to serialize to
  11397. */
  11398. serialize(serializationObject: any): void;
  11399. }
  11400. /**
  11401. * Strong typing of a Mesh related stage step action
  11402. */
  11403. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11404. /**
  11405. * Strong typing of a Evaluate Sub Mesh related stage step action
  11406. */
  11407. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11408. /**
  11409. * Strong typing of a Active Mesh related stage step action
  11410. */
  11411. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11412. /**
  11413. * Strong typing of a Camera related stage step action
  11414. */
  11415. export type CameraStageAction = (camera: Camera) => void;
  11416. /**
  11417. * Strong typing of a Camera Frame buffer related stage step action
  11418. */
  11419. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11420. /**
  11421. * Strong typing of a Render Target related stage step action
  11422. */
  11423. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11424. /**
  11425. * Strong typing of a RenderingGroup related stage step action
  11426. */
  11427. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11428. /**
  11429. * Strong typing of a Mesh Render related stage step action
  11430. */
  11431. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11432. /**
  11433. * Strong typing of a simple stage step action
  11434. */
  11435. export type SimpleStageAction = () => void;
  11436. /**
  11437. * Strong typing of a render target action.
  11438. */
  11439. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11440. /**
  11441. * Strong typing of a pointer move action.
  11442. */
  11443. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11444. /**
  11445. * Strong typing of a pointer up/down action.
  11446. */
  11447. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11448. /**
  11449. * Representation of a stage in the scene (Basically a list of ordered steps)
  11450. * @hidden
  11451. */
  11452. export class Stage<T extends Function> extends Array<{
  11453. index: number;
  11454. component: ISceneComponent;
  11455. action: T;
  11456. }> {
  11457. /**
  11458. * Hide ctor from the rest of the world.
  11459. * @param items The items to add.
  11460. */
  11461. private constructor();
  11462. /**
  11463. * Creates a new Stage.
  11464. * @returns A new instance of a Stage
  11465. */
  11466. static Create<T extends Function>(): Stage<T>;
  11467. /**
  11468. * Registers a step in an ordered way in the targeted stage.
  11469. * @param index Defines the position to register the step in
  11470. * @param component Defines the component attached to the step
  11471. * @param action Defines the action to launch during the step
  11472. */
  11473. registerStep(index: number, component: ISceneComponent, action: T): void;
  11474. /**
  11475. * Clears all the steps from the stage.
  11476. */
  11477. clear(): void;
  11478. }
  11479. }
  11480. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11481. import { Nullable } from "babylonjs/types";
  11482. import { Observable } from "babylonjs/Misc/observable";
  11483. import { Scene } from "babylonjs/scene";
  11484. import { Sprite } from "babylonjs/Sprites/sprite";
  11485. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11486. import { Ray } from "babylonjs/Culling/ray";
  11487. import { Camera } from "babylonjs/Cameras/camera";
  11488. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11489. import { ISceneComponent } from "babylonjs/sceneComponent";
  11490. module "babylonjs/scene" {
  11491. interface Scene {
  11492. /** @hidden */
  11493. _pointerOverSprite: Nullable<Sprite>;
  11494. /** @hidden */
  11495. _pickedDownSprite: Nullable<Sprite>;
  11496. /** @hidden */
  11497. _tempSpritePickingRay: Nullable<Ray>;
  11498. /**
  11499. * All of the sprite managers added to this scene
  11500. * @see http://doc.babylonjs.com/babylon101/sprites
  11501. */
  11502. spriteManagers: Array<ISpriteManager>;
  11503. /**
  11504. * An event triggered when sprites rendering is about to start
  11505. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11506. */
  11507. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11508. /**
  11509. * An event triggered when sprites rendering is done
  11510. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11511. */
  11512. onAfterSpritesRenderingObservable: Observable<Scene>;
  11513. /** @hidden */
  11514. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11515. /** Launch a ray to try to pick a sprite in the scene
  11516. * @param x position on screen
  11517. * @param y position on screen
  11518. * @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
  11519. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11521. * @returns a PickingInfo
  11522. */
  11523. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11524. /** Use the given ray to pick a sprite in the scene
  11525. * @param ray The ray (in world space) to use to pick meshes
  11526. * @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
  11527. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11528. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11529. * @returns a PickingInfo
  11530. */
  11531. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11532. /** @hidden */
  11533. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11534. /** Launch a ray to try to pick sprites in the scene
  11535. * @param x position on screen
  11536. * @param y position on screen
  11537. * @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
  11538. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11539. * @returns a PickingInfo array
  11540. */
  11541. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11542. /** Use the given ray to pick sprites in the scene
  11543. * @param ray The ray (in world space) to use to pick meshes
  11544. * @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
  11545. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11546. * @returns a PickingInfo array
  11547. */
  11548. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11549. /**
  11550. * Force the sprite under the pointer
  11551. * @param sprite defines the sprite to use
  11552. */
  11553. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11554. /**
  11555. * Gets the sprite under the pointer
  11556. * @returns a Sprite or null if no sprite is under the pointer
  11557. */
  11558. getPointerOverSprite(): Nullable<Sprite>;
  11559. }
  11560. }
  11561. /**
  11562. * Defines the sprite scene component responsible to manage sprites
  11563. * in a given scene.
  11564. */
  11565. export class SpriteSceneComponent implements ISceneComponent {
  11566. /**
  11567. * The component name helpfull to identify the component in the list of scene components.
  11568. */
  11569. readonly name: string;
  11570. /**
  11571. * The scene the component belongs to.
  11572. */
  11573. scene: Scene;
  11574. /** @hidden */
  11575. private _spritePredicate;
  11576. /**
  11577. * Creates a new instance of the component for the given scene
  11578. * @param scene Defines the scene to register the component in
  11579. */
  11580. constructor(scene: Scene);
  11581. /**
  11582. * Registers the component in a given scene
  11583. */
  11584. register(): void;
  11585. /**
  11586. * Rebuilds the elements related to this component in case of
  11587. * context lost for instance.
  11588. */
  11589. rebuild(): void;
  11590. /**
  11591. * Disposes the component and the associated ressources.
  11592. */
  11593. dispose(): void;
  11594. private _pickSpriteButKeepRay;
  11595. private _pointerMove;
  11596. private _pointerDown;
  11597. private _pointerUp;
  11598. }
  11599. }
  11600. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11601. /** @hidden */
  11602. export var fogFragmentDeclaration: {
  11603. name: string;
  11604. shader: string;
  11605. };
  11606. }
  11607. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11608. /** @hidden */
  11609. export var fogFragment: {
  11610. name: string;
  11611. shader: string;
  11612. };
  11613. }
  11614. declare module "babylonjs/Shaders/sprites.fragment" {
  11615. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11616. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11617. /** @hidden */
  11618. export var spritesPixelShader: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11624. /** @hidden */
  11625. export var fogVertexDeclaration: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module "babylonjs/Shaders/sprites.vertex" {
  11631. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11632. /** @hidden */
  11633. export var spritesVertexShader: {
  11634. name: string;
  11635. shader: string;
  11636. };
  11637. }
  11638. declare module "babylonjs/Sprites/spriteManager" {
  11639. import { IDisposable, Scene } from "babylonjs/scene";
  11640. import { Nullable } from "babylonjs/types";
  11641. import { Observable } from "babylonjs/Misc/observable";
  11642. import { Sprite } from "babylonjs/Sprites/sprite";
  11643. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11644. import { Camera } from "babylonjs/Cameras/camera";
  11645. import { Texture } from "babylonjs/Materials/Textures/texture";
  11646. import "babylonjs/Shaders/sprites.fragment";
  11647. import "babylonjs/Shaders/sprites.vertex";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. /**
  11650. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11651. */
  11652. export interface ISpriteManager extends IDisposable {
  11653. /**
  11654. * Restricts the camera to viewing objects with the same layerMask.
  11655. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11656. */
  11657. layerMask: number;
  11658. /**
  11659. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11660. */
  11661. isPickable: boolean;
  11662. /**
  11663. * Specifies the rendering group id for this mesh (0 by default)
  11664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11665. */
  11666. renderingGroupId: number;
  11667. /**
  11668. * Defines the list of sprites managed by the manager.
  11669. */
  11670. sprites: Array<Sprite>;
  11671. /**
  11672. * Tests the intersection of a sprite with a specific ray.
  11673. * @param ray The ray we are sending to test the collision
  11674. * @param camera The camera space we are sending rays in
  11675. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11676. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11677. * @returns picking info or null.
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Renders the list of sprites on screen.
  11690. */
  11691. render(): void;
  11692. }
  11693. /**
  11694. * Class used to manage multiple sprites on the same spritesheet
  11695. * @see http://doc.babylonjs.com/babylon101/sprites
  11696. */
  11697. export class SpriteManager implements ISpriteManager {
  11698. /** defines the manager's name */
  11699. name: string;
  11700. /** Gets the list of sprites */
  11701. sprites: Sprite[];
  11702. /** Gets or sets the rendering group id (0 by default) */
  11703. renderingGroupId: number;
  11704. /** Gets or sets camera layer mask */
  11705. layerMask: number;
  11706. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11707. fogEnabled: boolean;
  11708. /** Gets or sets a boolean indicating if the sprites are pickable */
  11709. isPickable: boolean;
  11710. /** Defines the default width of a cell in the spritesheet */
  11711. cellWidth: number;
  11712. /** Defines the default height of a cell in the spritesheet */
  11713. cellHeight: number;
  11714. /** Associative array from JSON sprite data file */
  11715. private _cellData;
  11716. /** Array of sprite names from JSON sprite data file */
  11717. private _spriteMap;
  11718. /** True when packed cell data from JSON file is ready*/
  11719. private _packedAndReady;
  11720. /**
  11721. * An event triggered when the manager is disposed.
  11722. */
  11723. onDisposeObservable: Observable<SpriteManager>;
  11724. private _onDisposeObserver;
  11725. /**
  11726. * Callback called when the manager is disposed
  11727. */
  11728. onDispose: () => void;
  11729. private _capacity;
  11730. private _fromPacked;
  11731. private _spriteTexture;
  11732. private _epsilon;
  11733. private _scene;
  11734. private _vertexData;
  11735. private _buffer;
  11736. private _vertexBuffers;
  11737. private _indexBuffer;
  11738. private _effectBase;
  11739. private _effectFog;
  11740. /**
  11741. * Gets or sets the spritesheet texture
  11742. */
  11743. texture: Texture;
  11744. /**
  11745. * Creates a new sprite manager
  11746. * @param name defines the manager's name
  11747. * @param imgUrl defines the sprite sheet url
  11748. * @param capacity defines the maximum allowed number of sprites
  11749. * @param cellSize defines the size of a sprite cell
  11750. * @param scene defines the hosting scene
  11751. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11752. * @param samplingMode defines the smapling mode to use with spritesheet
  11753. * @param fromPacked set to false; do not alter
  11754. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11755. */
  11756. constructor(
  11757. /** defines the manager's name */
  11758. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11759. private _makePacked;
  11760. private _appendSpriteVertex;
  11761. /**
  11762. * Intersects the sprites with a ray
  11763. * @param ray defines the ray to intersect with
  11764. * @param camera defines the current active camera
  11765. * @param predicate defines a predicate used to select candidate sprites
  11766. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11767. * @returns null if no hit or a PickingInfo
  11768. */
  11769. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11770. /**
  11771. * Intersects the sprites with a ray
  11772. * @param ray defines the ray to intersect with
  11773. * @param camera defines the current active camera
  11774. * @param predicate defines a predicate used to select candidate sprites
  11775. * @returns null if no hit or a PickingInfo array
  11776. */
  11777. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11778. /**
  11779. * Render all child sprites
  11780. */
  11781. render(): void;
  11782. /**
  11783. * Release associated resources
  11784. */
  11785. dispose(): void;
  11786. }
  11787. }
  11788. declare module "babylonjs/Sprites/sprite" {
  11789. import { Vector3 } from "babylonjs/Maths/math.vector";
  11790. import { Nullable } from "babylonjs/types";
  11791. import { ActionManager } from "babylonjs/Actions/actionManager";
  11792. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11793. import { Color4 } from "babylonjs/Maths/math.color";
  11794. /**
  11795. * Class used to represent a sprite
  11796. * @see http://doc.babylonjs.com/babylon101/sprites
  11797. */
  11798. export class Sprite {
  11799. /** defines the name */
  11800. name: string;
  11801. /** Gets or sets the current world position */
  11802. position: Vector3;
  11803. /** Gets or sets the main color */
  11804. color: Color4;
  11805. /** Gets or sets the width */
  11806. width: number;
  11807. /** Gets or sets the height */
  11808. height: number;
  11809. /** Gets or sets rotation angle */
  11810. angle: number;
  11811. /** Gets or sets the cell index in the sprite sheet */
  11812. cellIndex: number;
  11813. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11814. cellRef: string;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. size: number;
  11846. /**
  11847. * Creates a new Sprite
  11848. * @param name defines the name
  11849. * @param manager defines the manager
  11850. */
  11851. constructor(
  11852. /** defines the name */
  11853. name: string, manager: ISpriteManager);
  11854. /**
  11855. * Starts an animation
  11856. * @param from defines the initial key
  11857. * @param to defines the end key
  11858. * @param loop defines if the animation must loop
  11859. * @param delay defines the start delay (in ms)
  11860. * @param onAnimationEnd defines a callback to call when animation ends
  11861. */
  11862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11863. /** Stops current animation (if any) */
  11864. stopAnimation(): void;
  11865. /** @hidden */
  11866. _animate(deltaTime: number): void;
  11867. /** Release associated resources */
  11868. dispose(): void;
  11869. }
  11870. }
  11871. declare module "babylonjs/Collisions/pickingInfo" {
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11875. import { Sprite } from "babylonjs/Sprites/sprite";
  11876. import { Ray } from "babylonjs/Culling/ray";
  11877. /**
  11878. * Information about the result of picking within a scene
  11879. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11880. */
  11881. export class PickingInfo {
  11882. /** @hidden */
  11883. _pickingUnavailable: boolean;
  11884. /**
  11885. * If the pick collided with an object
  11886. */
  11887. hit: boolean;
  11888. /**
  11889. * Distance away where the pick collided
  11890. */
  11891. distance: number;
  11892. /**
  11893. * The location of pick collision
  11894. */
  11895. pickedPoint: Nullable<Vector3>;
  11896. /**
  11897. * The mesh corresponding the the pick collision
  11898. */
  11899. pickedMesh: Nullable<AbstractMesh>;
  11900. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11901. bu: number;
  11902. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11903. bv: number;
  11904. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11905. faceId: number;
  11906. /** Id of the the submesh that was picked */
  11907. subMeshId: number;
  11908. /** If a sprite was picked, this will be the sprite the pick collided with */
  11909. pickedSprite: Nullable<Sprite>;
  11910. /**
  11911. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11912. */
  11913. originMesh: Nullable<AbstractMesh>;
  11914. /**
  11915. * The ray that was used to perform the picking.
  11916. */
  11917. ray: Nullable<Ray>;
  11918. /**
  11919. * Gets the normal correspodning to the face the pick collided with
  11920. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11921. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11922. * @returns The normal correspodning to the face the pick collided with
  11923. */
  11924. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11925. /**
  11926. * Gets the texture coordinates of where the pick occured
  11927. * @returns the vector containing the coordnates of the texture
  11928. */
  11929. getTextureCoordinates(): Nullable<Vector2>;
  11930. }
  11931. }
  11932. declare module "babylonjs/Events/pointerEvents" {
  11933. import { Nullable } from "babylonjs/types";
  11934. import { Vector2 } from "babylonjs/Maths/math.vector";
  11935. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11936. import { Ray } from "babylonjs/Culling/ray";
  11937. /**
  11938. * Gather the list of pointer event types as constants.
  11939. */
  11940. export class PointerEventTypes {
  11941. /**
  11942. * 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.
  11943. */
  11944. static readonly POINTERDOWN: number;
  11945. /**
  11946. * The pointerup event is fired when a pointer is no longer active.
  11947. */
  11948. static readonly POINTERUP: number;
  11949. /**
  11950. * The pointermove event is fired when a pointer changes coordinates.
  11951. */
  11952. static readonly POINTERMOVE: number;
  11953. /**
  11954. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11955. */
  11956. static readonly POINTERWHEEL: number;
  11957. /**
  11958. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11959. */
  11960. static readonly POINTERPICK: number;
  11961. /**
  11962. * The pointertap event is fired when a the object has been touched and released without drag.
  11963. */
  11964. static readonly POINTERTAP: number;
  11965. /**
  11966. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11967. */
  11968. static readonly POINTERDOUBLETAP: number;
  11969. }
  11970. /**
  11971. * Base class of pointer info types.
  11972. */
  11973. export class PointerInfoBase {
  11974. /**
  11975. * Defines the type of event (PointerEventTypes)
  11976. */
  11977. type: number;
  11978. /**
  11979. * Defines the related dom event
  11980. */
  11981. event: PointerEvent | MouseWheelEvent;
  11982. /**
  11983. * Instantiates the base class of pointers info.
  11984. * @param type Defines the type of event (PointerEventTypes)
  11985. * @param event Defines the related dom event
  11986. */
  11987. constructor(
  11988. /**
  11989. * Defines the type of event (PointerEventTypes)
  11990. */
  11991. type: number,
  11992. /**
  11993. * Defines the related dom event
  11994. */
  11995. event: PointerEvent | MouseWheelEvent);
  11996. }
  11997. /**
  11998. * This class is used to store pointer related info for the onPrePointerObservable event.
  11999. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12000. */
  12001. export class PointerInfoPre extends PointerInfoBase {
  12002. /**
  12003. * Ray from a pointer if availible (eg. 6dof controller)
  12004. */
  12005. ray: Nullable<Ray>;
  12006. /**
  12007. * Defines the local position of the pointer on the canvas.
  12008. */
  12009. localPosition: Vector2;
  12010. /**
  12011. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12012. */
  12013. skipOnPointerObservable: boolean;
  12014. /**
  12015. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12016. * @param type Defines the type of event (PointerEventTypes)
  12017. * @param event Defines the related dom event
  12018. * @param localX Defines the local x coordinates of the pointer when the event occured
  12019. * @param localY Defines the local y coordinates of the pointer when the event occured
  12020. */
  12021. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12022. }
  12023. /**
  12024. * This type contains all the data related to a pointer event in Babylon.js.
  12025. * 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.
  12026. */
  12027. export class PointerInfo extends PointerInfoBase {
  12028. /**
  12029. * Defines the picking info associated to the info (if any)\
  12030. */
  12031. pickInfo: Nullable<PickingInfo>;
  12032. /**
  12033. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12034. * @param type Defines the type of event (PointerEventTypes)
  12035. * @param event Defines the related dom event
  12036. * @param pickInfo Defines the picking info associated to the info (if any)\
  12037. */
  12038. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12039. /**
  12040. * Defines the picking info associated to the info (if any)\
  12041. */
  12042. pickInfo: Nullable<PickingInfo>);
  12043. }
  12044. /**
  12045. * Data relating to a touch event on the screen.
  12046. */
  12047. export interface PointerTouch {
  12048. /**
  12049. * X coordinate of touch.
  12050. */
  12051. x: number;
  12052. /**
  12053. * Y coordinate of touch.
  12054. */
  12055. y: number;
  12056. /**
  12057. * Id of touch. Unique for each finger.
  12058. */
  12059. pointerId: number;
  12060. /**
  12061. * Event type passed from DOM.
  12062. */
  12063. type: any;
  12064. }
  12065. }
  12066. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12067. import { Observable } from "babylonjs/Misc/observable";
  12068. import { Nullable } from "babylonjs/types";
  12069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12071. /**
  12072. * Manage the mouse inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Define if touch is enabled in the mouse input
  12078. */
  12079. touchEnabled: boolean;
  12080. /**
  12081. * Defines the camera the input is attached to.
  12082. */
  12083. camera: FreeCamera;
  12084. /**
  12085. * Defines the buttons associated with the input to handle camera move.
  12086. */
  12087. buttons: number[];
  12088. /**
  12089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12090. */
  12091. angularSensibility: number;
  12092. private _pointerInput;
  12093. private _onMouseMove;
  12094. private _observer;
  12095. private previousPosition;
  12096. /**
  12097. * Observable for when a pointer move event occurs containing the move offset
  12098. */
  12099. onPointerMovedObservable: Observable<{
  12100. offsetX: number;
  12101. offsetY: number;
  12102. }>;
  12103. /**
  12104. * @hidden
  12105. * If the camera should be rotated automatically based on pointer movement
  12106. */
  12107. _allowCameraRotation: boolean;
  12108. /**
  12109. * Manage the mouse inputs to control the movement of a free camera.
  12110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12111. * @param touchEnabled Defines if touch is enabled or not
  12112. */
  12113. constructor(
  12114. /**
  12115. * Define if touch is enabled in the mouse input
  12116. */
  12117. touchEnabled?: boolean);
  12118. /**
  12119. * Attach the input controls to a specific dom element to get the input from.
  12120. * @param element Defines the element the controls should be listened from
  12121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12122. */
  12123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12124. /**
  12125. * Called on JS contextmenu event.
  12126. * Override this method to provide functionality.
  12127. */
  12128. protected onContextMenu(evt: PointerEvent): void;
  12129. /**
  12130. * Detach the current controls from the specified dom element.
  12131. * @param element Defines the element to stop listening the inputs from
  12132. */
  12133. detachControl(element: Nullable<HTMLElement>): void;
  12134. /**
  12135. * Gets the class name of the current intput.
  12136. * @returns the class name
  12137. */
  12138. getClassName(): string;
  12139. /**
  12140. * Get the friendly name associated with the input class.
  12141. * @returns the input friendly name
  12142. */
  12143. getSimpleName(): string;
  12144. }
  12145. }
  12146. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12147. import { Nullable } from "babylonjs/types";
  12148. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12149. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12150. /**
  12151. * Manage the touch inputs to control the movement of a free camera.
  12152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12153. */
  12154. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12155. /**
  12156. * Defines the camera the input is attached to.
  12157. */
  12158. camera: FreeCamera;
  12159. /**
  12160. * Defines the touch sensibility for rotation.
  12161. * The higher the faster.
  12162. */
  12163. touchAngularSensibility: number;
  12164. /**
  12165. * Defines the touch sensibility for move.
  12166. * The higher the faster.
  12167. */
  12168. touchMoveSensibility: number;
  12169. private _offsetX;
  12170. private _offsetY;
  12171. private _pointerPressed;
  12172. private _pointerInput;
  12173. private _observer;
  12174. private _onLostFocus;
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12181. /**
  12182. * Detach the current controls from the specified dom element.
  12183. * @param element Defines the element to stop listening the inputs from
  12184. */
  12185. detachControl(element: Nullable<HTMLElement>): void;
  12186. /**
  12187. * Update the current camera state depending on the inputs that have been used this frame.
  12188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12189. */
  12190. checkInputs(): void;
  12191. /**
  12192. * Gets the class name of the current intput.
  12193. * @returns the class name
  12194. */
  12195. getClassName(): string;
  12196. /**
  12197. * Get the friendly name associated with the input class.
  12198. * @returns the input friendly name
  12199. */
  12200. getSimpleName(): string;
  12201. }
  12202. }
  12203. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12206. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12207. import { Nullable } from "babylonjs/types";
  12208. /**
  12209. * Default Inputs manager for the FreeCamera.
  12210. * It groups all the default supported inputs for ease of use.
  12211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12212. */
  12213. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12214. /**
  12215. * @hidden
  12216. */
  12217. _mouseInput: Nullable<FreeCameraMouseInput>;
  12218. /**
  12219. * Instantiates a new FreeCameraInputsManager.
  12220. * @param camera Defines the camera the inputs belong to
  12221. */
  12222. constructor(camera: FreeCamera);
  12223. /**
  12224. * Add keyboard input support to the input manager.
  12225. * @returns the current input manager
  12226. */
  12227. addKeyboard(): FreeCameraInputsManager;
  12228. /**
  12229. * Add mouse input support to the input manager.
  12230. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12231. * @returns the current input manager
  12232. */
  12233. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12234. /**
  12235. * Removes the mouse input support from the manager
  12236. * @returns the current input manager
  12237. */
  12238. removeMouse(): FreeCameraInputsManager;
  12239. /**
  12240. * Add touch input support to the input manager.
  12241. * @returns the current input manager
  12242. */
  12243. addTouch(): FreeCameraInputsManager;
  12244. /**
  12245. * Remove all attached input methods from a camera
  12246. */
  12247. clear(): void;
  12248. }
  12249. }
  12250. declare module "babylonjs/Cameras/freeCamera" {
  12251. import { Vector3 } from "babylonjs/Maths/math.vector";
  12252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12253. import { Scene } from "babylonjs/scene";
  12254. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12255. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12256. /**
  12257. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12258. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12260. */
  12261. export class FreeCamera extends TargetCamera {
  12262. /**
  12263. * Define the collision ellipsoid of the camera.
  12264. * This is helpful to simulate a camera body like the player body around the camera
  12265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12266. */
  12267. ellipsoid: Vector3;
  12268. /**
  12269. * Define an offset for the position of the ellipsoid around the camera.
  12270. * This can be helpful to determine the center of the body near the gravity center of the body
  12271. * instead of its head.
  12272. */
  12273. ellipsoidOffset: Vector3;
  12274. /**
  12275. * Enable or disable collisions of the camera with the rest of the scene objects.
  12276. */
  12277. checkCollisions: boolean;
  12278. /**
  12279. * Enable or disable gravity on the camera.
  12280. */
  12281. applyGravity: boolean;
  12282. /**
  12283. * Define the input manager associated to the camera.
  12284. */
  12285. inputs: FreeCameraInputsManager;
  12286. /**
  12287. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12288. * Higher values reduce sensitivity.
  12289. */
  12290. /**
  12291. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12292. * Higher values reduce sensitivity.
  12293. */
  12294. angularSensibility: number;
  12295. /**
  12296. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12297. */
  12298. keysUp: number[];
  12299. /**
  12300. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12301. */
  12302. keysDown: number[];
  12303. /**
  12304. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12305. */
  12306. keysLeft: number[];
  12307. /**
  12308. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12309. */
  12310. keysRight: number[];
  12311. /**
  12312. * Event raised when the camera collide with a mesh in the scene.
  12313. */
  12314. onCollide: (collidedMesh: AbstractMesh) => void;
  12315. private _collider;
  12316. private _needMoveForGravity;
  12317. private _oldPosition;
  12318. private _diffPosition;
  12319. private _newPosition;
  12320. /** @hidden */
  12321. _localDirection: Vector3;
  12322. /** @hidden */
  12323. _transformedDirection: Vector3;
  12324. /**
  12325. * Instantiates a Free Camera.
  12326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12327. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12329. * @param name Define the name of the camera in the scene
  12330. * @param position Define the start position of the camera in the scene
  12331. * @param scene Define the scene the camera belongs to
  12332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12333. */
  12334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12335. /**
  12336. * Attached controls to the current camera.
  12337. * @param element Defines the element the controls should be listened from
  12338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12339. */
  12340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12341. /**
  12342. * Detach the current controls from the camera.
  12343. * The camera will stop reacting to inputs.
  12344. * @param element Defines the element to stop listening the inputs from
  12345. */
  12346. detachControl(element: HTMLElement): void;
  12347. private _collisionMask;
  12348. /**
  12349. * Define a collision mask to limit the list of object the camera can collide with
  12350. */
  12351. collisionMask: number;
  12352. /** @hidden */
  12353. _collideWithWorld(displacement: Vector3): void;
  12354. private _onCollisionPositionChange;
  12355. /** @hidden */
  12356. _checkInputs(): void;
  12357. /** @hidden */
  12358. _decideIfNeedsToMove(): boolean;
  12359. /** @hidden */
  12360. _updatePosition(): void;
  12361. /**
  12362. * Destroy the camera and release the current resources hold by it.
  12363. */
  12364. dispose(): void;
  12365. /**
  12366. * Gets the current object class name.
  12367. * @return the class name
  12368. */
  12369. getClassName(): string;
  12370. }
  12371. }
  12372. declare module "babylonjs/Gamepads/gamepad" {
  12373. import { Observable } from "babylonjs/Misc/observable";
  12374. /**
  12375. * Represents a gamepad control stick position
  12376. */
  12377. export class StickValues {
  12378. /**
  12379. * The x component of the control stick
  12380. */
  12381. x: number;
  12382. /**
  12383. * The y component of the control stick
  12384. */
  12385. y: number;
  12386. /**
  12387. * Initializes the gamepad x and y control stick values
  12388. * @param x The x component of the gamepad control stick value
  12389. * @param y The y component of the gamepad control stick value
  12390. */
  12391. constructor(
  12392. /**
  12393. * The x component of the control stick
  12394. */
  12395. x: number,
  12396. /**
  12397. * The y component of the control stick
  12398. */
  12399. y: number);
  12400. }
  12401. /**
  12402. * An interface which manages callbacks for gamepad button changes
  12403. */
  12404. export interface GamepadButtonChanges {
  12405. /**
  12406. * Called when a gamepad has been changed
  12407. */
  12408. changed: boolean;
  12409. /**
  12410. * Called when a gamepad press event has been triggered
  12411. */
  12412. pressChanged: boolean;
  12413. /**
  12414. * Called when a touch event has been triggered
  12415. */
  12416. touchChanged: boolean;
  12417. /**
  12418. * Called when a value has changed
  12419. */
  12420. valueChanged: boolean;
  12421. }
  12422. /**
  12423. * Represents a gamepad
  12424. */
  12425. export class Gamepad {
  12426. /**
  12427. * The id of the gamepad
  12428. */
  12429. id: string;
  12430. /**
  12431. * The index of the gamepad
  12432. */
  12433. index: number;
  12434. /**
  12435. * The browser gamepad
  12436. */
  12437. browserGamepad: any;
  12438. /**
  12439. * Specifies what type of gamepad this represents
  12440. */
  12441. type: number;
  12442. private _leftStick;
  12443. private _rightStick;
  12444. /** @hidden */
  12445. _isConnected: boolean;
  12446. private _leftStickAxisX;
  12447. private _leftStickAxisY;
  12448. private _rightStickAxisX;
  12449. private _rightStickAxisY;
  12450. /**
  12451. * Triggered when the left control stick has been changed
  12452. */
  12453. private _onleftstickchanged;
  12454. /**
  12455. * Triggered when the right control stick has been changed
  12456. */
  12457. private _onrightstickchanged;
  12458. /**
  12459. * Represents a gamepad controller
  12460. */
  12461. static GAMEPAD: number;
  12462. /**
  12463. * Represents a generic controller
  12464. */
  12465. static GENERIC: number;
  12466. /**
  12467. * Represents an XBox controller
  12468. */
  12469. static XBOX: number;
  12470. /**
  12471. * Represents a pose-enabled controller
  12472. */
  12473. static POSE_ENABLED: number;
  12474. /**
  12475. * Represents an Dual Shock controller
  12476. */
  12477. static DUALSHOCK: number;
  12478. /**
  12479. * Specifies whether the left control stick should be Y-inverted
  12480. */
  12481. protected _invertLeftStickY: boolean;
  12482. /**
  12483. * Specifies if the gamepad has been connected
  12484. */
  12485. readonly isConnected: boolean;
  12486. /**
  12487. * Initializes the gamepad
  12488. * @param id The id of the gamepad
  12489. * @param index The index of the gamepad
  12490. * @param browserGamepad The browser gamepad
  12491. * @param leftStickX The x component of the left joystick
  12492. * @param leftStickY The y component of the left joystick
  12493. * @param rightStickX The x component of the right joystick
  12494. * @param rightStickY The y component of the right joystick
  12495. */
  12496. constructor(
  12497. /**
  12498. * The id of the gamepad
  12499. */
  12500. id: string,
  12501. /**
  12502. * The index of the gamepad
  12503. */
  12504. index: number,
  12505. /**
  12506. * The browser gamepad
  12507. */
  12508. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12509. /**
  12510. * Callback triggered when the left joystick has changed
  12511. * @param callback
  12512. */
  12513. onleftstickchanged(callback: (values: StickValues) => void): void;
  12514. /**
  12515. * Callback triggered when the right joystick has changed
  12516. * @param callback
  12517. */
  12518. onrightstickchanged(callback: (values: StickValues) => void): void;
  12519. /**
  12520. * Gets the left joystick
  12521. */
  12522. /**
  12523. * Sets the left joystick values
  12524. */
  12525. leftStick: StickValues;
  12526. /**
  12527. * Gets the right joystick
  12528. */
  12529. /**
  12530. * Sets the right joystick value
  12531. */
  12532. rightStick: StickValues;
  12533. /**
  12534. * Updates the gamepad joystick positions
  12535. */
  12536. update(): void;
  12537. /**
  12538. * Disposes the gamepad
  12539. */
  12540. dispose(): void;
  12541. }
  12542. /**
  12543. * Represents a generic gamepad
  12544. */
  12545. export class GenericPad extends Gamepad {
  12546. private _buttons;
  12547. private _onbuttondown;
  12548. private _onbuttonup;
  12549. /**
  12550. * Observable triggered when a button has been pressed
  12551. */
  12552. onButtonDownObservable: Observable<number>;
  12553. /**
  12554. * Observable triggered when a button has been released
  12555. */
  12556. onButtonUpObservable: Observable<number>;
  12557. /**
  12558. * Callback triggered when a button has been pressed
  12559. * @param callback Called when a button has been pressed
  12560. */
  12561. onbuttondown(callback: (buttonPressed: number) => void): void;
  12562. /**
  12563. * Callback triggered when a button has been released
  12564. * @param callback Called when a button has been released
  12565. */
  12566. onbuttonup(callback: (buttonReleased: number) => void): void;
  12567. /**
  12568. * Initializes the generic gamepad
  12569. * @param id The id of the generic gamepad
  12570. * @param index The index of the generic gamepad
  12571. * @param browserGamepad The browser gamepad
  12572. */
  12573. constructor(id: string, index: number, browserGamepad: any);
  12574. private _setButtonValue;
  12575. /**
  12576. * Updates the generic gamepad
  12577. */
  12578. update(): void;
  12579. /**
  12580. * Disposes the generic gamepad
  12581. */
  12582. dispose(): void;
  12583. }
  12584. }
  12585. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12586. import { Nullable } from "babylonjs/types";
  12587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12588. import { Scene } from "babylonjs/scene";
  12589. module "babylonjs/Engines/engine" {
  12590. interface Engine {
  12591. /**
  12592. * Creates a raw texture
  12593. * @param data defines the data to store in the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param format defines the format of the data
  12597. * @param generateMipMaps defines if the engine should generate the mip levels
  12598. * @param invertY defines if data must be stored with Y axis inverted
  12599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12600. * @param compression defines the compression used (null by default)
  12601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12602. * @returns the raw texture inside an InternalTexture
  12603. */
  12604. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12605. /**
  12606. * Update a raw texture
  12607. * @param texture defines the texture to update
  12608. * @param data defines the data to store in the texture
  12609. * @param format defines the format of the data
  12610. * @param invertY defines if data must be stored with Y axis inverted
  12611. */
  12612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12613. /**
  12614. * Update a raw texture
  12615. * @param texture defines the texture to update
  12616. * @param data defines the data to store in the texture
  12617. * @param format defines the format of the data
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12621. */
  12622. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12623. /**
  12624. * Creates a new raw cube texture
  12625. * @param data defines the array of data to use to create each face
  12626. * @param size defines the size of the textures
  12627. * @param format defines the format of the data
  12628. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12629. * @param generateMipMaps defines if the engine should generate the mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compression used (null by default)
  12633. * @returns the cube texture as an InternalTexture
  12634. */
  12635. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12636. /**
  12637. * Update a raw cube texture
  12638. * @param texture defines the texture to udpdate
  12639. * @param data defines the data to store
  12640. * @param format defines the data format
  12641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw cube texture
  12647. * @param texture defines the texture to udpdate
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @param compression defines the compression used (null by default)
  12653. */
  12654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12655. /**
  12656. * Update a raw cube texture
  12657. * @param texture defines the texture to udpdate
  12658. * @param data defines the data to store
  12659. * @param format defines the data format
  12660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12661. * @param invertY defines if data must be stored with Y axis inverted
  12662. * @param compression defines the compression used (null by default)
  12663. * @param level defines which level of the texture to update
  12664. */
  12665. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12666. /**
  12667. * Creates a new raw cube texture from a specified url
  12668. * @param url defines the url where the data is located
  12669. * @param scene defines the current scene
  12670. * @param size defines the size of the textures
  12671. * @param format defines the format of the data
  12672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12673. * @param noMipmap defines if the engine should avoid generating the mip levels
  12674. * @param callback defines a callback used to extract texture data from loaded data
  12675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12676. * @param onLoad defines a callback called when texture is loaded
  12677. * @param onError defines a callback called if there is an error
  12678. * @returns the cube texture as an InternalTexture
  12679. */
  12680. 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;
  12681. /**
  12682. * Creates a new raw cube texture from a specified url
  12683. * @param url defines the url where the data is located
  12684. * @param scene defines the current scene
  12685. * @param size defines the size of the textures
  12686. * @param format defines the format of the data
  12687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12688. * @param noMipmap defines if the engine should avoid generating the mip levels
  12689. * @param callback defines a callback used to extract texture data from loaded data
  12690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12691. * @param onLoad defines a callback called when texture is loaded
  12692. * @param onError defines a callback called if there is an error
  12693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12694. * @param invertY defines if data must be stored with Y axis inverted
  12695. * @returns the cube texture as an InternalTexture
  12696. */
  12697. 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;
  12698. /**
  12699. * Creates a new raw 3D texture
  12700. * @param data defines the data used to create the texture
  12701. * @param width defines the width of the texture
  12702. * @param height defines the height of the texture
  12703. * @param depth defines the depth of the texture
  12704. * @param format defines the format of the texture
  12705. * @param generateMipMaps defines if the engine must generate mip levels
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12708. * @param compression defines the compressed used (can be null)
  12709. * @param textureType defines the compressed used (can be null)
  12710. * @returns a new raw 3D texture (stored in an InternalTexture)
  12711. */
  12712. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12713. /**
  12714. * Update a raw 3D texture
  12715. * @param texture defines the texture to update
  12716. * @param data defines the data to store
  12717. * @param format defines the data format
  12718. * @param invertY defines if data must be stored with Y axis inverted
  12719. */
  12720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12721. /**
  12722. * Update a raw 3D texture
  12723. * @param texture defines the texture to update
  12724. * @param data defines the data to store
  12725. * @param format defines the data format
  12726. * @param invertY defines if data must be stored with Y axis inverted
  12727. * @param compression defines the used compression (can be null)
  12728. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12729. */
  12730. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12731. /**
  12732. * Creates a new raw 2D array texture
  12733. * @param data defines the data used to create the texture
  12734. * @param width defines the width of the texture
  12735. * @param height defines the height of the texture
  12736. * @param depth defines the number of layers of the texture
  12737. * @param format defines the format of the texture
  12738. * @param generateMipMaps defines if the engine must generate mip levels
  12739. * @param invertY defines if data must be stored with Y axis inverted
  12740. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12741. * @param compression defines the compressed used (can be null)
  12742. * @param textureType defines the compressed used (can be null)
  12743. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12744. */
  12745. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12746. /**
  12747. * Update a raw 2D array texture
  12748. * @param texture defines the texture to update
  12749. * @param data defines the data to store
  12750. * @param format defines the data format
  12751. * @param invertY defines if data must be stored with Y axis inverted
  12752. */
  12753. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12754. /**
  12755. * Update a raw 2D array texture
  12756. * @param texture defines the texture to update
  12757. * @param data defines the data to store
  12758. * @param format defines the data format
  12759. * @param invertY defines if data must be stored with Y axis inverted
  12760. * @param compression defines the used compression (can be null)
  12761. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12762. */
  12763. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12764. }
  12765. }
  12766. }
  12767. declare module "babylonjs/Materials/Textures/rawTexture" {
  12768. import { Scene } from "babylonjs/scene";
  12769. import { Texture } from "babylonjs/Materials/Textures/texture";
  12770. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12771. /**
  12772. * Raw texture can help creating a texture directly from an array of data.
  12773. * This can be super useful if you either get the data from an uncompressed source or
  12774. * if you wish to create your texture pixel by pixel.
  12775. */
  12776. export class RawTexture extends Texture {
  12777. /**
  12778. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12779. */
  12780. format: number;
  12781. private _engine;
  12782. /**
  12783. * Instantiates a new RawTexture.
  12784. * Raw texture can help creating a texture directly from an array of data.
  12785. * This can be super useful if you either get the data from an uncompressed source or
  12786. * if you wish to create your texture pixel by pixel.
  12787. * @param data define the array of data to use to create the texture
  12788. * @param width define the width of the texture
  12789. * @param height define the height of the texture
  12790. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12791. * @param scene define the scene the texture belongs to
  12792. * @param generateMipMaps define whether mip maps should be generated or not
  12793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12795. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12796. */
  12797. constructor(data: ArrayBufferView, width: number, height: number,
  12798. /**
  12799. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12800. */
  12801. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12802. /**
  12803. * Updates the texture underlying data.
  12804. * @param data Define the new data of the texture
  12805. */
  12806. update(data: ArrayBufferView): void;
  12807. /**
  12808. * Creates a luminance texture from some data.
  12809. * @param data Define the texture data
  12810. * @param width Define the width of the texture
  12811. * @param height Define the height of the texture
  12812. * @param scene Define the scene the texture belongs to
  12813. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12814. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12815. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12816. * @returns the luminance texture
  12817. */
  12818. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12819. /**
  12820. * Creates a luminance alpha texture from some data.
  12821. * @param data Define the texture data
  12822. * @param width Define the width of the texture
  12823. * @param height Define the height of the texture
  12824. * @param scene Define the scene the texture belongs to
  12825. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12826. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12827. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12828. * @returns the luminance alpha texture
  12829. */
  12830. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12831. /**
  12832. * Creates an alpha texture from some data.
  12833. * @param data Define the texture data
  12834. * @param width Define the width of the texture
  12835. * @param height Define the height of the texture
  12836. * @param scene Define the scene the texture belongs to
  12837. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12838. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12839. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12840. * @returns the alpha texture
  12841. */
  12842. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12843. /**
  12844. * Creates a RGB texture from some data.
  12845. * @param data Define the texture data
  12846. * @param width Define the width of the texture
  12847. * @param height Define the height of the texture
  12848. * @param scene Define the scene the texture belongs to
  12849. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12852. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12853. * @returns the RGB alpha texture
  12854. */
  12855. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12856. /**
  12857. * Creates a RGBA texture from some data.
  12858. * @param data Define the texture data
  12859. * @param width Define the width of the texture
  12860. * @param height Define the height of the texture
  12861. * @param scene Define the scene the texture belongs to
  12862. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12863. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12864. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12865. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12866. * @returns the RGBA texture
  12867. */
  12868. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12869. /**
  12870. * Creates a R texture from some data.
  12871. * @param data Define the texture data
  12872. * @param width Define the width of the texture
  12873. * @param height Define the height of the texture
  12874. * @param scene Define the scene the texture belongs to
  12875. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12876. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12877. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12878. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12879. * @returns the R texture
  12880. */
  12881. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12882. }
  12883. }
  12884. declare module "babylonjs/Maths/math.size" {
  12885. /**
  12886. * Interface for the size containing width and height
  12887. */
  12888. export interface ISize {
  12889. /**
  12890. * Width
  12891. */
  12892. width: number;
  12893. /**
  12894. * Heighht
  12895. */
  12896. height: number;
  12897. }
  12898. /**
  12899. * Size containing widht and height
  12900. */
  12901. export class Size implements ISize {
  12902. /**
  12903. * Width
  12904. */
  12905. width: number;
  12906. /**
  12907. * Height
  12908. */
  12909. height: number;
  12910. /**
  12911. * Creates a Size object from the given width and height (floats).
  12912. * @param width width of the new size
  12913. * @param height height of the new size
  12914. */
  12915. constructor(width: number, height: number);
  12916. /**
  12917. * Returns a string with the Size width and height
  12918. * @returns a string with the Size width and height
  12919. */
  12920. toString(): string;
  12921. /**
  12922. * "Size"
  12923. * @returns the string "Size"
  12924. */
  12925. getClassName(): string;
  12926. /**
  12927. * Returns the Size hash code.
  12928. * @returns a hash code for a unique width and height
  12929. */
  12930. getHashCode(): number;
  12931. /**
  12932. * Updates the current size from the given one.
  12933. * @param src the given size
  12934. */
  12935. copyFrom(src: Size): void;
  12936. /**
  12937. * Updates in place the current Size from the given floats.
  12938. * @param width width of the new size
  12939. * @param height height of the new size
  12940. * @returns the updated Size.
  12941. */
  12942. copyFromFloats(width: number, height: number): Size;
  12943. /**
  12944. * Updates in place the current Size from the given floats.
  12945. * @param width width to set
  12946. * @param height height to set
  12947. * @returns the updated Size.
  12948. */
  12949. set(width: number, height: number): Size;
  12950. /**
  12951. * Multiplies the width and height by numbers
  12952. * @param w factor to multiple the width by
  12953. * @param h factor to multiple the height by
  12954. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12955. */
  12956. multiplyByFloats(w: number, h: number): Size;
  12957. /**
  12958. * Clones the size
  12959. * @returns a new Size copied from the given one.
  12960. */
  12961. clone(): Size;
  12962. /**
  12963. * True if the current Size and the given one width and height are strictly equal.
  12964. * @param other the other size to compare against
  12965. * @returns True if the current Size and the given one width and height are strictly equal.
  12966. */
  12967. equals(other: Size): boolean;
  12968. /**
  12969. * The surface of the Size : width * height (float).
  12970. */
  12971. readonly surface: number;
  12972. /**
  12973. * Create a new size of zero
  12974. * @returns a new Size set to (0.0, 0.0)
  12975. */
  12976. static Zero(): Size;
  12977. /**
  12978. * Sums the width and height of two sizes
  12979. * @param otherSize size to add to this size
  12980. * @returns a new Size set as the addition result of the current Size and the given one.
  12981. */
  12982. add(otherSize: Size): Size;
  12983. /**
  12984. * Subtracts the width and height of two
  12985. * @param otherSize size to subtract to this size
  12986. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12987. */
  12988. subtract(otherSize: Size): Size;
  12989. /**
  12990. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12991. * @param start starting size to lerp between
  12992. * @param end end size to lerp between
  12993. * @param amount amount to lerp between the start and end values
  12994. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12995. */
  12996. static Lerp(start: Size, end: Size, amount: number): Size;
  12997. }
  12998. }
  12999. declare module "babylonjs/Animations/runtimeAnimation" {
  13000. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13001. import { Animatable } from "babylonjs/Animations/animatable";
  13002. import { Scene } from "babylonjs/scene";
  13003. /**
  13004. * Defines a runtime animation
  13005. */
  13006. export class RuntimeAnimation {
  13007. private _events;
  13008. /**
  13009. * The current frame of the runtime animation
  13010. */
  13011. private _currentFrame;
  13012. /**
  13013. * The animation used by the runtime animation
  13014. */
  13015. private _animation;
  13016. /**
  13017. * The target of the runtime animation
  13018. */
  13019. private _target;
  13020. /**
  13021. * The initiating animatable
  13022. */
  13023. private _host;
  13024. /**
  13025. * The original value of the runtime animation
  13026. */
  13027. private _originalValue;
  13028. /**
  13029. * The original blend value of the runtime animation
  13030. */
  13031. private _originalBlendValue;
  13032. /**
  13033. * The offsets cache of the runtime animation
  13034. */
  13035. private _offsetsCache;
  13036. /**
  13037. * The high limits cache of the runtime animation
  13038. */
  13039. private _highLimitsCache;
  13040. /**
  13041. * Specifies if the runtime animation has been stopped
  13042. */
  13043. private _stopped;
  13044. /**
  13045. * The blending factor of the runtime animation
  13046. */
  13047. private _blendingFactor;
  13048. /**
  13049. * The BabylonJS scene
  13050. */
  13051. private _scene;
  13052. /**
  13053. * The current value of the runtime animation
  13054. */
  13055. private _currentValue;
  13056. /** @hidden */
  13057. _animationState: _IAnimationState;
  13058. /**
  13059. * The active target of the runtime animation
  13060. */
  13061. private _activeTargets;
  13062. private _currentActiveTarget;
  13063. private _directTarget;
  13064. /**
  13065. * The target path of the runtime animation
  13066. */
  13067. private _targetPath;
  13068. /**
  13069. * The weight of the runtime animation
  13070. */
  13071. private _weight;
  13072. /**
  13073. * The ratio offset of the runtime animation
  13074. */
  13075. private _ratioOffset;
  13076. /**
  13077. * The previous delay of the runtime animation
  13078. */
  13079. private _previousDelay;
  13080. /**
  13081. * The previous ratio of the runtime animation
  13082. */
  13083. private _previousRatio;
  13084. private _enableBlending;
  13085. private _keys;
  13086. private _minFrame;
  13087. private _maxFrame;
  13088. private _minValue;
  13089. private _maxValue;
  13090. private _targetIsArray;
  13091. /**
  13092. * Gets the current frame of the runtime animation
  13093. */
  13094. readonly currentFrame: number;
  13095. /**
  13096. * Gets the weight of the runtime animation
  13097. */
  13098. readonly weight: number;
  13099. /**
  13100. * Gets the current value of the runtime animation
  13101. */
  13102. readonly currentValue: any;
  13103. /**
  13104. * Gets the target path of the runtime animation
  13105. */
  13106. readonly targetPath: string;
  13107. /**
  13108. * Gets the actual target of the runtime animation
  13109. */
  13110. readonly target: any;
  13111. /** @hidden */
  13112. _onLoop: () => void;
  13113. /**
  13114. * Create a new RuntimeAnimation object
  13115. * @param target defines the target of the animation
  13116. * @param animation defines the source animation object
  13117. * @param scene defines the hosting scene
  13118. * @param host defines the initiating Animatable
  13119. */
  13120. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13121. private _preparePath;
  13122. /**
  13123. * Gets the animation from the runtime animation
  13124. */
  13125. readonly animation: Animation;
  13126. /**
  13127. * Resets the runtime animation to the beginning
  13128. * @param restoreOriginal defines whether to restore the target property to the original value
  13129. */
  13130. reset(restoreOriginal?: boolean): void;
  13131. /**
  13132. * Specifies if the runtime animation is stopped
  13133. * @returns Boolean specifying if the runtime animation is stopped
  13134. */
  13135. isStopped(): boolean;
  13136. /**
  13137. * Disposes of the runtime animation
  13138. */
  13139. dispose(): void;
  13140. /**
  13141. * Apply the interpolated value to the target
  13142. * @param currentValue defines the value computed by the animation
  13143. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13144. */
  13145. setValue(currentValue: any, weight: number): void;
  13146. private _getOriginalValues;
  13147. private _setValue;
  13148. /**
  13149. * Gets the loop pmode of the runtime animation
  13150. * @returns Loop Mode
  13151. */
  13152. private _getCorrectLoopMode;
  13153. /**
  13154. * Move the current animation to a given frame
  13155. * @param frame defines the frame to move to
  13156. */
  13157. goToFrame(frame: number): void;
  13158. /**
  13159. * @hidden Internal use only
  13160. */
  13161. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13162. /**
  13163. * Execute the current animation
  13164. * @param delay defines the delay to add to the current frame
  13165. * @param from defines the lower bound of the animation range
  13166. * @param to defines the upper bound of the animation range
  13167. * @param loop defines if the current animation must loop
  13168. * @param speedRatio defines the current speed ratio
  13169. * @param weight defines the weight of the animation (default is -1 so no weight)
  13170. * @param onLoop optional callback called when animation loops
  13171. * @returns a boolean indicating if the animation is running
  13172. */
  13173. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13174. }
  13175. }
  13176. declare module "babylonjs/Animations/animatable" {
  13177. import { Animation } from "babylonjs/Animations/animation";
  13178. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13179. import { Nullable } from "babylonjs/types";
  13180. import { Observable } from "babylonjs/Misc/observable";
  13181. import { Scene } from "babylonjs/scene";
  13182. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13183. import { Node } from "babylonjs/node";
  13184. /**
  13185. * Class used to store an actual running animation
  13186. */
  13187. export class Animatable {
  13188. /** defines the target object */
  13189. target: any;
  13190. /** defines the starting frame number (default is 0) */
  13191. fromFrame: number;
  13192. /** defines the ending frame number (default is 100) */
  13193. toFrame: number;
  13194. /** defines if the animation must loop (default is false) */
  13195. loopAnimation: boolean;
  13196. /** defines a callback to call when animation ends if it is not looping */
  13197. onAnimationEnd?: (() => void) | null | undefined;
  13198. /** defines a callback to call when animation loops */
  13199. onAnimationLoop?: (() => void) | null | undefined;
  13200. private _localDelayOffset;
  13201. private _pausedDelay;
  13202. private _runtimeAnimations;
  13203. private _paused;
  13204. private _scene;
  13205. private _speedRatio;
  13206. private _weight;
  13207. private _syncRoot;
  13208. /**
  13209. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13210. * This will only apply for non looping animation (default is true)
  13211. */
  13212. disposeOnEnd: boolean;
  13213. /**
  13214. * Gets a boolean indicating if the animation has started
  13215. */
  13216. animationStarted: boolean;
  13217. /**
  13218. * Observer raised when the animation ends
  13219. */
  13220. onAnimationEndObservable: Observable<Animatable>;
  13221. /**
  13222. * Observer raised when the animation loops
  13223. */
  13224. onAnimationLoopObservable: Observable<Animatable>;
  13225. /**
  13226. * Gets the root Animatable used to synchronize and normalize animations
  13227. */
  13228. readonly syncRoot: Nullable<Animatable>;
  13229. /**
  13230. * Gets the current frame of the first RuntimeAnimation
  13231. * Used to synchronize Animatables
  13232. */
  13233. readonly masterFrame: number;
  13234. /**
  13235. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13236. */
  13237. weight: number;
  13238. /**
  13239. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13240. */
  13241. speedRatio: number;
  13242. /**
  13243. * Creates a new Animatable
  13244. * @param scene defines the hosting scene
  13245. * @param target defines the target object
  13246. * @param fromFrame defines the starting frame number (default is 0)
  13247. * @param toFrame defines the ending frame number (default is 100)
  13248. * @param loopAnimation defines if the animation must loop (default is false)
  13249. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13250. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13251. * @param animations defines a group of animation to add to the new Animatable
  13252. * @param onAnimationLoop defines a callback to call when animation loops
  13253. */
  13254. constructor(scene: Scene,
  13255. /** defines the target object */
  13256. target: any,
  13257. /** defines the starting frame number (default is 0) */
  13258. fromFrame?: number,
  13259. /** defines the ending frame number (default is 100) */
  13260. toFrame?: number,
  13261. /** defines if the animation must loop (default is false) */
  13262. loopAnimation?: boolean, speedRatio?: number,
  13263. /** defines a callback to call when animation ends if it is not looping */
  13264. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13265. /** defines a callback to call when animation loops */
  13266. onAnimationLoop?: (() => void) | null | undefined);
  13267. /**
  13268. * Synchronize and normalize current Animatable with a source Animatable
  13269. * This is useful when using animation weights and when animations are not of the same length
  13270. * @param root defines the root Animatable to synchronize with
  13271. * @returns the current Animatable
  13272. */
  13273. syncWith(root: Animatable): Animatable;
  13274. /**
  13275. * Gets the list of runtime animations
  13276. * @returns an array of RuntimeAnimation
  13277. */
  13278. getAnimations(): RuntimeAnimation[];
  13279. /**
  13280. * Adds more animations to the current animatable
  13281. * @param target defines the target of the animations
  13282. * @param animations defines the new animations to add
  13283. */
  13284. appendAnimations(target: any, animations: Animation[]): void;
  13285. /**
  13286. * Gets the source animation for a specific property
  13287. * @param property defines the propertyu to look for
  13288. * @returns null or the source animation for the given property
  13289. */
  13290. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13291. /**
  13292. * Gets the runtime animation for a specific property
  13293. * @param property defines the propertyu to look for
  13294. * @returns null or the runtime animation for the given property
  13295. */
  13296. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13297. /**
  13298. * Resets the animatable to its original state
  13299. */
  13300. reset(): void;
  13301. /**
  13302. * Allows the animatable to blend with current running animations
  13303. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13304. * @param blendingSpeed defines the blending speed to use
  13305. */
  13306. enableBlending(blendingSpeed: number): void;
  13307. /**
  13308. * Disable animation blending
  13309. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13310. */
  13311. disableBlending(): void;
  13312. /**
  13313. * Jump directly to a given frame
  13314. * @param frame defines the frame to jump to
  13315. */
  13316. goToFrame(frame: number): void;
  13317. /**
  13318. * Pause the animation
  13319. */
  13320. pause(): void;
  13321. /**
  13322. * Restart the animation
  13323. */
  13324. restart(): void;
  13325. private _raiseOnAnimationEnd;
  13326. /**
  13327. * Stop and delete the current animation
  13328. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13329. * @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)
  13330. */
  13331. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13332. /**
  13333. * Wait asynchronously for the animation to end
  13334. * @returns a promise which will be fullfilled when the animation ends
  13335. */
  13336. waitAsync(): Promise<Animatable>;
  13337. /** @hidden */
  13338. _animate(delay: number): boolean;
  13339. }
  13340. module "babylonjs/scene" {
  13341. interface Scene {
  13342. /** @hidden */
  13343. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13344. /** @hidden */
  13345. _processLateAnimationBindingsForMatrices(holder: {
  13346. totalWeight: number;
  13347. animations: RuntimeAnimation[];
  13348. originalValue: Matrix;
  13349. }): any;
  13350. /** @hidden */
  13351. _processLateAnimationBindingsForQuaternions(holder: {
  13352. totalWeight: number;
  13353. animations: RuntimeAnimation[];
  13354. originalValue: Quaternion;
  13355. }, refQuaternion: Quaternion): Quaternion;
  13356. /** @hidden */
  13357. _processLateAnimationBindings(): void;
  13358. /**
  13359. * Will start the animation sequence of a given target
  13360. * @param target defines the target
  13361. * @param from defines from which frame should animation start
  13362. * @param to defines until which frame should animation run.
  13363. * @param weight defines the weight to apply to the animation (1.0 by default)
  13364. * @param loop defines if the animation loops
  13365. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13366. * @param onAnimationEnd defines the function to be executed when the animation ends
  13367. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13368. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13369. * @param onAnimationLoop defines the callback to call when an animation loops
  13370. * @returns the animatable object created for this animation
  13371. */
  13372. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13373. /**
  13374. * Will start the animation sequence of a given target
  13375. * @param target defines the target
  13376. * @param from defines from which frame should animation start
  13377. * @param to defines until which frame should animation run.
  13378. * @param loop defines if the animation loops
  13379. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13380. * @param onAnimationEnd defines the function to be executed when the animation ends
  13381. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13382. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13383. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13384. * @param onAnimationLoop defines the callback to call when an animation loops
  13385. * @returns the animatable object created for this animation
  13386. */
  13387. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13388. /**
  13389. * Will start the animation sequence of a given target and its hierarchy
  13390. * @param target defines the target
  13391. * @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.
  13392. * @param from defines from which frame should animation start
  13393. * @param to defines until which frame should animation run.
  13394. * @param loop defines if the animation loops
  13395. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13396. * @param onAnimationEnd defines the function to be executed when the animation ends
  13397. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13398. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13399. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13400. * @param onAnimationLoop defines the callback to call when an animation loops
  13401. * @returns the list of created animatables
  13402. */
  13403. 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[];
  13404. /**
  13405. * Begin a new animation on a given node
  13406. * @param target defines the target where the animation will take place
  13407. * @param animations defines the list of animations to start
  13408. * @param from defines the initial value
  13409. * @param to defines the final value
  13410. * @param loop defines if you want animation to loop (off by default)
  13411. * @param speedRatio defines the speed ratio to apply to all animations
  13412. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13413. * @param onAnimationLoop defines the callback to call when an animation loops
  13414. * @returns the list of created animatables
  13415. */
  13416. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13417. /**
  13418. * Begin a new animation on a given node and its hierarchy
  13419. * @param target defines the root node where the animation will take place
  13420. * @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.
  13421. * @param animations defines the list of animations to start
  13422. * @param from defines the initial value
  13423. * @param to defines the final value
  13424. * @param loop defines if you want animation to loop (off by default)
  13425. * @param speedRatio defines the speed ratio to apply to all animations
  13426. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13427. * @param onAnimationLoop defines the callback to call when an animation loops
  13428. * @returns the list of animatables created for all nodes
  13429. */
  13430. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13431. /**
  13432. * Gets the animatable associated with a specific target
  13433. * @param target defines the target of the animatable
  13434. * @returns the required animatable if found
  13435. */
  13436. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13437. /**
  13438. * Gets all animatables associated with a given target
  13439. * @param target defines the target to look animatables for
  13440. * @returns an array of Animatables
  13441. */
  13442. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13443. /**
  13444. * Stops and removes all animations that have been applied to the scene
  13445. */
  13446. stopAllAnimations(): void;
  13447. /**
  13448. * Gets the current delta time used by animation engine
  13449. */
  13450. deltaTime: number;
  13451. }
  13452. }
  13453. module "babylonjs/Bones/bone" {
  13454. interface Bone {
  13455. /**
  13456. * Copy an animation range from another bone
  13457. * @param source defines the source bone
  13458. * @param rangeName defines the range name to copy
  13459. * @param frameOffset defines the frame offset
  13460. * @param rescaleAsRequired defines if rescaling must be applied if required
  13461. * @param skelDimensionsRatio defines the scaling ratio
  13462. * @returns true if operation was successful
  13463. */
  13464. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13465. }
  13466. }
  13467. }
  13468. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13469. /**
  13470. * Class used to override all child animations of a given target
  13471. */
  13472. export class AnimationPropertiesOverride {
  13473. /**
  13474. * Gets or sets a value indicating if animation blending must be used
  13475. */
  13476. enableBlending: boolean;
  13477. /**
  13478. * Gets or sets the blending speed to use when enableBlending is true
  13479. */
  13480. blendingSpeed: number;
  13481. /**
  13482. * Gets or sets the default loop mode to use
  13483. */
  13484. loopMode: number;
  13485. }
  13486. }
  13487. declare module "babylonjs/Bones/skeleton" {
  13488. import { Bone } from "babylonjs/Bones/bone";
  13489. import { Observable } from "babylonjs/Misc/observable";
  13490. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13491. import { Scene } from "babylonjs/scene";
  13492. import { Nullable } from "babylonjs/types";
  13493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13494. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13495. import { Animatable } from "babylonjs/Animations/animatable";
  13496. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13497. import { Animation } from "babylonjs/Animations/animation";
  13498. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13499. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13500. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13501. /**
  13502. * Class used to handle skinning animations
  13503. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13504. */
  13505. export class Skeleton implements IAnimatable {
  13506. /** defines the skeleton name */
  13507. name: string;
  13508. /** defines the skeleton Id */
  13509. id: string;
  13510. /**
  13511. * Defines the list of child bones
  13512. */
  13513. bones: Bone[];
  13514. /**
  13515. * Defines an estimate of the dimension of the skeleton at rest
  13516. */
  13517. dimensionsAtRest: Vector3;
  13518. /**
  13519. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13520. */
  13521. needInitialSkinMatrix: boolean;
  13522. /**
  13523. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13524. */
  13525. overrideMesh: Nullable<AbstractMesh>;
  13526. /**
  13527. * Gets the list of animations attached to this skeleton
  13528. */
  13529. animations: Array<Animation>;
  13530. private _scene;
  13531. private _isDirty;
  13532. private _transformMatrices;
  13533. private _transformMatrixTexture;
  13534. private _meshesWithPoseMatrix;
  13535. private _animatables;
  13536. private _identity;
  13537. private _synchronizedWithMesh;
  13538. private _ranges;
  13539. private _lastAbsoluteTransformsUpdateId;
  13540. private _canUseTextureForBones;
  13541. private _uniqueId;
  13542. /** @hidden */
  13543. _numBonesWithLinkedTransformNode: number;
  13544. /** @hidden */
  13545. _hasWaitingData: Nullable<boolean>;
  13546. /**
  13547. * Specifies if the skeleton should be serialized
  13548. */
  13549. doNotSerialize: boolean;
  13550. private _useTextureToStoreBoneMatrices;
  13551. /**
  13552. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13553. * Please note that this option is not available if the hardware does not support it
  13554. */
  13555. useTextureToStoreBoneMatrices: boolean;
  13556. private _animationPropertiesOverride;
  13557. /**
  13558. * Gets or sets the animation properties override
  13559. */
  13560. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13561. /**
  13562. * List of inspectable custom properties (used by the Inspector)
  13563. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13564. */
  13565. inspectableCustomProperties: IInspectable[];
  13566. /**
  13567. * An observable triggered before computing the skeleton's matrices
  13568. */
  13569. onBeforeComputeObservable: Observable<Skeleton>;
  13570. /**
  13571. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13572. */
  13573. readonly isUsingTextureForMatrices: boolean;
  13574. /**
  13575. * Gets the unique ID of this skeleton
  13576. */
  13577. readonly uniqueId: number;
  13578. /**
  13579. * Creates a new skeleton
  13580. * @param name defines the skeleton name
  13581. * @param id defines the skeleton Id
  13582. * @param scene defines the hosting scene
  13583. */
  13584. constructor(
  13585. /** defines the skeleton name */
  13586. name: string,
  13587. /** defines the skeleton Id */
  13588. id: string, scene: Scene);
  13589. /**
  13590. * Gets the current object class name.
  13591. * @return the class name
  13592. */
  13593. getClassName(): string;
  13594. /**
  13595. * Returns an array containing the root bones
  13596. * @returns an array containing the root bones
  13597. */
  13598. getChildren(): Array<Bone>;
  13599. /**
  13600. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13601. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13602. * @returns a Float32Array containing matrices data
  13603. */
  13604. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13605. /**
  13606. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13607. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13608. * @returns a raw texture containing the data
  13609. */
  13610. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13611. /**
  13612. * Gets the current hosting scene
  13613. * @returns a scene object
  13614. */
  13615. getScene(): Scene;
  13616. /**
  13617. * Gets a string representing the current skeleton data
  13618. * @param fullDetails defines a boolean indicating if we want a verbose version
  13619. * @returns a string representing the current skeleton data
  13620. */
  13621. toString(fullDetails?: boolean): string;
  13622. /**
  13623. * Get bone's index searching by name
  13624. * @param name defines bone's name to search for
  13625. * @return the indice of the bone. Returns -1 if not found
  13626. */
  13627. getBoneIndexByName(name: string): number;
  13628. /**
  13629. * Creater a new animation range
  13630. * @param name defines the name of the range
  13631. * @param from defines the start key
  13632. * @param to defines the end key
  13633. */
  13634. createAnimationRange(name: string, from: number, to: number): void;
  13635. /**
  13636. * Delete a specific animation range
  13637. * @param name defines the name of the range
  13638. * @param deleteFrames defines if frames must be removed as well
  13639. */
  13640. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13641. /**
  13642. * Gets a specific animation range
  13643. * @param name defines the name of the range to look for
  13644. * @returns the requested animation range or null if not found
  13645. */
  13646. getAnimationRange(name: string): Nullable<AnimationRange>;
  13647. /**
  13648. * Gets the list of all animation ranges defined on this skeleton
  13649. * @returns an array
  13650. */
  13651. getAnimationRanges(): Nullable<AnimationRange>[];
  13652. /**
  13653. * Copy animation range from a source skeleton.
  13654. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13655. * @param source defines the source skeleton
  13656. * @param name defines the name of the range to copy
  13657. * @param rescaleAsRequired defines if rescaling must be applied if required
  13658. * @returns true if operation was successful
  13659. */
  13660. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13661. /**
  13662. * Forces the skeleton to go to rest pose
  13663. */
  13664. returnToRest(): void;
  13665. private _getHighestAnimationFrame;
  13666. /**
  13667. * Begin a specific animation range
  13668. * @param name defines the name of the range to start
  13669. * @param loop defines if looping must be turned on (false by default)
  13670. * @param speedRatio defines the speed ratio to apply (1 by default)
  13671. * @param onAnimationEnd defines a callback which will be called when animation will end
  13672. * @returns a new animatable
  13673. */
  13674. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13675. /** @hidden */
  13676. _markAsDirty(): void;
  13677. /** @hidden */
  13678. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13679. /** @hidden */
  13680. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13681. private _computeTransformMatrices;
  13682. /**
  13683. * Build all resources required to render a skeleton
  13684. */
  13685. prepare(): void;
  13686. /**
  13687. * Gets the list of animatables currently running for this skeleton
  13688. * @returns an array of animatables
  13689. */
  13690. getAnimatables(): IAnimatable[];
  13691. /**
  13692. * Clone the current skeleton
  13693. * @param name defines the name of the new skeleton
  13694. * @param id defines the id of the new skeleton
  13695. * @returns the new skeleton
  13696. */
  13697. clone(name: string, id?: string): Skeleton;
  13698. /**
  13699. * Enable animation blending for this skeleton
  13700. * @param blendingSpeed defines the blending speed to apply
  13701. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13702. */
  13703. enableBlending(blendingSpeed?: number): void;
  13704. /**
  13705. * Releases all resources associated with the current skeleton
  13706. */
  13707. dispose(): void;
  13708. /**
  13709. * Serialize the skeleton in a JSON object
  13710. * @returns a JSON object
  13711. */
  13712. serialize(): any;
  13713. /**
  13714. * Creates a new skeleton from serialized data
  13715. * @param parsedSkeleton defines the serialized data
  13716. * @param scene defines the hosting scene
  13717. * @returns a new skeleton
  13718. */
  13719. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13720. /**
  13721. * Compute all node absolute transforms
  13722. * @param forceUpdate defines if computation must be done even if cache is up to date
  13723. */
  13724. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13725. /**
  13726. * Gets the root pose matrix
  13727. * @returns a matrix
  13728. */
  13729. getPoseMatrix(): Nullable<Matrix>;
  13730. /**
  13731. * Sorts bones per internal index
  13732. */
  13733. sortBones(): void;
  13734. private _sortBones;
  13735. }
  13736. }
  13737. declare module "babylonjs/Bones/bone" {
  13738. import { Skeleton } from "babylonjs/Bones/skeleton";
  13739. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13740. import { Nullable } from "babylonjs/types";
  13741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13742. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13743. import { Node } from "babylonjs/node";
  13744. import { Space } from "babylonjs/Maths/math.axis";
  13745. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13746. /**
  13747. * Class used to store bone information
  13748. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13749. */
  13750. export class Bone extends Node {
  13751. /**
  13752. * defines the bone name
  13753. */
  13754. name: string;
  13755. private static _tmpVecs;
  13756. private static _tmpQuat;
  13757. private static _tmpMats;
  13758. /**
  13759. * Gets the list of child bones
  13760. */
  13761. children: Bone[];
  13762. /** Gets the animations associated with this bone */
  13763. animations: import("babylonjs/Animations/animation").Animation[];
  13764. /**
  13765. * Gets or sets bone length
  13766. */
  13767. length: number;
  13768. /**
  13769. * @hidden Internal only
  13770. * Set this value to map this bone to a different index in the transform matrices
  13771. * Set this value to -1 to exclude the bone from the transform matrices
  13772. */
  13773. _index: Nullable<number>;
  13774. private _skeleton;
  13775. private _localMatrix;
  13776. private _restPose;
  13777. private _baseMatrix;
  13778. private _absoluteTransform;
  13779. private _invertedAbsoluteTransform;
  13780. private _parent;
  13781. private _scalingDeterminant;
  13782. private _worldTransform;
  13783. private _localScaling;
  13784. private _localRotation;
  13785. private _localPosition;
  13786. private _needToDecompose;
  13787. private _needToCompose;
  13788. /** @hidden */
  13789. _linkedTransformNode: Nullable<TransformNode>;
  13790. /** @hidden */
  13791. _waitingTransformNodeId: Nullable<string>;
  13792. /** @hidden */
  13793. /** @hidden */
  13794. _matrix: Matrix;
  13795. /**
  13796. * Create a new bone
  13797. * @param name defines the bone name
  13798. * @param skeleton defines the parent skeleton
  13799. * @param parentBone defines the parent (can be null if the bone is the root)
  13800. * @param localMatrix defines the local matrix
  13801. * @param restPose defines the rest pose matrix
  13802. * @param baseMatrix defines the base matrix
  13803. * @param index defines index of the bone in the hiearchy
  13804. */
  13805. constructor(
  13806. /**
  13807. * defines the bone name
  13808. */
  13809. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13810. /**
  13811. * Gets the current object class name.
  13812. * @return the class name
  13813. */
  13814. getClassName(): string;
  13815. /**
  13816. * Gets the parent skeleton
  13817. * @returns a skeleton
  13818. */
  13819. getSkeleton(): Skeleton;
  13820. /**
  13821. * Gets parent bone
  13822. * @returns a bone or null if the bone is the root of the bone hierarchy
  13823. */
  13824. getParent(): Nullable<Bone>;
  13825. /**
  13826. * Returns an array containing the root bones
  13827. * @returns an array containing the root bones
  13828. */
  13829. getChildren(): Array<Bone>;
  13830. /**
  13831. * Gets the node index in matrix array generated for rendering
  13832. * @returns the node index
  13833. */
  13834. getIndex(): number;
  13835. /**
  13836. * Sets the parent bone
  13837. * @param parent defines the parent (can be null if the bone is the root)
  13838. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13839. */
  13840. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13841. /**
  13842. * Gets the local matrix
  13843. * @returns a matrix
  13844. */
  13845. getLocalMatrix(): Matrix;
  13846. /**
  13847. * Gets the base matrix (initial matrix which remains unchanged)
  13848. * @returns a matrix
  13849. */
  13850. getBaseMatrix(): Matrix;
  13851. /**
  13852. * Gets the rest pose matrix
  13853. * @returns a matrix
  13854. */
  13855. getRestPose(): Matrix;
  13856. /**
  13857. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13858. */
  13859. getWorldMatrix(): Matrix;
  13860. /**
  13861. * Sets the local matrix to rest pose matrix
  13862. */
  13863. returnToRest(): void;
  13864. /**
  13865. * Gets the inverse of the absolute transform matrix.
  13866. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13867. * @returns a matrix
  13868. */
  13869. getInvertedAbsoluteTransform(): Matrix;
  13870. /**
  13871. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13872. * @returns a matrix
  13873. */
  13874. getAbsoluteTransform(): Matrix;
  13875. /**
  13876. * Links with the given transform node.
  13877. * The local matrix of this bone is copied from the transform node every frame.
  13878. * @param transformNode defines the transform node to link to
  13879. */
  13880. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13881. /**
  13882. * Gets the node used to drive the bone's transformation
  13883. * @returns a transform node or null
  13884. */
  13885. getTransformNode(): Nullable<TransformNode>;
  13886. /** Gets or sets current position (in local space) */
  13887. position: Vector3;
  13888. /** Gets or sets current rotation (in local space) */
  13889. rotation: Vector3;
  13890. /** Gets or sets current rotation quaternion (in local space) */
  13891. rotationQuaternion: Quaternion;
  13892. /** Gets or sets current scaling (in local space) */
  13893. scaling: Vector3;
  13894. /**
  13895. * Gets the animation properties override
  13896. */
  13897. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13898. private _decompose;
  13899. private _compose;
  13900. /**
  13901. * Update the base and local matrices
  13902. * @param matrix defines the new base or local matrix
  13903. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13904. * @param updateLocalMatrix defines if the local matrix should be updated
  13905. */
  13906. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13907. /** @hidden */
  13908. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13909. /**
  13910. * Flag the bone as dirty (Forcing it to update everything)
  13911. */
  13912. markAsDirty(): void;
  13913. /** @hidden */
  13914. _markAsDirtyAndCompose(): void;
  13915. private _markAsDirtyAndDecompose;
  13916. /**
  13917. * Translate the bone in local or world space
  13918. * @param vec The amount to translate the bone
  13919. * @param space The space that the translation is in
  13920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13921. */
  13922. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13923. /**
  13924. * Set the postion of the bone in local or world space
  13925. * @param position The position to set the bone
  13926. * @param space The space that the position is in
  13927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13928. */
  13929. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13930. /**
  13931. * Set the absolute position of the bone (world space)
  13932. * @param position The position to set the bone
  13933. * @param mesh The mesh that this bone is attached to
  13934. */
  13935. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13936. /**
  13937. * Scale the bone on the x, y and z axes (in local space)
  13938. * @param x The amount to scale the bone on the x axis
  13939. * @param y The amount to scale the bone on the y axis
  13940. * @param z The amount to scale the bone on the z axis
  13941. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13942. */
  13943. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13944. /**
  13945. * Set the bone scaling in local space
  13946. * @param scale defines the scaling vector
  13947. */
  13948. setScale(scale: Vector3): void;
  13949. /**
  13950. * Gets the current scaling in local space
  13951. * @returns the current scaling vector
  13952. */
  13953. getScale(): Vector3;
  13954. /**
  13955. * Gets the current scaling in local space and stores it in a target vector
  13956. * @param result defines the target vector
  13957. */
  13958. getScaleToRef(result: Vector3): void;
  13959. /**
  13960. * Set the yaw, pitch, and roll of the bone in local or world space
  13961. * @param yaw The rotation of the bone on the y axis
  13962. * @param pitch The rotation of the bone on the x axis
  13963. * @param roll The rotation of the bone on the z axis
  13964. * @param space The space that the axes of rotation are in
  13965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13966. */
  13967. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13968. /**
  13969. * Add a rotation to the bone on an axis in local or world space
  13970. * @param axis The axis to rotate the bone on
  13971. * @param amount The amount to rotate the bone
  13972. * @param space The space that the axis is in
  13973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13974. */
  13975. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13976. /**
  13977. * Set the rotation of the bone to a particular axis angle in local or world space
  13978. * @param axis The axis to rotate the bone on
  13979. * @param angle The angle that the bone should be rotated to
  13980. * @param space The space that the axis is in
  13981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13982. */
  13983. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13984. /**
  13985. * Set the euler rotation of the bone in local of world space
  13986. * @param rotation The euler rotation that the bone should be set to
  13987. * @param space The space that the rotation is in
  13988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13989. */
  13990. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13991. /**
  13992. * Set the quaternion rotation of the bone in local of world space
  13993. * @param quat The quaternion rotation that the bone should be set to
  13994. * @param space The space that the rotation is in
  13995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13996. */
  13997. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13998. /**
  13999. * Set the rotation matrix of the bone in local of world space
  14000. * @param rotMat The rotation matrix that the bone should be set to
  14001. * @param space The space that the rotation is in
  14002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14003. */
  14004. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14005. private _rotateWithMatrix;
  14006. private _getNegativeRotationToRef;
  14007. /**
  14008. * Get the position of the bone in local or world space
  14009. * @param space The space that the returned position is in
  14010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14011. * @returns The position of the bone
  14012. */
  14013. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14014. /**
  14015. * Copy the position of the bone to a vector3 in local or world space
  14016. * @param space The space that the returned position is in
  14017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14018. * @param result The vector3 to copy the position to
  14019. */
  14020. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14021. /**
  14022. * Get the absolute position of the bone (world space)
  14023. * @param mesh The mesh that this bone is attached to
  14024. * @returns The absolute position of the bone
  14025. */
  14026. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14027. /**
  14028. * Copy the absolute position of the bone (world space) to the result param
  14029. * @param mesh The mesh that this bone is attached to
  14030. * @param result The vector3 to copy the absolute position to
  14031. */
  14032. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14033. /**
  14034. * Compute the absolute transforms of this bone and its children
  14035. */
  14036. computeAbsoluteTransforms(): void;
  14037. /**
  14038. * Get the world direction from an axis that is in the local space of the bone
  14039. * @param localAxis The local direction that is used to compute the world direction
  14040. * @param mesh The mesh that this bone is attached to
  14041. * @returns The world direction
  14042. */
  14043. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14044. /**
  14045. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14046. * @param localAxis The local direction that is used to compute the world direction
  14047. * @param mesh The mesh that this bone is attached to
  14048. * @param result The vector3 that the world direction will be copied to
  14049. */
  14050. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14051. /**
  14052. * Get the euler rotation of the bone in local or world space
  14053. * @param space The space that the rotation should be in
  14054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14055. * @returns The euler rotation
  14056. */
  14057. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14058. /**
  14059. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14060. * @param space The space that the rotation should be in
  14061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14062. * @param result The vector3 that the rotation should be copied to
  14063. */
  14064. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14065. /**
  14066. * Get the quaternion rotation of the bone in either local or world space
  14067. * @param space The space that the rotation should be in
  14068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14069. * @returns The quaternion rotation
  14070. */
  14071. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14072. /**
  14073. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14074. * @param space The space that the rotation should be in
  14075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14076. * @param result The quaternion that the rotation should be copied to
  14077. */
  14078. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14079. /**
  14080. * Get the rotation matrix of the bone in local or world space
  14081. * @param space The space that the rotation should be in
  14082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14083. * @returns The rotation matrix
  14084. */
  14085. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14086. /**
  14087. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14088. * @param space The space that the rotation should be in
  14089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14090. * @param result The quaternion that the rotation should be copied to
  14091. */
  14092. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14093. /**
  14094. * Get the world position of a point that is in the local space of the bone
  14095. * @param position The local position
  14096. * @param mesh The mesh that this bone is attached to
  14097. * @returns The world position
  14098. */
  14099. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14100. /**
  14101. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14102. * @param position The local position
  14103. * @param mesh The mesh that this bone is attached to
  14104. * @param result The vector3 that the world position should be copied to
  14105. */
  14106. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14107. /**
  14108. * Get the local position of a point that is in world space
  14109. * @param position The world position
  14110. * @param mesh The mesh that this bone is attached to
  14111. * @returns The local position
  14112. */
  14113. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14114. /**
  14115. * Get the local position of a point that is in world space and copy it to the result param
  14116. * @param position The world position
  14117. * @param mesh The mesh that this bone is attached to
  14118. * @param result The vector3 that the local position should be copied to
  14119. */
  14120. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14121. }
  14122. }
  14123. declare module "babylonjs/Meshes/transformNode" {
  14124. import { DeepImmutable } from "babylonjs/types";
  14125. import { Observable } from "babylonjs/Misc/observable";
  14126. import { Nullable } from "babylonjs/types";
  14127. import { Camera } from "babylonjs/Cameras/camera";
  14128. import { Scene } from "babylonjs/scene";
  14129. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14130. import { Node } from "babylonjs/node";
  14131. import { Bone } from "babylonjs/Bones/bone";
  14132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14133. import { Space } from "babylonjs/Maths/math.axis";
  14134. /**
  14135. * 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.
  14136. * @see https://doc.babylonjs.com/how_to/transformnode
  14137. */
  14138. export class TransformNode extends Node {
  14139. /**
  14140. * Object will not rotate to face the camera
  14141. */
  14142. static BILLBOARDMODE_NONE: number;
  14143. /**
  14144. * Object will rotate to face the camera but only on the x axis
  14145. */
  14146. static BILLBOARDMODE_X: number;
  14147. /**
  14148. * Object will rotate to face the camera but only on the y axis
  14149. */
  14150. static BILLBOARDMODE_Y: number;
  14151. /**
  14152. * Object will rotate to face the camera but only on the z axis
  14153. */
  14154. static BILLBOARDMODE_Z: number;
  14155. /**
  14156. * Object will rotate to face the camera
  14157. */
  14158. static BILLBOARDMODE_ALL: number;
  14159. /**
  14160. * Object will rotate to face the camera's position instead of orientation
  14161. */
  14162. static BILLBOARDMODE_USE_POSITION: number;
  14163. private _forward;
  14164. private _forwardInverted;
  14165. private _up;
  14166. private _right;
  14167. private _rightInverted;
  14168. private _position;
  14169. private _rotation;
  14170. private _rotationQuaternion;
  14171. protected _scaling: Vector3;
  14172. protected _isDirty: boolean;
  14173. private _transformToBoneReferal;
  14174. private _isAbsoluteSynced;
  14175. private _billboardMode;
  14176. /**
  14177. * Gets or sets the billboard mode. Default is 0.
  14178. *
  14179. * | Value | Type | Description |
  14180. * | --- | --- | --- |
  14181. * | 0 | BILLBOARDMODE_NONE | |
  14182. * | 1 | BILLBOARDMODE_X | |
  14183. * | 2 | BILLBOARDMODE_Y | |
  14184. * | 4 | BILLBOARDMODE_Z | |
  14185. * | 7 | BILLBOARDMODE_ALL | |
  14186. *
  14187. */
  14188. billboardMode: number;
  14189. private _preserveParentRotationForBillboard;
  14190. /**
  14191. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14192. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14193. */
  14194. preserveParentRotationForBillboard: boolean;
  14195. /**
  14196. * 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
  14197. */
  14198. scalingDeterminant: number;
  14199. private _infiniteDistance;
  14200. /**
  14201. * Gets or sets the distance of the object to max, often used by skybox
  14202. */
  14203. infiniteDistance: boolean;
  14204. /**
  14205. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14206. * By default the system will update normals to compensate
  14207. */
  14208. ignoreNonUniformScaling: boolean;
  14209. /**
  14210. * 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
  14211. */
  14212. reIntegrateRotationIntoRotationQuaternion: boolean;
  14213. /** @hidden */
  14214. _poseMatrix: Nullable<Matrix>;
  14215. /** @hidden */
  14216. _localMatrix: Matrix;
  14217. private _usePivotMatrix;
  14218. private _absolutePosition;
  14219. private _absoluteScaling;
  14220. private _absoluteRotationQuaternion;
  14221. private _pivotMatrix;
  14222. private _pivotMatrixInverse;
  14223. protected _postMultiplyPivotMatrix: boolean;
  14224. protected _isWorldMatrixFrozen: boolean;
  14225. /** @hidden */
  14226. _indexInSceneTransformNodesArray: number;
  14227. /**
  14228. * An event triggered after the world matrix is updated
  14229. */
  14230. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14231. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14232. /**
  14233. * Gets a string identifying the name of the class
  14234. * @returns "TransformNode" string
  14235. */
  14236. getClassName(): string;
  14237. /**
  14238. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14239. */
  14240. position: Vector3;
  14241. /**
  14242. * 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)).
  14243. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14244. */
  14245. rotation: Vector3;
  14246. /**
  14247. * 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)).
  14248. */
  14249. scaling: Vector3;
  14250. /**
  14251. * 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).
  14252. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14253. */
  14254. rotationQuaternion: Nullable<Quaternion>;
  14255. /**
  14256. * The forward direction of that transform in world space.
  14257. */
  14258. readonly forward: Vector3;
  14259. /**
  14260. * The up direction of that transform in world space.
  14261. */
  14262. readonly up: Vector3;
  14263. /**
  14264. * The right direction of that transform in world space.
  14265. */
  14266. readonly right: Vector3;
  14267. /**
  14268. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14269. * @param matrix the matrix to copy the pose from
  14270. * @returns this TransformNode.
  14271. */
  14272. updatePoseMatrix(matrix: Matrix): TransformNode;
  14273. /**
  14274. * Returns the mesh Pose matrix.
  14275. * @returns the pose matrix
  14276. */
  14277. getPoseMatrix(): Matrix;
  14278. /** @hidden */
  14279. _isSynchronized(): boolean;
  14280. /** @hidden */
  14281. _initCache(): void;
  14282. /**
  14283. * Flag the transform node as dirty (Forcing it to update everything)
  14284. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14285. * @returns this transform node
  14286. */
  14287. markAsDirty(property: string): TransformNode;
  14288. /**
  14289. * Returns the current mesh absolute position.
  14290. * Returns a Vector3.
  14291. */
  14292. readonly absolutePosition: Vector3;
  14293. /**
  14294. * Returns the current mesh absolute scaling.
  14295. * Returns a Vector3.
  14296. */
  14297. readonly absoluteScaling: Vector3;
  14298. /**
  14299. * Returns the current mesh absolute rotation.
  14300. * Returns a Quaternion.
  14301. */
  14302. readonly absoluteRotationQuaternion: Quaternion;
  14303. /**
  14304. * Sets a new matrix to apply before all other transformation
  14305. * @param matrix defines the transform matrix
  14306. * @returns the current TransformNode
  14307. */
  14308. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14309. /**
  14310. * Sets a new pivot matrix to the current node
  14311. * @param matrix defines the new pivot matrix to use
  14312. * @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
  14313. * @returns the current TransformNode
  14314. */
  14315. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14316. /**
  14317. * Returns the mesh pivot matrix.
  14318. * Default : Identity.
  14319. * @returns the matrix
  14320. */
  14321. getPivotMatrix(): Matrix;
  14322. /**
  14323. * Instantiate (when possible) or clone that node with its hierarchy
  14324. * @param newParent defines the new parent to use for the instance (or clone)
  14325. * @param options defines options to configure how copy is done
  14326. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14327. * @returns an instance (or a clone) of the current node with its hiearchy
  14328. */
  14329. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14330. doNotInstantiate: boolean;
  14331. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14332. /**
  14333. * Prevents the World matrix to be computed any longer
  14334. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14335. * @returns the TransformNode.
  14336. */
  14337. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14338. /**
  14339. * Allows back the World matrix computation.
  14340. * @returns the TransformNode.
  14341. */
  14342. unfreezeWorldMatrix(): this;
  14343. /**
  14344. * True if the World matrix has been frozen.
  14345. */
  14346. readonly isWorldMatrixFrozen: boolean;
  14347. /**
  14348. * Retuns the mesh absolute position in the World.
  14349. * @returns a Vector3.
  14350. */
  14351. getAbsolutePosition(): Vector3;
  14352. /**
  14353. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14354. * @param absolutePosition the absolute position to set
  14355. * @returns the TransformNode.
  14356. */
  14357. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14358. /**
  14359. * Sets the mesh position in its local space.
  14360. * @param vector3 the position to set in localspace
  14361. * @returns the TransformNode.
  14362. */
  14363. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14364. /**
  14365. * Returns the mesh position in the local space from the current World matrix values.
  14366. * @returns a new Vector3.
  14367. */
  14368. getPositionExpressedInLocalSpace(): Vector3;
  14369. /**
  14370. * Translates the mesh along the passed Vector3 in its local space.
  14371. * @param vector3 the distance to translate in localspace
  14372. * @returns the TransformNode.
  14373. */
  14374. locallyTranslate(vector3: Vector3): TransformNode;
  14375. private static _lookAtVectorCache;
  14376. /**
  14377. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14378. * @param targetPoint the position (must be in same space as current mesh) to look at
  14379. * @param yawCor optional yaw (y-axis) correction in radians
  14380. * @param pitchCor optional pitch (x-axis) correction in radians
  14381. * @param rollCor optional roll (z-axis) correction in radians
  14382. * @param space the choosen space of the target
  14383. * @returns the TransformNode.
  14384. */
  14385. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14386. /**
  14387. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14388. * This Vector3 is expressed in the World space.
  14389. * @param localAxis axis to rotate
  14390. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14391. */
  14392. getDirection(localAxis: Vector3): Vector3;
  14393. /**
  14394. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14395. * localAxis is expressed in the mesh local space.
  14396. * result is computed in the Wordl space from the mesh World matrix.
  14397. * @param localAxis axis to rotate
  14398. * @param result the resulting transformnode
  14399. * @returns this TransformNode.
  14400. */
  14401. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14402. /**
  14403. * Sets this transform node rotation to the given local axis.
  14404. * @param localAxis the axis in local space
  14405. * @param yawCor optional yaw (y-axis) correction in radians
  14406. * @param pitchCor optional pitch (x-axis) correction in radians
  14407. * @param rollCor optional roll (z-axis) correction in radians
  14408. * @returns this TransformNode
  14409. */
  14410. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14411. /**
  14412. * Sets a new pivot point to the current node
  14413. * @param point defines the new pivot point to use
  14414. * @param space defines if the point is in world or local space (local by default)
  14415. * @returns the current TransformNode
  14416. */
  14417. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14418. /**
  14419. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14420. * @returns the pivot point
  14421. */
  14422. getPivotPoint(): Vector3;
  14423. /**
  14424. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14425. * @param result the vector3 to store the result
  14426. * @returns this TransformNode.
  14427. */
  14428. getPivotPointToRef(result: Vector3): TransformNode;
  14429. /**
  14430. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14431. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14432. */
  14433. getAbsolutePivotPoint(): Vector3;
  14434. /**
  14435. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14436. * @param result vector3 to store the result
  14437. * @returns this TransformNode.
  14438. */
  14439. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14440. /**
  14441. * Defines the passed node as the parent of the current node.
  14442. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14443. * @see https://doc.babylonjs.com/how_to/parenting
  14444. * @param node the node ot set as the parent
  14445. * @returns this TransformNode.
  14446. */
  14447. setParent(node: Nullable<Node>): TransformNode;
  14448. private _nonUniformScaling;
  14449. /**
  14450. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14451. */
  14452. readonly nonUniformScaling: boolean;
  14453. /** @hidden */
  14454. _updateNonUniformScalingState(value: boolean): boolean;
  14455. /**
  14456. * Attach the current TransformNode to another TransformNode associated with a bone
  14457. * @param bone Bone affecting the TransformNode
  14458. * @param affectedTransformNode TransformNode associated with the bone
  14459. * @returns this object
  14460. */
  14461. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14462. /**
  14463. * Detach the transform node if its associated with a bone
  14464. * @returns this object
  14465. */
  14466. detachFromBone(): TransformNode;
  14467. private static _rotationAxisCache;
  14468. /**
  14469. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14470. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14471. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14472. * The passed axis is also normalized.
  14473. * @param axis the axis to rotate around
  14474. * @param amount the amount to rotate in radians
  14475. * @param space Space to rotate in (Default: local)
  14476. * @returns the TransformNode.
  14477. */
  14478. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14479. /**
  14480. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14481. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14482. * The passed axis is also normalized. .
  14483. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14484. * @param point the point to rotate around
  14485. * @param axis the axis to rotate around
  14486. * @param amount the amount to rotate in radians
  14487. * @returns the TransformNode
  14488. */
  14489. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14490. /**
  14491. * Translates the mesh along the axis vector for the passed distance in the given space.
  14492. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14493. * @param axis the axis to translate in
  14494. * @param distance the distance to translate
  14495. * @param space Space to rotate in (Default: local)
  14496. * @returns the TransformNode.
  14497. */
  14498. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14499. /**
  14500. * Adds a rotation step to the mesh current rotation.
  14501. * x, y, z are Euler angles expressed in radians.
  14502. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14503. * This means this rotation is made in the mesh local space only.
  14504. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14505. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14506. * ```javascript
  14507. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14508. * ```
  14509. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14510. * 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.
  14511. * @param x Rotation to add
  14512. * @param y Rotation to add
  14513. * @param z Rotation to add
  14514. * @returns the TransformNode.
  14515. */
  14516. addRotation(x: number, y: number, z: number): TransformNode;
  14517. /**
  14518. * @hidden
  14519. */
  14520. protected _getEffectiveParent(): Nullable<Node>;
  14521. /**
  14522. * Computes the world matrix of the node
  14523. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14524. * @returns the world matrix
  14525. */
  14526. computeWorldMatrix(force?: boolean): Matrix;
  14527. protected _afterComputeWorldMatrix(): void;
  14528. /**
  14529. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14530. * @param func callback function to add
  14531. *
  14532. * @returns the TransformNode.
  14533. */
  14534. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14535. /**
  14536. * Removes a registered callback function.
  14537. * @param func callback function to remove
  14538. * @returns the TransformNode.
  14539. */
  14540. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14541. /**
  14542. * Gets the position of the current mesh in camera space
  14543. * @param camera defines the camera to use
  14544. * @returns a position
  14545. */
  14546. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14547. /**
  14548. * Returns the distance from the mesh to the active camera
  14549. * @param camera defines the camera to use
  14550. * @returns the distance
  14551. */
  14552. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14553. /**
  14554. * Clone the current transform node
  14555. * @param name Name of the new clone
  14556. * @param newParent New parent for the clone
  14557. * @param doNotCloneChildren Do not clone children hierarchy
  14558. * @returns the new transform node
  14559. */
  14560. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14561. /**
  14562. * Serializes the objects information.
  14563. * @param currentSerializationObject defines the object to serialize in
  14564. * @returns the serialized object
  14565. */
  14566. serialize(currentSerializationObject?: any): any;
  14567. /**
  14568. * Returns a new TransformNode object parsed from the source provided.
  14569. * @param parsedTransformNode is the source.
  14570. * @param scene the scne the object belongs to
  14571. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14572. * @returns a new TransformNode object parsed from the source provided.
  14573. */
  14574. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14575. /**
  14576. * Get all child-transformNodes of this node
  14577. * @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
  14578. * @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
  14579. * @returns an array of TransformNode
  14580. */
  14581. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14582. /**
  14583. * Releases resources associated with this transform node.
  14584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14586. */
  14587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14588. /**
  14589. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14590. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14591. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14592. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14593. * @returns the current mesh
  14594. */
  14595. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14596. private _syncAbsoluteScalingAndRotation;
  14597. }
  14598. }
  14599. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14600. import { Observable } from "babylonjs/Misc/observable";
  14601. import { Nullable } from "babylonjs/types";
  14602. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14603. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14605. import { Ray } from "babylonjs/Culling/ray";
  14606. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14607. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14608. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14609. /**
  14610. * Defines the types of pose enabled controllers that are supported
  14611. */
  14612. export enum PoseEnabledControllerType {
  14613. /**
  14614. * HTC Vive
  14615. */
  14616. VIVE = 0,
  14617. /**
  14618. * Oculus Rift
  14619. */
  14620. OCULUS = 1,
  14621. /**
  14622. * Windows mixed reality
  14623. */
  14624. WINDOWS = 2,
  14625. /**
  14626. * Samsung gear VR
  14627. */
  14628. GEAR_VR = 3,
  14629. /**
  14630. * Google Daydream
  14631. */
  14632. DAYDREAM = 4,
  14633. /**
  14634. * Generic
  14635. */
  14636. GENERIC = 5
  14637. }
  14638. /**
  14639. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14640. */
  14641. export interface MutableGamepadButton {
  14642. /**
  14643. * Value of the button/trigger
  14644. */
  14645. value: number;
  14646. /**
  14647. * If the button/trigger is currently touched
  14648. */
  14649. touched: boolean;
  14650. /**
  14651. * If the button/trigger is currently pressed
  14652. */
  14653. pressed: boolean;
  14654. }
  14655. /**
  14656. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14657. * @hidden
  14658. */
  14659. export interface ExtendedGamepadButton extends GamepadButton {
  14660. /**
  14661. * If the button/trigger is currently pressed
  14662. */
  14663. readonly pressed: boolean;
  14664. /**
  14665. * If the button/trigger is currently touched
  14666. */
  14667. readonly touched: boolean;
  14668. /**
  14669. * Value of the button/trigger
  14670. */
  14671. readonly value: number;
  14672. }
  14673. /** @hidden */
  14674. export interface _GamePadFactory {
  14675. /**
  14676. * Returns wether or not the current gamepad can be created for this type of controller.
  14677. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14678. * @returns true if it can be created, otherwise false
  14679. */
  14680. canCreate(gamepadInfo: any): boolean;
  14681. /**
  14682. * Creates a new instance of the Gamepad.
  14683. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14684. * @returns the new gamepad instance
  14685. */
  14686. create(gamepadInfo: any): Gamepad;
  14687. }
  14688. /**
  14689. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14690. */
  14691. export class PoseEnabledControllerHelper {
  14692. /** @hidden */
  14693. static _ControllerFactories: _GamePadFactory[];
  14694. /** @hidden */
  14695. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14696. /**
  14697. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14698. * @param vrGamepad the gamepad to initialized
  14699. * @returns a vr controller of the type the gamepad identified as
  14700. */
  14701. static InitiateController(vrGamepad: any): Gamepad;
  14702. }
  14703. /**
  14704. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14705. */
  14706. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14707. /**
  14708. * If the controller is used in a webXR session
  14709. */
  14710. isXR: boolean;
  14711. private _deviceRoomPosition;
  14712. private _deviceRoomRotationQuaternion;
  14713. /**
  14714. * The device position in babylon space
  14715. */
  14716. devicePosition: Vector3;
  14717. /**
  14718. * The device rotation in babylon space
  14719. */
  14720. deviceRotationQuaternion: Quaternion;
  14721. /**
  14722. * The scale factor of the device in babylon space
  14723. */
  14724. deviceScaleFactor: number;
  14725. /**
  14726. * (Likely devicePosition should be used instead) The device position in its room space
  14727. */
  14728. position: Vector3;
  14729. /**
  14730. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14731. */
  14732. rotationQuaternion: Quaternion;
  14733. /**
  14734. * The type of controller (Eg. Windows mixed reality)
  14735. */
  14736. controllerType: PoseEnabledControllerType;
  14737. protected _calculatedPosition: Vector3;
  14738. private _calculatedRotation;
  14739. /**
  14740. * The raw pose from the device
  14741. */
  14742. rawPose: DevicePose;
  14743. private _trackPosition;
  14744. private _maxRotationDistFromHeadset;
  14745. private _draggedRoomRotation;
  14746. /**
  14747. * @hidden
  14748. */
  14749. _disableTrackPosition(fixedPosition: Vector3): void;
  14750. /**
  14751. * Internal, the mesh attached to the controller
  14752. * @hidden
  14753. */
  14754. _mesh: Nullable<AbstractMesh>;
  14755. private _poseControlledCamera;
  14756. private _leftHandSystemQuaternion;
  14757. /**
  14758. * Internal, matrix used to convert room space to babylon space
  14759. * @hidden
  14760. */
  14761. _deviceToWorld: Matrix;
  14762. /**
  14763. * Node to be used when casting a ray from the controller
  14764. * @hidden
  14765. */
  14766. _pointingPoseNode: Nullable<TransformNode>;
  14767. /**
  14768. * Name of the child mesh that can be used to cast a ray from the controller
  14769. */
  14770. static readonly POINTING_POSE: string;
  14771. /**
  14772. * Creates a new PoseEnabledController from a gamepad
  14773. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14774. */
  14775. constructor(browserGamepad: any);
  14776. private _workingMatrix;
  14777. /**
  14778. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14779. */
  14780. update(): void;
  14781. /**
  14782. * Updates only the pose device and mesh without doing any button event checking
  14783. */
  14784. protected _updatePoseAndMesh(): void;
  14785. /**
  14786. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14787. * @param poseData raw pose fromthe device
  14788. */
  14789. updateFromDevice(poseData: DevicePose): void;
  14790. /**
  14791. * @hidden
  14792. */
  14793. _meshAttachedObservable: Observable<AbstractMesh>;
  14794. /**
  14795. * Attaches a mesh to the controller
  14796. * @param mesh the mesh to be attached
  14797. */
  14798. attachToMesh(mesh: AbstractMesh): void;
  14799. /**
  14800. * Attaches the controllers mesh to a camera
  14801. * @param camera the camera the mesh should be attached to
  14802. */
  14803. attachToPoseControlledCamera(camera: TargetCamera): void;
  14804. /**
  14805. * Disposes of the controller
  14806. */
  14807. dispose(): void;
  14808. /**
  14809. * The mesh that is attached to the controller
  14810. */
  14811. readonly mesh: Nullable<AbstractMesh>;
  14812. /**
  14813. * Gets the ray of the controller in the direction the controller is pointing
  14814. * @param length the length the resulting ray should be
  14815. * @returns a ray in the direction the controller is pointing
  14816. */
  14817. getForwardRay(length?: number): Ray;
  14818. }
  14819. }
  14820. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14821. import { Observable } from "babylonjs/Misc/observable";
  14822. import { Scene } from "babylonjs/scene";
  14823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14824. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14825. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14826. import { Nullable } from "babylonjs/types";
  14827. /**
  14828. * Defines the WebVRController object that represents controllers tracked in 3D space
  14829. */
  14830. export abstract class WebVRController extends PoseEnabledController {
  14831. /**
  14832. * Internal, the default controller model for the controller
  14833. */
  14834. protected _defaultModel: Nullable<AbstractMesh>;
  14835. /**
  14836. * Fired when the trigger state has changed
  14837. */
  14838. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14839. /**
  14840. * Fired when the main button state has changed
  14841. */
  14842. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14843. /**
  14844. * Fired when the secondary button state has changed
  14845. */
  14846. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14847. /**
  14848. * Fired when the pad state has changed
  14849. */
  14850. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14851. /**
  14852. * Fired when controllers stick values have changed
  14853. */
  14854. onPadValuesChangedObservable: Observable<StickValues>;
  14855. /**
  14856. * Array of button availible on the controller
  14857. */
  14858. protected _buttons: Array<MutableGamepadButton>;
  14859. private _onButtonStateChange;
  14860. /**
  14861. * Fired when a controller button's state has changed
  14862. * @param callback the callback containing the button that was modified
  14863. */
  14864. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14865. /**
  14866. * X and Y axis corresponding to the controllers joystick
  14867. */
  14868. pad: StickValues;
  14869. /**
  14870. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14871. */
  14872. hand: string;
  14873. /**
  14874. * The default controller model for the controller
  14875. */
  14876. readonly defaultModel: Nullable<AbstractMesh>;
  14877. /**
  14878. * Creates a new WebVRController from a gamepad
  14879. * @param vrGamepad the gamepad that the WebVRController should be created from
  14880. */
  14881. constructor(vrGamepad: any);
  14882. /**
  14883. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14884. */
  14885. update(): void;
  14886. /**
  14887. * Function to be called when a button is modified
  14888. */
  14889. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14890. /**
  14891. * Loads a mesh and attaches it to the controller
  14892. * @param scene the scene the mesh should be added to
  14893. * @param meshLoaded callback for when the mesh has been loaded
  14894. */
  14895. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14896. private _setButtonValue;
  14897. private _changes;
  14898. private _checkChanges;
  14899. /**
  14900. * Disposes of th webVRCOntroller
  14901. */
  14902. dispose(): void;
  14903. }
  14904. }
  14905. declare module "babylonjs/Lights/hemisphericLight" {
  14906. import { Nullable } from "babylonjs/types";
  14907. import { Scene } from "babylonjs/scene";
  14908. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14909. import { Color3 } from "babylonjs/Maths/math.color";
  14910. import { Effect } from "babylonjs/Materials/effect";
  14911. import { Light } from "babylonjs/Lights/light";
  14912. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14913. /**
  14914. * The HemisphericLight simulates the ambient environment light,
  14915. * so the passed direction is the light reflection direction, not the incoming direction.
  14916. */
  14917. export class HemisphericLight extends Light {
  14918. /**
  14919. * The groundColor is the light in the opposite direction to the one specified during creation.
  14920. * 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.
  14921. */
  14922. groundColor: Color3;
  14923. /**
  14924. * The light reflection direction, not the incoming direction.
  14925. */
  14926. direction: Vector3;
  14927. /**
  14928. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14929. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14930. * The HemisphericLight can't cast shadows.
  14931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14932. * @param name The friendly name of the light
  14933. * @param direction The direction of the light reflection
  14934. * @param scene The scene the light belongs to
  14935. */
  14936. constructor(name: string, direction: Vector3, scene: Scene);
  14937. protected _buildUniformLayout(): void;
  14938. /**
  14939. * Returns the string "HemisphericLight".
  14940. * @return The class name
  14941. */
  14942. getClassName(): string;
  14943. /**
  14944. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14945. * Returns the updated direction.
  14946. * @param target The target the direction should point to
  14947. * @return The computed direction
  14948. */
  14949. setDirectionToTarget(target: Vector3): Vector3;
  14950. /**
  14951. * Returns the shadow generator associated to the light.
  14952. * @returns Always null for hemispheric lights because it does not support shadows.
  14953. */
  14954. getShadowGenerator(): Nullable<IShadowGenerator>;
  14955. /**
  14956. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14957. * @param effect The effect to update
  14958. * @param lightIndex The index of the light in the effect to update
  14959. * @returns The hemispheric light
  14960. */
  14961. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14962. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14963. /**
  14964. * Computes the world matrix of the node
  14965. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14966. * @param useWasUpdatedFlag defines a reserved property
  14967. * @returns the world matrix
  14968. */
  14969. computeWorldMatrix(): Matrix;
  14970. /**
  14971. * Returns the integer 3.
  14972. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14973. */
  14974. getTypeID(): number;
  14975. /**
  14976. * Prepares the list of defines specific to the light type.
  14977. * @param defines the list of defines
  14978. * @param lightIndex defines the index of the light for the effect
  14979. */
  14980. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14981. }
  14982. }
  14983. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14984. /** @hidden */
  14985. export var vrMultiviewToSingleviewPixelShader: {
  14986. name: string;
  14987. shader: string;
  14988. };
  14989. }
  14990. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14992. import { Scene } from "babylonjs/scene";
  14993. /**
  14994. * Renders to multiple views with a single draw call
  14995. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14996. */
  14997. export class MultiviewRenderTarget extends RenderTargetTexture {
  14998. /**
  14999. * Creates a multiview render target
  15000. * @param scene scene used with the render target
  15001. * @param size the size of the render target (used for each view)
  15002. */
  15003. constructor(scene: Scene, size?: number | {
  15004. width: number;
  15005. height: number;
  15006. } | {
  15007. ratio: number;
  15008. });
  15009. /**
  15010. * @hidden
  15011. * @param faceIndex the face index, if its a cube texture
  15012. */
  15013. _bindFrameBuffer(faceIndex?: number): void;
  15014. /**
  15015. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15016. * @returns the view count
  15017. */
  15018. getViewCount(): number;
  15019. }
  15020. }
  15021. declare module "babylonjs/Maths/math.frustum" {
  15022. import { Matrix } from "babylonjs/Maths/math.vector";
  15023. import { DeepImmutable } from "babylonjs/types";
  15024. import { Plane } from "babylonjs/Maths/math.plane";
  15025. /**
  15026. * Represents a camera frustum
  15027. */
  15028. export class Frustum {
  15029. /**
  15030. * Gets the planes representing the frustum
  15031. * @param transform matrix to be applied to the returned planes
  15032. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15033. */
  15034. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15035. /**
  15036. * Gets the near frustum plane transformed by the transform matrix
  15037. * @param transform transformation matrix to be applied to the resulting frustum plane
  15038. * @param frustumPlane the resuling frustum plane
  15039. */
  15040. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15041. /**
  15042. * Gets the far frustum plane transformed by the transform matrix
  15043. * @param transform transformation matrix to be applied to the resulting frustum plane
  15044. * @param frustumPlane the resuling frustum plane
  15045. */
  15046. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15047. /**
  15048. * Gets the left frustum plane transformed by the transform matrix
  15049. * @param transform transformation matrix to be applied to the resulting frustum plane
  15050. * @param frustumPlane the resuling frustum plane
  15051. */
  15052. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15053. /**
  15054. * Gets the right frustum plane transformed by the transform matrix
  15055. * @param transform transformation matrix to be applied to the resulting frustum plane
  15056. * @param frustumPlane the resuling frustum plane
  15057. */
  15058. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15059. /**
  15060. * Gets the top frustum plane transformed by the transform matrix
  15061. * @param transform transformation matrix to be applied to the resulting frustum plane
  15062. * @param frustumPlane the resuling frustum plane
  15063. */
  15064. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15065. /**
  15066. * Gets the bottom frustum plane transformed by the transform matrix
  15067. * @param transform transformation matrix to be applied to the resulting frustum plane
  15068. * @param frustumPlane the resuling frustum plane
  15069. */
  15070. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15071. /**
  15072. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15073. * @param transform transformation matrix to be applied to the resulting frustum planes
  15074. * @param frustumPlanes the resuling frustum planes
  15075. */
  15076. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15077. }
  15078. }
  15079. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15080. import { Camera } from "babylonjs/Cameras/camera";
  15081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15082. import { Nullable } from "babylonjs/types";
  15083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15084. import { Matrix } from "babylonjs/Maths/math.vector";
  15085. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15086. module "babylonjs/Engines/engine" {
  15087. interface Engine {
  15088. /**
  15089. * Creates a new multiview render target
  15090. * @param width defines the width of the texture
  15091. * @param height defines the height of the texture
  15092. * @returns the created multiview texture
  15093. */
  15094. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15095. /**
  15096. * Binds a multiview framebuffer to be drawn to
  15097. * @param multiviewTexture texture to bind
  15098. */
  15099. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15100. }
  15101. }
  15102. module "babylonjs/Cameras/camera" {
  15103. interface Camera {
  15104. /**
  15105. * @hidden
  15106. * 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)
  15107. */
  15108. _useMultiviewToSingleView: boolean;
  15109. /**
  15110. * @hidden
  15111. * 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)
  15112. */
  15113. _multiviewTexture: Nullable<RenderTargetTexture>;
  15114. /**
  15115. * @hidden
  15116. * ensures the multiview texture of the camera exists and has the specified width/height
  15117. * @param width height to set on the multiview texture
  15118. * @param height width to set on the multiview texture
  15119. */
  15120. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15121. }
  15122. }
  15123. module "babylonjs/scene" {
  15124. interface Scene {
  15125. /** @hidden */
  15126. _transformMatrixR: Matrix;
  15127. /** @hidden */
  15128. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15129. /** @hidden */
  15130. _createMultiviewUbo(): void;
  15131. /** @hidden */
  15132. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15133. /** @hidden */
  15134. _renderMultiviewToSingleView(camera: Camera): void;
  15135. }
  15136. }
  15137. }
  15138. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15139. import { Camera } from "babylonjs/Cameras/camera";
  15140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15141. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15142. import "babylonjs/Engines/Extensions/engine.multiview";
  15143. /**
  15144. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15145. * This will not be used for webXR as it supports displaying texture arrays directly
  15146. */
  15147. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15148. /**
  15149. * Initializes a VRMultiviewToSingleview
  15150. * @param name name of the post process
  15151. * @param camera camera to be applied to
  15152. * @param scaleFactor scaling factor to the size of the output texture
  15153. */
  15154. constructor(name: string, camera: Camera, scaleFactor: number);
  15155. }
  15156. }
  15157. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15158. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15159. import { Nullable } from "babylonjs/types";
  15160. import { Size } from "babylonjs/Maths/math.size";
  15161. import { Observable } from "babylonjs/Misc/observable";
  15162. /**
  15163. * Interface used to define additional presentation attributes
  15164. */
  15165. export interface IVRPresentationAttributes {
  15166. /**
  15167. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15168. */
  15169. highRefreshRate: boolean;
  15170. /**
  15171. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15172. */
  15173. foveationLevel: number;
  15174. }
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /** @hidden */
  15178. _vrDisplay: any;
  15179. /** @hidden */
  15180. _vrSupported: boolean;
  15181. /** @hidden */
  15182. _oldSize: Size;
  15183. /** @hidden */
  15184. _oldHardwareScaleFactor: number;
  15185. /** @hidden */
  15186. _vrExclusivePointerMode: boolean;
  15187. /** @hidden */
  15188. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15189. /** @hidden */
  15190. _onVRDisplayPointerRestricted: () => void;
  15191. /** @hidden */
  15192. _onVRDisplayPointerUnrestricted: () => void;
  15193. /** @hidden */
  15194. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15195. /** @hidden */
  15196. _onVrDisplayDisconnect: Nullable<() => void>;
  15197. /** @hidden */
  15198. _onVrDisplayPresentChange: Nullable<() => void>;
  15199. /**
  15200. * Observable signaled when VR display mode changes
  15201. */
  15202. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15203. /**
  15204. * Observable signaled when VR request present is complete
  15205. */
  15206. onVRRequestPresentComplete: Observable<boolean>;
  15207. /**
  15208. * Observable signaled when VR request present starts
  15209. */
  15210. onVRRequestPresentStart: Observable<Engine>;
  15211. /**
  15212. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15213. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15214. */
  15215. isInVRExclusivePointerMode: boolean;
  15216. /**
  15217. * Gets a boolean indicating if a webVR device was detected
  15218. * @returns true if a webVR device was detected
  15219. */
  15220. isVRDevicePresent(): boolean;
  15221. /**
  15222. * Gets the current webVR device
  15223. * @returns the current webVR device (or null)
  15224. */
  15225. getVRDevice(): any;
  15226. /**
  15227. * Initializes a webVR display and starts listening to display change events
  15228. * The onVRDisplayChangedObservable will be notified upon these changes
  15229. * @returns A promise containing a VRDisplay and if vr is supported
  15230. */
  15231. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15232. /** @hidden */
  15233. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15234. /**
  15235. * Gets or sets the presentation attributes used to configure VR rendering
  15236. */
  15237. vrPresentationAttributes?: IVRPresentationAttributes;
  15238. /**
  15239. * Call this function to switch to webVR mode
  15240. * Will do nothing if webVR is not supported or if there is no webVR device
  15241. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15242. */
  15243. enableVR(): void;
  15244. /** @hidden */
  15245. _onVRFullScreenTriggered(): void;
  15246. }
  15247. }
  15248. }
  15249. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15250. import { Nullable } from "babylonjs/types";
  15251. import { Observable } from "babylonjs/Misc/observable";
  15252. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15253. import { Scene } from "babylonjs/scene";
  15254. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15255. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15256. import { Node } from "babylonjs/node";
  15257. import { Ray } from "babylonjs/Culling/ray";
  15258. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15259. import "babylonjs/Engines/Extensions/engine.webVR";
  15260. /**
  15261. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15262. * IMPORTANT!! The data is right-hand data.
  15263. * @export
  15264. * @interface DevicePose
  15265. */
  15266. export interface DevicePose {
  15267. /**
  15268. * The position of the device, values in array are [x,y,z].
  15269. */
  15270. readonly position: Nullable<Float32Array>;
  15271. /**
  15272. * The linearVelocity of the device, values in array are [x,y,z].
  15273. */
  15274. readonly linearVelocity: Nullable<Float32Array>;
  15275. /**
  15276. * The linearAcceleration of the device, values in array are [x,y,z].
  15277. */
  15278. readonly linearAcceleration: Nullable<Float32Array>;
  15279. /**
  15280. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15281. */
  15282. readonly orientation: Nullable<Float32Array>;
  15283. /**
  15284. * The angularVelocity of the device, values in array are [x,y,z].
  15285. */
  15286. readonly angularVelocity: Nullable<Float32Array>;
  15287. /**
  15288. * The angularAcceleration of the device, values in array are [x,y,z].
  15289. */
  15290. readonly angularAcceleration: Nullable<Float32Array>;
  15291. }
  15292. /**
  15293. * Interface representing a pose controlled object in Babylon.
  15294. * A pose controlled object has both regular pose values as well as pose values
  15295. * from an external device such as a VR head mounted display
  15296. */
  15297. export interface PoseControlled {
  15298. /**
  15299. * The position of the object in babylon space.
  15300. */
  15301. position: Vector3;
  15302. /**
  15303. * The rotation quaternion of the object in babylon space.
  15304. */
  15305. rotationQuaternion: Quaternion;
  15306. /**
  15307. * The position of the device in babylon space.
  15308. */
  15309. devicePosition?: Vector3;
  15310. /**
  15311. * The rotation quaternion of the device in babylon space.
  15312. */
  15313. deviceRotationQuaternion: Quaternion;
  15314. /**
  15315. * The raw pose coming from the device.
  15316. */
  15317. rawPose: Nullable<DevicePose>;
  15318. /**
  15319. * The scale of the device to be used when translating from device space to babylon space.
  15320. */
  15321. deviceScaleFactor: number;
  15322. /**
  15323. * Updates the poseControlled values based on the input device pose.
  15324. * @param poseData the pose data to update the object with
  15325. */
  15326. updateFromDevice(poseData: DevicePose): void;
  15327. }
  15328. /**
  15329. * Set of options to customize the webVRCamera
  15330. */
  15331. export interface WebVROptions {
  15332. /**
  15333. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15334. */
  15335. trackPosition?: boolean;
  15336. /**
  15337. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15338. */
  15339. positionScale?: number;
  15340. /**
  15341. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15342. */
  15343. displayName?: string;
  15344. /**
  15345. * Should the native controller meshes be initialized. (default: true)
  15346. */
  15347. controllerMeshes?: boolean;
  15348. /**
  15349. * Creating a default HemiLight only on controllers. (default: true)
  15350. */
  15351. defaultLightingOnControllers?: boolean;
  15352. /**
  15353. * If you don't want to use the default VR button of the helper. (default: false)
  15354. */
  15355. useCustomVRButton?: boolean;
  15356. /**
  15357. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15358. */
  15359. customVRButton?: HTMLButtonElement;
  15360. /**
  15361. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15362. */
  15363. rayLength?: number;
  15364. /**
  15365. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15366. */
  15367. defaultHeight?: number;
  15368. /**
  15369. * If multiview should be used if availible (default: false)
  15370. */
  15371. useMultiview?: boolean;
  15372. }
  15373. /**
  15374. * This represents a WebVR camera.
  15375. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15376. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15377. */
  15378. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15379. private webVROptions;
  15380. /**
  15381. * @hidden
  15382. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15383. */
  15384. _vrDevice: any;
  15385. /**
  15386. * The rawPose of the vrDevice.
  15387. */
  15388. rawPose: Nullable<DevicePose>;
  15389. private _onVREnabled;
  15390. private _specsVersion;
  15391. private _attached;
  15392. private _frameData;
  15393. protected _descendants: Array<Node>;
  15394. private _deviceRoomPosition;
  15395. /** @hidden */
  15396. _deviceRoomRotationQuaternion: Quaternion;
  15397. private _standingMatrix;
  15398. /**
  15399. * Represents device position in babylon space.
  15400. */
  15401. devicePosition: Vector3;
  15402. /**
  15403. * Represents device rotation in babylon space.
  15404. */
  15405. deviceRotationQuaternion: Quaternion;
  15406. /**
  15407. * The scale of the device to be used when translating from device space to babylon space.
  15408. */
  15409. deviceScaleFactor: number;
  15410. private _deviceToWorld;
  15411. private _worldToDevice;
  15412. /**
  15413. * References to the webVR controllers for the vrDevice.
  15414. */
  15415. controllers: Array<WebVRController>;
  15416. /**
  15417. * Emits an event when a controller is attached.
  15418. */
  15419. onControllersAttachedObservable: Observable<WebVRController[]>;
  15420. /**
  15421. * Emits an event when a controller's mesh has been loaded;
  15422. */
  15423. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15424. /**
  15425. * Emits an event when the HMD's pose has been updated.
  15426. */
  15427. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15428. private _poseSet;
  15429. /**
  15430. * If the rig cameras be used as parent instead of this camera.
  15431. */
  15432. rigParenting: boolean;
  15433. private _lightOnControllers;
  15434. private _defaultHeight?;
  15435. /**
  15436. * Instantiates a WebVRFreeCamera.
  15437. * @param name The name of the WebVRFreeCamera
  15438. * @param position The starting anchor position for the camera
  15439. * @param scene The scene the camera belongs to
  15440. * @param webVROptions a set of customizable options for the webVRCamera
  15441. */
  15442. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15443. /**
  15444. * Gets the device distance from the ground in meters.
  15445. * @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.
  15446. */
  15447. deviceDistanceToRoomGround(): number;
  15448. /**
  15449. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15450. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15451. */
  15452. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15453. /**
  15454. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15455. * @returns A promise with a boolean set to if the standing matrix is supported.
  15456. */
  15457. useStandingMatrixAsync(): Promise<boolean>;
  15458. /**
  15459. * Disposes the camera
  15460. */
  15461. dispose(): void;
  15462. /**
  15463. * Gets a vrController by name.
  15464. * @param name The name of the controller to retreive
  15465. * @returns the controller matching the name specified or null if not found
  15466. */
  15467. getControllerByName(name: string): Nullable<WebVRController>;
  15468. private _leftController;
  15469. /**
  15470. * The controller corresponding to the users left hand.
  15471. */
  15472. readonly leftController: Nullable<WebVRController>;
  15473. private _rightController;
  15474. /**
  15475. * The controller corresponding to the users right hand.
  15476. */
  15477. readonly rightController: Nullable<WebVRController>;
  15478. /**
  15479. * Casts a ray forward from the vrCamera's gaze.
  15480. * @param length Length of the ray (default: 100)
  15481. * @returns the ray corresponding to the gaze
  15482. */
  15483. getForwardRay(length?: number): Ray;
  15484. /**
  15485. * @hidden
  15486. * Updates the camera based on device's frame data
  15487. */
  15488. _checkInputs(): void;
  15489. /**
  15490. * Updates the poseControlled values based on the input device pose.
  15491. * @param poseData Pose coming from the device
  15492. */
  15493. updateFromDevice(poseData: DevicePose): void;
  15494. private _htmlElementAttached;
  15495. private _detachIfAttached;
  15496. /**
  15497. * WebVR's attach control will start broadcasting frames to the device.
  15498. * Note that in certain browsers (chrome for example) this function must be called
  15499. * within a user-interaction callback. Example:
  15500. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15501. *
  15502. * @param element html element to attach the vrDevice to
  15503. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15504. */
  15505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15506. /**
  15507. * Detaches the camera from the html element and disables VR
  15508. *
  15509. * @param element html element to detach from
  15510. */
  15511. detachControl(element: HTMLElement): void;
  15512. /**
  15513. * @returns the name of this class
  15514. */
  15515. getClassName(): string;
  15516. /**
  15517. * Calls resetPose on the vrDisplay
  15518. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15519. */
  15520. resetToCurrentRotation(): void;
  15521. /**
  15522. * @hidden
  15523. * Updates the rig cameras (left and right eye)
  15524. */
  15525. _updateRigCameras(): void;
  15526. private _workingVector;
  15527. private _oneVector;
  15528. private _workingMatrix;
  15529. private updateCacheCalled;
  15530. private _correctPositionIfNotTrackPosition;
  15531. /**
  15532. * @hidden
  15533. * Updates the cached values of the camera
  15534. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15535. */
  15536. _updateCache(ignoreParentClass?: boolean): void;
  15537. /**
  15538. * @hidden
  15539. * Get current device position in babylon world
  15540. */
  15541. _computeDevicePosition(): void;
  15542. /**
  15543. * Updates the current device position and rotation in the babylon world
  15544. */
  15545. update(): void;
  15546. /**
  15547. * @hidden
  15548. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15549. * @returns an identity matrix
  15550. */
  15551. _getViewMatrix(): Matrix;
  15552. private _tmpMatrix;
  15553. /**
  15554. * This function is called by the two RIG cameras.
  15555. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15556. * @hidden
  15557. */
  15558. _getWebVRViewMatrix(): Matrix;
  15559. /** @hidden */
  15560. _getWebVRProjectionMatrix(): Matrix;
  15561. private _onGamepadConnectedObserver;
  15562. private _onGamepadDisconnectedObserver;
  15563. private _updateCacheWhenTrackingDisabledObserver;
  15564. /**
  15565. * Initializes the controllers and their meshes
  15566. */
  15567. initControllers(): void;
  15568. }
  15569. }
  15570. declare module "babylonjs/PostProcesses/postProcess" {
  15571. import { Nullable } from "babylonjs/types";
  15572. import { SmartArray } from "babylonjs/Misc/smartArray";
  15573. import { Observable } from "babylonjs/Misc/observable";
  15574. import { Vector2 } from "babylonjs/Maths/math.vector";
  15575. import { Camera } from "babylonjs/Cameras/camera";
  15576. import { Effect } from "babylonjs/Materials/effect";
  15577. import "babylonjs/Shaders/postprocess.vertex";
  15578. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15579. import { Engine } from "babylonjs/Engines/engine";
  15580. import { Color4 } from "babylonjs/Maths/math.color";
  15581. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15583. /**
  15584. * Size options for a post process
  15585. */
  15586. export type PostProcessOptions = {
  15587. width: number;
  15588. height: number;
  15589. };
  15590. /**
  15591. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15592. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15593. */
  15594. export class PostProcess {
  15595. /** Name of the PostProcess. */
  15596. name: string;
  15597. /**
  15598. * Gets or sets the unique id of the post process
  15599. */
  15600. uniqueId: number;
  15601. /**
  15602. * Width of the texture to apply the post process on
  15603. */
  15604. width: number;
  15605. /**
  15606. * Height of the texture to apply the post process on
  15607. */
  15608. height: number;
  15609. /**
  15610. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15611. * @hidden
  15612. */
  15613. _outputTexture: Nullable<InternalTexture>;
  15614. /**
  15615. * Sampling mode used by the shader
  15616. * See https://doc.babylonjs.com/classes/3.1/texture
  15617. */
  15618. renderTargetSamplingMode: number;
  15619. /**
  15620. * Clear color to use when screen clearing
  15621. */
  15622. clearColor: Color4;
  15623. /**
  15624. * If the buffer needs to be cleared before applying the post process. (default: true)
  15625. * Should be set to false if shader will overwrite all previous pixels.
  15626. */
  15627. autoClear: boolean;
  15628. /**
  15629. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15630. */
  15631. alphaMode: number;
  15632. /**
  15633. * Sets the setAlphaBlendConstants of the babylon engine
  15634. */
  15635. alphaConstants: Color4;
  15636. /**
  15637. * Animations to be used for the post processing
  15638. */
  15639. animations: import("babylonjs/Animations/animation").Animation[];
  15640. /**
  15641. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15642. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15643. */
  15644. enablePixelPerfectMode: boolean;
  15645. /**
  15646. * Force the postprocess to be applied without taking in account viewport
  15647. */
  15648. forceFullscreenViewport: boolean;
  15649. /**
  15650. * List of inspectable custom properties (used by the Inspector)
  15651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15652. */
  15653. inspectableCustomProperties: IInspectable[];
  15654. /**
  15655. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15656. *
  15657. * | Value | Type | Description |
  15658. * | ----- | ----------------------------------- | ----------- |
  15659. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15660. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15661. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15662. *
  15663. */
  15664. scaleMode: number;
  15665. /**
  15666. * Force textures to be a power of two (default: false)
  15667. */
  15668. alwaysForcePOT: boolean;
  15669. private _samples;
  15670. /**
  15671. * Number of sample textures (default: 1)
  15672. */
  15673. samples: number;
  15674. /**
  15675. * Modify the scale of the post process to be the same as the viewport (default: false)
  15676. */
  15677. adaptScaleToCurrentViewport: boolean;
  15678. private _camera;
  15679. private _scene;
  15680. private _engine;
  15681. private _options;
  15682. private _reusable;
  15683. private _textureType;
  15684. /**
  15685. * Smart array of input and output textures for the post process.
  15686. * @hidden
  15687. */
  15688. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15689. /**
  15690. * The index in _textures that corresponds to the output texture.
  15691. * @hidden
  15692. */
  15693. _currentRenderTextureInd: number;
  15694. private _effect;
  15695. private _samplers;
  15696. private _fragmentUrl;
  15697. private _vertexUrl;
  15698. private _parameters;
  15699. private _scaleRatio;
  15700. protected _indexParameters: any;
  15701. private _shareOutputWithPostProcess;
  15702. private _texelSize;
  15703. private _forcedOutputTexture;
  15704. /**
  15705. * Returns the fragment url or shader name used in the post process.
  15706. * @returns the fragment url or name in the shader store.
  15707. */
  15708. getEffectName(): string;
  15709. /**
  15710. * An event triggered when the postprocess is activated.
  15711. */
  15712. onActivateObservable: Observable<Camera>;
  15713. private _onActivateObserver;
  15714. /**
  15715. * A function that is added to the onActivateObservable
  15716. */
  15717. onActivate: Nullable<(camera: Camera) => void>;
  15718. /**
  15719. * An event triggered when the postprocess changes its size.
  15720. */
  15721. onSizeChangedObservable: Observable<PostProcess>;
  15722. private _onSizeChangedObserver;
  15723. /**
  15724. * A function that is added to the onSizeChangedObservable
  15725. */
  15726. onSizeChanged: (postProcess: PostProcess) => void;
  15727. /**
  15728. * An event triggered when the postprocess applies its effect.
  15729. */
  15730. onApplyObservable: Observable<Effect>;
  15731. private _onApplyObserver;
  15732. /**
  15733. * A function that is added to the onApplyObservable
  15734. */
  15735. onApply: (effect: Effect) => void;
  15736. /**
  15737. * An event triggered before rendering the postprocess
  15738. */
  15739. onBeforeRenderObservable: Observable<Effect>;
  15740. private _onBeforeRenderObserver;
  15741. /**
  15742. * A function that is added to the onBeforeRenderObservable
  15743. */
  15744. onBeforeRender: (effect: Effect) => void;
  15745. /**
  15746. * An event triggered after rendering the postprocess
  15747. */
  15748. onAfterRenderObservable: Observable<Effect>;
  15749. private _onAfterRenderObserver;
  15750. /**
  15751. * A function that is added to the onAfterRenderObservable
  15752. */
  15753. onAfterRender: (efect: Effect) => void;
  15754. /**
  15755. * 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
  15756. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15757. */
  15758. inputTexture: InternalTexture;
  15759. /**
  15760. * Gets the camera which post process is applied to.
  15761. * @returns The camera the post process is applied to.
  15762. */
  15763. getCamera(): Camera;
  15764. /**
  15765. * Gets the texel size of the postprocess.
  15766. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15767. */
  15768. readonly texelSize: Vector2;
  15769. /**
  15770. * Creates a new instance PostProcess
  15771. * @param name The name of the PostProcess.
  15772. * @param fragmentUrl The url of the fragment shader to be used.
  15773. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15774. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15775. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15776. * @param camera The camera to apply the render pass to.
  15777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15778. * @param engine The engine which the post process will be applied. (default: current engine)
  15779. * @param reusable If the post process can be reused on the same frame. (default: false)
  15780. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15781. * @param textureType Type of textures used when performing the post process. (default: 0)
  15782. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15783. * @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
  15784. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15785. */
  15786. constructor(
  15787. /** Name of the PostProcess. */
  15788. 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);
  15789. /**
  15790. * Gets a string idenfifying the name of the class
  15791. * @returns "PostProcess" string
  15792. */
  15793. getClassName(): string;
  15794. /**
  15795. * Gets the engine which this post process belongs to.
  15796. * @returns The engine the post process was enabled with.
  15797. */
  15798. getEngine(): Engine;
  15799. /**
  15800. * The effect that is created when initializing the post process.
  15801. * @returns The created effect corresponding the the postprocess.
  15802. */
  15803. getEffect(): Effect;
  15804. /**
  15805. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15806. * @param postProcess The post process to share the output with.
  15807. * @returns This post process.
  15808. */
  15809. shareOutputWith(postProcess: PostProcess): PostProcess;
  15810. /**
  15811. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15812. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15813. */
  15814. useOwnOutput(): void;
  15815. /**
  15816. * Updates the effect with the current post process compile time values and recompiles the shader.
  15817. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15818. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15819. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15820. * @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
  15821. * @param onCompiled Called when the shader has been compiled.
  15822. * @param onError Called if there is an error when compiling a shader.
  15823. */
  15824. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15825. /**
  15826. * The post process is reusable if it can be used multiple times within one frame.
  15827. * @returns If the post process is reusable
  15828. */
  15829. isReusable(): boolean;
  15830. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15831. markTextureDirty(): void;
  15832. /**
  15833. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15834. * 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.
  15835. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15836. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15837. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15838. * @returns The target texture that was bound to be written to.
  15839. */
  15840. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15841. /**
  15842. * If the post process is supported.
  15843. */
  15844. readonly isSupported: boolean;
  15845. /**
  15846. * The aspect ratio of the output texture.
  15847. */
  15848. readonly aspectRatio: number;
  15849. /**
  15850. * Get a value indicating if the post-process is ready to be used
  15851. * @returns true if the post-process is ready (shader is compiled)
  15852. */
  15853. isReady(): boolean;
  15854. /**
  15855. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15856. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15857. */
  15858. apply(): Nullable<Effect>;
  15859. private _disposeTextures;
  15860. /**
  15861. * Disposes the post process.
  15862. * @param camera The camera to dispose the post process on.
  15863. */
  15864. dispose(camera?: Camera): void;
  15865. }
  15866. }
  15867. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15868. /** @hidden */
  15869. export var kernelBlurVaryingDeclaration: {
  15870. name: string;
  15871. shader: string;
  15872. };
  15873. }
  15874. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15875. /** @hidden */
  15876. export var kernelBlurFragment: {
  15877. name: string;
  15878. shader: string;
  15879. };
  15880. }
  15881. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15882. /** @hidden */
  15883. export var kernelBlurFragment2: {
  15884. name: string;
  15885. shader: string;
  15886. };
  15887. }
  15888. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15889. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15890. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15891. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15892. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15893. /** @hidden */
  15894. export var kernelBlurPixelShader: {
  15895. name: string;
  15896. shader: string;
  15897. };
  15898. }
  15899. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15900. /** @hidden */
  15901. export var kernelBlurVertex: {
  15902. name: string;
  15903. shader: string;
  15904. };
  15905. }
  15906. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15907. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15908. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15909. /** @hidden */
  15910. export var kernelBlurVertexShader: {
  15911. name: string;
  15912. shader: string;
  15913. };
  15914. }
  15915. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15916. import { Vector2 } from "babylonjs/Maths/math.vector";
  15917. import { Nullable } from "babylonjs/types";
  15918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15919. import { Camera } from "babylonjs/Cameras/camera";
  15920. import { Effect } from "babylonjs/Materials/effect";
  15921. import { Engine } from "babylonjs/Engines/engine";
  15922. import "babylonjs/Shaders/kernelBlur.fragment";
  15923. import "babylonjs/Shaders/kernelBlur.vertex";
  15924. /**
  15925. * The Blur Post Process which blurs an image based on a kernel and direction.
  15926. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15927. */
  15928. export class BlurPostProcess extends PostProcess {
  15929. /** The direction in which to blur the image. */
  15930. direction: Vector2;
  15931. private blockCompilation;
  15932. protected _kernel: number;
  15933. protected _idealKernel: number;
  15934. protected _packedFloat: boolean;
  15935. private _staticDefines;
  15936. /**
  15937. * Sets the length in pixels of the blur sample region
  15938. */
  15939. /**
  15940. * Gets the length in pixels of the blur sample region
  15941. */
  15942. kernel: number;
  15943. /**
  15944. * Sets wether or not the blur needs to unpack/repack floats
  15945. */
  15946. /**
  15947. * Gets wether or not the blur is unpacking/repacking floats
  15948. */
  15949. packedFloat: boolean;
  15950. /**
  15951. * Creates a new instance BlurPostProcess
  15952. * @param name The name of the effect.
  15953. * @param direction The direction in which to blur the image.
  15954. * @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.
  15955. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15956. * @param camera The camera to apply the render pass to.
  15957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15958. * @param engine The engine which the post process will be applied. (default: current engine)
  15959. * @param reusable If the post process can be reused on the same frame. (default: false)
  15960. * @param textureType Type of textures used when performing the post process. (default: 0)
  15961. * @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)
  15962. */
  15963. constructor(name: string,
  15964. /** The direction in which to blur the image. */
  15965. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15966. /**
  15967. * Updates the effect with the current post process compile time values and recompiles the shader.
  15968. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15969. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15970. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15971. * @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
  15972. * @param onCompiled Called when the shader has been compiled.
  15973. * @param onError Called if there is an error when compiling a shader.
  15974. */
  15975. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15976. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15977. /**
  15978. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15979. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15980. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15981. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15982. * The gaps between physical kernels are compensated for in the weighting of the samples
  15983. * @param idealKernel Ideal blur kernel.
  15984. * @return Nearest best kernel.
  15985. */
  15986. protected _nearestBestKernel(idealKernel: number): number;
  15987. /**
  15988. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15989. * @param x The point on the Gaussian distribution to sample.
  15990. * @return the value of the Gaussian function at x.
  15991. */
  15992. protected _gaussianWeight(x: number): number;
  15993. /**
  15994. * Generates a string that can be used as a floating point number in GLSL.
  15995. * @param x Value to print.
  15996. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15997. * @return GLSL float string.
  15998. */
  15999. protected _glslFloat(x: number, decimalFigures?: number): string;
  16000. }
  16001. }
  16002. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16003. import { Scene } from "babylonjs/scene";
  16004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16005. import { Plane } from "babylonjs/Maths/math.plane";
  16006. /**
  16007. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16008. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16009. * You can then easily use it as a reflectionTexture on a flat surface.
  16010. * In case the surface is not a plane, please consider relying on reflection probes.
  16011. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16012. */
  16013. export class MirrorTexture extends RenderTargetTexture {
  16014. private scene;
  16015. /**
  16016. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16017. * 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.
  16018. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16019. */
  16020. mirrorPlane: Plane;
  16021. /**
  16022. * Define the blur ratio used to blur the reflection if needed.
  16023. */
  16024. blurRatio: number;
  16025. /**
  16026. * Define the adaptive blur kernel used to blur the reflection if needed.
  16027. * This will autocompute the closest best match for the `blurKernel`
  16028. */
  16029. adaptiveBlurKernel: number;
  16030. /**
  16031. * Define the blur kernel used to blur the reflection if needed.
  16032. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16033. */
  16034. blurKernel: number;
  16035. /**
  16036. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16037. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16038. */
  16039. blurKernelX: number;
  16040. /**
  16041. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16042. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16043. */
  16044. blurKernelY: number;
  16045. private _autoComputeBlurKernel;
  16046. protected _onRatioRescale(): void;
  16047. private _updateGammaSpace;
  16048. private _imageProcessingConfigChangeObserver;
  16049. private _transformMatrix;
  16050. private _mirrorMatrix;
  16051. private _savedViewMatrix;
  16052. private _blurX;
  16053. private _blurY;
  16054. private _adaptiveBlurKernel;
  16055. private _blurKernelX;
  16056. private _blurKernelY;
  16057. private _blurRatio;
  16058. /**
  16059. * Instantiates a Mirror Texture.
  16060. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16061. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16062. * You can then easily use it as a reflectionTexture on a flat surface.
  16063. * In case the surface is not a plane, please consider relying on reflection probes.
  16064. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16065. * @param name
  16066. * @param size
  16067. * @param scene
  16068. * @param generateMipMaps
  16069. * @param type
  16070. * @param samplingMode
  16071. * @param generateDepthBuffer
  16072. */
  16073. constructor(name: string, size: number | {
  16074. width: number;
  16075. height: number;
  16076. } | {
  16077. ratio: number;
  16078. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16079. private _preparePostProcesses;
  16080. /**
  16081. * Clone the mirror texture.
  16082. * @returns the cloned texture
  16083. */
  16084. clone(): MirrorTexture;
  16085. /**
  16086. * Serialize the texture to a JSON representation you could use in Parse later on
  16087. * @returns the serialized JSON representation
  16088. */
  16089. serialize(): any;
  16090. /**
  16091. * Dispose the texture and release its associated resources.
  16092. */
  16093. dispose(): void;
  16094. }
  16095. }
  16096. declare module "babylonjs/Materials/Textures/texture" {
  16097. import { Observable } from "babylonjs/Misc/observable";
  16098. import { Nullable } from "babylonjs/types";
  16099. import { Matrix } from "babylonjs/Maths/math.vector";
  16100. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16101. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16102. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16103. import { Scene } from "babylonjs/scene";
  16104. /**
  16105. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16106. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16107. */
  16108. export class Texture extends BaseTexture {
  16109. /**
  16110. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16111. */
  16112. static SerializeBuffers: boolean;
  16113. /** @hidden */
  16114. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16115. /** @hidden */
  16116. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16117. /** @hidden */
  16118. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16119. /** nearest is mag = nearest and min = nearest and mip = linear */
  16120. static readonly NEAREST_SAMPLINGMODE: number;
  16121. /** nearest is mag = nearest and min = nearest and mip = linear */
  16122. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16123. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16124. static readonly BILINEAR_SAMPLINGMODE: number;
  16125. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16126. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16127. /** Trilinear is mag = linear and min = linear and mip = linear */
  16128. static readonly TRILINEAR_SAMPLINGMODE: number;
  16129. /** Trilinear is mag = linear and min = linear and mip = linear */
  16130. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16131. /** mag = nearest and min = nearest and mip = nearest */
  16132. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16133. /** mag = nearest and min = linear and mip = nearest */
  16134. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16135. /** mag = nearest and min = linear and mip = linear */
  16136. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16137. /** mag = nearest and min = linear and mip = none */
  16138. static readonly NEAREST_LINEAR: number;
  16139. /** mag = nearest and min = nearest and mip = none */
  16140. static readonly NEAREST_NEAREST: number;
  16141. /** mag = linear and min = nearest and mip = nearest */
  16142. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16143. /** mag = linear and min = nearest and mip = linear */
  16144. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16145. /** mag = linear and min = linear and mip = none */
  16146. static readonly LINEAR_LINEAR: number;
  16147. /** mag = linear and min = nearest and mip = none */
  16148. static readonly LINEAR_NEAREST: number;
  16149. /** Explicit coordinates mode */
  16150. static readonly EXPLICIT_MODE: number;
  16151. /** Spherical coordinates mode */
  16152. static readonly SPHERICAL_MODE: number;
  16153. /** Planar coordinates mode */
  16154. static readonly PLANAR_MODE: number;
  16155. /** Cubic coordinates mode */
  16156. static readonly CUBIC_MODE: number;
  16157. /** Projection coordinates mode */
  16158. static readonly PROJECTION_MODE: number;
  16159. /** Inverse Cubic coordinates mode */
  16160. static readonly SKYBOX_MODE: number;
  16161. /** Inverse Cubic coordinates mode */
  16162. static readonly INVCUBIC_MODE: number;
  16163. /** Equirectangular coordinates mode */
  16164. static readonly EQUIRECTANGULAR_MODE: number;
  16165. /** Equirectangular Fixed coordinates mode */
  16166. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16167. /** Equirectangular Fixed Mirrored coordinates mode */
  16168. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16169. /** Texture is not repeating outside of 0..1 UVs */
  16170. static readonly CLAMP_ADDRESSMODE: number;
  16171. /** Texture is repeating outside of 0..1 UVs */
  16172. static readonly WRAP_ADDRESSMODE: number;
  16173. /** Texture is repeating and mirrored */
  16174. static readonly MIRROR_ADDRESSMODE: number;
  16175. /**
  16176. * 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
  16177. */
  16178. static UseSerializedUrlIfAny: boolean;
  16179. /**
  16180. * Define the url of the texture.
  16181. */
  16182. url: Nullable<string>;
  16183. /**
  16184. * Define an offset on the texture to offset the u coordinates of the UVs
  16185. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16186. */
  16187. uOffset: number;
  16188. /**
  16189. * Define an offset on the texture to offset the v coordinates of the UVs
  16190. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16191. */
  16192. vOffset: number;
  16193. /**
  16194. * Define an offset on the texture to scale the u coordinates of the UVs
  16195. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16196. */
  16197. uScale: number;
  16198. /**
  16199. * Define an offset on the texture to scale the v coordinates of the UVs
  16200. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16201. */
  16202. vScale: number;
  16203. /**
  16204. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16205. * @see http://doc.babylonjs.com/how_to/more_materials
  16206. */
  16207. uAng: number;
  16208. /**
  16209. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16210. * @see http://doc.babylonjs.com/how_to/more_materials
  16211. */
  16212. vAng: number;
  16213. /**
  16214. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16215. * @see http://doc.babylonjs.com/how_to/more_materials
  16216. */
  16217. wAng: number;
  16218. /**
  16219. * Defines the center of rotation (U)
  16220. */
  16221. uRotationCenter: number;
  16222. /**
  16223. * Defines the center of rotation (V)
  16224. */
  16225. vRotationCenter: number;
  16226. /**
  16227. * Defines the center of rotation (W)
  16228. */
  16229. wRotationCenter: number;
  16230. /**
  16231. * Are mip maps generated for this texture or not.
  16232. */
  16233. readonly noMipmap: boolean;
  16234. /**
  16235. * List of inspectable custom properties (used by the Inspector)
  16236. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16237. */
  16238. inspectableCustomProperties: Nullable<IInspectable[]>;
  16239. private _noMipmap;
  16240. /** @hidden */
  16241. _invertY: boolean;
  16242. private _rowGenerationMatrix;
  16243. private _cachedTextureMatrix;
  16244. private _projectionModeMatrix;
  16245. private _t0;
  16246. private _t1;
  16247. private _t2;
  16248. private _cachedUOffset;
  16249. private _cachedVOffset;
  16250. private _cachedUScale;
  16251. private _cachedVScale;
  16252. private _cachedUAng;
  16253. private _cachedVAng;
  16254. private _cachedWAng;
  16255. private _cachedProjectionMatrixId;
  16256. private _cachedCoordinatesMode;
  16257. /** @hidden */
  16258. protected _initialSamplingMode: number;
  16259. /** @hidden */
  16260. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16261. private _deleteBuffer;
  16262. protected _format: Nullable<number>;
  16263. private _delayedOnLoad;
  16264. private _delayedOnError;
  16265. private _mimeType?;
  16266. /**
  16267. * Observable triggered once the texture has been loaded.
  16268. */
  16269. onLoadObservable: Observable<Texture>;
  16270. protected _isBlocking: boolean;
  16271. /**
  16272. * Is the texture preventing material to render while loading.
  16273. * If false, a default texture will be used instead of the loading one during the preparation step.
  16274. */
  16275. isBlocking: boolean;
  16276. /**
  16277. * Get the current sampling mode associated with the texture.
  16278. */
  16279. readonly samplingMode: number;
  16280. /**
  16281. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16282. */
  16283. readonly invertY: boolean;
  16284. /**
  16285. * Instantiates a new texture.
  16286. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16287. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16288. * @param url defines the url of the picture to load as a texture
  16289. * @param scene defines the scene or engine the texture will belong to
  16290. * @param noMipmap defines if the texture will require mip maps or not
  16291. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16292. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16293. * @param onLoad defines a callback triggered when the texture has been loaded
  16294. * @param onError defines a callback triggered when an error occurred during the loading session
  16295. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16296. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16297. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16298. * @param mimeType defines an optional mime type information
  16299. */
  16300. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16301. /**
  16302. * Update the url (and optional buffer) of this texture if url was null during construction.
  16303. * @param url the url of the texture
  16304. * @param buffer the buffer of the texture (defaults to null)
  16305. * @param onLoad callback called when the texture is loaded (defaults to null)
  16306. */
  16307. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16308. /**
  16309. * Finish the loading sequence of a texture flagged as delayed load.
  16310. * @hidden
  16311. */
  16312. delayLoad(): void;
  16313. private _prepareRowForTextureGeneration;
  16314. /**
  16315. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16316. * @returns the transform matrix of the texture.
  16317. */
  16318. getTextureMatrix(): Matrix;
  16319. /**
  16320. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16321. * @returns The reflection texture transform
  16322. */
  16323. getReflectionTextureMatrix(): Matrix;
  16324. /**
  16325. * Clones the texture.
  16326. * @returns the cloned texture
  16327. */
  16328. clone(): Texture;
  16329. /**
  16330. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16331. * @returns The JSON representation of the texture
  16332. */
  16333. serialize(): any;
  16334. /**
  16335. * Get the current class name of the texture useful for serialization or dynamic coding.
  16336. * @returns "Texture"
  16337. */
  16338. getClassName(): string;
  16339. /**
  16340. * Dispose the texture and release its associated resources.
  16341. */
  16342. dispose(): void;
  16343. /**
  16344. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16345. * @param parsedTexture Define the JSON representation of the texture
  16346. * @param scene Define the scene the parsed texture should be instantiated in
  16347. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16348. * @returns The parsed texture if successful
  16349. */
  16350. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16351. /**
  16352. * Creates a texture from its base 64 representation.
  16353. * @param data Define the base64 payload without the data: prefix
  16354. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16355. * @param scene Define the scene the texture should belong to
  16356. * @param noMipmap Forces the texture to not create mip map information if true
  16357. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16358. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16359. * @param onLoad define a callback triggered when the texture has been loaded
  16360. * @param onError define a callback triggered when an error occurred during the loading session
  16361. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16362. * @returns the created texture
  16363. */
  16364. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16365. /**
  16366. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16367. * @param data Define the base64 payload without the data: prefix
  16368. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16369. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16370. * @param scene Define the scene the texture should belong to
  16371. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16372. * @param noMipmap Forces the texture to not create mip map information if true
  16373. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16374. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16375. * @param onLoad define a callback triggered when the texture has been loaded
  16376. * @param onError define a callback triggered when an error occurred during the loading session
  16377. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16378. * @returns the created texture
  16379. */
  16380. 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;
  16381. }
  16382. }
  16383. declare module "babylonjs/PostProcesses/postProcessManager" {
  16384. import { Nullable } from "babylonjs/types";
  16385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16386. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16387. import { Scene } from "babylonjs/scene";
  16388. /**
  16389. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16390. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16391. */
  16392. export class PostProcessManager {
  16393. private _scene;
  16394. private _indexBuffer;
  16395. private _vertexBuffers;
  16396. /**
  16397. * Creates a new instance PostProcess
  16398. * @param scene The scene that the post process is associated with.
  16399. */
  16400. constructor(scene: Scene);
  16401. private _prepareBuffers;
  16402. private _buildIndexBuffer;
  16403. /**
  16404. * Rebuilds the vertex buffers of the manager.
  16405. * @hidden
  16406. */
  16407. _rebuild(): void;
  16408. /**
  16409. * Prepares a frame to be run through a post process.
  16410. * @param sourceTexture The input texture to the post procesess. (default: null)
  16411. * @param postProcesses An array of post processes to be run. (default: null)
  16412. * @returns True if the post processes were able to be run.
  16413. * @hidden
  16414. */
  16415. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16416. /**
  16417. * Manually render a set of post processes to a texture.
  16418. * @param postProcesses An array of post processes to be run.
  16419. * @param targetTexture The target texture to render to.
  16420. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16421. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16422. * @param lodLevel defines which lod of the texture to render to
  16423. */
  16424. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16425. /**
  16426. * Finalize the result of the output of the postprocesses.
  16427. * @param doNotPresent If true the result will not be displayed to the screen.
  16428. * @param targetTexture The target texture to render to.
  16429. * @param faceIndex The index of the face to bind the target texture to.
  16430. * @param postProcesses The array of post processes to render.
  16431. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16432. * @hidden
  16433. */
  16434. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16435. /**
  16436. * Disposes of the post process manager.
  16437. */
  16438. dispose(): void;
  16439. }
  16440. }
  16441. declare module "babylonjs/Misc/gradients" {
  16442. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16443. /** Interface used by value gradients (color, factor, ...) */
  16444. export interface IValueGradient {
  16445. /**
  16446. * Gets or sets the gradient value (between 0 and 1)
  16447. */
  16448. gradient: number;
  16449. }
  16450. /** Class used to store color4 gradient */
  16451. export class ColorGradient implements IValueGradient {
  16452. /**
  16453. * Gets or sets the gradient value (between 0 and 1)
  16454. */
  16455. gradient: number;
  16456. /**
  16457. * Gets or sets first associated color
  16458. */
  16459. color1: Color4;
  16460. /**
  16461. * Gets or sets second associated color
  16462. */
  16463. color2?: Color4;
  16464. /**
  16465. * Will get a color picked randomly between color1 and color2.
  16466. * If color2 is undefined then color1 will be used
  16467. * @param result defines the target Color4 to store the result in
  16468. */
  16469. getColorToRef(result: Color4): void;
  16470. }
  16471. /** Class used to store color 3 gradient */
  16472. export class Color3Gradient implements IValueGradient {
  16473. /**
  16474. * Gets or sets the gradient value (between 0 and 1)
  16475. */
  16476. gradient: number;
  16477. /**
  16478. * Gets or sets the associated color
  16479. */
  16480. color: Color3;
  16481. }
  16482. /** Class used to store factor gradient */
  16483. export class FactorGradient implements IValueGradient {
  16484. /**
  16485. * Gets or sets the gradient value (between 0 and 1)
  16486. */
  16487. gradient: number;
  16488. /**
  16489. * Gets or sets first associated factor
  16490. */
  16491. factor1: number;
  16492. /**
  16493. * Gets or sets second associated factor
  16494. */
  16495. factor2?: number;
  16496. /**
  16497. * Will get a number picked randomly between factor1 and factor2.
  16498. * If factor2 is undefined then factor1 will be used
  16499. * @returns the picked number
  16500. */
  16501. getFactor(): number;
  16502. }
  16503. /**
  16504. * Helper used to simplify some generic gradient tasks
  16505. */
  16506. export class GradientHelper {
  16507. /**
  16508. * Gets the current gradient from an array of IValueGradient
  16509. * @param ratio defines the current ratio to get
  16510. * @param gradients defines the array of IValueGradient
  16511. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16512. */
  16513. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16514. }
  16515. }
  16516. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16518. import { Nullable } from "babylonjs/types";
  16519. module "babylonjs/Engines/thinEngine" {
  16520. interface ThinEngine {
  16521. /**
  16522. * Creates a dynamic texture
  16523. * @param width defines the width of the texture
  16524. * @param height defines the height of the texture
  16525. * @param generateMipMaps defines if the engine should generate the mip levels
  16526. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16527. * @returns the dynamic texture inside an InternalTexture
  16528. */
  16529. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16530. /**
  16531. * Update the content of a dynamic texture
  16532. * @param texture defines the texture to update
  16533. * @param canvas defines the canvas containing the source
  16534. * @param invertY defines if data must be stored with Y axis inverted
  16535. * @param premulAlpha defines if alpha is stored as premultiplied
  16536. * @param format defines the format of the data
  16537. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16538. */
  16539. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16540. }
  16541. }
  16542. }
  16543. declare module "babylonjs/Misc/canvasGenerator" {
  16544. /**
  16545. * Helper class used to generate a canvas to manipulate images
  16546. */
  16547. export class CanvasGenerator {
  16548. /**
  16549. * Create a new canvas (or offscreen canvas depending on the context)
  16550. * @param width defines the expected width
  16551. * @param height defines the expected height
  16552. * @return a new canvas or offscreen canvas
  16553. */
  16554. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16555. }
  16556. }
  16557. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16558. import { Scene } from "babylonjs/scene";
  16559. import { Texture } from "babylonjs/Materials/Textures/texture";
  16560. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16561. /**
  16562. * A class extending Texture allowing drawing on a texture
  16563. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16564. */
  16565. export class DynamicTexture extends Texture {
  16566. private _generateMipMaps;
  16567. private _canvas;
  16568. private _context;
  16569. private _engine;
  16570. /**
  16571. * Creates a DynamicTexture
  16572. * @param name defines the name of the texture
  16573. * @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
  16574. * @param scene defines the scene where you want the texture
  16575. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16576. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16577. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16578. */
  16579. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16580. /**
  16581. * Get the current class name of the texture useful for serialization or dynamic coding.
  16582. * @returns "DynamicTexture"
  16583. */
  16584. getClassName(): string;
  16585. /**
  16586. * Gets the current state of canRescale
  16587. */
  16588. readonly canRescale: boolean;
  16589. private _recreate;
  16590. /**
  16591. * Scales the texture
  16592. * @param ratio the scale factor to apply to both width and height
  16593. */
  16594. scale(ratio: number): void;
  16595. /**
  16596. * Resizes the texture
  16597. * @param width the new width
  16598. * @param height the new height
  16599. */
  16600. scaleTo(width: number, height: number): void;
  16601. /**
  16602. * Gets the context of the canvas used by the texture
  16603. * @returns the canvas context of the dynamic texture
  16604. */
  16605. getContext(): CanvasRenderingContext2D;
  16606. /**
  16607. * Clears the texture
  16608. */
  16609. clear(): void;
  16610. /**
  16611. * Updates the texture
  16612. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16613. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16614. */
  16615. update(invertY?: boolean, premulAlpha?: boolean): void;
  16616. /**
  16617. * Draws text onto the texture
  16618. * @param text defines the text to be drawn
  16619. * @param x defines the placement of the text from the left
  16620. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16621. * @param font defines the font to be used with font-style, font-size, font-name
  16622. * @param color defines the color used for the text
  16623. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16624. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16625. * @param update defines whether texture is immediately update (default is true)
  16626. */
  16627. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16628. /**
  16629. * Clones the texture
  16630. * @returns the clone of the texture.
  16631. */
  16632. clone(): DynamicTexture;
  16633. /**
  16634. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16635. * @returns a serialized dynamic texture object
  16636. */
  16637. serialize(): any;
  16638. /** @hidden */
  16639. _rebuild(): void;
  16640. }
  16641. }
  16642. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16643. import { Scene } from "babylonjs/scene";
  16644. import { ISceneComponent } from "babylonjs/sceneComponent";
  16645. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16646. module "babylonjs/abstractScene" {
  16647. interface AbstractScene {
  16648. /**
  16649. * The list of procedural textures added to the scene
  16650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16651. */
  16652. proceduralTextures: Array<ProceduralTexture>;
  16653. }
  16654. }
  16655. /**
  16656. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16657. * in a given scene.
  16658. */
  16659. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16660. /**
  16661. * The component name helpfull to identify the component in the list of scene components.
  16662. */
  16663. readonly name: string;
  16664. /**
  16665. * The scene the component belongs to.
  16666. */
  16667. scene: Scene;
  16668. /**
  16669. * Creates a new instance of the component for the given scene
  16670. * @param scene Defines the scene to register the component in
  16671. */
  16672. constructor(scene: Scene);
  16673. /**
  16674. * Registers the component in a given scene
  16675. */
  16676. register(): void;
  16677. /**
  16678. * Rebuilds the elements related to this component in case of
  16679. * context lost for instance.
  16680. */
  16681. rebuild(): void;
  16682. /**
  16683. * Disposes the component and the associated ressources.
  16684. */
  16685. dispose(): void;
  16686. private _beforeClear;
  16687. }
  16688. }
  16689. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16691. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16692. module "babylonjs/Engines/thinEngine" {
  16693. interface ThinEngine {
  16694. /**
  16695. * Creates a new render target cube texture
  16696. * @param size defines the size of the texture
  16697. * @param options defines the options used to create the texture
  16698. * @returns a new render target cube texture stored in an InternalTexture
  16699. */
  16700. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16701. }
  16702. }
  16703. }
  16704. declare module "babylonjs/Shaders/procedural.vertex" {
  16705. /** @hidden */
  16706. export var proceduralVertexShader: {
  16707. name: string;
  16708. shader: string;
  16709. };
  16710. }
  16711. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16712. import { Observable } from "babylonjs/Misc/observable";
  16713. import { Nullable } from "babylonjs/types";
  16714. import { Scene } from "babylonjs/scene";
  16715. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16716. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16717. import { Effect } from "babylonjs/Materials/effect";
  16718. import { Texture } from "babylonjs/Materials/Textures/texture";
  16719. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16720. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16721. import "babylonjs/Shaders/procedural.vertex";
  16722. /**
  16723. * 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.
  16724. * This is the base class of any Procedural texture and contains most of the shareable code.
  16725. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16726. */
  16727. export class ProceduralTexture extends Texture {
  16728. isCube: boolean;
  16729. /**
  16730. * Define if the texture is enabled or not (disabled texture will not render)
  16731. */
  16732. isEnabled: boolean;
  16733. /**
  16734. * Define if the texture must be cleared before rendering (default is true)
  16735. */
  16736. autoClear: boolean;
  16737. /**
  16738. * Callback called when the texture is generated
  16739. */
  16740. onGenerated: () => void;
  16741. /**
  16742. * Event raised when the texture is generated
  16743. */
  16744. onGeneratedObservable: Observable<ProceduralTexture>;
  16745. /** @hidden */
  16746. _generateMipMaps: boolean;
  16747. /** @hidden **/
  16748. _effect: Effect;
  16749. /** @hidden */
  16750. _textures: {
  16751. [key: string]: Texture;
  16752. };
  16753. private _size;
  16754. private _currentRefreshId;
  16755. private _refreshRate;
  16756. private _vertexBuffers;
  16757. private _indexBuffer;
  16758. private _uniforms;
  16759. private _samplers;
  16760. private _fragment;
  16761. private _floats;
  16762. private _ints;
  16763. private _floatsArrays;
  16764. private _colors3;
  16765. private _colors4;
  16766. private _vectors2;
  16767. private _vectors3;
  16768. private _matrices;
  16769. private _fallbackTexture;
  16770. private _fallbackTextureUsed;
  16771. private _engine;
  16772. private _cachedDefines;
  16773. private _contentUpdateId;
  16774. private _contentData;
  16775. /**
  16776. * Instantiates a new procedural texture.
  16777. * 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.
  16778. * This is the base class of any Procedural texture and contains most of the shareable code.
  16779. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16780. * @param name Define the name of the texture
  16781. * @param size Define the size of the texture to create
  16782. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16783. * @param scene Define the scene the texture belongs to
  16784. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16785. * @param generateMipMaps Define if the texture should creates mip maps or not
  16786. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16787. */
  16788. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16789. /**
  16790. * The effect that is created when initializing the post process.
  16791. * @returns The created effect corresponding the the postprocess.
  16792. */
  16793. getEffect(): Effect;
  16794. /**
  16795. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16796. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16797. */
  16798. getContent(): Nullable<ArrayBufferView>;
  16799. private _createIndexBuffer;
  16800. /** @hidden */
  16801. _rebuild(): void;
  16802. /**
  16803. * Resets the texture in order to recreate its associated resources.
  16804. * This can be called in case of context loss
  16805. */
  16806. reset(): void;
  16807. protected _getDefines(): string;
  16808. /**
  16809. * Is the texture ready to be used ? (rendered at least once)
  16810. * @returns true if ready, otherwise, false.
  16811. */
  16812. isReady(): boolean;
  16813. /**
  16814. * Resets the refresh counter of the texture and start bak from scratch.
  16815. * Could be useful to regenerate the texture if it is setup to render only once.
  16816. */
  16817. resetRefreshCounter(): void;
  16818. /**
  16819. * Set the fragment shader to use in order to render the texture.
  16820. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16821. */
  16822. setFragment(fragment: any): void;
  16823. /**
  16824. * Define the refresh rate of the texture or the rendering frequency.
  16825. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16826. */
  16827. refreshRate: number;
  16828. /** @hidden */
  16829. _shouldRender(): boolean;
  16830. /**
  16831. * Get the size the texture is rendering at.
  16832. * @returns the size (texture is always squared)
  16833. */
  16834. getRenderSize(): number;
  16835. /**
  16836. * Resize the texture to new value.
  16837. * @param size Define the new size the texture should have
  16838. * @param generateMipMaps Define whether the new texture should create mip maps
  16839. */
  16840. resize(size: number, generateMipMaps: boolean): void;
  16841. private _checkUniform;
  16842. /**
  16843. * Set a texture in the shader program used to render.
  16844. * @param name Define the name of the uniform samplers as defined in the shader
  16845. * @param texture Define the texture to bind to this sampler
  16846. * @return the texture itself allowing "fluent" like uniform updates
  16847. */
  16848. setTexture(name: string, texture: Texture): ProceduralTexture;
  16849. /**
  16850. * Set a float in the shader.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the texture itself allowing "fluent" like uniform updates
  16854. */
  16855. setFloat(name: string, value: number): ProceduralTexture;
  16856. /**
  16857. * Set a int in the shader.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the texture itself allowing "fluent" like uniform updates
  16861. */
  16862. setInt(name: string, value: number): ProceduralTexture;
  16863. /**
  16864. * Set an array of floats in the shader.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the texture itself allowing "fluent" like uniform updates
  16868. */
  16869. setFloats(name: string, value: number[]): ProceduralTexture;
  16870. /**
  16871. * Set a vec3 in the shader from a Color3.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the texture itself allowing "fluent" like uniform updates
  16875. */
  16876. setColor3(name: string, value: Color3): ProceduralTexture;
  16877. /**
  16878. * Set a vec4 in the shader from a Color4.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the texture itself allowing "fluent" like uniform updates
  16882. */
  16883. setColor4(name: string, value: Color4): ProceduralTexture;
  16884. /**
  16885. * Set a vec2 in the shader from a Vector2.
  16886. * @param name Define the name of the uniform as defined in the shader
  16887. * @param value Define the value to give to the uniform
  16888. * @return the texture itself allowing "fluent" like uniform updates
  16889. */
  16890. setVector2(name: string, value: Vector2): ProceduralTexture;
  16891. /**
  16892. * Set a vec3 in the shader from a Vector3.
  16893. * @param name Define the name of the uniform as defined in the shader
  16894. * @param value Define the value to give to the uniform
  16895. * @return the texture itself allowing "fluent" like uniform updates
  16896. */
  16897. setVector3(name: string, value: Vector3): ProceduralTexture;
  16898. /**
  16899. * Set a mat4 in the shader from a MAtrix.
  16900. * @param name Define the name of the uniform as defined in the shader
  16901. * @param value Define the value to give to the uniform
  16902. * @return the texture itself allowing "fluent" like uniform updates
  16903. */
  16904. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16905. /**
  16906. * Render the texture to its associated render target.
  16907. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16908. */
  16909. render(useCameraPostProcess?: boolean): void;
  16910. /**
  16911. * Clone the texture.
  16912. * @returns the cloned texture
  16913. */
  16914. clone(): ProceduralTexture;
  16915. /**
  16916. * Dispose the texture and release its asoociated resources.
  16917. */
  16918. dispose(): void;
  16919. }
  16920. }
  16921. declare module "babylonjs/Particles/baseParticleSystem" {
  16922. import { Nullable } from "babylonjs/types";
  16923. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16925. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16926. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16927. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16928. import { Scene } from "babylonjs/scene";
  16929. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16930. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16931. import { Texture } from "babylonjs/Materials/Textures/texture";
  16932. import { Color4 } from "babylonjs/Maths/math.color";
  16933. import { Animation } from "babylonjs/Animations/animation";
  16934. /**
  16935. * This represents the base class for particle system in Babylon.
  16936. * 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.
  16937. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16938. * @example https://doc.babylonjs.com/babylon101/particles
  16939. */
  16940. export class BaseParticleSystem {
  16941. /**
  16942. * Source color is added to the destination color without alpha affecting the result
  16943. */
  16944. static BLENDMODE_ONEONE: number;
  16945. /**
  16946. * Blend current color and particle color using particle’s alpha
  16947. */
  16948. static BLENDMODE_STANDARD: number;
  16949. /**
  16950. * Add current color and particle color multiplied by particle’s alpha
  16951. */
  16952. static BLENDMODE_ADD: number;
  16953. /**
  16954. * Multiply current color with particle color
  16955. */
  16956. static BLENDMODE_MULTIPLY: number;
  16957. /**
  16958. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16959. */
  16960. static BLENDMODE_MULTIPLYADD: number;
  16961. /**
  16962. * List of animations used by the particle system.
  16963. */
  16964. animations: Animation[];
  16965. /**
  16966. * The id of the Particle system.
  16967. */
  16968. id: string;
  16969. /**
  16970. * The friendly name of the Particle system.
  16971. */
  16972. name: string;
  16973. /**
  16974. * The rendering group used by the Particle system to chose when to render.
  16975. */
  16976. renderingGroupId: number;
  16977. /**
  16978. * The emitter represents the Mesh or position we are attaching the particle system to.
  16979. */
  16980. emitter: Nullable<AbstractMesh | Vector3>;
  16981. /**
  16982. * The maximum number of particles to emit per frame
  16983. */
  16984. emitRate: number;
  16985. /**
  16986. * If you want to launch only a few particles at once, that can be done, as well.
  16987. */
  16988. manualEmitCount: number;
  16989. /**
  16990. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16991. */
  16992. updateSpeed: number;
  16993. /**
  16994. * The amount of time the particle system is running (depends of the overall update speed).
  16995. */
  16996. targetStopDuration: number;
  16997. /**
  16998. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16999. */
  17000. disposeOnStop: boolean;
  17001. /**
  17002. * Minimum power of emitting particles.
  17003. */
  17004. minEmitPower: number;
  17005. /**
  17006. * Maximum power of emitting particles.
  17007. */
  17008. maxEmitPower: number;
  17009. /**
  17010. * Minimum life time of emitting particles.
  17011. */
  17012. minLifeTime: number;
  17013. /**
  17014. * Maximum life time of emitting particles.
  17015. */
  17016. maxLifeTime: number;
  17017. /**
  17018. * Minimum Size of emitting particles.
  17019. */
  17020. minSize: number;
  17021. /**
  17022. * Maximum Size of emitting particles.
  17023. */
  17024. maxSize: number;
  17025. /**
  17026. * Minimum scale of emitting particles on X axis.
  17027. */
  17028. minScaleX: number;
  17029. /**
  17030. * Maximum scale of emitting particles on X axis.
  17031. */
  17032. maxScaleX: number;
  17033. /**
  17034. * Minimum scale of emitting particles on Y axis.
  17035. */
  17036. minScaleY: number;
  17037. /**
  17038. * Maximum scale of emitting particles on Y axis.
  17039. */
  17040. maxScaleY: number;
  17041. /**
  17042. * Gets or sets the minimal initial rotation in radians.
  17043. */
  17044. minInitialRotation: number;
  17045. /**
  17046. * Gets or sets the maximal initial rotation in radians.
  17047. */
  17048. maxInitialRotation: number;
  17049. /**
  17050. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17051. */
  17052. minAngularSpeed: number;
  17053. /**
  17054. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17055. */
  17056. maxAngularSpeed: number;
  17057. /**
  17058. * The texture used to render each particle. (this can be a spritesheet)
  17059. */
  17060. particleTexture: Nullable<Texture>;
  17061. /**
  17062. * The layer mask we are rendering the particles through.
  17063. */
  17064. layerMask: number;
  17065. /**
  17066. * This can help using your own shader to render the particle system.
  17067. * The according effect will be created
  17068. */
  17069. customShader: any;
  17070. /**
  17071. * By default particle system starts as soon as they are created. This prevents the
  17072. * automatic start to happen and let you decide when to start emitting particles.
  17073. */
  17074. preventAutoStart: boolean;
  17075. private _noiseTexture;
  17076. /**
  17077. * Gets or sets a texture used to add random noise to particle positions
  17078. */
  17079. noiseTexture: Nullable<ProceduralTexture>;
  17080. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17081. noiseStrength: Vector3;
  17082. /**
  17083. * Callback triggered when the particle animation is ending.
  17084. */
  17085. onAnimationEnd: Nullable<() => void>;
  17086. /**
  17087. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17088. */
  17089. blendMode: number;
  17090. /**
  17091. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17092. * to override the particles.
  17093. */
  17094. forceDepthWrite: boolean;
  17095. /** 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 */
  17096. preWarmCycles: number;
  17097. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17098. preWarmStepOffset: number;
  17099. /**
  17100. * 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)
  17101. */
  17102. spriteCellChangeSpeed: number;
  17103. /**
  17104. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17105. */
  17106. startSpriteCellID: number;
  17107. /**
  17108. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17109. */
  17110. endSpriteCellID: number;
  17111. /**
  17112. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17113. */
  17114. spriteCellWidth: number;
  17115. /**
  17116. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17117. */
  17118. spriteCellHeight: number;
  17119. /**
  17120. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17121. */
  17122. spriteRandomStartCell: boolean;
  17123. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17124. translationPivot: Vector2;
  17125. /** @hidden */
  17126. protected _isAnimationSheetEnabled: boolean;
  17127. /**
  17128. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17129. */
  17130. beginAnimationOnStart: boolean;
  17131. /**
  17132. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17133. */
  17134. beginAnimationFrom: number;
  17135. /**
  17136. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17137. */
  17138. beginAnimationTo: number;
  17139. /**
  17140. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17141. */
  17142. beginAnimationLoop: boolean;
  17143. /**
  17144. * Gets or sets a world offset applied to all particles
  17145. */
  17146. worldOffset: Vector3;
  17147. /**
  17148. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17149. */
  17150. isAnimationSheetEnabled: boolean;
  17151. /**
  17152. * Get hosting scene
  17153. * @returns the scene
  17154. */
  17155. getScene(): Scene;
  17156. /**
  17157. * You can use gravity if you want to give an orientation to your particles.
  17158. */
  17159. gravity: Vector3;
  17160. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17161. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17162. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17163. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17164. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17165. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17166. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17167. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17168. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17169. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17170. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17171. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17172. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17173. /**
  17174. * Defines the delay in milliseconds before starting the system (0 by default)
  17175. */
  17176. startDelay: number;
  17177. /**
  17178. * Gets the current list of drag gradients.
  17179. * You must use addDragGradient and removeDragGradient to udpate this list
  17180. * @returns the list of drag gradients
  17181. */
  17182. getDragGradients(): Nullable<Array<FactorGradient>>;
  17183. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17184. limitVelocityDamping: number;
  17185. /**
  17186. * Gets the current list of limit velocity gradients.
  17187. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17188. * @returns the list of limit velocity gradients
  17189. */
  17190. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17191. /**
  17192. * Gets the current list of color gradients.
  17193. * You must use addColorGradient and removeColorGradient to udpate this list
  17194. * @returns the list of color gradients
  17195. */
  17196. getColorGradients(): Nullable<Array<ColorGradient>>;
  17197. /**
  17198. * Gets the current list of size gradients.
  17199. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17200. * @returns the list of size gradients
  17201. */
  17202. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17203. /**
  17204. * Gets the current list of color remap gradients.
  17205. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17206. * @returns the list of color remap gradients
  17207. */
  17208. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17209. /**
  17210. * Gets the current list of alpha remap gradients.
  17211. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17212. * @returns the list of alpha remap gradients
  17213. */
  17214. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17215. /**
  17216. * Gets the current list of life time gradients.
  17217. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17218. * @returns the list of life time gradients
  17219. */
  17220. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17221. /**
  17222. * Gets the current list of angular speed gradients.
  17223. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17224. * @returns the list of angular speed gradients
  17225. */
  17226. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17227. /**
  17228. * Gets the current list of velocity gradients.
  17229. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17230. * @returns the list of velocity gradients
  17231. */
  17232. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17233. /**
  17234. * Gets the current list of start size gradients.
  17235. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17236. * @returns the list of start size gradients
  17237. */
  17238. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17239. /**
  17240. * Gets the current list of emit rate gradients.
  17241. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17242. * @returns the list of emit rate gradients
  17243. */
  17244. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17245. /**
  17246. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17247. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17248. */
  17249. direction1: Vector3;
  17250. /**
  17251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17252. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17253. */
  17254. direction2: Vector3;
  17255. /**
  17256. * 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.
  17257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17258. */
  17259. minEmitBox: Vector3;
  17260. /**
  17261. * 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.
  17262. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17263. */
  17264. maxEmitBox: Vector3;
  17265. /**
  17266. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17267. */
  17268. color1: Color4;
  17269. /**
  17270. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17271. */
  17272. color2: Color4;
  17273. /**
  17274. * Color the particle will have at the end of its lifetime
  17275. */
  17276. colorDead: Color4;
  17277. /**
  17278. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17279. */
  17280. textureMask: Color4;
  17281. /**
  17282. * The particle emitter type defines the emitter used by the particle system.
  17283. * It can be for example box, sphere, or cone...
  17284. */
  17285. particleEmitterType: IParticleEmitterType;
  17286. /** @hidden */
  17287. _isSubEmitter: boolean;
  17288. /**
  17289. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17290. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17291. */
  17292. billboardMode: number;
  17293. protected _isBillboardBased: boolean;
  17294. /**
  17295. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17296. */
  17297. isBillboardBased: boolean;
  17298. /**
  17299. * The scene the particle system belongs to.
  17300. */
  17301. protected _scene: Scene;
  17302. /**
  17303. * Local cache of defines for image processing.
  17304. */
  17305. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17306. /**
  17307. * Default configuration related to image processing available in the standard Material.
  17308. */
  17309. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17310. /**
  17311. * Gets the image processing configuration used either in this material.
  17312. */
  17313. /**
  17314. * Sets the Default image processing configuration used either in the this material.
  17315. *
  17316. * If sets to null, the scene one is in use.
  17317. */
  17318. imageProcessingConfiguration: ImageProcessingConfiguration;
  17319. /**
  17320. * Attaches a new image processing configuration to the Standard Material.
  17321. * @param configuration
  17322. */
  17323. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17324. /** @hidden */
  17325. protected _reset(): void;
  17326. /** @hidden */
  17327. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17328. /**
  17329. * Instantiates a particle system.
  17330. * 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.
  17331. * @param name The name of the particle system
  17332. */
  17333. constructor(name: string);
  17334. /**
  17335. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17338. * @returns the emitter
  17339. */
  17340. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17341. /**
  17342. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17343. * @param radius The radius of the hemisphere to emit from
  17344. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17345. * @returns the emitter
  17346. */
  17347. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17348. /**
  17349. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17350. * @param radius The radius of the sphere to emit from
  17351. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17352. * @returns the emitter
  17353. */
  17354. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17355. /**
  17356. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17357. * @param radius The radius of the sphere to emit from
  17358. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17359. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17360. * @returns the emitter
  17361. */
  17362. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17363. /**
  17364. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17365. * @param radius The radius of the emission cylinder
  17366. * @param height The height of the emission cylinder
  17367. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17368. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17369. * @returns the emitter
  17370. */
  17371. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17372. /**
  17373. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17374. * @param radius The radius of the cylinder to emit from
  17375. * @param height The height of the emission cylinder
  17376. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17377. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17378. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17379. * @returns the emitter
  17380. */
  17381. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17382. /**
  17383. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17384. * @param radius The radius of the cone to emit from
  17385. * @param angle The base angle of the cone
  17386. * @returns the emitter
  17387. */
  17388. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17389. /**
  17390. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17391. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17392. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17393. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17394. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17395. * @returns the emitter
  17396. */
  17397. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17398. }
  17399. }
  17400. declare module "babylonjs/Particles/subEmitter" {
  17401. import { Scene } from "babylonjs/scene";
  17402. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17403. /**
  17404. * Type of sub emitter
  17405. */
  17406. export enum SubEmitterType {
  17407. /**
  17408. * Attached to the particle over it's lifetime
  17409. */
  17410. ATTACHED = 0,
  17411. /**
  17412. * Created when the particle dies
  17413. */
  17414. END = 1
  17415. }
  17416. /**
  17417. * Sub emitter class used to emit particles from an existing particle
  17418. */
  17419. export class SubEmitter {
  17420. /**
  17421. * the particle system to be used by the sub emitter
  17422. */
  17423. particleSystem: ParticleSystem;
  17424. /**
  17425. * Type of the submitter (Default: END)
  17426. */
  17427. type: SubEmitterType;
  17428. /**
  17429. * 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)
  17430. * Note: This only is supported when using an emitter of type Mesh
  17431. */
  17432. inheritDirection: boolean;
  17433. /**
  17434. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17435. */
  17436. inheritedVelocityAmount: number;
  17437. /**
  17438. * Creates a sub emitter
  17439. * @param particleSystem the particle system to be used by the sub emitter
  17440. */
  17441. constructor(
  17442. /**
  17443. * the particle system to be used by the sub emitter
  17444. */
  17445. particleSystem: ParticleSystem);
  17446. /**
  17447. * Clones the sub emitter
  17448. * @returns the cloned sub emitter
  17449. */
  17450. clone(): SubEmitter;
  17451. /**
  17452. * Serialize current object to a JSON object
  17453. * @returns the serialized object
  17454. */
  17455. serialize(): any;
  17456. /** @hidden */
  17457. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17458. /**
  17459. * Creates a new SubEmitter from a serialized JSON version
  17460. * @param serializationObject defines the JSON object to read from
  17461. * @param scene defines the hosting scene
  17462. * @param rootUrl defines the rootUrl for data loading
  17463. * @returns a new SubEmitter
  17464. */
  17465. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17466. /** Release associated resources */
  17467. dispose(): void;
  17468. }
  17469. }
  17470. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17471. /** @hidden */
  17472. export var clipPlaneFragmentDeclaration: {
  17473. name: string;
  17474. shader: string;
  17475. };
  17476. }
  17477. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17478. /** @hidden */
  17479. export var imageProcessingDeclaration: {
  17480. name: string;
  17481. shader: string;
  17482. };
  17483. }
  17484. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17485. /** @hidden */
  17486. export var imageProcessingFunctions: {
  17487. name: string;
  17488. shader: string;
  17489. };
  17490. }
  17491. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17492. /** @hidden */
  17493. export var clipPlaneFragment: {
  17494. name: string;
  17495. shader: string;
  17496. };
  17497. }
  17498. declare module "babylonjs/Shaders/particles.fragment" {
  17499. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17500. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17501. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17502. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17503. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17504. /** @hidden */
  17505. export var particlesPixelShader: {
  17506. name: string;
  17507. shader: string;
  17508. };
  17509. }
  17510. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17511. /** @hidden */
  17512. export var clipPlaneVertexDeclaration: {
  17513. name: string;
  17514. shader: string;
  17515. };
  17516. }
  17517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17518. /** @hidden */
  17519. export var clipPlaneVertex: {
  17520. name: string;
  17521. shader: string;
  17522. };
  17523. }
  17524. declare module "babylonjs/Shaders/particles.vertex" {
  17525. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17527. /** @hidden */
  17528. export var particlesVertexShader: {
  17529. name: string;
  17530. shader: string;
  17531. };
  17532. }
  17533. declare module "babylonjs/Particles/particleSystem" {
  17534. import { Nullable } from "babylonjs/types";
  17535. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17536. import { Observable } from "babylonjs/Misc/observable";
  17537. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17538. import { Effect } from "babylonjs/Materials/effect";
  17539. import { Scene, IDisposable } from "babylonjs/scene";
  17540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17541. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17542. import { Particle } from "babylonjs/Particles/particle";
  17543. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17544. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17545. import "babylonjs/Shaders/particles.fragment";
  17546. import "babylonjs/Shaders/particles.vertex";
  17547. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17548. /**
  17549. * This represents a particle system in Babylon.
  17550. * 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.
  17551. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17552. * @example https://doc.babylonjs.com/babylon101/particles
  17553. */
  17554. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17555. /**
  17556. * Billboard mode will only apply to Y axis
  17557. */
  17558. static readonly BILLBOARDMODE_Y: number;
  17559. /**
  17560. * Billboard mode will apply to all axes
  17561. */
  17562. static readonly BILLBOARDMODE_ALL: number;
  17563. /**
  17564. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17565. */
  17566. static readonly BILLBOARDMODE_STRETCHED: number;
  17567. /**
  17568. * This function can be defined to provide custom update for active particles.
  17569. * This function will be called instead of regular update (age, position, color, etc.).
  17570. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17571. */
  17572. updateFunction: (particles: Particle[]) => void;
  17573. private _emitterWorldMatrix;
  17574. /**
  17575. * This function can be defined to specify initial direction for every new particle.
  17576. * It by default use the emitterType defined function
  17577. */
  17578. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17579. /**
  17580. * This function can be defined to specify initial position for every new particle.
  17581. * It by default use the emitterType defined function
  17582. */
  17583. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17584. /**
  17585. * @hidden
  17586. */
  17587. _inheritedVelocityOffset: Vector3;
  17588. /**
  17589. * An event triggered when the system is disposed
  17590. */
  17591. onDisposeObservable: Observable<ParticleSystem>;
  17592. private _onDisposeObserver;
  17593. /**
  17594. * Sets a callback that will be triggered when the system is disposed
  17595. */
  17596. onDispose: () => void;
  17597. private _particles;
  17598. private _epsilon;
  17599. private _capacity;
  17600. private _stockParticles;
  17601. private _newPartsExcess;
  17602. private _vertexData;
  17603. private _vertexBuffer;
  17604. private _vertexBuffers;
  17605. private _spriteBuffer;
  17606. private _indexBuffer;
  17607. private _effect;
  17608. private _customEffect;
  17609. private _cachedDefines;
  17610. private _scaledColorStep;
  17611. private _colorDiff;
  17612. private _scaledDirection;
  17613. private _scaledGravity;
  17614. private _currentRenderId;
  17615. private _alive;
  17616. private _useInstancing;
  17617. private _started;
  17618. private _stopped;
  17619. private _actualFrame;
  17620. private _scaledUpdateSpeed;
  17621. private _vertexBufferSize;
  17622. /** @hidden */
  17623. _currentEmitRateGradient: Nullable<FactorGradient>;
  17624. /** @hidden */
  17625. _currentEmitRate1: number;
  17626. /** @hidden */
  17627. _currentEmitRate2: number;
  17628. /** @hidden */
  17629. _currentStartSizeGradient: Nullable<FactorGradient>;
  17630. /** @hidden */
  17631. _currentStartSize1: number;
  17632. /** @hidden */
  17633. _currentStartSize2: number;
  17634. private readonly _rawTextureWidth;
  17635. private _rampGradientsTexture;
  17636. private _useRampGradients;
  17637. /** Gets or sets a boolean indicating that ramp gradients must be used
  17638. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17639. */
  17640. useRampGradients: boolean;
  17641. /**
  17642. * 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.
  17643. * 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: [])
  17644. */
  17645. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17646. private _subEmitters;
  17647. /**
  17648. * @hidden
  17649. * If the particle systems emitter should be disposed when the particle system is disposed
  17650. */
  17651. _disposeEmitterOnDispose: boolean;
  17652. /**
  17653. * The current active Sub-systems, this property is used by the root particle system only.
  17654. */
  17655. activeSubSystems: Array<ParticleSystem>;
  17656. private _rootParticleSystem;
  17657. /**
  17658. * Gets the current list of active particles
  17659. */
  17660. readonly particles: Particle[];
  17661. /**
  17662. * Returns the string "ParticleSystem"
  17663. * @returns a string containing the class name
  17664. */
  17665. getClassName(): string;
  17666. /**
  17667. * Instantiates a particle system.
  17668. * 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.
  17669. * @param name The name of the particle system
  17670. * @param capacity The max number of particles alive at the same time
  17671. * @param scene The scene the particle system belongs to
  17672. * @param customEffect a custom effect used to change the way particles are rendered by default
  17673. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17674. * @param epsilon Offset used to render the particles
  17675. */
  17676. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17677. private _addFactorGradient;
  17678. private _removeFactorGradient;
  17679. /**
  17680. * Adds a new life time gradient
  17681. * @param gradient defines the gradient to use (between 0 and 1)
  17682. * @param factor defines the life time factor to affect to the specified gradient
  17683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17684. * @returns the current particle system
  17685. */
  17686. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17687. /**
  17688. * Remove a specific life time gradient
  17689. * @param gradient defines the gradient to remove
  17690. * @returns the current particle system
  17691. */
  17692. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17693. /**
  17694. * Adds a new size gradient
  17695. * @param gradient defines the gradient to use (between 0 and 1)
  17696. * @param factor defines the size factor to affect to the specified gradient
  17697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17698. * @returns the current particle system
  17699. */
  17700. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17701. /**
  17702. * Remove a specific size gradient
  17703. * @param gradient defines the gradient to remove
  17704. * @returns the current particle system
  17705. */
  17706. removeSizeGradient(gradient: number): IParticleSystem;
  17707. /**
  17708. * Adds a new color remap gradient
  17709. * @param gradient defines the gradient to use (between 0 and 1)
  17710. * @param min defines the color remap minimal range
  17711. * @param max defines the color remap maximal range
  17712. * @returns the current particle system
  17713. */
  17714. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17715. /**
  17716. * Remove a specific color remap gradient
  17717. * @param gradient defines the gradient to remove
  17718. * @returns the current particle system
  17719. */
  17720. removeColorRemapGradient(gradient: number): IParticleSystem;
  17721. /**
  17722. * Adds a new alpha remap gradient
  17723. * @param gradient defines the gradient to use (between 0 and 1)
  17724. * @param min defines the alpha remap minimal range
  17725. * @param max defines the alpha remap maximal range
  17726. * @returns the current particle system
  17727. */
  17728. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17729. /**
  17730. * Remove a specific alpha remap gradient
  17731. * @param gradient defines the gradient to remove
  17732. * @returns the current particle system
  17733. */
  17734. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17735. /**
  17736. * Adds a new angular speed gradient
  17737. * @param gradient defines the gradient to use (between 0 and 1)
  17738. * @param factor defines the angular speed to affect to the specified gradient
  17739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17740. * @returns the current particle system
  17741. */
  17742. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17743. /**
  17744. * Remove a specific angular speed gradient
  17745. * @param gradient defines the gradient to remove
  17746. * @returns the current particle system
  17747. */
  17748. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17749. /**
  17750. * Adds a new velocity gradient
  17751. * @param gradient defines the gradient to use (between 0 and 1)
  17752. * @param factor defines the velocity to affect to the specified gradient
  17753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17754. * @returns the current particle system
  17755. */
  17756. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17757. /**
  17758. * Remove a specific velocity gradient
  17759. * @param gradient defines the gradient to remove
  17760. * @returns the current particle system
  17761. */
  17762. removeVelocityGradient(gradient: number): IParticleSystem;
  17763. /**
  17764. * Adds a new limit velocity gradient
  17765. * @param gradient defines the gradient to use (between 0 and 1)
  17766. * @param factor defines the limit velocity value to affect to the specified gradient
  17767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17768. * @returns the current particle system
  17769. */
  17770. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17771. /**
  17772. * Remove a specific limit velocity gradient
  17773. * @param gradient defines the gradient to remove
  17774. * @returns the current particle system
  17775. */
  17776. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17777. /**
  17778. * Adds a new drag gradient
  17779. * @param gradient defines the gradient to use (between 0 and 1)
  17780. * @param factor defines the drag value to affect to the specified gradient
  17781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17782. * @returns the current particle system
  17783. */
  17784. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17785. /**
  17786. * Remove a specific drag gradient
  17787. * @param gradient defines the gradient to remove
  17788. * @returns the current particle system
  17789. */
  17790. removeDragGradient(gradient: number): IParticleSystem;
  17791. /**
  17792. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17793. * @param gradient defines the gradient to use (between 0 and 1)
  17794. * @param factor defines the emit rate value to affect to the specified gradient
  17795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17796. * @returns the current particle system
  17797. */
  17798. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17799. /**
  17800. * Remove a specific emit rate gradient
  17801. * @param gradient defines the gradient to remove
  17802. * @returns the current particle system
  17803. */
  17804. removeEmitRateGradient(gradient: number): IParticleSystem;
  17805. /**
  17806. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17807. * @param gradient defines the gradient to use (between 0 and 1)
  17808. * @param factor defines the start size value to affect to the specified gradient
  17809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17810. * @returns the current particle system
  17811. */
  17812. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17813. /**
  17814. * Remove a specific start size gradient
  17815. * @param gradient defines the gradient to remove
  17816. * @returns the current particle system
  17817. */
  17818. removeStartSizeGradient(gradient: number): IParticleSystem;
  17819. private _createRampGradientTexture;
  17820. /**
  17821. * Gets the current list of ramp gradients.
  17822. * You must use addRampGradient and removeRampGradient to udpate this list
  17823. * @returns the list of ramp gradients
  17824. */
  17825. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17826. /**
  17827. * Adds a new ramp gradient used to remap particle colors
  17828. * @param gradient defines the gradient to use (between 0 and 1)
  17829. * @param color defines the color to affect to the specified gradient
  17830. * @returns the current particle system
  17831. */
  17832. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17833. /**
  17834. * Remove a specific ramp gradient
  17835. * @param gradient defines the gradient to remove
  17836. * @returns the current particle system
  17837. */
  17838. removeRampGradient(gradient: number): ParticleSystem;
  17839. /**
  17840. * Adds a new color gradient
  17841. * @param gradient defines the gradient to use (between 0 and 1)
  17842. * @param color1 defines the color to affect to the specified gradient
  17843. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17844. * @returns this particle system
  17845. */
  17846. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17847. /**
  17848. * Remove a specific color gradient
  17849. * @param gradient defines the gradient to remove
  17850. * @returns this particle system
  17851. */
  17852. removeColorGradient(gradient: number): IParticleSystem;
  17853. private _fetchR;
  17854. protected _reset(): void;
  17855. private _resetEffect;
  17856. private _createVertexBuffers;
  17857. private _createIndexBuffer;
  17858. /**
  17859. * Gets the maximum number of particles active at the same time.
  17860. * @returns The max number of active particles.
  17861. */
  17862. getCapacity(): number;
  17863. /**
  17864. * Gets whether there are still active particles in the system.
  17865. * @returns True if it is alive, otherwise false.
  17866. */
  17867. isAlive(): boolean;
  17868. /**
  17869. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17870. * @returns True if it has been started, otherwise false.
  17871. */
  17872. isStarted(): boolean;
  17873. private _prepareSubEmitterInternalArray;
  17874. /**
  17875. * Starts the particle system and begins to emit
  17876. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17877. */
  17878. start(delay?: number): void;
  17879. /**
  17880. * Stops the particle system.
  17881. * @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.
  17882. */
  17883. stop(stopSubEmitters?: boolean): void;
  17884. /**
  17885. * Remove all active particles
  17886. */
  17887. reset(): void;
  17888. /**
  17889. * @hidden (for internal use only)
  17890. */
  17891. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17892. /**
  17893. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17894. * Its lifetime will start back at 0.
  17895. */
  17896. recycleParticle: (particle: Particle) => void;
  17897. private _stopSubEmitters;
  17898. private _createParticle;
  17899. private _removeFromRoot;
  17900. private _emitFromParticle;
  17901. private _update;
  17902. /** @hidden */
  17903. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17904. /** @hidden */
  17905. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17906. /** @hidden */
  17907. private _getEffect;
  17908. /**
  17909. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17910. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17911. */
  17912. animate(preWarmOnly?: boolean): void;
  17913. private _appendParticleVertices;
  17914. /**
  17915. * Rebuilds the particle system.
  17916. */
  17917. rebuild(): void;
  17918. /**
  17919. * Is this system ready to be used/rendered
  17920. * @return true if the system is ready
  17921. */
  17922. isReady(): boolean;
  17923. private _render;
  17924. /**
  17925. * Renders the particle system in its current state.
  17926. * @returns the current number of particles
  17927. */
  17928. render(): number;
  17929. /**
  17930. * Disposes the particle system and free the associated resources
  17931. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17932. */
  17933. dispose(disposeTexture?: boolean): void;
  17934. /**
  17935. * Clones the particle system.
  17936. * @param name The name of the cloned object
  17937. * @param newEmitter The new emitter to use
  17938. * @returns the cloned particle system
  17939. */
  17940. clone(name: string, newEmitter: any): ParticleSystem;
  17941. /**
  17942. * Serializes the particle system to a JSON object.
  17943. * @returns the JSON object
  17944. */
  17945. serialize(): any;
  17946. /** @hidden */
  17947. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17948. /** @hidden */
  17949. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17950. /**
  17951. * Parses a JSON object to create a particle system.
  17952. * @param parsedParticleSystem The JSON object to parse
  17953. * @param scene The scene to create the particle system in
  17954. * @param rootUrl The root url to use to load external dependencies like texture
  17955. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17956. * @returns the Parsed particle system
  17957. */
  17958. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17959. }
  17960. }
  17961. declare module "babylonjs/Particles/particle" {
  17962. import { Nullable } from "babylonjs/types";
  17963. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17964. import { Color4 } from "babylonjs/Maths/math.color";
  17965. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17966. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17967. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17968. /**
  17969. * A particle represents one of the element emitted by a particle system.
  17970. * This is mainly define by its coordinates, direction, velocity and age.
  17971. */
  17972. export class Particle {
  17973. /**
  17974. * The particle system the particle belongs to.
  17975. */
  17976. particleSystem: ParticleSystem;
  17977. private static _Count;
  17978. /**
  17979. * Unique ID of the particle
  17980. */
  17981. id: number;
  17982. /**
  17983. * The world position of the particle in the scene.
  17984. */
  17985. position: Vector3;
  17986. /**
  17987. * The world direction of the particle in the scene.
  17988. */
  17989. direction: Vector3;
  17990. /**
  17991. * The color of the particle.
  17992. */
  17993. color: Color4;
  17994. /**
  17995. * The color change of the particle per step.
  17996. */
  17997. colorStep: Color4;
  17998. /**
  17999. * Defines how long will the life of the particle be.
  18000. */
  18001. lifeTime: number;
  18002. /**
  18003. * The current age of the particle.
  18004. */
  18005. age: number;
  18006. /**
  18007. * The current size of the particle.
  18008. */
  18009. size: number;
  18010. /**
  18011. * The current scale of the particle.
  18012. */
  18013. scale: Vector2;
  18014. /**
  18015. * The current angle of the particle.
  18016. */
  18017. angle: number;
  18018. /**
  18019. * Defines how fast is the angle changing.
  18020. */
  18021. angularSpeed: number;
  18022. /**
  18023. * Defines the cell index used by the particle to be rendered from a sprite.
  18024. */
  18025. cellIndex: number;
  18026. /**
  18027. * The information required to support color remapping
  18028. */
  18029. remapData: Vector4;
  18030. /** @hidden */
  18031. _randomCellOffset?: number;
  18032. /** @hidden */
  18033. _initialDirection: Nullable<Vector3>;
  18034. /** @hidden */
  18035. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18036. /** @hidden */
  18037. _initialStartSpriteCellID: number;
  18038. /** @hidden */
  18039. _initialEndSpriteCellID: number;
  18040. /** @hidden */
  18041. _currentColorGradient: Nullable<ColorGradient>;
  18042. /** @hidden */
  18043. _currentColor1: Color4;
  18044. /** @hidden */
  18045. _currentColor2: Color4;
  18046. /** @hidden */
  18047. _currentSizeGradient: Nullable<FactorGradient>;
  18048. /** @hidden */
  18049. _currentSize1: number;
  18050. /** @hidden */
  18051. _currentSize2: number;
  18052. /** @hidden */
  18053. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18054. /** @hidden */
  18055. _currentAngularSpeed1: number;
  18056. /** @hidden */
  18057. _currentAngularSpeed2: number;
  18058. /** @hidden */
  18059. _currentVelocityGradient: Nullable<FactorGradient>;
  18060. /** @hidden */
  18061. _currentVelocity1: number;
  18062. /** @hidden */
  18063. _currentVelocity2: number;
  18064. /** @hidden */
  18065. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18066. /** @hidden */
  18067. _currentLimitVelocity1: number;
  18068. /** @hidden */
  18069. _currentLimitVelocity2: number;
  18070. /** @hidden */
  18071. _currentDragGradient: Nullable<FactorGradient>;
  18072. /** @hidden */
  18073. _currentDrag1: number;
  18074. /** @hidden */
  18075. _currentDrag2: number;
  18076. /** @hidden */
  18077. _randomNoiseCoordinates1: Vector3;
  18078. /** @hidden */
  18079. _randomNoiseCoordinates2: Vector3;
  18080. /**
  18081. * Creates a new instance Particle
  18082. * @param particleSystem the particle system the particle belongs to
  18083. */
  18084. constructor(
  18085. /**
  18086. * The particle system the particle belongs to.
  18087. */
  18088. particleSystem: ParticleSystem);
  18089. private updateCellInfoFromSystem;
  18090. /**
  18091. * Defines how the sprite cell index is updated for the particle
  18092. */
  18093. updateCellIndex(): void;
  18094. /** @hidden */
  18095. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18096. /** @hidden */
  18097. _inheritParticleInfoToSubEmitters(): void;
  18098. /** @hidden */
  18099. _reset(): void;
  18100. /**
  18101. * Copy the properties of particle to another one.
  18102. * @param other the particle to copy the information to.
  18103. */
  18104. copyTo(other: Particle): void;
  18105. }
  18106. }
  18107. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18108. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18109. import { Effect } from "babylonjs/Materials/effect";
  18110. import { Particle } from "babylonjs/Particles/particle";
  18111. /**
  18112. * Particle emitter represents a volume emitting particles.
  18113. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18114. */
  18115. export interface IParticleEmitterType {
  18116. /**
  18117. * Called by the particle System when the direction is computed for the created particle.
  18118. * @param worldMatrix is the world matrix of the particle system
  18119. * @param directionToUpdate is the direction vector to update with the result
  18120. * @param particle is the particle we are computed the direction for
  18121. */
  18122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18123. /**
  18124. * Called by the particle System when the position is computed for the created particle.
  18125. * @param worldMatrix is the world matrix of the particle system
  18126. * @param positionToUpdate is the position vector to update with the result
  18127. * @param particle is the particle we are computed the position for
  18128. */
  18129. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18130. /**
  18131. * Clones the current emitter and returns a copy of it
  18132. * @returns the new emitter
  18133. */
  18134. clone(): IParticleEmitterType;
  18135. /**
  18136. * Called by the GPUParticleSystem to setup the update shader
  18137. * @param effect defines the update shader
  18138. */
  18139. applyToShader(effect: Effect): void;
  18140. /**
  18141. * Returns a string to use to update the GPU particles update shader
  18142. * @returns the effect defines string
  18143. */
  18144. getEffectDefines(): string;
  18145. /**
  18146. * Returns a string representing the class name
  18147. * @returns a string containing the class name
  18148. */
  18149. getClassName(): string;
  18150. /**
  18151. * Serializes the particle system to a JSON object.
  18152. * @returns the JSON object
  18153. */
  18154. serialize(): any;
  18155. /**
  18156. * Parse properties from a JSON object
  18157. * @param serializationObject defines the JSON object
  18158. */
  18159. parse(serializationObject: any): void;
  18160. }
  18161. }
  18162. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18163. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18164. import { Effect } from "babylonjs/Materials/effect";
  18165. import { Particle } from "babylonjs/Particles/particle";
  18166. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18167. /**
  18168. * Particle emitter emitting particles from the inside of a box.
  18169. * It emits the particles randomly between 2 given directions.
  18170. */
  18171. export class BoxParticleEmitter implements IParticleEmitterType {
  18172. /**
  18173. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18174. */
  18175. direction1: Vector3;
  18176. /**
  18177. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18178. */
  18179. direction2: Vector3;
  18180. /**
  18181. * 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.
  18182. */
  18183. minEmitBox: Vector3;
  18184. /**
  18185. * 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.
  18186. */
  18187. maxEmitBox: Vector3;
  18188. /**
  18189. * Creates a new instance BoxParticleEmitter
  18190. */
  18191. constructor();
  18192. /**
  18193. * Called by the particle System when the direction is computed for the created particle.
  18194. * @param worldMatrix is the world matrix of the particle system
  18195. * @param directionToUpdate is the direction vector to update with the result
  18196. * @param particle is the particle we are computed the direction for
  18197. */
  18198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18199. /**
  18200. * Called by the particle System when the position is computed for the created particle.
  18201. * @param worldMatrix is the world matrix of the particle system
  18202. * @param positionToUpdate is the position vector to update with the result
  18203. * @param particle is the particle we are computed the position for
  18204. */
  18205. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18206. /**
  18207. * Clones the current emitter and returns a copy of it
  18208. * @returns the new emitter
  18209. */
  18210. clone(): BoxParticleEmitter;
  18211. /**
  18212. * Called by the GPUParticleSystem to setup the update shader
  18213. * @param effect defines the update shader
  18214. */
  18215. applyToShader(effect: Effect): void;
  18216. /**
  18217. * Returns a string to use to update the GPU particles update shader
  18218. * @returns a string containng the defines string
  18219. */
  18220. getEffectDefines(): string;
  18221. /**
  18222. * Returns the string "BoxParticleEmitter"
  18223. * @returns a string containing the class name
  18224. */
  18225. getClassName(): string;
  18226. /**
  18227. * Serializes the particle system to a JSON object.
  18228. * @returns the JSON object
  18229. */
  18230. serialize(): any;
  18231. /**
  18232. * Parse properties from a JSON object
  18233. * @param serializationObject defines the JSON object
  18234. */
  18235. parse(serializationObject: any): void;
  18236. }
  18237. }
  18238. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18240. import { Effect } from "babylonjs/Materials/effect";
  18241. import { Particle } from "babylonjs/Particles/particle";
  18242. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18243. /**
  18244. * Particle emitter emitting particles from the inside of a cone.
  18245. * It emits the particles alongside the cone volume from the base to the particle.
  18246. * The emission direction might be randomized.
  18247. */
  18248. export class ConeParticleEmitter implements IParticleEmitterType {
  18249. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18250. directionRandomizer: number;
  18251. private _radius;
  18252. private _angle;
  18253. private _height;
  18254. /**
  18255. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18256. */
  18257. radiusRange: number;
  18258. /**
  18259. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18260. */
  18261. heightRange: number;
  18262. /**
  18263. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18264. */
  18265. emitFromSpawnPointOnly: boolean;
  18266. /**
  18267. * Gets or sets the radius of the emission cone
  18268. */
  18269. radius: number;
  18270. /**
  18271. * Gets or sets the angle of the emission cone
  18272. */
  18273. angle: number;
  18274. private _buildHeight;
  18275. /**
  18276. * Creates a new instance ConeParticleEmitter
  18277. * @param radius the radius of the emission cone (1 by default)
  18278. * @param angle the cone base angle (PI by default)
  18279. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18280. */
  18281. constructor(radius?: number, angle?: number,
  18282. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18283. directionRandomizer?: number);
  18284. /**
  18285. * Called by the particle System when the direction is computed for the created particle.
  18286. * @param worldMatrix is the world matrix of the particle system
  18287. * @param directionToUpdate is the direction vector to update with the result
  18288. * @param particle is the particle we are computed the direction for
  18289. */
  18290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18291. /**
  18292. * Called by the particle System when the position is computed for the created particle.
  18293. * @param worldMatrix is the world matrix of the particle system
  18294. * @param positionToUpdate is the position vector to update with the result
  18295. * @param particle is the particle we are computed the position for
  18296. */
  18297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18298. /**
  18299. * Clones the current emitter and returns a copy of it
  18300. * @returns the new emitter
  18301. */
  18302. clone(): ConeParticleEmitter;
  18303. /**
  18304. * Called by the GPUParticleSystem to setup the update shader
  18305. * @param effect defines the update shader
  18306. */
  18307. applyToShader(effect: Effect): void;
  18308. /**
  18309. * Returns a string to use to update the GPU particles update shader
  18310. * @returns a string containng the defines string
  18311. */
  18312. getEffectDefines(): string;
  18313. /**
  18314. * Returns the string "ConeParticleEmitter"
  18315. * @returns a string containing the class name
  18316. */
  18317. getClassName(): string;
  18318. /**
  18319. * Serializes the particle system to a JSON object.
  18320. * @returns the JSON object
  18321. */
  18322. serialize(): any;
  18323. /**
  18324. * Parse properties from a JSON object
  18325. * @param serializationObject defines the JSON object
  18326. */
  18327. parse(serializationObject: any): void;
  18328. }
  18329. }
  18330. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18331. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18332. import { Effect } from "babylonjs/Materials/effect";
  18333. import { Particle } from "babylonjs/Particles/particle";
  18334. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18335. /**
  18336. * Particle emitter emitting particles from the inside of a cylinder.
  18337. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18338. */
  18339. export class CylinderParticleEmitter implements IParticleEmitterType {
  18340. /**
  18341. * The radius of the emission cylinder.
  18342. */
  18343. radius: number;
  18344. /**
  18345. * The height of the emission cylinder.
  18346. */
  18347. height: number;
  18348. /**
  18349. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18350. */
  18351. radiusRange: number;
  18352. /**
  18353. * How much to randomize the particle direction [0-1].
  18354. */
  18355. directionRandomizer: number;
  18356. /**
  18357. * Creates a new instance CylinderParticleEmitter
  18358. * @param radius the radius of the emission cylinder (1 by default)
  18359. * @param height the height of the emission cylinder (1 by default)
  18360. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18361. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18362. */
  18363. constructor(
  18364. /**
  18365. * The radius of the emission cylinder.
  18366. */
  18367. radius?: number,
  18368. /**
  18369. * The height of the emission cylinder.
  18370. */
  18371. height?: number,
  18372. /**
  18373. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18374. */
  18375. radiusRange?: number,
  18376. /**
  18377. * How much to randomize the particle direction [0-1].
  18378. */
  18379. directionRandomizer?: number);
  18380. /**
  18381. * Called by the particle System when the direction is computed for the created particle.
  18382. * @param worldMatrix is the world matrix of the particle system
  18383. * @param directionToUpdate is the direction vector to update with the result
  18384. * @param particle is the particle we are computed the direction for
  18385. */
  18386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18387. /**
  18388. * Called by the particle System when the position is computed for the created particle.
  18389. * @param worldMatrix is the world matrix of the particle system
  18390. * @param positionToUpdate is the position vector to update with the result
  18391. * @param particle is the particle we are computed the position for
  18392. */
  18393. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18394. /**
  18395. * Clones the current emitter and returns a copy of it
  18396. * @returns the new emitter
  18397. */
  18398. clone(): CylinderParticleEmitter;
  18399. /**
  18400. * Called by the GPUParticleSystem to setup the update shader
  18401. * @param effect defines the update shader
  18402. */
  18403. applyToShader(effect: Effect): void;
  18404. /**
  18405. * Returns a string to use to update the GPU particles update shader
  18406. * @returns a string containng the defines string
  18407. */
  18408. getEffectDefines(): string;
  18409. /**
  18410. * Returns the string "CylinderParticleEmitter"
  18411. * @returns a string containing the class name
  18412. */
  18413. getClassName(): string;
  18414. /**
  18415. * Serializes the particle system to a JSON object.
  18416. * @returns the JSON object
  18417. */
  18418. serialize(): any;
  18419. /**
  18420. * Parse properties from a JSON object
  18421. * @param serializationObject defines the JSON object
  18422. */
  18423. parse(serializationObject: any): void;
  18424. }
  18425. /**
  18426. * Particle emitter emitting particles from the inside of a cylinder.
  18427. * It emits the particles randomly between two vectors.
  18428. */
  18429. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18430. /**
  18431. * The min limit of the emission direction.
  18432. */
  18433. direction1: Vector3;
  18434. /**
  18435. * The max limit of the emission direction.
  18436. */
  18437. direction2: Vector3;
  18438. /**
  18439. * Creates a new instance CylinderDirectedParticleEmitter
  18440. * @param radius the radius of the emission cylinder (1 by default)
  18441. * @param height the height of the emission cylinder (1 by default)
  18442. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18443. * @param direction1 the min limit of the emission direction (up vector by default)
  18444. * @param direction2 the max limit of the emission direction (up vector by default)
  18445. */
  18446. constructor(radius?: number, height?: number, radiusRange?: number,
  18447. /**
  18448. * The min limit of the emission direction.
  18449. */
  18450. direction1?: Vector3,
  18451. /**
  18452. * The max limit of the emission direction.
  18453. */
  18454. direction2?: Vector3);
  18455. /**
  18456. * Called by the particle System when the direction is computed for the created particle.
  18457. * @param worldMatrix is the world matrix of the particle system
  18458. * @param directionToUpdate is the direction vector to update with the result
  18459. * @param particle is the particle we are computed the direction for
  18460. */
  18461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18462. /**
  18463. * Clones the current emitter and returns a copy of it
  18464. * @returns the new emitter
  18465. */
  18466. clone(): CylinderDirectedParticleEmitter;
  18467. /**
  18468. * Called by the GPUParticleSystem to setup the update shader
  18469. * @param effect defines the update shader
  18470. */
  18471. applyToShader(effect: Effect): void;
  18472. /**
  18473. * Returns a string to use to update the GPU particles update shader
  18474. * @returns a string containng the defines string
  18475. */
  18476. getEffectDefines(): string;
  18477. /**
  18478. * Returns the string "CylinderDirectedParticleEmitter"
  18479. * @returns a string containing the class name
  18480. */
  18481. getClassName(): string;
  18482. /**
  18483. * Serializes the particle system to a JSON object.
  18484. * @returns the JSON object
  18485. */
  18486. serialize(): any;
  18487. /**
  18488. * Parse properties from a JSON object
  18489. * @param serializationObject defines the JSON object
  18490. */
  18491. parse(serializationObject: any): void;
  18492. }
  18493. }
  18494. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18495. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18496. import { Effect } from "babylonjs/Materials/effect";
  18497. import { Particle } from "babylonjs/Particles/particle";
  18498. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18499. /**
  18500. * Particle emitter emitting particles from the inside of a hemisphere.
  18501. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18502. */
  18503. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18504. /**
  18505. * The radius of the emission hemisphere.
  18506. */
  18507. radius: number;
  18508. /**
  18509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18510. */
  18511. radiusRange: number;
  18512. /**
  18513. * How much to randomize the particle direction [0-1].
  18514. */
  18515. directionRandomizer: number;
  18516. /**
  18517. * Creates a new instance HemisphericParticleEmitter
  18518. * @param radius the radius of the emission hemisphere (1 by default)
  18519. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18521. */
  18522. constructor(
  18523. /**
  18524. * The radius of the emission hemisphere.
  18525. */
  18526. radius?: number,
  18527. /**
  18528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18529. */
  18530. radiusRange?: number,
  18531. /**
  18532. * How much to randomize the particle direction [0-1].
  18533. */
  18534. directionRandomizer?: number);
  18535. /**
  18536. * Called by the particle System when the direction is computed for the created particle.
  18537. * @param worldMatrix is the world matrix of the particle system
  18538. * @param directionToUpdate is the direction vector to update with the result
  18539. * @param particle is the particle we are computed the direction for
  18540. */
  18541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18542. /**
  18543. * Called by the particle System when the position is computed for the created particle.
  18544. * @param worldMatrix is the world matrix of the particle system
  18545. * @param positionToUpdate is the position vector to update with the result
  18546. * @param particle is the particle we are computed the position for
  18547. */
  18548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18549. /**
  18550. * Clones the current emitter and returns a copy of it
  18551. * @returns the new emitter
  18552. */
  18553. clone(): HemisphericParticleEmitter;
  18554. /**
  18555. * Called by the GPUParticleSystem to setup the update shader
  18556. * @param effect defines the update shader
  18557. */
  18558. applyToShader(effect: Effect): void;
  18559. /**
  18560. * Returns a string to use to update the GPU particles update shader
  18561. * @returns a string containng the defines string
  18562. */
  18563. getEffectDefines(): string;
  18564. /**
  18565. * Returns the string "HemisphericParticleEmitter"
  18566. * @returns a string containing the class name
  18567. */
  18568. getClassName(): string;
  18569. /**
  18570. * Serializes the particle system to a JSON object.
  18571. * @returns the JSON object
  18572. */
  18573. serialize(): any;
  18574. /**
  18575. * Parse properties from a JSON object
  18576. * @param serializationObject defines the JSON object
  18577. */
  18578. parse(serializationObject: any): void;
  18579. }
  18580. }
  18581. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18582. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18583. import { Effect } from "babylonjs/Materials/effect";
  18584. import { Particle } from "babylonjs/Particles/particle";
  18585. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18586. /**
  18587. * Particle emitter emitting particles from a point.
  18588. * It emits the particles randomly between 2 given directions.
  18589. */
  18590. export class PointParticleEmitter implements IParticleEmitterType {
  18591. /**
  18592. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18593. */
  18594. direction1: Vector3;
  18595. /**
  18596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18597. */
  18598. direction2: Vector3;
  18599. /**
  18600. * Creates a new instance PointParticleEmitter
  18601. */
  18602. constructor();
  18603. /**
  18604. * Called by the particle System when the direction is computed for the created particle.
  18605. * @param worldMatrix is the world matrix of the particle system
  18606. * @param directionToUpdate is the direction vector to update with the result
  18607. * @param particle is the particle we are computed the direction for
  18608. */
  18609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18610. /**
  18611. * Called by the particle System when the position is computed for the created particle.
  18612. * @param worldMatrix is the world matrix of the particle system
  18613. * @param positionToUpdate is the position vector to update with the result
  18614. * @param particle is the particle we are computed the position for
  18615. */
  18616. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18617. /**
  18618. * Clones the current emitter and returns a copy of it
  18619. * @returns the new emitter
  18620. */
  18621. clone(): PointParticleEmitter;
  18622. /**
  18623. * Called by the GPUParticleSystem to setup the update shader
  18624. * @param effect defines the update shader
  18625. */
  18626. applyToShader(effect: Effect): void;
  18627. /**
  18628. * Returns a string to use to update the GPU particles update shader
  18629. * @returns a string containng the defines string
  18630. */
  18631. getEffectDefines(): string;
  18632. /**
  18633. * Returns the string "PointParticleEmitter"
  18634. * @returns a string containing the class name
  18635. */
  18636. getClassName(): string;
  18637. /**
  18638. * Serializes the particle system to a JSON object.
  18639. * @returns the JSON object
  18640. */
  18641. serialize(): any;
  18642. /**
  18643. * Parse properties from a JSON object
  18644. * @param serializationObject defines the JSON object
  18645. */
  18646. parse(serializationObject: any): void;
  18647. }
  18648. }
  18649. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18650. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18651. import { Effect } from "babylonjs/Materials/effect";
  18652. import { Particle } from "babylonjs/Particles/particle";
  18653. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18654. /**
  18655. * Particle emitter emitting particles from the inside of a sphere.
  18656. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18657. */
  18658. export class SphereParticleEmitter implements IParticleEmitterType {
  18659. /**
  18660. * The radius of the emission sphere.
  18661. */
  18662. radius: number;
  18663. /**
  18664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18665. */
  18666. radiusRange: number;
  18667. /**
  18668. * How much to randomize the particle direction [0-1].
  18669. */
  18670. directionRandomizer: number;
  18671. /**
  18672. * Creates a new instance SphereParticleEmitter
  18673. * @param radius the radius of the emission sphere (1 by default)
  18674. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18675. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18676. */
  18677. constructor(
  18678. /**
  18679. * The radius of the emission sphere.
  18680. */
  18681. radius?: number,
  18682. /**
  18683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18684. */
  18685. radiusRange?: number,
  18686. /**
  18687. * How much to randomize the particle direction [0-1].
  18688. */
  18689. directionRandomizer?: number);
  18690. /**
  18691. * Called by the particle System when the direction is computed for the created particle.
  18692. * @param worldMatrix is the world matrix of the particle system
  18693. * @param directionToUpdate is the direction vector to update with the result
  18694. * @param particle is the particle we are computed the direction for
  18695. */
  18696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18697. /**
  18698. * Called by the particle System when the position is computed for the created particle.
  18699. * @param worldMatrix is the world matrix of the particle system
  18700. * @param positionToUpdate is the position vector to update with the result
  18701. * @param particle is the particle we are computed the position for
  18702. */
  18703. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18704. /**
  18705. * Clones the current emitter and returns a copy of it
  18706. * @returns the new emitter
  18707. */
  18708. clone(): SphereParticleEmitter;
  18709. /**
  18710. * Called by the GPUParticleSystem to setup the update shader
  18711. * @param effect defines the update shader
  18712. */
  18713. applyToShader(effect: Effect): void;
  18714. /**
  18715. * Returns a string to use to update the GPU particles update shader
  18716. * @returns a string containng the defines string
  18717. */
  18718. getEffectDefines(): string;
  18719. /**
  18720. * Returns the string "SphereParticleEmitter"
  18721. * @returns a string containing the class name
  18722. */
  18723. getClassName(): string;
  18724. /**
  18725. * Serializes the particle system to a JSON object.
  18726. * @returns the JSON object
  18727. */
  18728. serialize(): any;
  18729. /**
  18730. * Parse properties from a JSON object
  18731. * @param serializationObject defines the JSON object
  18732. */
  18733. parse(serializationObject: any): void;
  18734. }
  18735. /**
  18736. * Particle emitter emitting particles from the inside of a sphere.
  18737. * It emits the particles randomly between two vectors.
  18738. */
  18739. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18740. /**
  18741. * The min limit of the emission direction.
  18742. */
  18743. direction1: Vector3;
  18744. /**
  18745. * The max limit of the emission direction.
  18746. */
  18747. direction2: Vector3;
  18748. /**
  18749. * Creates a new instance SphereDirectedParticleEmitter
  18750. * @param radius the radius of the emission sphere (1 by default)
  18751. * @param direction1 the min limit of the emission direction (up vector by default)
  18752. * @param direction2 the max limit of the emission direction (up vector by default)
  18753. */
  18754. constructor(radius?: number,
  18755. /**
  18756. * The min limit of the emission direction.
  18757. */
  18758. direction1?: Vector3,
  18759. /**
  18760. * The max limit of the emission direction.
  18761. */
  18762. direction2?: Vector3);
  18763. /**
  18764. * Called by the particle System when the direction is computed for the created particle.
  18765. * @param worldMatrix is the world matrix of the particle system
  18766. * @param directionToUpdate is the direction vector to update with the result
  18767. * @param particle is the particle we are computed the direction for
  18768. */
  18769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18770. /**
  18771. * Clones the current emitter and returns a copy of it
  18772. * @returns the new emitter
  18773. */
  18774. clone(): SphereDirectedParticleEmitter;
  18775. /**
  18776. * Called by the GPUParticleSystem to setup the update shader
  18777. * @param effect defines the update shader
  18778. */
  18779. applyToShader(effect: Effect): void;
  18780. /**
  18781. * Returns a string to use to update the GPU particles update shader
  18782. * @returns a string containng the defines string
  18783. */
  18784. getEffectDefines(): string;
  18785. /**
  18786. * Returns the string "SphereDirectedParticleEmitter"
  18787. * @returns a string containing the class name
  18788. */
  18789. getClassName(): string;
  18790. /**
  18791. * Serializes the particle system to a JSON object.
  18792. * @returns the JSON object
  18793. */
  18794. serialize(): any;
  18795. /**
  18796. * Parse properties from a JSON object
  18797. * @param serializationObject defines the JSON object
  18798. */
  18799. parse(serializationObject: any): void;
  18800. }
  18801. }
  18802. declare module "babylonjs/Particles/EmitterTypes/index" {
  18803. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18804. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18805. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18806. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18807. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18808. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18809. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18810. }
  18811. declare module "babylonjs/Particles/IParticleSystem" {
  18812. import { Nullable } from "babylonjs/types";
  18813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18814. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18817. import { Texture } from "babylonjs/Materials/Textures/texture";
  18818. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18819. import { Scene } from "babylonjs/scene";
  18820. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18821. import { Animation } from "babylonjs/Animations/animation";
  18822. /**
  18823. * Interface representing a particle system in Babylon.js.
  18824. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18825. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18826. */
  18827. export interface IParticleSystem {
  18828. /**
  18829. * List of animations used by the particle system.
  18830. */
  18831. animations: Animation[];
  18832. /**
  18833. * The id of the Particle system.
  18834. */
  18835. id: string;
  18836. /**
  18837. * The name of the Particle system.
  18838. */
  18839. name: string;
  18840. /**
  18841. * The emitter represents the Mesh or position we are attaching the particle system to.
  18842. */
  18843. emitter: Nullable<AbstractMesh | Vector3>;
  18844. /**
  18845. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18846. */
  18847. isBillboardBased: boolean;
  18848. /**
  18849. * The rendering group used by the Particle system to chose when to render.
  18850. */
  18851. renderingGroupId: number;
  18852. /**
  18853. * The layer mask we are rendering the particles through.
  18854. */
  18855. layerMask: number;
  18856. /**
  18857. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18858. */
  18859. updateSpeed: number;
  18860. /**
  18861. * The amount of time the particle system is running (depends of the overall update speed).
  18862. */
  18863. targetStopDuration: number;
  18864. /**
  18865. * The texture used to render each particle. (this can be a spritesheet)
  18866. */
  18867. particleTexture: Nullable<Texture>;
  18868. /**
  18869. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18870. */
  18871. blendMode: number;
  18872. /**
  18873. * Minimum life time of emitting particles.
  18874. */
  18875. minLifeTime: number;
  18876. /**
  18877. * Maximum life time of emitting particles.
  18878. */
  18879. maxLifeTime: number;
  18880. /**
  18881. * Minimum Size of emitting particles.
  18882. */
  18883. minSize: number;
  18884. /**
  18885. * Maximum Size of emitting particles.
  18886. */
  18887. maxSize: number;
  18888. /**
  18889. * Minimum scale of emitting particles on X axis.
  18890. */
  18891. minScaleX: number;
  18892. /**
  18893. * Maximum scale of emitting particles on X axis.
  18894. */
  18895. maxScaleX: number;
  18896. /**
  18897. * Minimum scale of emitting particles on Y axis.
  18898. */
  18899. minScaleY: number;
  18900. /**
  18901. * Maximum scale of emitting particles on Y axis.
  18902. */
  18903. maxScaleY: number;
  18904. /**
  18905. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18906. */
  18907. color1: Color4;
  18908. /**
  18909. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18910. */
  18911. color2: Color4;
  18912. /**
  18913. * Color the particle will have at the end of its lifetime.
  18914. */
  18915. colorDead: Color4;
  18916. /**
  18917. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18918. */
  18919. emitRate: number;
  18920. /**
  18921. * You can use gravity if you want to give an orientation to your particles.
  18922. */
  18923. gravity: Vector3;
  18924. /**
  18925. * Minimum power of emitting particles.
  18926. */
  18927. minEmitPower: number;
  18928. /**
  18929. * Maximum power of emitting particles.
  18930. */
  18931. maxEmitPower: number;
  18932. /**
  18933. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18934. */
  18935. minAngularSpeed: number;
  18936. /**
  18937. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18938. */
  18939. maxAngularSpeed: number;
  18940. /**
  18941. * Gets or sets the minimal initial rotation in radians.
  18942. */
  18943. minInitialRotation: number;
  18944. /**
  18945. * Gets or sets the maximal initial rotation in radians.
  18946. */
  18947. maxInitialRotation: number;
  18948. /**
  18949. * The particle emitter type defines the emitter used by the particle system.
  18950. * It can be for example box, sphere, or cone...
  18951. */
  18952. particleEmitterType: Nullable<IParticleEmitterType>;
  18953. /**
  18954. * Defines the delay in milliseconds before starting the system (0 by default)
  18955. */
  18956. startDelay: number;
  18957. /**
  18958. * 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
  18959. */
  18960. preWarmCycles: number;
  18961. /**
  18962. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18963. */
  18964. preWarmStepOffset: number;
  18965. /**
  18966. * 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)
  18967. */
  18968. spriteCellChangeSpeed: number;
  18969. /**
  18970. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18971. */
  18972. startSpriteCellID: number;
  18973. /**
  18974. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18975. */
  18976. endSpriteCellID: number;
  18977. /**
  18978. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18979. */
  18980. spriteCellWidth: number;
  18981. /**
  18982. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18983. */
  18984. spriteCellHeight: number;
  18985. /**
  18986. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18987. */
  18988. spriteRandomStartCell: boolean;
  18989. /**
  18990. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18991. */
  18992. isAnimationSheetEnabled: boolean;
  18993. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18994. translationPivot: Vector2;
  18995. /**
  18996. * Gets or sets a texture used to add random noise to particle positions
  18997. */
  18998. noiseTexture: Nullable<BaseTexture>;
  18999. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19000. noiseStrength: Vector3;
  19001. /**
  19002. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19003. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19004. */
  19005. billboardMode: number;
  19006. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19007. limitVelocityDamping: number;
  19008. /**
  19009. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19010. */
  19011. beginAnimationOnStart: boolean;
  19012. /**
  19013. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19014. */
  19015. beginAnimationFrom: number;
  19016. /**
  19017. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19018. */
  19019. beginAnimationTo: number;
  19020. /**
  19021. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19022. */
  19023. beginAnimationLoop: boolean;
  19024. /**
  19025. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19026. */
  19027. disposeOnStop: boolean;
  19028. /**
  19029. * Gets the maximum number of particles active at the same time.
  19030. * @returns The max number of active particles.
  19031. */
  19032. getCapacity(): number;
  19033. /**
  19034. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19035. * @returns True if it has been started, otherwise false.
  19036. */
  19037. isStarted(): boolean;
  19038. /**
  19039. * Animates the particle system for this frame.
  19040. */
  19041. animate(): void;
  19042. /**
  19043. * Renders the particle system in its current state.
  19044. * @returns the current number of particles
  19045. */
  19046. render(): number;
  19047. /**
  19048. * Dispose the particle system and frees its associated resources.
  19049. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19050. */
  19051. dispose(disposeTexture?: boolean): void;
  19052. /**
  19053. * Clones the particle system.
  19054. * @param name The name of the cloned object
  19055. * @param newEmitter The new emitter to use
  19056. * @returns the cloned particle system
  19057. */
  19058. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19059. /**
  19060. * Serializes the particle system to a JSON object.
  19061. * @returns the JSON object
  19062. */
  19063. serialize(): any;
  19064. /**
  19065. * Rebuild the particle system
  19066. */
  19067. rebuild(): void;
  19068. /**
  19069. * Starts the particle system and begins to emit
  19070. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19071. */
  19072. start(delay?: number): void;
  19073. /**
  19074. * Stops the particle system.
  19075. */
  19076. stop(): void;
  19077. /**
  19078. * Remove all active particles
  19079. */
  19080. reset(): void;
  19081. /**
  19082. * Is this system ready to be used/rendered
  19083. * @return true if the system is ready
  19084. */
  19085. isReady(): boolean;
  19086. /**
  19087. * Adds a new color gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param color1 defines the color to affect to the specified gradient
  19090. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19091. * @returns the current particle system
  19092. */
  19093. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19094. /**
  19095. * Remove a specific color gradient
  19096. * @param gradient defines the gradient to remove
  19097. * @returns the current particle system
  19098. */
  19099. removeColorGradient(gradient: number): IParticleSystem;
  19100. /**
  19101. * Adds a new size gradient
  19102. * @param gradient defines the gradient to use (between 0 and 1)
  19103. * @param factor defines the size factor to affect to the specified gradient
  19104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19105. * @returns the current particle system
  19106. */
  19107. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19108. /**
  19109. * Remove a specific size gradient
  19110. * @param gradient defines the gradient to remove
  19111. * @returns the current particle system
  19112. */
  19113. removeSizeGradient(gradient: number): IParticleSystem;
  19114. /**
  19115. * Gets the current list of color gradients.
  19116. * You must use addColorGradient and removeColorGradient to udpate this list
  19117. * @returns the list of color gradients
  19118. */
  19119. getColorGradients(): Nullable<Array<ColorGradient>>;
  19120. /**
  19121. * Gets the current list of size gradients.
  19122. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19123. * @returns the list of size gradients
  19124. */
  19125. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19126. /**
  19127. * Gets the current list of angular speed gradients.
  19128. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19129. * @returns the list of angular speed gradients
  19130. */
  19131. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19132. /**
  19133. * Adds a new angular speed gradient
  19134. * @param gradient defines the gradient to use (between 0 and 1)
  19135. * @param factor defines the angular speed to affect to the specified gradient
  19136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19137. * @returns the current particle system
  19138. */
  19139. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19140. /**
  19141. * Remove a specific angular speed gradient
  19142. * @param gradient defines the gradient to remove
  19143. * @returns the current particle system
  19144. */
  19145. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19146. /**
  19147. * Gets the current list of velocity gradients.
  19148. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19149. * @returns the list of velocity gradients
  19150. */
  19151. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new velocity gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param factor defines the velocity to affect to the specified gradient
  19156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19157. * @returns the current particle system
  19158. */
  19159. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19160. /**
  19161. * Remove a specific velocity gradient
  19162. * @param gradient defines the gradient to remove
  19163. * @returns the current particle system
  19164. */
  19165. removeVelocityGradient(gradient: number): IParticleSystem;
  19166. /**
  19167. * Gets the current list of limit velocity gradients.
  19168. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19169. * @returns the list of limit velocity gradients
  19170. */
  19171. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19172. /**
  19173. * Adds a new limit velocity gradient
  19174. * @param gradient defines the gradient to use (between 0 and 1)
  19175. * @param factor defines the limit velocity to affect to the specified gradient
  19176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19177. * @returns the current particle system
  19178. */
  19179. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19180. /**
  19181. * Remove a specific limit velocity gradient
  19182. * @param gradient defines the gradient to remove
  19183. * @returns the current particle system
  19184. */
  19185. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19186. /**
  19187. * Adds a new drag gradient
  19188. * @param gradient defines the gradient to use (between 0 and 1)
  19189. * @param factor defines the drag to affect to the specified gradient
  19190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19191. * @returns the current particle system
  19192. */
  19193. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19194. /**
  19195. * Remove a specific drag gradient
  19196. * @param gradient defines the gradient to remove
  19197. * @returns the current particle system
  19198. */
  19199. removeDragGradient(gradient: number): IParticleSystem;
  19200. /**
  19201. * Gets the current list of drag gradients.
  19202. * You must use addDragGradient and removeDragGradient to udpate this list
  19203. * @returns the list of drag gradients
  19204. */
  19205. getDragGradients(): Nullable<Array<FactorGradient>>;
  19206. /**
  19207. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19208. * @param gradient defines the gradient to use (between 0 and 1)
  19209. * @param factor defines the emit rate to affect to the specified gradient
  19210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19211. * @returns the current particle system
  19212. */
  19213. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19214. /**
  19215. * Remove a specific emit rate gradient
  19216. * @param gradient defines the gradient to remove
  19217. * @returns the current particle system
  19218. */
  19219. removeEmitRateGradient(gradient: number): IParticleSystem;
  19220. /**
  19221. * Gets the current list of emit rate gradients.
  19222. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19223. * @returns the list of emit rate gradients
  19224. */
  19225. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19226. /**
  19227. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19228. * @param gradient defines the gradient to use (between 0 and 1)
  19229. * @param factor defines the start size to affect to the specified gradient
  19230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19231. * @returns the current particle system
  19232. */
  19233. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19234. /**
  19235. * Remove a specific start size gradient
  19236. * @param gradient defines the gradient to remove
  19237. * @returns the current particle system
  19238. */
  19239. removeStartSizeGradient(gradient: number): IParticleSystem;
  19240. /**
  19241. * Gets the current list of start size gradients.
  19242. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19243. * @returns the list of start size gradients
  19244. */
  19245. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19246. /**
  19247. * Adds a new life time gradient
  19248. * @param gradient defines the gradient to use (between 0 and 1)
  19249. * @param factor defines the life time factor to affect to the specified gradient
  19250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19251. * @returns the current particle system
  19252. */
  19253. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19254. /**
  19255. * Remove a specific life time gradient
  19256. * @param gradient defines the gradient to remove
  19257. * @returns the current particle system
  19258. */
  19259. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19260. /**
  19261. * Gets the current list of life time gradients.
  19262. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19263. * @returns the list of life time gradients
  19264. */
  19265. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19266. /**
  19267. * Gets the current list of color gradients.
  19268. * You must use addColorGradient and removeColorGradient to udpate this list
  19269. * @returns the list of color gradients
  19270. */
  19271. getColorGradients(): Nullable<Array<ColorGradient>>;
  19272. /**
  19273. * Adds a new ramp gradient used to remap particle colors
  19274. * @param gradient defines the gradient to use (between 0 and 1)
  19275. * @param color defines the color to affect to the specified gradient
  19276. * @returns the current particle system
  19277. */
  19278. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19279. /**
  19280. * Gets the current list of ramp gradients.
  19281. * You must use addRampGradient and removeRampGradient to udpate this list
  19282. * @returns the list of ramp gradients
  19283. */
  19284. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19285. /** Gets or sets a boolean indicating that ramp gradients must be used
  19286. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19287. */
  19288. useRampGradients: boolean;
  19289. /**
  19290. * Adds a new color remap gradient
  19291. * @param gradient defines the gradient to use (between 0 and 1)
  19292. * @param min defines the color remap minimal range
  19293. * @param max defines the color remap maximal range
  19294. * @returns the current particle system
  19295. */
  19296. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19297. /**
  19298. * Gets the current list of color remap gradients.
  19299. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19300. * @returns the list of color remap gradients
  19301. */
  19302. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19303. /**
  19304. * Adds a new alpha remap gradient
  19305. * @param gradient defines the gradient to use (between 0 and 1)
  19306. * @param min defines the alpha remap minimal range
  19307. * @param max defines the alpha remap maximal range
  19308. * @returns the current particle system
  19309. */
  19310. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of alpha remap gradients.
  19313. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19314. * @returns the list of alpha remap gradients
  19315. */
  19316. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19319. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19320. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19321. * @returns the emitter
  19322. */
  19323. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19324. /**
  19325. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19326. * @param radius The radius of the hemisphere to emit from
  19327. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19328. * @returns the emitter
  19329. */
  19330. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19331. /**
  19332. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19333. * @param radius The radius of the sphere to emit from
  19334. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19335. * @returns the emitter
  19336. */
  19337. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19338. /**
  19339. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19340. * @param radius The radius of the sphere to emit from
  19341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19343. * @returns the emitter
  19344. */
  19345. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19346. /**
  19347. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19348. * @param radius The radius of the emission cylinder
  19349. * @param height The height of the emission cylinder
  19350. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19351. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19352. * @returns the emitter
  19353. */
  19354. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19355. /**
  19356. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19357. * @param radius The radius of the cylinder to emit from
  19358. * @param height The height of the emission cylinder
  19359. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19360. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19361. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19362. * @returns the emitter
  19363. */
  19364. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19365. /**
  19366. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19367. * @param radius The radius of the cone to emit from
  19368. * @param angle The base angle of the cone
  19369. * @returns the emitter
  19370. */
  19371. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19372. /**
  19373. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19374. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19375. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19376. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19377. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19378. * @returns the emitter
  19379. */
  19380. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19381. /**
  19382. * Get hosting scene
  19383. * @returns the scene
  19384. */
  19385. getScene(): Scene;
  19386. }
  19387. }
  19388. declare module "babylonjs/Meshes/instancedMesh" {
  19389. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19391. import { Camera } from "babylonjs/Cameras/camera";
  19392. import { Node } from "babylonjs/node";
  19393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19394. import { Mesh } from "babylonjs/Meshes/mesh";
  19395. import { Material } from "babylonjs/Materials/material";
  19396. import { Skeleton } from "babylonjs/Bones/skeleton";
  19397. import { Light } from "babylonjs/Lights/light";
  19398. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19399. /**
  19400. * Creates an instance based on a source mesh.
  19401. */
  19402. export class InstancedMesh extends AbstractMesh {
  19403. private _sourceMesh;
  19404. private _currentLOD;
  19405. /** @hidden */
  19406. _indexInSourceMeshInstanceArray: number;
  19407. constructor(name: string, source: Mesh);
  19408. /**
  19409. * Returns the string "InstancedMesh".
  19410. */
  19411. getClassName(): string;
  19412. /** Gets the list of lights affecting that mesh */
  19413. readonly lightSources: Light[];
  19414. _resyncLightSources(): void;
  19415. _resyncLighSource(light: Light): void;
  19416. _removeLightSource(light: Light, dispose: boolean): void;
  19417. /**
  19418. * If the source mesh receives shadows
  19419. */
  19420. readonly receiveShadows: boolean;
  19421. /**
  19422. * The material of the source mesh
  19423. */
  19424. readonly material: Nullable<Material>;
  19425. /**
  19426. * Visibility of the source mesh
  19427. */
  19428. readonly visibility: number;
  19429. /**
  19430. * Skeleton of the source mesh
  19431. */
  19432. readonly skeleton: Nullable<Skeleton>;
  19433. /**
  19434. * Rendering ground id of the source mesh
  19435. */
  19436. renderingGroupId: number;
  19437. /**
  19438. * Returns the total number of vertices (integer).
  19439. */
  19440. getTotalVertices(): number;
  19441. /**
  19442. * Returns a positive integer : the total number of indices in this mesh geometry.
  19443. * @returns the numner of indices or zero if the mesh has no geometry.
  19444. */
  19445. getTotalIndices(): number;
  19446. /**
  19447. * The source mesh of the instance
  19448. */
  19449. readonly sourceMesh: Mesh;
  19450. /**
  19451. * Is this node ready to be used/rendered
  19452. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19453. * @return {boolean} is it ready
  19454. */
  19455. isReady(completeCheck?: boolean): boolean;
  19456. /**
  19457. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19458. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19459. * @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.
  19460. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19461. */
  19462. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19463. /**
  19464. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19465. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19466. * The `data` are either a numeric array either a Float32Array.
  19467. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19468. * 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).
  19469. * Note that a new underlying VertexBuffer object is created each call.
  19470. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19471. *
  19472. * Possible `kind` values :
  19473. * - VertexBuffer.PositionKind
  19474. * - VertexBuffer.UVKind
  19475. * - VertexBuffer.UV2Kind
  19476. * - VertexBuffer.UV3Kind
  19477. * - VertexBuffer.UV4Kind
  19478. * - VertexBuffer.UV5Kind
  19479. * - VertexBuffer.UV6Kind
  19480. * - VertexBuffer.ColorKind
  19481. * - VertexBuffer.MatricesIndicesKind
  19482. * - VertexBuffer.MatricesIndicesExtraKind
  19483. * - VertexBuffer.MatricesWeightsKind
  19484. * - VertexBuffer.MatricesWeightsExtraKind
  19485. *
  19486. * Returns the Mesh.
  19487. */
  19488. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19489. /**
  19490. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19491. * If the mesh has no geometry, it is simply returned as it is.
  19492. * The `data` are either a numeric array either a Float32Array.
  19493. * No new underlying VertexBuffer object is created.
  19494. * 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.
  19495. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19496. *
  19497. * Possible `kind` values :
  19498. * - VertexBuffer.PositionKind
  19499. * - VertexBuffer.UVKind
  19500. * - VertexBuffer.UV2Kind
  19501. * - VertexBuffer.UV3Kind
  19502. * - VertexBuffer.UV4Kind
  19503. * - VertexBuffer.UV5Kind
  19504. * - VertexBuffer.UV6Kind
  19505. * - VertexBuffer.ColorKind
  19506. * - VertexBuffer.MatricesIndicesKind
  19507. * - VertexBuffer.MatricesIndicesExtraKind
  19508. * - VertexBuffer.MatricesWeightsKind
  19509. * - VertexBuffer.MatricesWeightsExtraKind
  19510. *
  19511. * Returns the Mesh.
  19512. */
  19513. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19514. /**
  19515. * Sets the mesh indices.
  19516. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19517. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19518. * This method creates a new index buffer each call.
  19519. * Returns the Mesh.
  19520. */
  19521. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19522. /**
  19523. * Boolean : True if the mesh owns the requested kind of data.
  19524. */
  19525. isVerticesDataPresent(kind: string): boolean;
  19526. /**
  19527. * Returns an array of indices (IndicesArray).
  19528. */
  19529. getIndices(): Nullable<IndicesArray>;
  19530. readonly _positions: Nullable<Vector3[]>;
  19531. /**
  19532. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19533. * This means the mesh underlying bounding box and sphere are recomputed.
  19534. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19535. * @returns the current mesh
  19536. */
  19537. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19538. /** @hidden */
  19539. _preActivate(): InstancedMesh;
  19540. /** @hidden */
  19541. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19542. /** @hidden */
  19543. _postActivate(): void;
  19544. getWorldMatrix(): Matrix;
  19545. readonly isAnInstance: boolean;
  19546. /**
  19547. * Returns the current associated LOD AbstractMesh.
  19548. */
  19549. getLOD(camera: Camera): AbstractMesh;
  19550. /** @hidden */
  19551. _syncSubMeshes(): InstancedMesh;
  19552. /** @hidden */
  19553. _generatePointsArray(): boolean;
  19554. /**
  19555. * Creates a new InstancedMesh from the current mesh.
  19556. * - name (string) : the cloned mesh name
  19557. * - newParent (optional Node) : the optional Node to parent the clone to.
  19558. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19559. *
  19560. * Returns the clone.
  19561. */
  19562. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19563. /**
  19564. * Disposes the InstancedMesh.
  19565. * Returns nothing.
  19566. */
  19567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19568. }
  19569. module "babylonjs/Meshes/mesh" {
  19570. interface Mesh {
  19571. /**
  19572. * Register a custom buffer that will be instanced
  19573. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19574. * @param kind defines the buffer kind
  19575. * @param stride defines the stride in floats
  19576. */
  19577. registerInstancedBuffer(kind: string, stride: number): void;
  19578. /** @hidden */
  19579. _userInstancedBuffersStorage: {
  19580. data: {
  19581. [key: string]: Float32Array;
  19582. };
  19583. sizes: {
  19584. [key: string]: number;
  19585. };
  19586. vertexBuffers: {
  19587. [key: string]: Nullable<VertexBuffer>;
  19588. };
  19589. strides: {
  19590. [key: string]: number;
  19591. };
  19592. };
  19593. }
  19594. }
  19595. module "babylonjs/Meshes/abstractMesh" {
  19596. interface AbstractMesh {
  19597. /**
  19598. * Object used to store instanced buffers defined by user
  19599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19600. */
  19601. instancedBuffers: {
  19602. [key: string]: any;
  19603. };
  19604. }
  19605. }
  19606. }
  19607. declare module "babylonjs/Materials/shaderMaterial" {
  19608. import { Scene } from "babylonjs/scene";
  19609. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19611. import { Mesh } from "babylonjs/Meshes/mesh";
  19612. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19614. import { Texture } from "babylonjs/Materials/Textures/texture";
  19615. import { Material } from "babylonjs/Materials/material";
  19616. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19617. /**
  19618. * Defines the options associated with the creation of a shader material.
  19619. */
  19620. export interface IShaderMaterialOptions {
  19621. /**
  19622. * Does the material work in alpha blend mode
  19623. */
  19624. needAlphaBlending: boolean;
  19625. /**
  19626. * Does the material work in alpha test mode
  19627. */
  19628. needAlphaTesting: boolean;
  19629. /**
  19630. * The list of attribute names used in the shader
  19631. */
  19632. attributes: string[];
  19633. /**
  19634. * The list of unifrom names used in the shader
  19635. */
  19636. uniforms: string[];
  19637. /**
  19638. * The list of UBO names used in the shader
  19639. */
  19640. uniformBuffers: string[];
  19641. /**
  19642. * The list of sampler names used in the shader
  19643. */
  19644. samplers: string[];
  19645. /**
  19646. * The list of defines used in the shader
  19647. */
  19648. defines: string[];
  19649. }
  19650. /**
  19651. * 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.
  19652. *
  19653. * This returned material effects how the mesh will look based on the code in the shaders.
  19654. *
  19655. * @see http://doc.babylonjs.com/how_to/shader_material
  19656. */
  19657. export class ShaderMaterial extends Material {
  19658. private _shaderPath;
  19659. private _options;
  19660. private _textures;
  19661. private _textureArrays;
  19662. private _floats;
  19663. private _ints;
  19664. private _floatsArrays;
  19665. private _colors3;
  19666. private _colors3Arrays;
  19667. private _colors4;
  19668. private _colors4Arrays;
  19669. private _vectors2;
  19670. private _vectors3;
  19671. private _vectors4;
  19672. private _matrices;
  19673. private _matrices3x3;
  19674. private _matrices2x2;
  19675. private _vectors2Arrays;
  19676. private _vectors3Arrays;
  19677. private _vectors4Arrays;
  19678. private _cachedWorldViewMatrix;
  19679. private _cachedWorldViewProjectionMatrix;
  19680. private _renderId;
  19681. /**
  19682. * Instantiate a new shader material.
  19683. * 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.
  19684. * This returned material effects how the mesh will look based on the code in the shaders.
  19685. * @see http://doc.babylonjs.com/how_to/shader_material
  19686. * @param name Define the name of the material in the scene
  19687. * @param scene Define the scene the material belongs to
  19688. * @param shaderPath Defines the route to the shader code in one of three ways:
  19689. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19690. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19691. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19692. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19693. * @param options Define the options used to create the shader
  19694. */
  19695. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19696. /**
  19697. * Gets the options used to compile the shader.
  19698. * They can be modified to trigger a new compilation
  19699. */
  19700. readonly options: IShaderMaterialOptions;
  19701. /**
  19702. * Gets the current class name of the material e.g. "ShaderMaterial"
  19703. * Mainly use in serialization.
  19704. * @returns the class name
  19705. */
  19706. getClassName(): string;
  19707. /**
  19708. * Specifies if the material will require alpha blending
  19709. * @returns a boolean specifying if alpha blending is needed
  19710. */
  19711. needAlphaBlending(): boolean;
  19712. /**
  19713. * Specifies if this material should be rendered in alpha test mode
  19714. * @returns a boolean specifying if an alpha test is needed.
  19715. */
  19716. needAlphaTesting(): boolean;
  19717. private _checkUniform;
  19718. /**
  19719. * Set a texture in the shader.
  19720. * @param name Define the name of the uniform samplers as defined in the shader
  19721. * @param texture Define the texture to bind to this sampler
  19722. * @return the material itself allowing "fluent" like uniform updates
  19723. */
  19724. setTexture(name: string, texture: Texture): ShaderMaterial;
  19725. /**
  19726. * Set a texture array in the shader.
  19727. * @param name Define the name of the uniform sampler array as defined in the shader
  19728. * @param textures Define the list of textures to bind to this sampler
  19729. * @return the material itself allowing "fluent" like uniform updates
  19730. */
  19731. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19732. /**
  19733. * Set a float in the shader.
  19734. * @param name Define the name of the uniform as defined in the shader
  19735. * @param value Define the value to give to the uniform
  19736. * @return the material itself allowing "fluent" like uniform updates
  19737. */
  19738. setFloat(name: string, value: number): ShaderMaterial;
  19739. /**
  19740. * Set a int in the shader.
  19741. * @param name Define the name of the uniform as defined in the shader
  19742. * @param value Define the value to give to the uniform
  19743. * @return the material itself allowing "fluent" like uniform updates
  19744. */
  19745. setInt(name: string, value: number): ShaderMaterial;
  19746. /**
  19747. * Set an array of floats in the shader.
  19748. * @param name Define the name of the uniform as defined in the shader
  19749. * @param value Define the value to give to the uniform
  19750. * @return the material itself allowing "fluent" like uniform updates
  19751. */
  19752. setFloats(name: string, value: number[]): ShaderMaterial;
  19753. /**
  19754. * Set a vec3 in the shader from a Color3.
  19755. * @param name Define the name of the uniform as defined in the shader
  19756. * @param value Define the value to give to the uniform
  19757. * @return the material itself allowing "fluent" like uniform updates
  19758. */
  19759. setColor3(name: string, value: Color3): ShaderMaterial;
  19760. /**
  19761. * Set a vec3 array in the shader from a Color3 array.
  19762. * @param name Define the name of the uniform as defined in the shader
  19763. * @param value Define the value to give to the uniform
  19764. * @return the material itself allowing "fluent" like uniform updates
  19765. */
  19766. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19767. /**
  19768. * Set a vec4 in the shader from a Color4.
  19769. * @param name Define the name of the uniform as defined in the shader
  19770. * @param value Define the value to give to the uniform
  19771. * @return the material itself allowing "fluent" like uniform updates
  19772. */
  19773. setColor4(name: string, value: Color4): ShaderMaterial;
  19774. /**
  19775. * Set a vec4 array in the shader from a Color4 array.
  19776. * @param name Define the name of the uniform as defined in the shader
  19777. * @param value Define the value to give to the uniform
  19778. * @return the material itself allowing "fluent" like uniform updates
  19779. */
  19780. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19781. /**
  19782. * Set a vec2 in the shader from a Vector2.
  19783. * @param name Define the name of the uniform as defined in the shader
  19784. * @param value Define the value to give to the uniform
  19785. * @return the material itself allowing "fluent" like uniform updates
  19786. */
  19787. setVector2(name: string, value: Vector2): ShaderMaterial;
  19788. /**
  19789. * Set a vec3 in the shader from a Vector3.
  19790. * @param name Define the name of the uniform as defined in the shader
  19791. * @param value Define the value to give to the uniform
  19792. * @return the material itself allowing "fluent" like uniform updates
  19793. */
  19794. setVector3(name: string, value: Vector3): ShaderMaterial;
  19795. /**
  19796. * Set a vec4 in the shader from a Vector4.
  19797. * @param name Define the name of the uniform as defined in the shader
  19798. * @param value Define the value to give to the uniform
  19799. * @return the material itself allowing "fluent" like uniform updates
  19800. */
  19801. setVector4(name: string, value: Vector4): ShaderMaterial;
  19802. /**
  19803. * Set a mat4 in the shader from a Matrix.
  19804. * @param name Define the name of the uniform as defined in the shader
  19805. * @param value Define the value to give to the uniform
  19806. * @return the material itself allowing "fluent" like uniform updates
  19807. */
  19808. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19809. /**
  19810. * Set a mat3 in the shader from a Float32Array.
  19811. * @param name Define the name of the uniform as defined in the shader
  19812. * @param value Define the value to give to the uniform
  19813. * @return the material itself allowing "fluent" like uniform updates
  19814. */
  19815. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19816. /**
  19817. * Set a mat2 in the shader from a Float32Array.
  19818. * @param name Define the name of the uniform as defined in the shader
  19819. * @param value Define the value to give to the uniform
  19820. * @return the material itself allowing "fluent" like uniform updates
  19821. */
  19822. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19823. /**
  19824. * Set a vec2 array in the shader from a number array.
  19825. * @param name Define the name of the uniform as defined in the shader
  19826. * @param value Define the value to give to the uniform
  19827. * @return the material itself allowing "fluent" like uniform updates
  19828. */
  19829. setArray2(name: string, value: number[]): ShaderMaterial;
  19830. /**
  19831. * Set a vec3 array in the shader from a number array.
  19832. * @param name Define the name of the uniform as defined in the shader
  19833. * @param value Define the value to give to the uniform
  19834. * @return the material itself allowing "fluent" like uniform updates
  19835. */
  19836. setArray3(name: string, value: number[]): ShaderMaterial;
  19837. /**
  19838. * Set a vec4 array in the shader from a number array.
  19839. * @param name Define the name of the uniform as defined in the shader
  19840. * @param value Define the value to give to the uniform
  19841. * @return the material itself allowing "fluent" like uniform updates
  19842. */
  19843. setArray4(name: string, value: number[]): ShaderMaterial;
  19844. private _checkCache;
  19845. /**
  19846. * Specifies that the submesh is ready to be used
  19847. * @param mesh defines the mesh to check
  19848. * @param subMesh defines which submesh to check
  19849. * @param useInstances specifies that instances should be used
  19850. * @returns a boolean indicating that the submesh is ready or not
  19851. */
  19852. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19853. /**
  19854. * Checks if the material is ready to render the requested mesh
  19855. * @param mesh Define the mesh to render
  19856. * @param useInstances Define whether or not the material is used with instances
  19857. * @returns true if ready, otherwise false
  19858. */
  19859. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19860. /**
  19861. * Binds the world matrix to the material
  19862. * @param world defines the world transformation matrix
  19863. */
  19864. bindOnlyWorldMatrix(world: Matrix): void;
  19865. /**
  19866. * Binds the material to the mesh
  19867. * @param world defines the world transformation matrix
  19868. * @param mesh defines the mesh to bind the material to
  19869. */
  19870. bind(world: Matrix, mesh?: Mesh): void;
  19871. /**
  19872. * Gets the active textures from the material
  19873. * @returns an array of textures
  19874. */
  19875. getActiveTextures(): BaseTexture[];
  19876. /**
  19877. * Specifies if the material uses a texture
  19878. * @param texture defines the texture to check against the material
  19879. * @returns a boolean specifying if the material uses the texture
  19880. */
  19881. hasTexture(texture: BaseTexture): boolean;
  19882. /**
  19883. * Makes a duplicate of the material, and gives it a new name
  19884. * @param name defines the new name for the duplicated material
  19885. * @returns the cloned material
  19886. */
  19887. clone(name: string): ShaderMaterial;
  19888. /**
  19889. * Disposes the material
  19890. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19891. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19892. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19893. */
  19894. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19895. /**
  19896. * Serializes this material in a JSON representation
  19897. * @returns the serialized material object
  19898. */
  19899. serialize(): any;
  19900. /**
  19901. * Creates a shader material from parsed shader material data
  19902. * @param source defines the JSON represnetation of the material
  19903. * @param scene defines the hosting scene
  19904. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19905. * @returns a new material
  19906. */
  19907. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19908. }
  19909. }
  19910. declare module "babylonjs/Shaders/color.fragment" {
  19911. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19912. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19913. /** @hidden */
  19914. export var colorPixelShader: {
  19915. name: string;
  19916. shader: string;
  19917. };
  19918. }
  19919. declare module "babylonjs/Shaders/color.vertex" {
  19920. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19921. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19922. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19923. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19924. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19925. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19926. /** @hidden */
  19927. export var colorVertexShader: {
  19928. name: string;
  19929. shader: string;
  19930. };
  19931. }
  19932. declare module "babylonjs/Meshes/linesMesh" {
  19933. import { Nullable } from "babylonjs/types";
  19934. import { Scene } from "babylonjs/scene";
  19935. import { Color3 } from "babylonjs/Maths/math.color";
  19936. import { Node } from "babylonjs/node";
  19937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19938. import { Mesh } from "babylonjs/Meshes/mesh";
  19939. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19940. import { Effect } from "babylonjs/Materials/effect";
  19941. import { Material } from "babylonjs/Materials/material";
  19942. import "babylonjs/Shaders/color.fragment";
  19943. import "babylonjs/Shaders/color.vertex";
  19944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19945. /**
  19946. * Line mesh
  19947. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19948. */
  19949. export class LinesMesh extends Mesh {
  19950. /**
  19951. * If vertex color should be applied to the mesh
  19952. */
  19953. readonly useVertexColor?: boolean | undefined;
  19954. /**
  19955. * If vertex alpha should be applied to the mesh
  19956. */
  19957. readonly useVertexAlpha?: boolean | undefined;
  19958. /**
  19959. * Color of the line (Default: White)
  19960. */
  19961. color: Color3;
  19962. /**
  19963. * Alpha of the line (Default: 1)
  19964. */
  19965. alpha: number;
  19966. /**
  19967. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19968. * This margin is expressed in world space coordinates, so its value may vary.
  19969. * Default value is 0.1
  19970. */
  19971. intersectionThreshold: number;
  19972. private _colorShader;
  19973. private color4;
  19974. /**
  19975. * Creates a new LinesMesh
  19976. * @param name defines the name
  19977. * @param scene defines the hosting scene
  19978. * @param parent defines the parent mesh if any
  19979. * @param source defines the optional source LinesMesh used to clone data from
  19980. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19981. * When false, achieved by calling a clone(), also passing False.
  19982. * This will make creation of children, recursive.
  19983. * @param useVertexColor defines if this LinesMesh supports vertex color
  19984. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19985. */
  19986. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19987. /**
  19988. * If vertex color should be applied to the mesh
  19989. */
  19990. useVertexColor?: boolean | undefined,
  19991. /**
  19992. * If vertex alpha should be applied to the mesh
  19993. */
  19994. useVertexAlpha?: boolean | undefined);
  19995. private _addClipPlaneDefine;
  19996. private _removeClipPlaneDefine;
  19997. isReady(): boolean;
  19998. /**
  19999. * Returns the string "LineMesh"
  20000. */
  20001. getClassName(): string;
  20002. /**
  20003. * @hidden
  20004. */
  20005. /**
  20006. * @hidden
  20007. */
  20008. material: Material;
  20009. /**
  20010. * @hidden
  20011. */
  20012. readonly checkCollisions: boolean;
  20013. /** @hidden */
  20014. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20015. /** @hidden */
  20016. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20017. /**
  20018. * Disposes of the line mesh
  20019. * @param doNotRecurse If children should be disposed
  20020. */
  20021. dispose(doNotRecurse?: boolean): void;
  20022. /**
  20023. * Returns a new LineMesh object cloned from the current one.
  20024. */
  20025. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20026. /**
  20027. * Creates a new InstancedLinesMesh object from the mesh model.
  20028. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20029. * @param name defines the name of the new instance
  20030. * @returns a new InstancedLinesMesh
  20031. */
  20032. createInstance(name: string): InstancedLinesMesh;
  20033. }
  20034. /**
  20035. * Creates an instance based on a source LinesMesh
  20036. */
  20037. export class InstancedLinesMesh extends InstancedMesh {
  20038. /**
  20039. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20040. * This margin is expressed in world space coordinates, so its value may vary.
  20041. * Initilized with the intersectionThreshold value of the source LinesMesh
  20042. */
  20043. intersectionThreshold: number;
  20044. constructor(name: string, source: LinesMesh);
  20045. /**
  20046. * Returns the string "InstancedLinesMesh".
  20047. */
  20048. getClassName(): string;
  20049. }
  20050. }
  20051. declare module "babylonjs/Shaders/line.fragment" {
  20052. /** @hidden */
  20053. export var linePixelShader: {
  20054. name: string;
  20055. shader: string;
  20056. };
  20057. }
  20058. declare module "babylonjs/Shaders/line.vertex" {
  20059. /** @hidden */
  20060. export var lineVertexShader: {
  20061. name: string;
  20062. shader: string;
  20063. };
  20064. }
  20065. declare module "babylonjs/Rendering/edgesRenderer" {
  20066. import { Nullable } from "babylonjs/types";
  20067. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20069. import { Vector3 } from "babylonjs/Maths/math.vector";
  20070. import { IDisposable } from "babylonjs/scene";
  20071. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20072. import "babylonjs/Shaders/line.fragment";
  20073. import "babylonjs/Shaders/line.vertex";
  20074. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20075. module "babylonjs/Meshes/abstractMesh" {
  20076. interface AbstractMesh {
  20077. /**
  20078. * Gets the edgesRenderer associated with the mesh
  20079. */
  20080. edgesRenderer: Nullable<EdgesRenderer>;
  20081. }
  20082. }
  20083. module "babylonjs/Meshes/linesMesh" {
  20084. interface LinesMesh {
  20085. /**
  20086. * Enables the edge rendering mode on the mesh.
  20087. * This mode makes the mesh edges visible
  20088. * @param epsilon defines the maximal distance between two angles to detect a face
  20089. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20090. * @returns the currentAbstractMesh
  20091. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20092. */
  20093. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20094. }
  20095. }
  20096. module "babylonjs/Meshes/linesMesh" {
  20097. interface InstancedLinesMesh {
  20098. /**
  20099. * Enables the edge rendering mode on the mesh.
  20100. * This mode makes the mesh edges visible
  20101. * @param epsilon defines the maximal distance between two angles to detect a face
  20102. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20103. * @returns the current InstancedLinesMesh
  20104. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20105. */
  20106. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20107. }
  20108. }
  20109. /**
  20110. * Defines the minimum contract an Edges renderer should follow.
  20111. */
  20112. export interface IEdgesRenderer extends IDisposable {
  20113. /**
  20114. * Gets or sets a boolean indicating if the edgesRenderer is active
  20115. */
  20116. isEnabled: boolean;
  20117. /**
  20118. * Renders the edges of the attached mesh,
  20119. */
  20120. render(): void;
  20121. /**
  20122. * Checks wether or not the edges renderer is ready to render.
  20123. * @return true if ready, otherwise false.
  20124. */
  20125. isReady(): boolean;
  20126. }
  20127. /**
  20128. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20129. */
  20130. export class EdgesRenderer implements IEdgesRenderer {
  20131. /**
  20132. * Define the size of the edges with an orthographic camera
  20133. */
  20134. edgesWidthScalerForOrthographic: number;
  20135. /**
  20136. * Define the size of the edges with a perspective camera
  20137. */
  20138. edgesWidthScalerForPerspective: number;
  20139. protected _source: AbstractMesh;
  20140. protected _linesPositions: number[];
  20141. protected _linesNormals: number[];
  20142. protected _linesIndices: number[];
  20143. protected _epsilon: number;
  20144. protected _indicesCount: number;
  20145. protected _lineShader: ShaderMaterial;
  20146. protected _ib: DataBuffer;
  20147. protected _buffers: {
  20148. [key: string]: Nullable<VertexBuffer>;
  20149. };
  20150. protected _checkVerticesInsteadOfIndices: boolean;
  20151. private _meshRebuildObserver;
  20152. private _meshDisposeObserver;
  20153. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20154. isEnabled: boolean;
  20155. /**
  20156. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20157. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20158. * @param source Mesh used to create edges
  20159. * @param epsilon sum of angles in adjacency to check for edge
  20160. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20161. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20162. */
  20163. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20164. protected _prepareRessources(): void;
  20165. /** @hidden */
  20166. _rebuild(): void;
  20167. /**
  20168. * Releases the required resources for the edges renderer
  20169. */
  20170. dispose(): void;
  20171. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20172. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20173. /**
  20174. * Checks if the pair of p0 and p1 is en edge
  20175. * @param faceIndex
  20176. * @param edge
  20177. * @param faceNormals
  20178. * @param p0
  20179. * @param p1
  20180. * @private
  20181. */
  20182. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20183. /**
  20184. * push line into the position, normal and index buffer
  20185. * @protected
  20186. */
  20187. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20188. /**
  20189. * Generates lines edges from adjacencjes
  20190. * @private
  20191. */
  20192. _generateEdgesLines(): void;
  20193. /**
  20194. * Checks wether or not the edges renderer is ready to render.
  20195. * @return true if ready, otherwise false.
  20196. */
  20197. isReady(): boolean;
  20198. /**
  20199. * Renders the edges of the attached mesh,
  20200. */
  20201. render(): void;
  20202. }
  20203. /**
  20204. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20205. */
  20206. export class LineEdgesRenderer extends EdgesRenderer {
  20207. /**
  20208. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20209. * @param source LineMesh used to generate edges
  20210. * @param epsilon not important (specified angle for edge detection)
  20211. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20212. */
  20213. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20214. /**
  20215. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20216. */
  20217. _generateEdgesLines(): void;
  20218. }
  20219. }
  20220. declare module "babylonjs/Rendering/renderingGroup" {
  20221. import { SmartArray } from "babylonjs/Misc/smartArray";
  20222. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20224. import { Nullable } from "babylonjs/types";
  20225. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20226. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20227. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20228. import { Material } from "babylonjs/Materials/material";
  20229. import { Scene } from "babylonjs/scene";
  20230. /**
  20231. * This represents the object necessary to create a rendering group.
  20232. * This is exclusively used and created by the rendering manager.
  20233. * To modify the behavior, you use the available helpers in your scene or meshes.
  20234. * @hidden
  20235. */
  20236. export class RenderingGroup {
  20237. index: number;
  20238. private static _zeroVector;
  20239. private _scene;
  20240. private _opaqueSubMeshes;
  20241. private _transparentSubMeshes;
  20242. private _alphaTestSubMeshes;
  20243. private _depthOnlySubMeshes;
  20244. private _particleSystems;
  20245. private _spriteManagers;
  20246. private _opaqueSortCompareFn;
  20247. private _alphaTestSortCompareFn;
  20248. private _transparentSortCompareFn;
  20249. private _renderOpaque;
  20250. private _renderAlphaTest;
  20251. private _renderTransparent;
  20252. /** @hidden */
  20253. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20254. onBeforeTransparentRendering: () => void;
  20255. /**
  20256. * Set the opaque sort comparison function.
  20257. * If null the sub meshes will be render in the order they were created
  20258. */
  20259. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20260. /**
  20261. * Set the alpha test sort comparison function.
  20262. * If null the sub meshes will be render in the order they were created
  20263. */
  20264. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20265. /**
  20266. * Set the transparent sort comparison function.
  20267. * If null the sub meshes will be render in the order they were created
  20268. */
  20269. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20270. /**
  20271. * Creates a new rendering group.
  20272. * @param index The rendering group index
  20273. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20274. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20275. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20276. */
  20277. 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>);
  20278. /**
  20279. * Render all the sub meshes contained in the group.
  20280. * @param customRenderFunction Used to override the default render behaviour of the group.
  20281. * @returns true if rendered some submeshes.
  20282. */
  20283. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20284. /**
  20285. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20286. * @param subMeshes The submeshes to render
  20287. */
  20288. private renderOpaqueSorted;
  20289. /**
  20290. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20291. * @param subMeshes The submeshes to render
  20292. */
  20293. private renderAlphaTestSorted;
  20294. /**
  20295. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20296. * @param subMeshes The submeshes to render
  20297. */
  20298. private renderTransparentSorted;
  20299. /**
  20300. * Renders the submeshes in a specified order.
  20301. * @param subMeshes The submeshes to sort before render
  20302. * @param sortCompareFn The comparison function use to sort
  20303. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20304. * @param transparent Specifies to activate blending if true
  20305. */
  20306. private static renderSorted;
  20307. /**
  20308. * Renders the submeshes in the order they were dispatched (no sort applied).
  20309. * @param subMeshes The submeshes to render
  20310. */
  20311. private static renderUnsorted;
  20312. /**
  20313. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20314. * are rendered back to front if in the same alpha index.
  20315. *
  20316. * @param a The first submesh
  20317. * @param b The second submesh
  20318. * @returns The result of the comparison
  20319. */
  20320. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20321. /**
  20322. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20323. * are rendered back to front.
  20324. *
  20325. * @param a The first submesh
  20326. * @param b The second submesh
  20327. * @returns The result of the comparison
  20328. */
  20329. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20330. /**
  20331. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20332. * are rendered front to back (prevent overdraw).
  20333. *
  20334. * @param a The first submesh
  20335. * @param b The second submesh
  20336. * @returns The result of the comparison
  20337. */
  20338. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20339. /**
  20340. * Resets the different lists of submeshes to prepare a new frame.
  20341. */
  20342. prepare(): void;
  20343. dispose(): void;
  20344. /**
  20345. * Inserts the submesh in its correct queue depending on its material.
  20346. * @param subMesh The submesh to dispatch
  20347. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20348. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20349. */
  20350. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20351. dispatchSprites(spriteManager: ISpriteManager): void;
  20352. dispatchParticles(particleSystem: IParticleSystem): void;
  20353. private _renderParticles;
  20354. private _renderSprites;
  20355. }
  20356. }
  20357. declare module "babylonjs/Rendering/renderingManager" {
  20358. import { Nullable } from "babylonjs/types";
  20359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20360. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20361. import { SmartArray } from "babylonjs/Misc/smartArray";
  20362. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20363. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20364. import { Material } from "babylonjs/Materials/material";
  20365. import { Scene } from "babylonjs/scene";
  20366. import { Camera } from "babylonjs/Cameras/camera";
  20367. /**
  20368. * Interface describing the different options available in the rendering manager
  20369. * regarding Auto Clear between groups.
  20370. */
  20371. export interface IRenderingManagerAutoClearSetup {
  20372. /**
  20373. * Defines whether or not autoclear is enable.
  20374. */
  20375. autoClear: boolean;
  20376. /**
  20377. * Defines whether or not to autoclear the depth buffer.
  20378. */
  20379. depth: boolean;
  20380. /**
  20381. * Defines whether or not to autoclear the stencil buffer.
  20382. */
  20383. stencil: boolean;
  20384. }
  20385. /**
  20386. * This class is used by the onRenderingGroupObservable
  20387. */
  20388. export class RenderingGroupInfo {
  20389. /**
  20390. * The Scene that being rendered
  20391. */
  20392. scene: Scene;
  20393. /**
  20394. * The camera currently used for the rendering pass
  20395. */
  20396. camera: Nullable<Camera>;
  20397. /**
  20398. * The ID of the renderingGroup being processed
  20399. */
  20400. renderingGroupId: number;
  20401. }
  20402. /**
  20403. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20404. * It is enable to manage the different groups as well as the different necessary sort functions.
  20405. * This should not be used directly aside of the few static configurations
  20406. */
  20407. export class RenderingManager {
  20408. /**
  20409. * The max id used for rendering groups (not included)
  20410. */
  20411. static MAX_RENDERINGGROUPS: number;
  20412. /**
  20413. * The min id used for rendering groups (included)
  20414. */
  20415. static MIN_RENDERINGGROUPS: number;
  20416. /**
  20417. * Used to globally prevent autoclearing scenes.
  20418. */
  20419. static AUTOCLEAR: boolean;
  20420. /**
  20421. * @hidden
  20422. */
  20423. _useSceneAutoClearSetup: boolean;
  20424. private _scene;
  20425. private _renderingGroups;
  20426. private _depthStencilBufferAlreadyCleaned;
  20427. private _autoClearDepthStencil;
  20428. private _customOpaqueSortCompareFn;
  20429. private _customAlphaTestSortCompareFn;
  20430. private _customTransparentSortCompareFn;
  20431. private _renderingGroupInfo;
  20432. /**
  20433. * Instantiates a new rendering group for a particular scene
  20434. * @param scene Defines the scene the groups belongs to
  20435. */
  20436. constructor(scene: Scene);
  20437. private _clearDepthStencilBuffer;
  20438. /**
  20439. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20440. * @hidden
  20441. */
  20442. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20443. /**
  20444. * Resets the different information of the group to prepare a new frame
  20445. * @hidden
  20446. */
  20447. reset(): void;
  20448. /**
  20449. * Dispose and release the group and its associated resources.
  20450. * @hidden
  20451. */
  20452. dispose(): void;
  20453. /**
  20454. * Clear the info related to rendering groups preventing retention points during dispose.
  20455. */
  20456. freeRenderingGroups(): void;
  20457. private _prepareRenderingGroup;
  20458. /**
  20459. * Add a sprite manager to the rendering manager in order to render it this frame.
  20460. * @param spriteManager Define the sprite manager to render
  20461. */
  20462. dispatchSprites(spriteManager: ISpriteManager): void;
  20463. /**
  20464. * Add a particle system to the rendering manager in order to render it this frame.
  20465. * @param particleSystem Define the particle system to render
  20466. */
  20467. dispatchParticles(particleSystem: IParticleSystem): void;
  20468. /**
  20469. * Add a submesh to the manager in order to render it this frame
  20470. * @param subMesh The submesh to dispatch
  20471. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20472. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20473. */
  20474. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20475. /**
  20476. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20477. * This allowed control for front to back rendering or reversly depending of the special needs.
  20478. *
  20479. * @param renderingGroupId The rendering group id corresponding to its index
  20480. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20481. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20482. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20483. */
  20484. 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;
  20485. /**
  20486. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20487. *
  20488. * @param renderingGroupId The rendering group id corresponding to its index
  20489. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20490. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20491. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20492. */
  20493. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20494. /**
  20495. * Gets the current auto clear configuration for one rendering group of the rendering
  20496. * manager.
  20497. * @param index the rendering group index to get the information for
  20498. * @returns The auto clear setup for the requested rendering group
  20499. */
  20500. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20501. }
  20502. }
  20503. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20504. import { Observable } from "babylonjs/Misc/observable";
  20505. import { SmartArray } from "babylonjs/Misc/smartArray";
  20506. import { Nullable } from "babylonjs/types";
  20507. import { Camera } from "babylonjs/Cameras/camera";
  20508. import { Scene } from "babylonjs/scene";
  20509. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20510. import { Color4 } from "babylonjs/Maths/math.color";
  20511. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20513. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20514. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20515. import { Texture } from "babylonjs/Materials/Textures/texture";
  20516. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20517. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20518. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20519. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20520. import { Engine } from "babylonjs/Engines/engine";
  20521. /**
  20522. * This Helps creating a texture that will be created from a camera in your scene.
  20523. * It is basically a dynamic texture that could be used to create special effects for instance.
  20524. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20525. */
  20526. export class RenderTargetTexture extends Texture {
  20527. isCube: boolean;
  20528. /**
  20529. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20530. */
  20531. static readonly REFRESHRATE_RENDER_ONCE: number;
  20532. /**
  20533. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20534. */
  20535. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20536. /**
  20537. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20538. * the central point of your effect and can save a lot of performances.
  20539. */
  20540. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20541. /**
  20542. * Use this predicate to dynamically define the list of mesh you want to render.
  20543. * If set, the renderList property will be overwritten.
  20544. */
  20545. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20546. private _renderList;
  20547. /**
  20548. * Use this list to define the list of mesh you want to render.
  20549. */
  20550. renderList: Nullable<Array<AbstractMesh>>;
  20551. private _hookArray;
  20552. /**
  20553. * Define if particles should be rendered in your texture.
  20554. */
  20555. renderParticles: boolean;
  20556. /**
  20557. * Define if sprites should be rendered in your texture.
  20558. */
  20559. renderSprites: boolean;
  20560. /**
  20561. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20562. */
  20563. coordinatesMode: number;
  20564. /**
  20565. * Define the camera used to render the texture.
  20566. */
  20567. activeCamera: Nullable<Camera>;
  20568. /**
  20569. * Override the render function of the texture with your own one.
  20570. */
  20571. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20572. /**
  20573. * Define if camera post processes should be use while rendering the texture.
  20574. */
  20575. useCameraPostProcesses: boolean;
  20576. /**
  20577. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20578. */
  20579. ignoreCameraViewport: boolean;
  20580. private _postProcessManager;
  20581. private _postProcesses;
  20582. private _resizeObserver;
  20583. /**
  20584. * An event triggered when the texture is unbind.
  20585. */
  20586. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20587. /**
  20588. * An event triggered when the texture is unbind.
  20589. */
  20590. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20591. private _onAfterUnbindObserver;
  20592. /**
  20593. * Set a after unbind callback in the texture.
  20594. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20595. */
  20596. onAfterUnbind: () => void;
  20597. /**
  20598. * An event triggered before rendering the texture
  20599. */
  20600. onBeforeRenderObservable: Observable<number>;
  20601. private _onBeforeRenderObserver;
  20602. /**
  20603. * Set a before render callback in the texture.
  20604. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20605. */
  20606. onBeforeRender: (faceIndex: number) => void;
  20607. /**
  20608. * An event triggered after rendering the texture
  20609. */
  20610. onAfterRenderObservable: Observable<number>;
  20611. private _onAfterRenderObserver;
  20612. /**
  20613. * Set a after render callback in the texture.
  20614. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20615. */
  20616. onAfterRender: (faceIndex: number) => void;
  20617. /**
  20618. * An event triggered after the texture clear
  20619. */
  20620. onClearObservable: Observable<Engine>;
  20621. private _onClearObserver;
  20622. /**
  20623. * Set a clear callback in the texture.
  20624. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20625. */
  20626. onClear: (Engine: Engine) => void;
  20627. /**
  20628. * An event triggered when the texture is resized.
  20629. */
  20630. onResizeObservable: Observable<RenderTargetTexture>;
  20631. /**
  20632. * Define the clear color of the Render Target if it should be different from the scene.
  20633. */
  20634. clearColor: Color4;
  20635. protected _size: number | {
  20636. width: number;
  20637. height: number;
  20638. };
  20639. protected _initialSizeParameter: number | {
  20640. width: number;
  20641. height: number;
  20642. } | {
  20643. ratio: number;
  20644. };
  20645. protected _sizeRatio: Nullable<number>;
  20646. /** @hidden */
  20647. _generateMipMaps: boolean;
  20648. protected _renderingManager: RenderingManager;
  20649. /** @hidden */
  20650. _waitingRenderList: string[];
  20651. protected _doNotChangeAspectRatio: boolean;
  20652. protected _currentRefreshId: number;
  20653. protected _refreshRate: number;
  20654. protected _textureMatrix: Matrix;
  20655. protected _samples: number;
  20656. protected _renderTargetOptions: RenderTargetCreationOptions;
  20657. /**
  20658. * Gets render target creation options that were used.
  20659. */
  20660. readonly renderTargetOptions: RenderTargetCreationOptions;
  20661. protected _engine: Engine;
  20662. protected _onRatioRescale(): void;
  20663. /**
  20664. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20665. * It must define where the camera used to render the texture is set
  20666. */
  20667. boundingBoxPosition: Vector3;
  20668. private _boundingBoxSize;
  20669. /**
  20670. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20671. * When defined, the cubemap will switch to local mode
  20672. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20673. * @example https://www.babylonjs-playground.com/#RNASML
  20674. */
  20675. boundingBoxSize: Vector3;
  20676. /**
  20677. * In case the RTT has been created with a depth texture, get the associated
  20678. * depth texture.
  20679. * Otherwise, return null.
  20680. */
  20681. depthStencilTexture: Nullable<InternalTexture>;
  20682. /**
  20683. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20684. * or used a shadow, depth texture...
  20685. * @param name The friendly name of the texture
  20686. * @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)
  20687. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20688. * @param generateMipMaps True if mip maps need to be generated after render.
  20689. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20690. * @param type The type of the buffer in the RTT (int, half float, float...)
  20691. * @param isCube True if a cube texture needs to be created
  20692. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20693. * @param generateDepthBuffer True to generate a depth buffer
  20694. * @param generateStencilBuffer True to generate a stencil buffer
  20695. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20696. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20697. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20698. */
  20699. constructor(name: string, size: number | {
  20700. width: number;
  20701. height: number;
  20702. } | {
  20703. ratio: number;
  20704. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20705. /**
  20706. * Creates a depth stencil texture.
  20707. * This is only available in WebGL 2 or with the depth texture extension available.
  20708. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20709. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20710. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20711. */
  20712. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20713. private _processSizeParameter;
  20714. /**
  20715. * Define the number of samples to use in case of MSAA.
  20716. * It defaults to one meaning no MSAA has been enabled.
  20717. */
  20718. samples: number;
  20719. /**
  20720. * Resets the refresh counter of the texture and start bak from scratch.
  20721. * Could be useful to regenerate the texture if it is setup to render only once.
  20722. */
  20723. resetRefreshCounter(): void;
  20724. /**
  20725. * Define the refresh rate of the texture or the rendering frequency.
  20726. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20727. */
  20728. refreshRate: number;
  20729. /**
  20730. * Adds a post process to the render target rendering passes.
  20731. * @param postProcess define the post process to add
  20732. */
  20733. addPostProcess(postProcess: PostProcess): void;
  20734. /**
  20735. * Clear all the post processes attached to the render target
  20736. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20737. */
  20738. clearPostProcesses(dispose?: boolean): void;
  20739. /**
  20740. * Remove one of the post process from the list of attached post processes to the texture
  20741. * @param postProcess define the post process to remove from the list
  20742. */
  20743. removePostProcess(postProcess: PostProcess): void;
  20744. /** @hidden */
  20745. _shouldRender(): boolean;
  20746. /**
  20747. * Gets the actual render size of the texture.
  20748. * @returns the width of the render size
  20749. */
  20750. getRenderSize(): number;
  20751. /**
  20752. * Gets the actual render width of the texture.
  20753. * @returns the width of the render size
  20754. */
  20755. getRenderWidth(): number;
  20756. /**
  20757. * Gets the actual render height of the texture.
  20758. * @returns the height of the render size
  20759. */
  20760. getRenderHeight(): number;
  20761. /**
  20762. * Get if the texture can be rescaled or not.
  20763. */
  20764. readonly canRescale: boolean;
  20765. /**
  20766. * Resize the texture using a ratio.
  20767. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20768. */
  20769. scale(ratio: number): void;
  20770. /**
  20771. * Get the texture reflection matrix used to rotate/transform the reflection.
  20772. * @returns the reflection matrix
  20773. */
  20774. getReflectionTextureMatrix(): Matrix;
  20775. /**
  20776. * Resize the texture to a new desired size.
  20777. * Be carrefull as it will recreate all the data in the new texture.
  20778. * @param size Define the new size. It can be:
  20779. * - a number for squared texture,
  20780. * - an object containing { width: number, height: number }
  20781. * - or an object containing a ratio { ratio: number }
  20782. */
  20783. resize(size: number | {
  20784. width: number;
  20785. height: number;
  20786. } | {
  20787. ratio: number;
  20788. }): void;
  20789. /**
  20790. * Renders all the objects from the render list into the texture.
  20791. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20792. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20793. */
  20794. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20795. private _bestReflectionRenderTargetDimension;
  20796. /**
  20797. * @hidden
  20798. * @param faceIndex face index to bind to if this is a cubetexture
  20799. */
  20800. _bindFrameBuffer(faceIndex?: number): void;
  20801. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20802. private renderToTarget;
  20803. /**
  20804. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20805. * This allowed control for front to back rendering or reversly depending of the special needs.
  20806. *
  20807. * @param renderingGroupId The rendering group id corresponding to its index
  20808. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20809. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20810. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20811. */
  20812. 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;
  20813. /**
  20814. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20815. *
  20816. * @param renderingGroupId The rendering group id corresponding to its index
  20817. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20818. */
  20819. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20820. /**
  20821. * Clones the texture.
  20822. * @returns the cloned texture
  20823. */
  20824. clone(): RenderTargetTexture;
  20825. /**
  20826. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20827. * @returns The JSON representation of the texture
  20828. */
  20829. serialize(): any;
  20830. /**
  20831. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20832. */
  20833. disposeFramebufferObjects(): void;
  20834. /**
  20835. * Dispose the texture and release its associated resources.
  20836. */
  20837. dispose(): void;
  20838. /** @hidden */
  20839. _rebuild(): void;
  20840. /**
  20841. * Clear the info related to rendering groups preventing retention point in material dispose.
  20842. */
  20843. freeRenderingGroups(): void;
  20844. /**
  20845. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20846. * @returns the view count
  20847. */
  20848. getViewCount(): number;
  20849. }
  20850. }
  20851. declare module "babylonjs/Materials/material" {
  20852. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20853. import { SmartArray } from "babylonjs/Misc/smartArray";
  20854. import { Observable } from "babylonjs/Misc/observable";
  20855. import { Nullable } from "babylonjs/types";
  20856. import { Scene } from "babylonjs/scene";
  20857. import { Matrix } from "babylonjs/Maths/math.vector";
  20858. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20860. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20861. import { Effect } from "babylonjs/Materials/effect";
  20862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20863. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20864. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20865. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20866. import { Mesh } from "babylonjs/Meshes/mesh";
  20867. import { Animation } from "babylonjs/Animations/animation";
  20868. /**
  20869. * Options for compiling materials.
  20870. */
  20871. export interface IMaterialCompilationOptions {
  20872. /**
  20873. * Defines whether clip planes are enabled.
  20874. */
  20875. clipPlane: boolean;
  20876. /**
  20877. * Defines whether instances are enabled.
  20878. */
  20879. useInstances: boolean;
  20880. }
  20881. /**
  20882. * Base class for the main features of a material in Babylon.js
  20883. */
  20884. export class Material implements IAnimatable {
  20885. /**
  20886. * Returns the triangle fill mode
  20887. */
  20888. static readonly TriangleFillMode: number;
  20889. /**
  20890. * Returns the wireframe mode
  20891. */
  20892. static readonly WireFrameFillMode: number;
  20893. /**
  20894. * Returns the point fill mode
  20895. */
  20896. static readonly PointFillMode: number;
  20897. /**
  20898. * Returns the point list draw mode
  20899. */
  20900. static readonly PointListDrawMode: number;
  20901. /**
  20902. * Returns the line list draw mode
  20903. */
  20904. static readonly LineListDrawMode: number;
  20905. /**
  20906. * Returns the line loop draw mode
  20907. */
  20908. static readonly LineLoopDrawMode: number;
  20909. /**
  20910. * Returns the line strip draw mode
  20911. */
  20912. static readonly LineStripDrawMode: number;
  20913. /**
  20914. * Returns the triangle strip draw mode
  20915. */
  20916. static readonly TriangleStripDrawMode: number;
  20917. /**
  20918. * Returns the triangle fan draw mode
  20919. */
  20920. static readonly TriangleFanDrawMode: number;
  20921. /**
  20922. * Stores the clock-wise side orientation
  20923. */
  20924. static readonly ClockWiseSideOrientation: number;
  20925. /**
  20926. * Stores the counter clock-wise side orientation
  20927. */
  20928. static readonly CounterClockWiseSideOrientation: number;
  20929. /**
  20930. * The dirty texture flag value
  20931. */
  20932. static readonly TextureDirtyFlag: number;
  20933. /**
  20934. * The dirty light flag value
  20935. */
  20936. static readonly LightDirtyFlag: number;
  20937. /**
  20938. * The dirty fresnel flag value
  20939. */
  20940. static readonly FresnelDirtyFlag: number;
  20941. /**
  20942. * The dirty attribute flag value
  20943. */
  20944. static readonly AttributesDirtyFlag: number;
  20945. /**
  20946. * The dirty misc flag value
  20947. */
  20948. static readonly MiscDirtyFlag: number;
  20949. /**
  20950. * The all dirty flag value
  20951. */
  20952. static readonly AllDirtyFlag: number;
  20953. /**
  20954. * The ID of the material
  20955. */
  20956. id: string;
  20957. /**
  20958. * Gets or sets the unique id of the material
  20959. */
  20960. uniqueId: number;
  20961. /**
  20962. * The name of the material
  20963. */
  20964. name: string;
  20965. /**
  20966. * Gets or sets user defined metadata
  20967. */
  20968. metadata: any;
  20969. /**
  20970. * For internal use only. Please do not use.
  20971. */
  20972. reservedDataStore: any;
  20973. /**
  20974. * Specifies if the ready state should be checked on each call
  20975. */
  20976. checkReadyOnEveryCall: boolean;
  20977. /**
  20978. * Specifies if the ready state should be checked once
  20979. */
  20980. checkReadyOnlyOnce: boolean;
  20981. /**
  20982. * The state of the material
  20983. */
  20984. state: string;
  20985. /**
  20986. * The alpha value of the material
  20987. */
  20988. protected _alpha: number;
  20989. /**
  20990. * List of inspectable custom properties (used by the Inspector)
  20991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20992. */
  20993. inspectableCustomProperties: IInspectable[];
  20994. /**
  20995. * Sets the alpha value of the material
  20996. */
  20997. /**
  20998. * Gets the alpha value of the material
  20999. */
  21000. alpha: number;
  21001. /**
  21002. * Specifies if back face culling is enabled
  21003. */
  21004. protected _backFaceCulling: boolean;
  21005. /**
  21006. * Sets the back-face culling state
  21007. */
  21008. /**
  21009. * Gets the back-face culling state
  21010. */
  21011. backFaceCulling: boolean;
  21012. /**
  21013. * Stores the value for side orientation
  21014. */
  21015. sideOrientation: number;
  21016. /**
  21017. * Callback triggered when the material is compiled
  21018. */
  21019. onCompiled: Nullable<(effect: Effect) => void>;
  21020. /**
  21021. * Callback triggered when an error occurs
  21022. */
  21023. onError: Nullable<(effect: Effect, errors: string) => void>;
  21024. /**
  21025. * Callback triggered to get the render target textures
  21026. */
  21027. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21028. /**
  21029. * Gets a boolean indicating that current material needs to register RTT
  21030. */
  21031. readonly hasRenderTargetTextures: boolean;
  21032. /**
  21033. * Specifies if the material should be serialized
  21034. */
  21035. doNotSerialize: boolean;
  21036. /**
  21037. * @hidden
  21038. */
  21039. _storeEffectOnSubMeshes: boolean;
  21040. /**
  21041. * Stores the animations for the material
  21042. */
  21043. animations: Nullable<Array<Animation>>;
  21044. /**
  21045. * An event triggered when the material is disposed
  21046. */
  21047. onDisposeObservable: Observable<Material>;
  21048. /**
  21049. * An observer which watches for dispose events
  21050. */
  21051. private _onDisposeObserver;
  21052. private _onUnBindObservable;
  21053. /**
  21054. * Called during a dispose event
  21055. */
  21056. onDispose: () => void;
  21057. private _onBindObservable;
  21058. /**
  21059. * An event triggered when the material is bound
  21060. */
  21061. readonly onBindObservable: Observable<AbstractMesh>;
  21062. /**
  21063. * An observer which watches for bind events
  21064. */
  21065. private _onBindObserver;
  21066. /**
  21067. * Called during a bind event
  21068. */
  21069. onBind: (Mesh: AbstractMesh) => void;
  21070. /**
  21071. * An event triggered when the material is unbound
  21072. */
  21073. readonly onUnBindObservable: Observable<Material>;
  21074. /**
  21075. * Stores the value of the alpha mode
  21076. */
  21077. private _alphaMode;
  21078. /**
  21079. * Sets the value of the alpha mode.
  21080. *
  21081. * | Value | Type | Description |
  21082. * | --- | --- | --- |
  21083. * | 0 | ALPHA_DISABLE | |
  21084. * | 1 | ALPHA_ADD | |
  21085. * | 2 | ALPHA_COMBINE | |
  21086. * | 3 | ALPHA_SUBTRACT | |
  21087. * | 4 | ALPHA_MULTIPLY | |
  21088. * | 5 | ALPHA_MAXIMIZED | |
  21089. * | 6 | ALPHA_ONEONE | |
  21090. * | 7 | ALPHA_PREMULTIPLIED | |
  21091. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21092. * | 9 | ALPHA_INTERPOLATE | |
  21093. * | 10 | ALPHA_SCREENMODE | |
  21094. *
  21095. */
  21096. /**
  21097. * Gets the value of the alpha mode
  21098. */
  21099. alphaMode: number;
  21100. /**
  21101. * Stores the state of the need depth pre-pass value
  21102. */
  21103. private _needDepthPrePass;
  21104. /**
  21105. * Sets the need depth pre-pass value
  21106. */
  21107. /**
  21108. * Gets the depth pre-pass value
  21109. */
  21110. needDepthPrePass: boolean;
  21111. /**
  21112. * Specifies if depth writing should be disabled
  21113. */
  21114. disableDepthWrite: boolean;
  21115. /**
  21116. * Specifies if depth writing should be forced
  21117. */
  21118. forceDepthWrite: boolean;
  21119. /**
  21120. * Specifies if there should be a separate pass for culling
  21121. */
  21122. separateCullingPass: boolean;
  21123. /**
  21124. * Stores the state specifing if fog should be enabled
  21125. */
  21126. private _fogEnabled;
  21127. /**
  21128. * Sets the state for enabling fog
  21129. */
  21130. /**
  21131. * Gets the value of the fog enabled state
  21132. */
  21133. fogEnabled: boolean;
  21134. /**
  21135. * Stores the size of points
  21136. */
  21137. pointSize: number;
  21138. /**
  21139. * Stores the z offset value
  21140. */
  21141. zOffset: number;
  21142. /**
  21143. * Gets a value specifying if wireframe mode is enabled
  21144. */
  21145. /**
  21146. * Sets the state of wireframe mode
  21147. */
  21148. wireframe: boolean;
  21149. /**
  21150. * Gets the value specifying if point clouds are enabled
  21151. */
  21152. /**
  21153. * Sets the state of point cloud mode
  21154. */
  21155. pointsCloud: boolean;
  21156. /**
  21157. * Gets the material fill mode
  21158. */
  21159. /**
  21160. * Sets the material fill mode
  21161. */
  21162. fillMode: number;
  21163. /**
  21164. * @hidden
  21165. * Stores the effects for the material
  21166. */
  21167. _effect: Nullable<Effect>;
  21168. /**
  21169. * @hidden
  21170. * Specifies if the material was previously ready
  21171. */
  21172. _wasPreviouslyReady: boolean;
  21173. /**
  21174. * Specifies if uniform buffers should be used
  21175. */
  21176. private _useUBO;
  21177. /**
  21178. * Stores a reference to the scene
  21179. */
  21180. private _scene;
  21181. /**
  21182. * Stores the fill mode state
  21183. */
  21184. private _fillMode;
  21185. /**
  21186. * Specifies if the depth write state should be cached
  21187. */
  21188. private _cachedDepthWriteState;
  21189. /**
  21190. * Stores the uniform buffer
  21191. */
  21192. protected _uniformBuffer: UniformBuffer;
  21193. /** @hidden */
  21194. _indexInSceneMaterialArray: number;
  21195. /** @hidden */
  21196. meshMap: Nullable<{
  21197. [id: string]: AbstractMesh | undefined;
  21198. }>;
  21199. /**
  21200. * Creates a material instance
  21201. * @param name defines the name of the material
  21202. * @param scene defines the scene to reference
  21203. * @param doNotAdd specifies if the material should be added to the scene
  21204. */
  21205. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21206. /**
  21207. * Returns a string representation of the current material
  21208. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21209. * @returns a string with material information
  21210. */
  21211. toString(fullDetails?: boolean): string;
  21212. /**
  21213. * Gets the class name of the material
  21214. * @returns a string with the class name of the material
  21215. */
  21216. getClassName(): string;
  21217. /**
  21218. * Specifies if updates for the material been locked
  21219. */
  21220. readonly isFrozen: boolean;
  21221. /**
  21222. * Locks updates for the material
  21223. */
  21224. freeze(): void;
  21225. /**
  21226. * Unlocks updates for the material
  21227. */
  21228. unfreeze(): void;
  21229. /**
  21230. * Specifies if the material is ready to be used
  21231. * @param mesh defines the mesh to check
  21232. * @param useInstances specifies if instances should be used
  21233. * @returns a boolean indicating if the material is ready to be used
  21234. */
  21235. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21236. /**
  21237. * Specifies that the submesh is ready to be used
  21238. * @param mesh defines the mesh to check
  21239. * @param subMesh defines which submesh to check
  21240. * @param useInstances specifies that instances should be used
  21241. * @returns a boolean indicating that the submesh is ready or not
  21242. */
  21243. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21244. /**
  21245. * Returns the material effect
  21246. * @returns the effect associated with the material
  21247. */
  21248. getEffect(): Nullable<Effect>;
  21249. /**
  21250. * Returns the current scene
  21251. * @returns a Scene
  21252. */
  21253. getScene(): Scene;
  21254. /**
  21255. * Specifies if the material will require alpha blending
  21256. * @returns a boolean specifying if alpha blending is needed
  21257. */
  21258. needAlphaBlending(): boolean;
  21259. /**
  21260. * Specifies if the mesh will require alpha blending
  21261. * @param mesh defines the mesh to check
  21262. * @returns a boolean specifying if alpha blending is needed for the mesh
  21263. */
  21264. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21265. /**
  21266. * Specifies if this material should be rendered in alpha test mode
  21267. * @returns a boolean specifying if an alpha test is needed.
  21268. */
  21269. needAlphaTesting(): boolean;
  21270. /**
  21271. * Gets the texture used for the alpha test
  21272. * @returns the texture to use for alpha testing
  21273. */
  21274. getAlphaTestTexture(): Nullable<BaseTexture>;
  21275. /**
  21276. * Marks the material to indicate that it needs to be re-calculated
  21277. */
  21278. markDirty(): void;
  21279. /** @hidden */
  21280. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21281. /**
  21282. * Binds the material to the mesh
  21283. * @param world defines the world transformation matrix
  21284. * @param mesh defines the mesh to bind the material to
  21285. */
  21286. bind(world: Matrix, mesh?: Mesh): void;
  21287. /**
  21288. * Binds the submesh to the material
  21289. * @param world defines the world transformation matrix
  21290. * @param mesh defines the mesh containing the submesh
  21291. * @param subMesh defines the submesh to bind the material to
  21292. */
  21293. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21294. /**
  21295. * Binds the world matrix to the material
  21296. * @param world defines the world transformation matrix
  21297. */
  21298. bindOnlyWorldMatrix(world: Matrix): void;
  21299. /**
  21300. * Binds the scene's uniform buffer to the effect.
  21301. * @param effect defines the effect to bind to the scene uniform buffer
  21302. * @param sceneUbo defines the uniform buffer storing scene data
  21303. */
  21304. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21305. /**
  21306. * Binds the view matrix to the effect
  21307. * @param effect defines the effect to bind the view matrix to
  21308. */
  21309. bindView(effect: Effect): void;
  21310. /**
  21311. * Binds the view projection matrix to the effect
  21312. * @param effect defines the effect to bind the view projection matrix to
  21313. */
  21314. bindViewProjection(effect: Effect): void;
  21315. /**
  21316. * Specifies if material alpha testing should be turned on for the mesh
  21317. * @param mesh defines the mesh to check
  21318. */
  21319. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21320. /**
  21321. * Processes to execute after binding the material to a mesh
  21322. * @param mesh defines the rendered mesh
  21323. */
  21324. protected _afterBind(mesh?: Mesh): void;
  21325. /**
  21326. * Unbinds the material from the mesh
  21327. */
  21328. unbind(): void;
  21329. /**
  21330. * Gets the active textures from the material
  21331. * @returns an array of textures
  21332. */
  21333. getActiveTextures(): BaseTexture[];
  21334. /**
  21335. * Specifies if the material uses a texture
  21336. * @param texture defines the texture to check against the material
  21337. * @returns a boolean specifying if the material uses the texture
  21338. */
  21339. hasTexture(texture: BaseTexture): boolean;
  21340. /**
  21341. * Makes a duplicate of the material, and gives it a new name
  21342. * @param name defines the new name for the duplicated material
  21343. * @returns the cloned material
  21344. */
  21345. clone(name: string): Nullable<Material>;
  21346. /**
  21347. * Gets the meshes bound to the material
  21348. * @returns an array of meshes bound to the material
  21349. */
  21350. getBindedMeshes(): AbstractMesh[];
  21351. /**
  21352. * Force shader compilation
  21353. * @param mesh defines the mesh associated with this material
  21354. * @param onCompiled defines a function to execute once the material is compiled
  21355. * @param options defines the options to configure the compilation
  21356. * @param onError defines a function to execute if the material fails compiling
  21357. */
  21358. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21359. /**
  21360. * Force shader compilation
  21361. * @param mesh defines the mesh that will use this material
  21362. * @param options defines additional options for compiling the shaders
  21363. * @returns a promise that resolves when the compilation completes
  21364. */
  21365. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21366. private static readonly _AllDirtyCallBack;
  21367. private static readonly _ImageProcessingDirtyCallBack;
  21368. private static readonly _TextureDirtyCallBack;
  21369. private static readonly _FresnelDirtyCallBack;
  21370. private static readonly _MiscDirtyCallBack;
  21371. private static readonly _LightsDirtyCallBack;
  21372. private static readonly _AttributeDirtyCallBack;
  21373. private static _FresnelAndMiscDirtyCallBack;
  21374. private static _TextureAndMiscDirtyCallBack;
  21375. private static readonly _DirtyCallbackArray;
  21376. private static readonly _RunDirtyCallBacks;
  21377. /**
  21378. * Marks a define in the material to indicate that it needs to be re-computed
  21379. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21380. */
  21381. markAsDirty(flag: number): void;
  21382. /**
  21383. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21384. * @param func defines a function which checks material defines against the submeshes
  21385. */
  21386. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21387. /**
  21388. * Indicates that we need to re-calculated for all submeshes
  21389. */
  21390. protected _markAllSubMeshesAsAllDirty(): void;
  21391. /**
  21392. * Indicates that image processing needs to be re-calculated for all submeshes
  21393. */
  21394. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21395. /**
  21396. * Indicates that textures need to be re-calculated for all submeshes
  21397. */
  21398. protected _markAllSubMeshesAsTexturesDirty(): void;
  21399. /**
  21400. * Indicates that fresnel needs to be re-calculated for all submeshes
  21401. */
  21402. protected _markAllSubMeshesAsFresnelDirty(): void;
  21403. /**
  21404. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21405. */
  21406. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21407. /**
  21408. * Indicates that lights need to be re-calculated for all submeshes
  21409. */
  21410. protected _markAllSubMeshesAsLightsDirty(): void;
  21411. /**
  21412. * Indicates that attributes need to be re-calculated for all submeshes
  21413. */
  21414. protected _markAllSubMeshesAsAttributesDirty(): void;
  21415. /**
  21416. * Indicates that misc needs to be re-calculated for all submeshes
  21417. */
  21418. protected _markAllSubMeshesAsMiscDirty(): void;
  21419. /**
  21420. * Indicates that textures and misc need to be re-calculated for all submeshes
  21421. */
  21422. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21423. /**
  21424. * Disposes the material
  21425. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21426. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21427. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21428. */
  21429. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21430. /** @hidden */
  21431. private releaseVertexArrayObject;
  21432. /**
  21433. * Serializes this material
  21434. * @returns the serialized material object
  21435. */
  21436. serialize(): any;
  21437. /**
  21438. * Creates a material from parsed material data
  21439. * @param parsedMaterial defines parsed material data
  21440. * @param scene defines the hosting scene
  21441. * @param rootUrl defines the root URL to use to load textures
  21442. * @returns a new material
  21443. */
  21444. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21445. }
  21446. }
  21447. declare module "babylonjs/Materials/multiMaterial" {
  21448. import { Nullable } from "babylonjs/types";
  21449. import { Scene } from "babylonjs/scene";
  21450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21451. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21453. import { Material } from "babylonjs/Materials/material";
  21454. /**
  21455. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21456. * separate meshes. This can be use to improve performances.
  21457. * @see http://doc.babylonjs.com/how_to/multi_materials
  21458. */
  21459. export class MultiMaterial extends Material {
  21460. private _subMaterials;
  21461. /**
  21462. * Gets or Sets the list of Materials used within the multi material.
  21463. * They need to be ordered according to the submeshes order in the associated mesh
  21464. */
  21465. subMaterials: Nullable<Material>[];
  21466. /**
  21467. * Function used to align with Node.getChildren()
  21468. * @returns the list of Materials used within the multi material
  21469. */
  21470. getChildren(): Nullable<Material>[];
  21471. /**
  21472. * Instantiates a new Multi Material
  21473. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21474. * separate meshes. This can be use to improve performances.
  21475. * @see http://doc.babylonjs.com/how_to/multi_materials
  21476. * @param name Define the name in the scene
  21477. * @param scene Define the scene the material belongs to
  21478. */
  21479. constructor(name: string, scene: Scene);
  21480. private _hookArray;
  21481. /**
  21482. * Get one of the submaterial by its index in the submaterials array
  21483. * @param index The index to look the sub material at
  21484. * @returns The Material if the index has been defined
  21485. */
  21486. getSubMaterial(index: number): Nullable<Material>;
  21487. /**
  21488. * Get the list of active textures for the whole sub materials list.
  21489. * @returns All the textures that will be used during the rendering
  21490. */
  21491. getActiveTextures(): BaseTexture[];
  21492. /**
  21493. * Gets the current class name of the material e.g. "MultiMaterial"
  21494. * Mainly use in serialization.
  21495. * @returns the class name
  21496. */
  21497. getClassName(): string;
  21498. /**
  21499. * Checks if the material is ready to render the requested sub mesh
  21500. * @param mesh Define the mesh the submesh belongs to
  21501. * @param subMesh Define the sub mesh to look readyness for
  21502. * @param useInstances Define whether or not the material is used with instances
  21503. * @returns true if ready, otherwise false
  21504. */
  21505. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21506. /**
  21507. * Clones the current material and its related sub materials
  21508. * @param name Define the name of the newly cloned material
  21509. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21510. * @returns the cloned material
  21511. */
  21512. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21513. /**
  21514. * Serializes the materials into a JSON representation.
  21515. * @returns the JSON representation
  21516. */
  21517. serialize(): any;
  21518. /**
  21519. * Dispose the material and release its associated resources
  21520. * @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)
  21521. * @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)
  21522. * @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)
  21523. */
  21524. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21525. /**
  21526. * Creates a MultiMaterial from parsed MultiMaterial data.
  21527. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21528. * @param scene defines the hosting scene
  21529. * @returns a new MultiMaterial
  21530. */
  21531. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21532. }
  21533. }
  21534. declare module "babylonjs/Meshes/subMesh" {
  21535. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21536. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21537. import { Engine } from "babylonjs/Engines/engine";
  21538. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21539. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21540. import { Effect } from "babylonjs/Materials/effect";
  21541. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21542. import { Plane } from "babylonjs/Maths/math.plane";
  21543. import { Collider } from "babylonjs/Collisions/collider";
  21544. import { Material } from "babylonjs/Materials/material";
  21545. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21547. import { Mesh } from "babylonjs/Meshes/mesh";
  21548. import { Ray } from "babylonjs/Culling/ray";
  21549. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21550. /**
  21551. * Base class for submeshes
  21552. */
  21553. export class BaseSubMesh {
  21554. /** @hidden */
  21555. _materialDefines: Nullable<MaterialDefines>;
  21556. /** @hidden */
  21557. _materialEffect: Nullable<Effect>;
  21558. /**
  21559. * Gets associated effect
  21560. */
  21561. readonly effect: Nullable<Effect>;
  21562. /**
  21563. * Sets associated effect (effect used to render this submesh)
  21564. * @param effect defines the effect to associate with
  21565. * @param defines defines the set of defines used to compile this effect
  21566. */
  21567. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21568. }
  21569. /**
  21570. * Defines a subdivision inside a mesh
  21571. */
  21572. export class SubMesh extends BaseSubMesh implements ICullable {
  21573. /** the material index to use */
  21574. materialIndex: number;
  21575. /** vertex index start */
  21576. verticesStart: number;
  21577. /** vertices count */
  21578. verticesCount: number;
  21579. /** index start */
  21580. indexStart: number;
  21581. /** indices count */
  21582. indexCount: number;
  21583. /** @hidden */
  21584. _linesIndexCount: number;
  21585. private _mesh;
  21586. private _renderingMesh;
  21587. private _boundingInfo;
  21588. private _linesIndexBuffer;
  21589. /** @hidden */
  21590. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21591. /** @hidden */
  21592. _trianglePlanes: Plane[];
  21593. /** @hidden */
  21594. _lastColliderTransformMatrix: Nullable<Matrix>;
  21595. /** @hidden */
  21596. _renderId: number;
  21597. /** @hidden */
  21598. _alphaIndex: number;
  21599. /** @hidden */
  21600. _distanceToCamera: number;
  21601. /** @hidden */
  21602. _id: number;
  21603. private _currentMaterial;
  21604. /**
  21605. * Add a new submesh to a mesh
  21606. * @param materialIndex defines the material index to use
  21607. * @param verticesStart defines vertex index start
  21608. * @param verticesCount defines vertices count
  21609. * @param indexStart defines index start
  21610. * @param indexCount defines indices count
  21611. * @param mesh defines the parent mesh
  21612. * @param renderingMesh defines an optional rendering mesh
  21613. * @param createBoundingBox defines if bounding box should be created for this submesh
  21614. * @returns the new submesh
  21615. */
  21616. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21617. /**
  21618. * Creates a new submesh
  21619. * @param materialIndex defines the material index to use
  21620. * @param verticesStart defines vertex index start
  21621. * @param verticesCount defines vertices count
  21622. * @param indexStart defines index start
  21623. * @param indexCount defines indices count
  21624. * @param mesh defines the parent mesh
  21625. * @param renderingMesh defines an optional rendering mesh
  21626. * @param createBoundingBox defines if bounding box should be created for this submesh
  21627. */
  21628. constructor(
  21629. /** the material index to use */
  21630. materialIndex: number,
  21631. /** vertex index start */
  21632. verticesStart: number,
  21633. /** vertices count */
  21634. verticesCount: number,
  21635. /** index start */
  21636. indexStart: number,
  21637. /** indices count */
  21638. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21639. /**
  21640. * Returns true if this submesh covers the entire parent mesh
  21641. * @ignorenaming
  21642. */
  21643. readonly IsGlobal: boolean;
  21644. /**
  21645. * Returns the submesh BoudingInfo object
  21646. * @returns current bounding info (or mesh's one if the submesh is global)
  21647. */
  21648. getBoundingInfo(): BoundingInfo;
  21649. /**
  21650. * Sets the submesh BoundingInfo
  21651. * @param boundingInfo defines the new bounding info to use
  21652. * @returns the SubMesh
  21653. */
  21654. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21655. /**
  21656. * Returns the mesh of the current submesh
  21657. * @return the parent mesh
  21658. */
  21659. getMesh(): AbstractMesh;
  21660. /**
  21661. * Returns the rendering mesh of the submesh
  21662. * @returns the rendering mesh (could be different from parent mesh)
  21663. */
  21664. getRenderingMesh(): Mesh;
  21665. /**
  21666. * Returns the submesh material
  21667. * @returns null or the current material
  21668. */
  21669. getMaterial(): Nullable<Material>;
  21670. /**
  21671. * Sets a new updated BoundingInfo object to the submesh
  21672. * @param data defines an optional position array to use to determine the bounding info
  21673. * @returns the SubMesh
  21674. */
  21675. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21676. /** @hidden */
  21677. _checkCollision(collider: Collider): boolean;
  21678. /**
  21679. * Updates the submesh BoundingInfo
  21680. * @param world defines the world matrix to use to update the bounding info
  21681. * @returns the submesh
  21682. */
  21683. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21684. /**
  21685. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21686. * @param frustumPlanes defines the frustum planes
  21687. * @returns true if the submesh is intersecting with the frustum
  21688. */
  21689. isInFrustum(frustumPlanes: Plane[]): boolean;
  21690. /**
  21691. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21692. * @param frustumPlanes defines the frustum planes
  21693. * @returns true if the submesh is inside the frustum
  21694. */
  21695. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21696. /**
  21697. * Renders the submesh
  21698. * @param enableAlphaMode defines if alpha needs to be used
  21699. * @returns the submesh
  21700. */
  21701. render(enableAlphaMode: boolean): SubMesh;
  21702. /**
  21703. * @hidden
  21704. */
  21705. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21706. /**
  21707. * Checks if the submesh intersects with a ray
  21708. * @param ray defines the ray to test
  21709. * @returns true is the passed ray intersects the submesh bounding box
  21710. */
  21711. canIntersects(ray: Ray): boolean;
  21712. /**
  21713. * Intersects current submesh with a ray
  21714. * @param ray defines the ray to test
  21715. * @param positions defines mesh's positions array
  21716. * @param indices defines mesh's indices array
  21717. * @param fastCheck defines if only bounding info should be used
  21718. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21719. * @returns intersection info or null if no intersection
  21720. */
  21721. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21722. /** @hidden */
  21723. private _intersectLines;
  21724. /** @hidden */
  21725. private _intersectUnIndexedLines;
  21726. /** @hidden */
  21727. private _intersectTriangles;
  21728. /** @hidden */
  21729. private _intersectUnIndexedTriangles;
  21730. /** @hidden */
  21731. _rebuild(): void;
  21732. /**
  21733. * Creates a new submesh from the passed mesh
  21734. * @param newMesh defines the new hosting mesh
  21735. * @param newRenderingMesh defines an optional rendering mesh
  21736. * @returns the new submesh
  21737. */
  21738. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21739. /**
  21740. * Release associated resources
  21741. */
  21742. dispose(): void;
  21743. /**
  21744. * Gets the class name
  21745. * @returns the string "SubMesh".
  21746. */
  21747. getClassName(): string;
  21748. /**
  21749. * Creates a new submesh from indices data
  21750. * @param materialIndex the index of the main mesh material
  21751. * @param startIndex the index where to start the copy in the mesh indices array
  21752. * @param indexCount the number of indices to copy then from the startIndex
  21753. * @param mesh the main mesh to create the submesh from
  21754. * @param renderingMesh the optional rendering mesh
  21755. * @returns a new submesh
  21756. */
  21757. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21758. }
  21759. }
  21760. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21761. /**
  21762. * Class used to represent data loading progression
  21763. */
  21764. export class SceneLoaderFlags {
  21765. private static _ForceFullSceneLoadingForIncremental;
  21766. private static _ShowLoadingScreen;
  21767. private static _CleanBoneMatrixWeights;
  21768. private static _loggingLevel;
  21769. /**
  21770. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21771. */
  21772. static ForceFullSceneLoadingForIncremental: boolean;
  21773. /**
  21774. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21775. */
  21776. static ShowLoadingScreen: boolean;
  21777. /**
  21778. * Defines the current logging level (while loading the scene)
  21779. * @ignorenaming
  21780. */
  21781. static loggingLevel: number;
  21782. /**
  21783. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21784. */
  21785. static CleanBoneMatrixWeights: boolean;
  21786. }
  21787. }
  21788. declare module "babylonjs/Meshes/geometry" {
  21789. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21790. import { Scene } from "babylonjs/scene";
  21791. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21792. import { Engine } from "babylonjs/Engines/engine";
  21793. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21794. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21795. import { Effect } from "babylonjs/Materials/effect";
  21796. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21797. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21798. import { Mesh } from "babylonjs/Meshes/mesh";
  21799. /**
  21800. * Class used to store geometry data (vertex buffers + index buffer)
  21801. */
  21802. export class Geometry implements IGetSetVerticesData {
  21803. /**
  21804. * Gets or sets the ID of the geometry
  21805. */
  21806. id: string;
  21807. /**
  21808. * Gets or sets the unique ID of the geometry
  21809. */
  21810. uniqueId: number;
  21811. /**
  21812. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21813. */
  21814. delayLoadState: number;
  21815. /**
  21816. * Gets the file containing the data to load when running in delay load state
  21817. */
  21818. delayLoadingFile: Nullable<string>;
  21819. /**
  21820. * Callback called when the geometry is updated
  21821. */
  21822. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21823. private _scene;
  21824. private _engine;
  21825. private _meshes;
  21826. private _totalVertices;
  21827. /** @hidden */
  21828. _indices: IndicesArray;
  21829. /** @hidden */
  21830. _vertexBuffers: {
  21831. [key: string]: VertexBuffer;
  21832. };
  21833. private _isDisposed;
  21834. private _extend;
  21835. private _boundingBias;
  21836. /** @hidden */
  21837. _delayInfo: Array<string>;
  21838. private _indexBuffer;
  21839. private _indexBufferIsUpdatable;
  21840. /** @hidden */
  21841. _boundingInfo: Nullable<BoundingInfo>;
  21842. /** @hidden */
  21843. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21844. /** @hidden */
  21845. _softwareSkinningFrameId: number;
  21846. private _vertexArrayObjects;
  21847. private _updatable;
  21848. /** @hidden */
  21849. _positions: Nullable<Vector3[]>;
  21850. /**
  21851. * 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
  21852. */
  21853. /**
  21854. * 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
  21855. */
  21856. boundingBias: Vector2;
  21857. /**
  21858. * Static function used to attach a new empty geometry to a mesh
  21859. * @param mesh defines the mesh to attach the geometry to
  21860. * @returns the new Geometry
  21861. */
  21862. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21863. /**
  21864. * Creates a new geometry
  21865. * @param id defines the unique ID
  21866. * @param scene defines the hosting scene
  21867. * @param vertexData defines the VertexData used to get geometry data
  21868. * @param updatable defines if geometry must be updatable (false by default)
  21869. * @param mesh defines the mesh that will be associated with the geometry
  21870. */
  21871. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21872. /**
  21873. * Gets the current extend of the geometry
  21874. */
  21875. readonly extend: {
  21876. minimum: Vector3;
  21877. maximum: Vector3;
  21878. };
  21879. /**
  21880. * Gets the hosting scene
  21881. * @returns the hosting Scene
  21882. */
  21883. getScene(): Scene;
  21884. /**
  21885. * Gets the hosting engine
  21886. * @returns the hosting Engine
  21887. */
  21888. getEngine(): Engine;
  21889. /**
  21890. * Defines if the geometry is ready to use
  21891. * @returns true if the geometry is ready to be used
  21892. */
  21893. isReady(): boolean;
  21894. /**
  21895. * Gets a value indicating that the geometry should not be serialized
  21896. */
  21897. readonly doNotSerialize: boolean;
  21898. /** @hidden */
  21899. _rebuild(): void;
  21900. /**
  21901. * Affects all geometry data in one call
  21902. * @param vertexData defines the geometry data
  21903. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21904. */
  21905. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21906. /**
  21907. * Set specific vertex data
  21908. * @param kind defines the data kind (Position, normal, etc...)
  21909. * @param data defines the vertex data to use
  21910. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21911. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21912. */
  21913. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21914. /**
  21915. * Removes a specific vertex data
  21916. * @param kind defines the data kind (Position, normal, etc...)
  21917. */
  21918. removeVerticesData(kind: string): void;
  21919. /**
  21920. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21921. * @param buffer defines the vertex buffer to use
  21922. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21923. */
  21924. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21925. /**
  21926. * Update a specific vertex buffer
  21927. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21928. * It will do nothing if the buffer is not updatable
  21929. * @param kind defines the data kind (Position, normal, etc...)
  21930. * @param data defines the data to use
  21931. * @param offset defines the offset in the target buffer where to store the data
  21932. * @param useBytes set to true if the offset is in bytes
  21933. */
  21934. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21935. /**
  21936. * Update a specific vertex buffer
  21937. * This function will create a new buffer if the current one is not updatable
  21938. * @param kind defines the data kind (Position, normal, etc...)
  21939. * @param data defines the data to use
  21940. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21941. */
  21942. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21943. private _updateBoundingInfo;
  21944. /** @hidden */
  21945. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21946. /**
  21947. * Gets total number of vertices
  21948. * @returns the total number of vertices
  21949. */
  21950. getTotalVertices(): number;
  21951. /**
  21952. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21953. * @param kind defines the data kind (Position, normal, etc...)
  21954. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21955. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21956. * @returns a float array containing vertex data
  21957. */
  21958. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21959. /**
  21960. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21961. * @param kind defines the data kind (Position, normal, etc...)
  21962. * @returns true if the vertex buffer with the specified kind is updatable
  21963. */
  21964. isVertexBufferUpdatable(kind: string): boolean;
  21965. /**
  21966. * Gets a specific vertex buffer
  21967. * @param kind defines the data kind (Position, normal, etc...)
  21968. * @returns a VertexBuffer
  21969. */
  21970. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21971. /**
  21972. * Returns all vertex buffers
  21973. * @return an object holding all vertex buffers indexed by kind
  21974. */
  21975. getVertexBuffers(): Nullable<{
  21976. [key: string]: VertexBuffer;
  21977. }>;
  21978. /**
  21979. * Gets a boolean indicating if specific vertex buffer is present
  21980. * @param kind defines the data kind (Position, normal, etc...)
  21981. * @returns true if data is present
  21982. */
  21983. isVerticesDataPresent(kind: string): boolean;
  21984. /**
  21985. * Gets a list of all attached data kinds (Position, normal, etc...)
  21986. * @returns a list of string containing all kinds
  21987. */
  21988. getVerticesDataKinds(): string[];
  21989. /**
  21990. * Update index buffer
  21991. * @param indices defines the indices to store in the index buffer
  21992. * @param offset defines the offset in the target buffer where to store the data
  21993. * @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)
  21994. */
  21995. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21996. /**
  21997. * Creates a new index buffer
  21998. * @param indices defines the indices to store in the index buffer
  21999. * @param totalVertices defines the total number of vertices (could be null)
  22000. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22001. */
  22002. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22003. /**
  22004. * Return the total number of indices
  22005. * @returns the total number of indices
  22006. */
  22007. getTotalIndices(): number;
  22008. /**
  22009. * Gets the index buffer array
  22010. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22011. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22012. * @returns the index buffer array
  22013. */
  22014. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22015. /**
  22016. * Gets the index buffer
  22017. * @return the index buffer
  22018. */
  22019. getIndexBuffer(): Nullable<DataBuffer>;
  22020. /** @hidden */
  22021. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22022. /**
  22023. * Release the associated resources for a specific mesh
  22024. * @param mesh defines the source mesh
  22025. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22026. */
  22027. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22028. /**
  22029. * Apply current geometry to a given mesh
  22030. * @param mesh defines the mesh to apply geometry to
  22031. */
  22032. applyToMesh(mesh: Mesh): void;
  22033. private _updateExtend;
  22034. private _applyToMesh;
  22035. private notifyUpdate;
  22036. /**
  22037. * Load the geometry if it was flagged as delay loaded
  22038. * @param scene defines the hosting scene
  22039. * @param onLoaded defines a callback called when the geometry is loaded
  22040. */
  22041. load(scene: Scene, onLoaded?: () => void): void;
  22042. private _queueLoad;
  22043. /**
  22044. * Invert the geometry to move from a right handed system to a left handed one.
  22045. */
  22046. toLeftHanded(): void;
  22047. /** @hidden */
  22048. _resetPointsArrayCache(): void;
  22049. /** @hidden */
  22050. _generatePointsArray(): boolean;
  22051. /**
  22052. * Gets a value indicating if the geometry is disposed
  22053. * @returns true if the geometry was disposed
  22054. */
  22055. isDisposed(): boolean;
  22056. private _disposeVertexArrayObjects;
  22057. /**
  22058. * Free all associated resources
  22059. */
  22060. dispose(): void;
  22061. /**
  22062. * Clone the current geometry into a new geometry
  22063. * @param id defines the unique ID of the new geometry
  22064. * @returns a new geometry object
  22065. */
  22066. copy(id: string): Geometry;
  22067. /**
  22068. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22069. * @return a JSON representation of the current geometry data (without the vertices data)
  22070. */
  22071. serialize(): any;
  22072. private toNumberArray;
  22073. /**
  22074. * Serialize all vertices data into a JSON oject
  22075. * @returns a JSON representation of the current geometry data
  22076. */
  22077. serializeVerticeData(): any;
  22078. /**
  22079. * Extracts a clone of a mesh geometry
  22080. * @param mesh defines the source mesh
  22081. * @param id defines the unique ID of the new geometry object
  22082. * @returns the new geometry object
  22083. */
  22084. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22085. /**
  22086. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22087. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22088. * Be aware Math.random() could cause collisions, but:
  22089. * "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"
  22090. * @returns a string containing a new GUID
  22091. */
  22092. static RandomId(): string;
  22093. /** @hidden */
  22094. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22095. private static _CleanMatricesWeights;
  22096. /**
  22097. * Create a new geometry from persisted data (Using .babylon file format)
  22098. * @param parsedVertexData defines the persisted data
  22099. * @param scene defines the hosting scene
  22100. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22101. * @returns the new geometry object
  22102. */
  22103. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22104. }
  22105. }
  22106. declare module "babylonjs/Meshes/mesh.vertexData" {
  22107. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22108. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22109. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22110. import { Geometry } from "babylonjs/Meshes/geometry";
  22111. import { Mesh } from "babylonjs/Meshes/mesh";
  22112. /**
  22113. * Define an interface for all classes that will get and set the data on vertices
  22114. */
  22115. export interface IGetSetVerticesData {
  22116. /**
  22117. * Gets a boolean indicating if specific vertex data is present
  22118. * @param kind defines the vertex data kind to use
  22119. * @returns true is data kind is present
  22120. */
  22121. isVerticesDataPresent(kind: string): boolean;
  22122. /**
  22123. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22124. * @param kind defines the data kind (Position, normal, etc...)
  22125. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22126. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22127. * @returns a float array containing vertex data
  22128. */
  22129. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22130. /**
  22131. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22132. * @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.
  22133. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22134. * @returns the indices array or an empty array if the mesh has no geometry
  22135. */
  22136. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22137. /**
  22138. * Set specific vertex data
  22139. * @param kind defines the data kind (Position, normal, etc...)
  22140. * @param data defines the vertex data to use
  22141. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22142. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22143. */
  22144. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22145. /**
  22146. * Update a specific associated vertex buffer
  22147. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22148. * - VertexBuffer.PositionKind
  22149. * - VertexBuffer.UVKind
  22150. * - VertexBuffer.UV2Kind
  22151. * - VertexBuffer.UV3Kind
  22152. * - VertexBuffer.UV4Kind
  22153. * - VertexBuffer.UV5Kind
  22154. * - VertexBuffer.UV6Kind
  22155. * - VertexBuffer.ColorKind
  22156. * - VertexBuffer.MatricesIndicesKind
  22157. * - VertexBuffer.MatricesIndicesExtraKind
  22158. * - VertexBuffer.MatricesWeightsKind
  22159. * - VertexBuffer.MatricesWeightsExtraKind
  22160. * @param data defines the data source
  22161. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22162. * @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)
  22163. */
  22164. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22165. /**
  22166. * Creates a new index buffer
  22167. * @param indices defines the indices to store in the index buffer
  22168. * @param totalVertices defines the total number of vertices (could be null)
  22169. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22170. */
  22171. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22172. }
  22173. /**
  22174. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22175. */
  22176. export class VertexData {
  22177. /**
  22178. * Mesh side orientation : usually the external or front surface
  22179. */
  22180. static readonly FRONTSIDE: number;
  22181. /**
  22182. * Mesh side orientation : usually the internal or back surface
  22183. */
  22184. static readonly BACKSIDE: number;
  22185. /**
  22186. * Mesh side orientation : both internal and external or front and back surfaces
  22187. */
  22188. static readonly DOUBLESIDE: number;
  22189. /**
  22190. * Mesh side orientation : by default, `FRONTSIDE`
  22191. */
  22192. static readonly DEFAULTSIDE: number;
  22193. /**
  22194. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22195. */
  22196. positions: Nullable<FloatArray>;
  22197. /**
  22198. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22199. */
  22200. normals: Nullable<FloatArray>;
  22201. /**
  22202. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22203. */
  22204. tangents: Nullable<FloatArray>;
  22205. /**
  22206. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22207. */
  22208. uvs: Nullable<FloatArray>;
  22209. /**
  22210. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22211. */
  22212. uvs2: Nullable<FloatArray>;
  22213. /**
  22214. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22215. */
  22216. uvs3: Nullable<FloatArray>;
  22217. /**
  22218. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22219. */
  22220. uvs4: Nullable<FloatArray>;
  22221. /**
  22222. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22223. */
  22224. uvs5: Nullable<FloatArray>;
  22225. /**
  22226. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22227. */
  22228. uvs6: Nullable<FloatArray>;
  22229. /**
  22230. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22231. */
  22232. colors: Nullable<FloatArray>;
  22233. /**
  22234. * 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).
  22235. */
  22236. matricesIndices: Nullable<FloatArray>;
  22237. /**
  22238. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22239. */
  22240. matricesWeights: Nullable<FloatArray>;
  22241. /**
  22242. * An array extending the number of possible indices
  22243. */
  22244. matricesIndicesExtra: Nullable<FloatArray>;
  22245. /**
  22246. * An array extending the number of possible weights when the number of indices is extended
  22247. */
  22248. matricesWeightsExtra: Nullable<FloatArray>;
  22249. /**
  22250. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22251. */
  22252. indices: Nullable<IndicesArray>;
  22253. /**
  22254. * Uses the passed data array to set the set the values for the specified kind of data
  22255. * @param data a linear array of floating numbers
  22256. * @param kind the type of data that is being set, eg positions, colors etc
  22257. */
  22258. set(data: FloatArray, kind: string): void;
  22259. /**
  22260. * Associates the vertexData to the passed Mesh.
  22261. * Sets it as updatable or not (default `false`)
  22262. * @param mesh the mesh the vertexData is applied to
  22263. * @param updatable when used and having the value true allows new data to update the vertexData
  22264. * @returns the VertexData
  22265. */
  22266. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22267. /**
  22268. * Associates the vertexData to the passed Geometry.
  22269. * Sets it as updatable or not (default `false`)
  22270. * @param geometry the geometry the vertexData is applied to
  22271. * @param updatable when used and having the value true allows new data to update the vertexData
  22272. * @returns VertexData
  22273. */
  22274. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22275. /**
  22276. * Updates the associated mesh
  22277. * @param mesh the mesh to be updated
  22278. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22279. * @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
  22280. * @returns VertexData
  22281. */
  22282. updateMesh(mesh: Mesh): VertexData;
  22283. /**
  22284. * Updates the associated geometry
  22285. * @param geometry the geometry to be updated
  22286. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22287. * @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
  22288. * @returns VertexData.
  22289. */
  22290. updateGeometry(geometry: Geometry): VertexData;
  22291. private _applyTo;
  22292. private _update;
  22293. /**
  22294. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22295. * @param matrix the transforming matrix
  22296. * @returns the VertexData
  22297. */
  22298. transform(matrix: Matrix): VertexData;
  22299. /**
  22300. * Merges the passed VertexData into the current one
  22301. * @param other the VertexData to be merged into the current one
  22302. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22303. * @returns the modified VertexData
  22304. */
  22305. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22306. private _mergeElement;
  22307. private _validate;
  22308. /**
  22309. * Serializes the VertexData
  22310. * @returns a serialized object
  22311. */
  22312. serialize(): any;
  22313. /**
  22314. * Extracts the vertexData from a mesh
  22315. * @param mesh the mesh from which to extract the VertexData
  22316. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22317. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22318. * @returns the object VertexData associated to the passed mesh
  22319. */
  22320. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22321. /**
  22322. * Extracts the vertexData from the geometry
  22323. * @param geometry the geometry from which to extract the VertexData
  22324. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22325. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22326. * @returns the object VertexData associated to the passed mesh
  22327. */
  22328. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22329. private static _ExtractFrom;
  22330. /**
  22331. * Creates the VertexData for a Ribbon
  22332. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22333. * * pathArray array of paths, each of which an array of successive Vector3
  22334. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22335. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22336. * * 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
  22337. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22338. * * 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)
  22339. * * 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)
  22340. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22341. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22342. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22343. * @returns the VertexData of the ribbon
  22344. */
  22345. static CreateRibbon(options: {
  22346. pathArray: Vector3[][];
  22347. closeArray?: boolean;
  22348. closePath?: boolean;
  22349. offset?: number;
  22350. sideOrientation?: number;
  22351. frontUVs?: Vector4;
  22352. backUVs?: Vector4;
  22353. invertUV?: boolean;
  22354. uvs?: Vector2[];
  22355. colors?: Color4[];
  22356. }): VertexData;
  22357. /**
  22358. * Creates the VertexData for a box
  22359. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22360. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22361. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22362. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22363. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22364. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22365. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22367. * * 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)
  22368. * * 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)
  22369. * @returns the VertexData of the box
  22370. */
  22371. static CreateBox(options: {
  22372. size?: number;
  22373. width?: number;
  22374. height?: number;
  22375. depth?: number;
  22376. faceUV?: Vector4[];
  22377. faceColors?: Color4[];
  22378. sideOrientation?: number;
  22379. frontUVs?: Vector4;
  22380. backUVs?: Vector4;
  22381. }): VertexData;
  22382. /**
  22383. * Creates the VertexData for a tiled box
  22384. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22385. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22386. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22387. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22389. * @returns the VertexData of the box
  22390. */
  22391. static CreateTiledBox(options: {
  22392. pattern?: number;
  22393. width?: number;
  22394. height?: number;
  22395. depth?: number;
  22396. tileSize?: number;
  22397. tileWidth?: number;
  22398. tileHeight?: number;
  22399. alignHorizontal?: number;
  22400. alignVertical?: number;
  22401. faceUV?: Vector4[];
  22402. faceColors?: Color4[];
  22403. sideOrientation?: number;
  22404. }): VertexData;
  22405. /**
  22406. * Creates the VertexData for a tiled plane
  22407. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22408. * * pattern a limited pattern arrangement depending on the number
  22409. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22410. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22411. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22412. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22413. * * 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)
  22414. * * 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)
  22415. * @returns the VertexData of the tiled plane
  22416. */
  22417. static CreateTiledPlane(options: {
  22418. pattern?: number;
  22419. tileSize?: number;
  22420. tileWidth?: number;
  22421. tileHeight?: number;
  22422. size?: number;
  22423. width?: number;
  22424. height?: number;
  22425. alignHorizontal?: number;
  22426. alignVertical?: number;
  22427. sideOrientation?: number;
  22428. frontUVs?: Vector4;
  22429. backUVs?: Vector4;
  22430. }): VertexData;
  22431. /**
  22432. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22433. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22434. * * segments sets the number of horizontal strips optional, default 32
  22435. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22436. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22437. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22438. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22439. * * 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
  22440. * * 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
  22441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22442. * * 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)
  22443. * * 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)
  22444. * @returns the VertexData of the ellipsoid
  22445. */
  22446. static CreateSphere(options: {
  22447. segments?: number;
  22448. diameter?: number;
  22449. diameterX?: number;
  22450. diameterY?: number;
  22451. diameterZ?: number;
  22452. arc?: number;
  22453. slice?: number;
  22454. sideOrientation?: number;
  22455. frontUVs?: Vector4;
  22456. backUVs?: Vector4;
  22457. }): VertexData;
  22458. /**
  22459. * Creates the VertexData for a cylinder, cone or prism
  22460. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22461. * * height sets the height (y direction) of the cylinder, optional, default 2
  22462. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22463. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22464. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22465. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22466. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22467. * * 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
  22468. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22469. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22470. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22471. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22473. * * 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)
  22474. * * 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)
  22475. * @returns the VertexData of the cylinder, cone or prism
  22476. */
  22477. static CreateCylinder(options: {
  22478. height?: number;
  22479. diameterTop?: number;
  22480. diameterBottom?: number;
  22481. diameter?: number;
  22482. tessellation?: number;
  22483. subdivisions?: number;
  22484. arc?: number;
  22485. faceColors?: Color4[];
  22486. faceUV?: Vector4[];
  22487. hasRings?: boolean;
  22488. enclose?: boolean;
  22489. sideOrientation?: number;
  22490. frontUVs?: Vector4;
  22491. backUVs?: Vector4;
  22492. }): VertexData;
  22493. /**
  22494. * Creates the VertexData for a torus
  22495. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22496. * * diameter the diameter of the torus, optional default 1
  22497. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22498. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22500. * * 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)
  22501. * * 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)
  22502. * @returns the VertexData of the torus
  22503. */
  22504. static CreateTorus(options: {
  22505. diameter?: number;
  22506. thickness?: number;
  22507. tessellation?: number;
  22508. sideOrientation?: number;
  22509. frontUVs?: Vector4;
  22510. backUVs?: Vector4;
  22511. }): VertexData;
  22512. /**
  22513. * Creates the VertexData of the LineSystem
  22514. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22515. * - lines an array of lines, each line being an array of successive Vector3
  22516. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22517. * @returns the VertexData of the LineSystem
  22518. */
  22519. static CreateLineSystem(options: {
  22520. lines: Vector3[][];
  22521. colors?: Nullable<Color4[][]>;
  22522. }): VertexData;
  22523. /**
  22524. * Create the VertexData for a DashedLines
  22525. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22526. * - points an array successive Vector3
  22527. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22528. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22529. * - dashNb the intended total number of dashes, optional, default 200
  22530. * @returns the VertexData for the DashedLines
  22531. */
  22532. static CreateDashedLines(options: {
  22533. points: Vector3[];
  22534. dashSize?: number;
  22535. gapSize?: number;
  22536. dashNb?: number;
  22537. }): VertexData;
  22538. /**
  22539. * Creates the VertexData for a Ground
  22540. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22541. * - width the width (x direction) of the ground, optional, default 1
  22542. * - height the height (z direction) of the ground, optional, default 1
  22543. * - subdivisions the number of subdivisions per side, optional, default 1
  22544. * @returns the VertexData of the Ground
  22545. */
  22546. static CreateGround(options: {
  22547. width?: number;
  22548. height?: number;
  22549. subdivisions?: number;
  22550. subdivisionsX?: number;
  22551. subdivisionsY?: number;
  22552. }): VertexData;
  22553. /**
  22554. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22555. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22556. * * xmin the ground minimum X coordinate, optional, default -1
  22557. * * zmin the ground minimum Z coordinate, optional, default -1
  22558. * * xmax the ground maximum X coordinate, optional, default 1
  22559. * * zmax the ground maximum Z coordinate, optional, default 1
  22560. * * 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}
  22561. * * 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}
  22562. * @returns the VertexData of the TiledGround
  22563. */
  22564. static CreateTiledGround(options: {
  22565. xmin: number;
  22566. zmin: number;
  22567. xmax: number;
  22568. zmax: number;
  22569. subdivisions?: {
  22570. w: number;
  22571. h: number;
  22572. };
  22573. precision?: {
  22574. w: number;
  22575. h: number;
  22576. };
  22577. }): VertexData;
  22578. /**
  22579. * Creates the VertexData of the Ground designed from a heightmap
  22580. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22581. * * width the width (x direction) of the ground
  22582. * * height the height (z direction) of the ground
  22583. * * subdivisions the number of subdivisions per side
  22584. * * minHeight the minimum altitude on the ground, optional, default 0
  22585. * * maxHeight the maximum altitude on the ground, optional default 1
  22586. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22587. * * buffer the array holding the image color data
  22588. * * bufferWidth the width of image
  22589. * * bufferHeight the height of image
  22590. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22591. * @returns the VertexData of the Ground designed from a heightmap
  22592. */
  22593. static CreateGroundFromHeightMap(options: {
  22594. width: number;
  22595. height: number;
  22596. subdivisions: number;
  22597. minHeight: number;
  22598. maxHeight: number;
  22599. colorFilter: Color3;
  22600. buffer: Uint8Array;
  22601. bufferWidth: number;
  22602. bufferHeight: number;
  22603. alphaFilter: number;
  22604. }): VertexData;
  22605. /**
  22606. * Creates the VertexData for a Plane
  22607. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22608. * * size sets the width and height of the plane to the value of size, optional default 1
  22609. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22610. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22611. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22612. * * 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)
  22613. * * 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)
  22614. * @returns the VertexData of the box
  22615. */
  22616. static CreatePlane(options: {
  22617. size?: number;
  22618. width?: number;
  22619. height?: number;
  22620. sideOrientation?: number;
  22621. frontUVs?: Vector4;
  22622. backUVs?: Vector4;
  22623. }): VertexData;
  22624. /**
  22625. * Creates the VertexData of the Disc or regular Polygon
  22626. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22627. * * radius the radius of the disc, optional default 0.5
  22628. * * tessellation the number of polygon sides, optional, default 64
  22629. * * 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
  22630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22631. * * 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)
  22632. * * 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)
  22633. * @returns the VertexData of the box
  22634. */
  22635. static CreateDisc(options: {
  22636. radius?: number;
  22637. tessellation?: number;
  22638. arc?: number;
  22639. sideOrientation?: number;
  22640. frontUVs?: Vector4;
  22641. backUVs?: Vector4;
  22642. }): VertexData;
  22643. /**
  22644. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22645. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22646. * @param polygon a mesh built from polygonTriangulation.build()
  22647. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22648. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22649. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22650. * @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)
  22651. * @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)
  22652. * @returns the VertexData of the Polygon
  22653. */
  22654. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22655. /**
  22656. * Creates the VertexData of the IcoSphere
  22657. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22658. * * radius the radius of the IcoSphere, optional default 1
  22659. * * radiusX allows stretching in the x direction, optional, default radius
  22660. * * radiusY allows stretching in the y direction, optional, default radius
  22661. * * radiusZ allows stretching in the z direction, optional, default radius
  22662. * * flat when true creates a flat shaded mesh, optional, default true
  22663. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22665. * * 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)
  22666. * * 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)
  22667. * @returns the VertexData of the IcoSphere
  22668. */
  22669. static CreateIcoSphere(options: {
  22670. radius?: number;
  22671. radiusX?: number;
  22672. radiusY?: number;
  22673. radiusZ?: number;
  22674. flat?: boolean;
  22675. subdivisions?: number;
  22676. sideOrientation?: number;
  22677. frontUVs?: Vector4;
  22678. backUVs?: Vector4;
  22679. }): VertexData;
  22680. /**
  22681. * Creates the VertexData for a Polyhedron
  22682. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22683. * * type provided types are:
  22684. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22685. * * 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)
  22686. * * size the size of the IcoSphere, optional default 1
  22687. * * sizeX allows stretching in the x direction, optional, default size
  22688. * * sizeY allows stretching in the y direction, optional, default size
  22689. * * sizeZ allows stretching in the z direction, optional, default size
  22690. * * 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
  22691. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22692. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22693. * * flat when true creates a flat shaded mesh, optional, default true
  22694. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22696. * * 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)
  22697. * * 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)
  22698. * @returns the VertexData of the Polyhedron
  22699. */
  22700. static CreatePolyhedron(options: {
  22701. type?: number;
  22702. size?: number;
  22703. sizeX?: number;
  22704. sizeY?: number;
  22705. sizeZ?: number;
  22706. custom?: any;
  22707. faceUV?: Vector4[];
  22708. faceColors?: Color4[];
  22709. flat?: boolean;
  22710. sideOrientation?: number;
  22711. frontUVs?: Vector4;
  22712. backUVs?: Vector4;
  22713. }): VertexData;
  22714. /**
  22715. * Creates the VertexData for a TorusKnot
  22716. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22717. * * radius the radius of the torus knot, optional, default 2
  22718. * * tube the thickness of the tube, optional, default 0.5
  22719. * * radialSegments the number of sides on each tube segments, optional, default 32
  22720. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22721. * * p the number of windings around the z axis, optional, default 2
  22722. * * q the number of windings around the x axis, optional, default 3
  22723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22724. * * 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)
  22725. * * 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)
  22726. * @returns the VertexData of the Torus Knot
  22727. */
  22728. static CreateTorusKnot(options: {
  22729. radius?: number;
  22730. tube?: number;
  22731. radialSegments?: number;
  22732. tubularSegments?: number;
  22733. p?: number;
  22734. q?: number;
  22735. sideOrientation?: number;
  22736. frontUVs?: Vector4;
  22737. backUVs?: Vector4;
  22738. }): VertexData;
  22739. /**
  22740. * Compute normals for given positions and indices
  22741. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22742. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22743. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22744. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22745. * * facetNormals : optional array of facet normals (vector3)
  22746. * * facetPositions : optional array of facet positions (vector3)
  22747. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22748. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22749. * * bInfo : optional bounding info, required for facetPartitioning computation
  22750. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22751. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22752. * * useRightHandedSystem: optional boolean to for right handed system computation
  22753. * * depthSort : optional boolean to enable the facet depth sort computation
  22754. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22755. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22756. */
  22757. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22758. facetNormals?: any;
  22759. facetPositions?: any;
  22760. facetPartitioning?: any;
  22761. ratio?: number;
  22762. bInfo?: any;
  22763. bbSize?: Vector3;
  22764. subDiv?: any;
  22765. useRightHandedSystem?: boolean;
  22766. depthSort?: boolean;
  22767. distanceTo?: Vector3;
  22768. depthSortedFacets?: any;
  22769. }): void;
  22770. /** @hidden */
  22771. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22772. /**
  22773. * Applies VertexData created from the imported parameters to the geometry
  22774. * @param parsedVertexData the parsed data from an imported file
  22775. * @param geometry the geometry to apply the VertexData to
  22776. */
  22777. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22778. }
  22779. }
  22780. declare module "babylonjs/Morph/morphTarget" {
  22781. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22782. import { Observable } from "babylonjs/Misc/observable";
  22783. import { Nullable, FloatArray } from "babylonjs/types";
  22784. import { Scene } from "babylonjs/scene";
  22785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22786. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22787. /**
  22788. * Defines a target to use with MorphTargetManager
  22789. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22790. */
  22791. export class MorphTarget implements IAnimatable {
  22792. /** defines the name of the target */
  22793. name: string;
  22794. /**
  22795. * Gets or sets the list of animations
  22796. */
  22797. animations: import("babylonjs/Animations/animation").Animation[];
  22798. private _scene;
  22799. private _positions;
  22800. private _normals;
  22801. private _tangents;
  22802. private _uvs;
  22803. private _influence;
  22804. private _uniqueId;
  22805. /**
  22806. * Observable raised when the influence changes
  22807. */
  22808. onInfluenceChanged: Observable<boolean>;
  22809. /** @hidden */
  22810. _onDataLayoutChanged: Observable<void>;
  22811. /**
  22812. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22813. */
  22814. influence: number;
  22815. /**
  22816. * Gets or sets the id of the morph Target
  22817. */
  22818. id: string;
  22819. private _animationPropertiesOverride;
  22820. /**
  22821. * Gets or sets the animation properties override
  22822. */
  22823. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22824. /**
  22825. * Creates a new MorphTarget
  22826. * @param name defines the name of the target
  22827. * @param influence defines the influence to use
  22828. * @param scene defines the scene the morphtarget belongs to
  22829. */
  22830. constructor(
  22831. /** defines the name of the target */
  22832. name: string, influence?: number, scene?: Nullable<Scene>);
  22833. /**
  22834. * Gets the unique ID of this manager
  22835. */
  22836. readonly uniqueId: number;
  22837. /**
  22838. * Gets a boolean defining if the target contains position data
  22839. */
  22840. readonly hasPositions: boolean;
  22841. /**
  22842. * Gets a boolean defining if the target contains normal data
  22843. */
  22844. readonly hasNormals: boolean;
  22845. /**
  22846. * Gets a boolean defining if the target contains tangent data
  22847. */
  22848. readonly hasTangents: boolean;
  22849. /**
  22850. * Gets a boolean defining if the target contains texture coordinates data
  22851. */
  22852. readonly hasUVs: boolean;
  22853. /**
  22854. * Affects position data to this target
  22855. * @param data defines the position data to use
  22856. */
  22857. setPositions(data: Nullable<FloatArray>): void;
  22858. /**
  22859. * Gets the position data stored in this target
  22860. * @returns a FloatArray containing the position data (or null if not present)
  22861. */
  22862. getPositions(): Nullable<FloatArray>;
  22863. /**
  22864. * Affects normal data to this target
  22865. * @param data defines the normal data to use
  22866. */
  22867. setNormals(data: Nullable<FloatArray>): void;
  22868. /**
  22869. * Gets the normal data stored in this target
  22870. * @returns a FloatArray containing the normal data (or null if not present)
  22871. */
  22872. getNormals(): Nullable<FloatArray>;
  22873. /**
  22874. * Affects tangent data to this target
  22875. * @param data defines the tangent data to use
  22876. */
  22877. setTangents(data: Nullable<FloatArray>): void;
  22878. /**
  22879. * Gets the tangent data stored in this target
  22880. * @returns a FloatArray containing the tangent data (or null if not present)
  22881. */
  22882. getTangents(): Nullable<FloatArray>;
  22883. /**
  22884. * Affects texture coordinates data to this target
  22885. * @param data defines the texture coordinates data to use
  22886. */
  22887. setUVs(data: Nullable<FloatArray>): void;
  22888. /**
  22889. * Gets the texture coordinates data stored in this target
  22890. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22891. */
  22892. getUVs(): Nullable<FloatArray>;
  22893. /**
  22894. * Clone the current target
  22895. * @returns a new MorphTarget
  22896. */
  22897. clone(): MorphTarget;
  22898. /**
  22899. * Serializes the current target into a Serialization object
  22900. * @returns the serialized object
  22901. */
  22902. serialize(): any;
  22903. /**
  22904. * Returns the string "MorphTarget"
  22905. * @returns "MorphTarget"
  22906. */
  22907. getClassName(): string;
  22908. /**
  22909. * Creates a new target from serialized data
  22910. * @param serializationObject defines the serialized data to use
  22911. * @returns a new MorphTarget
  22912. */
  22913. static Parse(serializationObject: any): MorphTarget;
  22914. /**
  22915. * Creates a MorphTarget from mesh data
  22916. * @param mesh defines the source mesh
  22917. * @param name defines the name to use for the new target
  22918. * @param influence defines the influence to attach to the target
  22919. * @returns a new MorphTarget
  22920. */
  22921. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22922. }
  22923. }
  22924. declare module "babylonjs/Morph/morphTargetManager" {
  22925. import { Nullable } from "babylonjs/types";
  22926. import { Scene } from "babylonjs/scene";
  22927. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22928. /**
  22929. * This class is used to deform meshes using morphing between different targets
  22930. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22931. */
  22932. export class MorphTargetManager {
  22933. private _targets;
  22934. private _targetInfluenceChangedObservers;
  22935. private _targetDataLayoutChangedObservers;
  22936. private _activeTargets;
  22937. private _scene;
  22938. private _influences;
  22939. private _supportsNormals;
  22940. private _supportsTangents;
  22941. private _supportsUVs;
  22942. private _vertexCount;
  22943. private _uniqueId;
  22944. private _tempInfluences;
  22945. /**
  22946. * Gets or sets a boolean indicating if normals must be morphed
  22947. */
  22948. enableNormalMorphing: boolean;
  22949. /**
  22950. * Gets or sets a boolean indicating if tangents must be morphed
  22951. */
  22952. enableTangentMorphing: boolean;
  22953. /**
  22954. * Gets or sets a boolean indicating if UV must be morphed
  22955. */
  22956. enableUVMorphing: boolean;
  22957. /**
  22958. * Creates a new MorphTargetManager
  22959. * @param scene defines the current scene
  22960. */
  22961. constructor(scene?: Nullable<Scene>);
  22962. /**
  22963. * Gets the unique ID of this manager
  22964. */
  22965. readonly uniqueId: number;
  22966. /**
  22967. * Gets the number of vertices handled by this manager
  22968. */
  22969. readonly vertexCount: number;
  22970. /**
  22971. * Gets a boolean indicating if this manager supports morphing of normals
  22972. */
  22973. readonly supportsNormals: boolean;
  22974. /**
  22975. * Gets a boolean indicating if this manager supports morphing of tangents
  22976. */
  22977. readonly supportsTangents: boolean;
  22978. /**
  22979. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22980. */
  22981. readonly supportsUVs: boolean;
  22982. /**
  22983. * Gets the number of targets stored in this manager
  22984. */
  22985. readonly numTargets: number;
  22986. /**
  22987. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22988. */
  22989. readonly numInfluencers: number;
  22990. /**
  22991. * Gets the list of influences (one per target)
  22992. */
  22993. readonly influences: Float32Array;
  22994. /**
  22995. * Gets the active target at specified index. An active target is a target with an influence > 0
  22996. * @param index defines the index to check
  22997. * @returns the requested target
  22998. */
  22999. getActiveTarget(index: number): MorphTarget;
  23000. /**
  23001. * Gets the target at specified index
  23002. * @param index defines the index to check
  23003. * @returns the requested target
  23004. */
  23005. getTarget(index: number): MorphTarget;
  23006. /**
  23007. * Add a new target to this manager
  23008. * @param target defines the target to add
  23009. */
  23010. addTarget(target: MorphTarget): void;
  23011. /**
  23012. * Removes a target from the manager
  23013. * @param target defines the target to remove
  23014. */
  23015. removeTarget(target: MorphTarget): void;
  23016. /**
  23017. * Clone the current manager
  23018. * @returns a new MorphTargetManager
  23019. */
  23020. clone(): MorphTargetManager;
  23021. /**
  23022. * Serializes the current manager into a Serialization object
  23023. * @returns the serialized object
  23024. */
  23025. serialize(): any;
  23026. private _syncActiveTargets;
  23027. /**
  23028. * Syncrhonize the targets with all the meshes using this morph target manager
  23029. */
  23030. synchronize(): void;
  23031. /**
  23032. * Creates a new MorphTargetManager from serialized data
  23033. * @param serializationObject defines the serialized data
  23034. * @param scene defines the hosting scene
  23035. * @returns the new MorphTargetManager
  23036. */
  23037. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23038. }
  23039. }
  23040. declare module "babylonjs/Meshes/meshLODLevel" {
  23041. import { Mesh } from "babylonjs/Meshes/mesh";
  23042. import { Nullable } from "babylonjs/types";
  23043. /**
  23044. * Class used to represent a specific level of detail of a mesh
  23045. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23046. */
  23047. export class MeshLODLevel {
  23048. /** Defines the distance where this level should start being displayed */
  23049. distance: number;
  23050. /** Defines the mesh to use to render this level */
  23051. mesh: Nullable<Mesh>;
  23052. /**
  23053. * Creates a new LOD level
  23054. * @param distance defines the distance where this level should star being displayed
  23055. * @param mesh defines the mesh to use to render this level
  23056. */
  23057. constructor(
  23058. /** Defines the distance where this level should start being displayed */
  23059. distance: number,
  23060. /** Defines the mesh to use to render this level */
  23061. mesh: Nullable<Mesh>);
  23062. }
  23063. }
  23064. declare module "babylonjs/Meshes/groundMesh" {
  23065. import { Scene } from "babylonjs/scene";
  23066. import { Vector3 } from "babylonjs/Maths/math.vector";
  23067. import { Mesh } from "babylonjs/Meshes/mesh";
  23068. /**
  23069. * Mesh representing the gorund
  23070. */
  23071. export class GroundMesh extends Mesh {
  23072. /** If octree should be generated */
  23073. generateOctree: boolean;
  23074. private _heightQuads;
  23075. /** @hidden */
  23076. _subdivisionsX: number;
  23077. /** @hidden */
  23078. _subdivisionsY: number;
  23079. /** @hidden */
  23080. _width: number;
  23081. /** @hidden */
  23082. _height: number;
  23083. /** @hidden */
  23084. _minX: number;
  23085. /** @hidden */
  23086. _maxX: number;
  23087. /** @hidden */
  23088. _minZ: number;
  23089. /** @hidden */
  23090. _maxZ: number;
  23091. constructor(name: string, scene: Scene);
  23092. /**
  23093. * "GroundMesh"
  23094. * @returns "GroundMesh"
  23095. */
  23096. getClassName(): string;
  23097. /**
  23098. * The minimum of x and y subdivisions
  23099. */
  23100. readonly subdivisions: number;
  23101. /**
  23102. * X subdivisions
  23103. */
  23104. readonly subdivisionsX: number;
  23105. /**
  23106. * Y subdivisions
  23107. */
  23108. readonly subdivisionsY: number;
  23109. /**
  23110. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23111. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23112. * @param chunksCount the number of subdivisions for x and y
  23113. * @param octreeBlocksSize (Default: 32)
  23114. */
  23115. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23116. /**
  23117. * Returns a height (y) value in the Worl system :
  23118. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23119. * @param x x coordinate
  23120. * @param z z coordinate
  23121. * @returns the ground y position if (x, z) are outside the ground surface.
  23122. */
  23123. getHeightAtCoordinates(x: number, z: number): number;
  23124. /**
  23125. * Returns a normalized vector (Vector3) orthogonal to the ground
  23126. * at the ground coordinates (x, z) expressed in the World system.
  23127. * @param x x coordinate
  23128. * @param z z coordinate
  23129. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23130. */
  23131. getNormalAtCoordinates(x: number, z: number): Vector3;
  23132. /**
  23133. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23134. * at the ground coordinates (x, z) expressed in the World system.
  23135. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23136. * @param x x coordinate
  23137. * @param z z coordinate
  23138. * @param ref vector to store the result
  23139. * @returns the GroundMesh.
  23140. */
  23141. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23142. /**
  23143. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23144. * if the ground has been updated.
  23145. * This can be used in the render loop.
  23146. * @returns the GroundMesh.
  23147. */
  23148. updateCoordinateHeights(): GroundMesh;
  23149. private _getFacetAt;
  23150. private _initHeightQuads;
  23151. private _computeHeightQuads;
  23152. /**
  23153. * Serializes this ground mesh
  23154. * @param serializationObject object to write serialization to
  23155. */
  23156. serialize(serializationObject: any): void;
  23157. /**
  23158. * Parses a serialized ground mesh
  23159. * @param parsedMesh the serialized mesh
  23160. * @param scene the scene to create the ground mesh in
  23161. * @returns the created ground mesh
  23162. */
  23163. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23164. }
  23165. }
  23166. declare module "babylonjs/Physics/physicsJoint" {
  23167. import { Vector3 } from "babylonjs/Maths/math.vector";
  23168. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23169. /**
  23170. * Interface for Physics-Joint data
  23171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23172. */
  23173. export interface PhysicsJointData {
  23174. /**
  23175. * The main pivot of the joint
  23176. */
  23177. mainPivot?: Vector3;
  23178. /**
  23179. * The connected pivot of the joint
  23180. */
  23181. connectedPivot?: Vector3;
  23182. /**
  23183. * The main axis of the joint
  23184. */
  23185. mainAxis?: Vector3;
  23186. /**
  23187. * The connected axis of the joint
  23188. */
  23189. connectedAxis?: Vector3;
  23190. /**
  23191. * The collision of the joint
  23192. */
  23193. collision?: boolean;
  23194. /**
  23195. * Native Oimo/Cannon/Energy data
  23196. */
  23197. nativeParams?: any;
  23198. }
  23199. /**
  23200. * This is a holder class for the physics joint created by the physics plugin
  23201. * It holds a set of functions to control the underlying joint
  23202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23203. */
  23204. export class PhysicsJoint {
  23205. /**
  23206. * The type of the physics joint
  23207. */
  23208. type: number;
  23209. /**
  23210. * The data for the physics joint
  23211. */
  23212. jointData: PhysicsJointData;
  23213. private _physicsJoint;
  23214. protected _physicsPlugin: IPhysicsEnginePlugin;
  23215. /**
  23216. * Initializes the physics joint
  23217. * @param type The type of the physics joint
  23218. * @param jointData The data for the physics joint
  23219. */
  23220. constructor(
  23221. /**
  23222. * The type of the physics joint
  23223. */
  23224. type: number,
  23225. /**
  23226. * The data for the physics joint
  23227. */
  23228. jointData: PhysicsJointData);
  23229. /**
  23230. * Gets the physics joint
  23231. */
  23232. /**
  23233. * Sets the physics joint
  23234. */
  23235. physicsJoint: any;
  23236. /**
  23237. * Sets the physics plugin
  23238. */
  23239. physicsPlugin: IPhysicsEnginePlugin;
  23240. /**
  23241. * Execute a function that is physics-plugin specific.
  23242. * @param {Function} func the function that will be executed.
  23243. * It accepts two parameters: the physics world and the physics joint
  23244. */
  23245. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23246. /**
  23247. * Distance-Joint type
  23248. */
  23249. static DistanceJoint: number;
  23250. /**
  23251. * Hinge-Joint type
  23252. */
  23253. static HingeJoint: number;
  23254. /**
  23255. * Ball-and-Socket joint type
  23256. */
  23257. static BallAndSocketJoint: number;
  23258. /**
  23259. * Wheel-Joint type
  23260. */
  23261. static WheelJoint: number;
  23262. /**
  23263. * Slider-Joint type
  23264. */
  23265. static SliderJoint: number;
  23266. /**
  23267. * Prismatic-Joint type
  23268. */
  23269. static PrismaticJoint: number;
  23270. /**
  23271. * Universal-Joint type
  23272. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23273. */
  23274. static UniversalJoint: number;
  23275. /**
  23276. * Hinge-Joint 2 type
  23277. */
  23278. static Hinge2Joint: number;
  23279. /**
  23280. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23281. */
  23282. static PointToPointJoint: number;
  23283. /**
  23284. * Spring-Joint type
  23285. */
  23286. static SpringJoint: number;
  23287. /**
  23288. * Lock-Joint type
  23289. */
  23290. static LockJoint: number;
  23291. }
  23292. /**
  23293. * A class representing a physics distance joint
  23294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23295. */
  23296. export class DistanceJoint extends PhysicsJoint {
  23297. /**
  23298. *
  23299. * @param jointData The data for the Distance-Joint
  23300. */
  23301. constructor(jointData: DistanceJointData);
  23302. /**
  23303. * Update the predefined distance.
  23304. * @param maxDistance The maximum preferred distance
  23305. * @param minDistance The minimum preferred distance
  23306. */
  23307. updateDistance(maxDistance: number, minDistance?: number): void;
  23308. }
  23309. /**
  23310. * Represents a Motor-Enabled Joint
  23311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23312. */
  23313. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23314. /**
  23315. * Initializes the Motor-Enabled Joint
  23316. * @param type The type of the joint
  23317. * @param jointData The physica joint data for the joint
  23318. */
  23319. constructor(type: number, jointData: PhysicsJointData);
  23320. /**
  23321. * Set the motor values.
  23322. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23323. * @param force the force to apply
  23324. * @param maxForce max force for this motor.
  23325. */
  23326. setMotor(force?: number, maxForce?: number): void;
  23327. /**
  23328. * Set the motor's limits.
  23329. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23330. * @param upperLimit The upper limit of the motor
  23331. * @param lowerLimit The lower limit of the motor
  23332. */
  23333. setLimit(upperLimit: number, lowerLimit?: number): void;
  23334. }
  23335. /**
  23336. * This class represents a single physics Hinge-Joint
  23337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23338. */
  23339. export class HingeJoint extends MotorEnabledJoint {
  23340. /**
  23341. * Initializes the Hinge-Joint
  23342. * @param jointData The joint data for the Hinge-Joint
  23343. */
  23344. constructor(jointData: PhysicsJointData);
  23345. /**
  23346. * Set the motor values.
  23347. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23348. * @param {number} force the force to apply
  23349. * @param {number} maxForce max force for this motor.
  23350. */
  23351. setMotor(force?: number, maxForce?: number): void;
  23352. /**
  23353. * Set the motor's limits.
  23354. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23355. * @param upperLimit The upper limit of the motor
  23356. * @param lowerLimit The lower limit of the motor
  23357. */
  23358. setLimit(upperLimit: number, lowerLimit?: number): void;
  23359. }
  23360. /**
  23361. * This class represents a dual hinge physics joint (same as wheel joint)
  23362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23363. */
  23364. export class Hinge2Joint extends MotorEnabledJoint {
  23365. /**
  23366. * Initializes the Hinge2-Joint
  23367. * @param jointData The joint data for the Hinge2-Joint
  23368. */
  23369. constructor(jointData: PhysicsJointData);
  23370. /**
  23371. * Set the motor values.
  23372. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23373. * @param {number} targetSpeed the speed the motor is to reach
  23374. * @param {number} maxForce max force for this motor.
  23375. * @param {motorIndex} the motor's index, 0 or 1.
  23376. */
  23377. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23378. /**
  23379. * Set the motor limits.
  23380. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23381. * @param {number} upperLimit the upper limit
  23382. * @param {number} lowerLimit lower limit
  23383. * @param {motorIndex} the motor's index, 0 or 1.
  23384. */
  23385. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23386. }
  23387. /**
  23388. * Interface for a motor enabled joint
  23389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23390. */
  23391. export interface IMotorEnabledJoint {
  23392. /**
  23393. * Physics joint
  23394. */
  23395. physicsJoint: any;
  23396. /**
  23397. * Sets the motor of the motor-enabled joint
  23398. * @param force The force of the motor
  23399. * @param maxForce The maximum force of the motor
  23400. * @param motorIndex The index of the motor
  23401. */
  23402. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23403. /**
  23404. * Sets the limit of the motor
  23405. * @param upperLimit The upper limit of the motor
  23406. * @param lowerLimit The lower limit of the motor
  23407. * @param motorIndex The index of the motor
  23408. */
  23409. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23410. }
  23411. /**
  23412. * Joint data for a Distance-Joint
  23413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23414. */
  23415. export interface DistanceJointData extends PhysicsJointData {
  23416. /**
  23417. * Max distance the 2 joint objects can be apart
  23418. */
  23419. maxDistance: number;
  23420. }
  23421. /**
  23422. * Joint data from a spring joint
  23423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23424. */
  23425. export interface SpringJointData extends PhysicsJointData {
  23426. /**
  23427. * Length of the spring
  23428. */
  23429. length: number;
  23430. /**
  23431. * Stiffness of the spring
  23432. */
  23433. stiffness: number;
  23434. /**
  23435. * Damping of the spring
  23436. */
  23437. damping: number;
  23438. /** this callback will be called when applying the force to the impostors. */
  23439. forceApplicationCallback: () => void;
  23440. }
  23441. }
  23442. declare module "babylonjs/Physics/physicsRaycastResult" {
  23443. import { Vector3 } from "babylonjs/Maths/math.vector";
  23444. /**
  23445. * Holds the data for the raycast result
  23446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23447. */
  23448. export class PhysicsRaycastResult {
  23449. private _hasHit;
  23450. private _hitDistance;
  23451. private _hitNormalWorld;
  23452. private _hitPointWorld;
  23453. private _rayFromWorld;
  23454. private _rayToWorld;
  23455. /**
  23456. * Gets if there was a hit
  23457. */
  23458. readonly hasHit: boolean;
  23459. /**
  23460. * Gets the distance from the hit
  23461. */
  23462. readonly hitDistance: number;
  23463. /**
  23464. * Gets the hit normal/direction in the world
  23465. */
  23466. readonly hitNormalWorld: Vector3;
  23467. /**
  23468. * Gets the hit point in the world
  23469. */
  23470. readonly hitPointWorld: Vector3;
  23471. /**
  23472. * Gets the ray "start point" of the ray in the world
  23473. */
  23474. readonly rayFromWorld: Vector3;
  23475. /**
  23476. * Gets the ray "end point" of the ray in the world
  23477. */
  23478. readonly rayToWorld: Vector3;
  23479. /**
  23480. * Sets the hit data (normal & point in world space)
  23481. * @param hitNormalWorld defines the normal in world space
  23482. * @param hitPointWorld defines the point in world space
  23483. */
  23484. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23485. /**
  23486. * Sets the distance from the start point to the hit point
  23487. * @param distance
  23488. */
  23489. setHitDistance(distance: number): void;
  23490. /**
  23491. * Calculates the distance manually
  23492. */
  23493. calculateHitDistance(): void;
  23494. /**
  23495. * Resets all the values to default
  23496. * @param from The from point on world space
  23497. * @param to The to point on world space
  23498. */
  23499. reset(from?: Vector3, to?: Vector3): void;
  23500. }
  23501. /**
  23502. * Interface for the size containing width and height
  23503. */
  23504. interface IXYZ {
  23505. /**
  23506. * X
  23507. */
  23508. x: number;
  23509. /**
  23510. * Y
  23511. */
  23512. y: number;
  23513. /**
  23514. * Z
  23515. */
  23516. z: number;
  23517. }
  23518. }
  23519. declare module "babylonjs/Physics/IPhysicsEngine" {
  23520. import { Nullable } from "babylonjs/types";
  23521. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23523. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23524. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23525. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23526. /**
  23527. * Interface used to describe a physics joint
  23528. */
  23529. export interface PhysicsImpostorJoint {
  23530. /** Defines the main impostor to which the joint is linked */
  23531. mainImpostor: PhysicsImpostor;
  23532. /** Defines the impostor that is connected to the main impostor using this joint */
  23533. connectedImpostor: PhysicsImpostor;
  23534. /** Defines the joint itself */
  23535. joint: PhysicsJoint;
  23536. }
  23537. /** @hidden */
  23538. export interface IPhysicsEnginePlugin {
  23539. world: any;
  23540. name: string;
  23541. setGravity(gravity: Vector3): void;
  23542. setTimeStep(timeStep: number): void;
  23543. getTimeStep(): number;
  23544. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23545. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23546. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23547. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23548. removePhysicsBody(impostor: PhysicsImpostor): void;
  23549. generateJoint(joint: PhysicsImpostorJoint): void;
  23550. removeJoint(joint: PhysicsImpostorJoint): void;
  23551. isSupported(): boolean;
  23552. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23553. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23554. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23555. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23556. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23557. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23558. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23559. getBodyMass(impostor: PhysicsImpostor): number;
  23560. getBodyFriction(impostor: PhysicsImpostor): number;
  23561. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23562. getBodyRestitution(impostor: PhysicsImpostor): number;
  23563. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23564. getBodyPressure?(impostor: PhysicsImpostor): number;
  23565. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23566. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23567. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23568. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23569. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23570. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23571. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23572. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23573. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23574. sleepBody(impostor: PhysicsImpostor): void;
  23575. wakeUpBody(impostor: PhysicsImpostor): void;
  23576. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23577. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23578. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23579. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23580. getRadius(impostor: PhysicsImpostor): number;
  23581. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23582. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23583. dispose(): void;
  23584. }
  23585. /**
  23586. * Interface used to define a physics engine
  23587. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23588. */
  23589. export interface IPhysicsEngine {
  23590. /**
  23591. * Gets the gravity vector used by the simulation
  23592. */
  23593. gravity: Vector3;
  23594. /**
  23595. * Sets the gravity vector used by the simulation
  23596. * @param gravity defines the gravity vector to use
  23597. */
  23598. setGravity(gravity: Vector3): void;
  23599. /**
  23600. * Set the time step of the physics engine.
  23601. * Default is 1/60.
  23602. * To slow it down, enter 1/600 for example.
  23603. * To speed it up, 1/30
  23604. * @param newTimeStep the new timestep to apply to this world.
  23605. */
  23606. setTimeStep(newTimeStep: number): void;
  23607. /**
  23608. * Get the time step of the physics engine.
  23609. * @returns the current time step
  23610. */
  23611. getTimeStep(): number;
  23612. /**
  23613. * Release all resources
  23614. */
  23615. dispose(): void;
  23616. /**
  23617. * Gets the name of the current physics plugin
  23618. * @returns the name of the plugin
  23619. */
  23620. getPhysicsPluginName(): string;
  23621. /**
  23622. * Adding a new impostor for the impostor tracking.
  23623. * This will be done by the impostor itself.
  23624. * @param impostor the impostor to add
  23625. */
  23626. addImpostor(impostor: PhysicsImpostor): void;
  23627. /**
  23628. * Remove an impostor from the engine.
  23629. * This impostor and its mesh will not longer be updated by the physics engine.
  23630. * @param impostor the impostor to remove
  23631. */
  23632. removeImpostor(impostor: PhysicsImpostor): void;
  23633. /**
  23634. * Add a joint to the physics engine
  23635. * @param mainImpostor defines the main impostor to which the joint is added.
  23636. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23637. * @param joint defines the joint that will connect both impostors.
  23638. */
  23639. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23640. /**
  23641. * Removes a joint from the simulation
  23642. * @param mainImpostor defines the impostor used with the joint
  23643. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23644. * @param joint defines the joint to remove
  23645. */
  23646. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23647. /**
  23648. * Gets the current plugin used to run the simulation
  23649. * @returns current plugin
  23650. */
  23651. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23652. /**
  23653. * Gets the list of physic impostors
  23654. * @returns an array of PhysicsImpostor
  23655. */
  23656. getImpostors(): Array<PhysicsImpostor>;
  23657. /**
  23658. * Gets the impostor for a physics enabled object
  23659. * @param object defines the object impersonated by the impostor
  23660. * @returns the PhysicsImpostor or null if not found
  23661. */
  23662. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23663. /**
  23664. * Gets the impostor for a physics body object
  23665. * @param body defines physics body used by the impostor
  23666. * @returns the PhysicsImpostor or null if not found
  23667. */
  23668. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23669. /**
  23670. * Does a raycast in the physics world
  23671. * @param from when should the ray start?
  23672. * @param to when should the ray end?
  23673. * @returns PhysicsRaycastResult
  23674. */
  23675. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23676. /**
  23677. * Called by the scene. No need to call it.
  23678. * @param delta defines the timespam between frames
  23679. */
  23680. _step(delta: number): void;
  23681. }
  23682. }
  23683. declare module "babylonjs/Physics/physicsImpostor" {
  23684. import { Nullable, IndicesArray } from "babylonjs/types";
  23685. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23686. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23688. import { Scene } from "babylonjs/scene";
  23689. import { Bone } from "babylonjs/Bones/bone";
  23690. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23691. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23692. import { Space } from "babylonjs/Maths/math.axis";
  23693. /**
  23694. * The interface for the physics imposter parameters
  23695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23696. */
  23697. export interface PhysicsImpostorParameters {
  23698. /**
  23699. * The mass of the physics imposter
  23700. */
  23701. mass: number;
  23702. /**
  23703. * The friction of the physics imposter
  23704. */
  23705. friction?: number;
  23706. /**
  23707. * The coefficient of restitution of the physics imposter
  23708. */
  23709. restitution?: number;
  23710. /**
  23711. * The native options of the physics imposter
  23712. */
  23713. nativeOptions?: any;
  23714. /**
  23715. * Specifies if the parent should be ignored
  23716. */
  23717. ignoreParent?: boolean;
  23718. /**
  23719. * Specifies if bi-directional transformations should be disabled
  23720. */
  23721. disableBidirectionalTransformation?: boolean;
  23722. /**
  23723. * The pressure inside the physics imposter, soft object only
  23724. */
  23725. pressure?: number;
  23726. /**
  23727. * The stiffness the physics imposter, soft object only
  23728. */
  23729. stiffness?: number;
  23730. /**
  23731. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23732. */
  23733. velocityIterations?: number;
  23734. /**
  23735. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23736. */
  23737. positionIterations?: number;
  23738. /**
  23739. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23740. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23741. * Add to fix multiple points
  23742. */
  23743. fixedPoints?: number;
  23744. /**
  23745. * The collision margin around a soft object
  23746. */
  23747. margin?: number;
  23748. /**
  23749. * The collision margin around a soft object
  23750. */
  23751. damping?: number;
  23752. /**
  23753. * The path for a rope based on an extrusion
  23754. */
  23755. path?: any;
  23756. /**
  23757. * The shape of an extrusion used for a rope based on an extrusion
  23758. */
  23759. shape?: any;
  23760. }
  23761. /**
  23762. * Interface for a physics-enabled object
  23763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23764. */
  23765. export interface IPhysicsEnabledObject {
  23766. /**
  23767. * The position of the physics-enabled object
  23768. */
  23769. position: Vector3;
  23770. /**
  23771. * The rotation of the physics-enabled object
  23772. */
  23773. rotationQuaternion: Nullable<Quaternion>;
  23774. /**
  23775. * The scale of the physics-enabled object
  23776. */
  23777. scaling: Vector3;
  23778. /**
  23779. * The rotation of the physics-enabled object
  23780. */
  23781. rotation?: Vector3;
  23782. /**
  23783. * The parent of the physics-enabled object
  23784. */
  23785. parent?: any;
  23786. /**
  23787. * The bounding info of the physics-enabled object
  23788. * @returns The bounding info of the physics-enabled object
  23789. */
  23790. getBoundingInfo(): BoundingInfo;
  23791. /**
  23792. * Computes the world matrix
  23793. * @param force Specifies if the world matrix should be computed by force
  23794. * @returns A world matrix
  23795. */
  23796. computeWorldMatrix(force: boolean): Matrix;
  23797. /**
  23798. * Gets the world matrix
  23799. * @returns A world matrix
  23800. */
  23801. getWorldMatrix?(): Matrix;
  23802. /**
  23803. * Gets the child meshes
  23804. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23805. * @returns An array of abstract meshes
  23806. */
  23807. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23808. /**
  23809. * Gets the vertex data
  23810. * @param kind The type of vertex data
  23811. * @returns A nullable array of numbers, or a float32 array
  23812. */
  23813. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23814. /**
  23815. * Gets the indices from the mesh
  23816. * @returns A nullable array of index arrays
  23817. */
  23818. getIndices?(): Nullable<IndicesArray>;
  23819. /**
  23820. * Gets the scene from the mesh
  23821. * @returns the indices array or null
  23822. */
  23823. getScene?(): Scene;
  23824. /**
  23825. * Gets the absolute position from the mesh
  23826. * @returns the absolute position
  23827. */
  23828. getAbsolutePosition(): Vector3;
  23829. /**
  23830. * Gets the absolute pivot point from the mesh
  23831. * @returns the absolute pivot point
  23832. */
  23833. getAbsolutePivotPoint(): Vector3;
  23834. /**
  23835. * Rotates the mesh
  23836. * @param axis The axis of rotation
  23837. * @param amount The amount of rotation
  23838. * @param space The space of the rotation
  23839. * @returns The rotation transform node
  23840. */
  23841. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23842. /**
  23843. * Translates the mesh
  23844. * @param axis The axis of translation
  23845. * @param distance The distance of translation
  23846. * @param space The space of the translation
  23847. * @returns The transform node
  23848. */
  23849. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23850. /**
  23851. * Sets the absolute position of the mesh
  23852. * @param absolutePosition The absolute position of the mesh
  23853. * @returns The transform node
  23854. */
  23855. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23856. /**
  23857. * Gets the class name of the mesh
  23858. * @returns The class name
  23859. */
  23860. getClassName(): string;
  23861. }
  23862. /**
  23863. * Represents a physics imposter
  23864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23865. */
  23866. export class PhysicsImpostor {
  23867. /**
  23868. * The physics-enabled object used as the physics imposter
  23869. */
  23870. object: IPhysicsEnabledObject;
  23871. /**
  23872. * The type of the physics imposter
  23873. */
  23874. type: number;
  23875. private _options;
  23876. private _scene?;
  23877. /**
  23878. * The default object size of the imposter
  23879. */
  23880. static DEFAULT_OBJECT_SIZE: Vector3;
  23881. /**
  23882. * The identity quaternion of the imposter
  23883. */
  23884. static IDENTITY_QUATERNION: Quaternion;
  23885. /** @hidden */
  23886. _pluginData: any;
  23887. private _physicsEngine;
  23888. private _physicsBody;
  23889. private _bodyUpdateRequired;
  23890. private _onBeforePhysicsStepCallbacks;
  23891. private _onAfterPhysicsStepCallbacks;
  23892. /** @hidden */
  23893. _onPhysicsCollideCallbacks: Array<{
  23894. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23895. otherImpostors: Array<PhysicsImpostor>;
  23896. }>;
  23897. private _deltaPosition;
  23898. private _deltaRotation;
  23899. private _deltaRotationConjugated;
  23900. /** @hidden */
  23901. _isFromLine: boolean;
  23902. private _parent;
  23903. private _isDisposed;
  23904. private static _tmpVecs;
  23905. private static _tmpQuat;
  23906. /**
  23907. * Specifies if the physics imposter is disposed
  23908. */
  23909. readonly isDisposed: boolean;
  23910. /**
  23911. * Gets the mass of the physics imposter
  23912. */
  23913. mass: number;
  23914. /**
  23915. * Gets the coefficient of friction
  23916. */
  23917. /**
  23918. * Sets the coefficient of friction
  23919. */
  23920. friction: number;
  23921. /**
  23922. * Gets the coefficient of restitution
  23923. */
  23924. /**
  23925. * Sets the coefficient of restitution
  23926. */
  23927. restitution: number;
  23928. /**
  23929. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23930. */
  23931. /**
  23932. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23933. */
  23934. pressure: number;
  23935. /**
  23936. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23937. */
  23938. /**
  23939. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23940. */
  23941. stiffness: number;
  23942. /**
  23943. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23944. */
  23945. /**
  23946. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23947. */
  23948. velocityIterations: number;
  23949. /**
  23950. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23951. */
  23952. /**
  23953. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23954. */
  23955. positionIterations: number;
  23956. /**
  23957. * The unique id of the physics imposter
  23958. * set by the physics engine when adding this impostor to the array
  23959. */
  23960. uniqueId: number;
  23961. /**
  23962. * @hidden
  23963. */
  23964. soft: boolean;
  23965. /**
  23966. * @hidden
  23967. */
  23968. segments: number;
  23969. private _joints;
  23970. /**
  23971. * Initializes the physics imposter
  23972. * @param object The physics-enabled object used as the physics imposter
  23973. * @param type The type of the physics imposter
  23974. * @param _options The options for the physics imposter
  23975. * @param _scene The Babylon scene
  23976. */
  23977. constructor(
  23978. /**
  23979. * The physics-enabled object used as the physics imposter
  23980. */
  23981. object: IPhysicsEnabledObject,
  23982. /**
  23983. * The type of the physics imposter
  23984. */
  23985. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23986. /**
  23987. * This function will completly initialize this impostor.
  23988. * It will create a new body - but only if this mesh has no parent.
  23989. * If it has, this impostor will not be used other than to define the impostor
  23990. * of the child mesh.
  23991. * @hidden
  23992. */
  23993. _init(): void;
  23994. private _getPhysicsParent;
  23995. /**
  23996. * Should a new body be generated.
  23997. * @returns boolean specifying if body initialization is required
  23998. */
  23999. isBodyInitRequired(): boolean;
  24000. /**
  24001. * Sets the updated scaling
  24002. * @param updated Specifies if the scaling is updated
  24003. */
  24004. setScalingUpdated(): void;
  24005. /**
  24006. * Force a regeneration of this or the parent's impostor's body.
  24007. * Use under cautious - This will remove all joints already implemented.
  24008. */
  24009. forceUpdate(): void;
  24010. /**
  24011. * Gets the body that holds this impostor. Either its own, or its parent.
  24012. */
  24013. /**
  24014. * Set the physics body. Used mainly by the physics engine/plugin
  24015. */
  24016. physicsBody: any;
  24017. /**
  24018. * Get the parent of the physics imposter
  24019. * @returns Physics imposter or null
  24020. */
  24021. /**
  24022. * Sets the parent of the physics imposter
  24023. */
  24024. parent: Nullable<PhysicsImpostor>;
  24025. /**
  24026. * Resets the update flags
  24027. */
  24028. resetUpdateFlags(): void;
  24029. /**
  24030. * Gets the object extend size
  24031. * @returns the object extend size
  24032. */
  24033. getObjectExtendSize(): Vector3;
  24034. /**
  24035. * Gets the object center
  24036. * @returns The object center
  24037. */
  24038. getObjectCenter(): Vector3;
  24039. /**
  24040. * Get a specific parametes from the options parameter
  24041. * @param paramName The object parameter name
  24042. * @returns The object parameter
  24043. */
  24044. getParam(paramName: string): any;
  24045. /**
  24046. * Sets a specific parameter in the options given to the physics plugin
  24047. * @param paramName The parameter name
  24048. * @param value The value of the parameter
  24049. */
  24050. setParam(paramName: string, value: number): void;
  24051. /**
  24052. * Specifically change the body's mass option. Won't recreate the physics body object
  24053. * @param mass The mass of the physics imposter
  24054. */
  24055. setMass(mass: number): void;
  24056. /**
  24057. * Gets the linear velocity
  24058. * @returns linear velocity or null
  24059. */
  24060. getLinearVelocity(): Nullable<Vector3>;
  24061. /**
  24062. * Sets the linear velocity
  24063. * @param velocity linear velocity or null
  24064. */
  24065. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24066. /**
  24067. * Gets the angular velocity
  24068. * @returns angular velocity or null
  24069. */
  24070. getAngularVelocity(): Nullable<Vector3>;
  24071. /**
  24072. * Sets the angular velocity
  24073. * @param velocity The velocity or null
  24074. */
  24075. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24076. /**
  24077. * Execute a function with the physics plugin native code
  24078. * Provide a function the will have two variables - the world object and the physics body object
  24079. * @param func The function to execute with the physics plugin native code
  24080. */
  24081. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24082. /**
  24083. * Register a function that will be executed before the physics world is stepping forward
  24084. * @param func The function to execute before the physics world is stepped forward
  24085. */
  24086. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24087. /**
  24088. * Unregister a function that will be executed before the physics world is stepping forward
  24089. * @param func The function to execute before the physics world is stepped forward
  24090. */
  24091. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24092. /**
  24093. * Register a function that will be executed after the physics step
  24094. * @param func The function to execute after physics step
  24095. */
  24096. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24097. /**
  24098. * Unregisters a function that will be executed after the physics step
  24099. * @param func The function to execute after physics step
  24100. */
  24101. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24102. /**
  24103. * register a function that will be executed when this impostor collides against a different body
  24104. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24105. * @param func Callback that is executed on collision
  24106. */
  24107. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24108. /**
  24109. * Unregisters the physics imposter on contact
  24110. * @param collideAgainst The physics object to collide against
  24111. * @param func Callback to execute on collision
  24112. */
  24113. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24114. private _tmpQuat;
  24115. private _tmpQuat2;
  24116. /**
  24117. * Get the parent rotation
  24118. * @returns The parent rotation
  24119. */
  24120. getParentsRotation(): Quaternion;
  24121. /**
  24122. * this function is executed by the physics engine.
  24123. */
  24124. beforeStep: () => void;
  24125. /**
  24126. * this function is executed by the physics engine
  24127. */
  24128. afterStep: () => void;
  24129. /**
  24130. * Legacy collision detection event support
  24131. */
  24132. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24133. /**
  24134. * event and body object due to cannon's event-based architecture.
  24135. */
  24136. onCollide: (e: {
  24137. body: any;
  24138. }) => void;
  24139. /**
  24140. * Apply a force
  24141. * @param force The force to apply
  24142. * @param contactPoint The contact point for the force
  24143. * @returns The physics imposter
  24144. */
  24145. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24146. /**
  24147. * Apply an impulse
  24148. * @param force The impulse force
  24149. * @param contactPoint The contact point for the impulse force
  24150. * @returns The physics imposter
  24151. */
  24152. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24153. /**
  24154. * A help function to create a joint
  24155. * @param otherImpostor A physics imposter used to create a joint
  24156. * @param jointType The type of joint
  24157. * @param jointData The data for the joint
  24158. * @returns The physics imposter
  24159. */
  24160. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24161. /**
  24162. * Add a joint to this impostor with a different impostor
  24163. * @param otherImpostor A physics imposter used to add a joint
  24164. * @param joint The joint to add
  24165. * @returns The physics imposter
  24166. */
  24167. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24168. /**
  24169. * Add an anchor to a cloth impostor
  24170. * @param otherImpostor rigid impostor to anchor to
  24171. * @param width ratio across width from 0 to 1
  24172. * @param height ratio up height from 0 to 1
  24173. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24174. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24175. * @returns impostor the soft imposter
  24176. */
  24177. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24178. /**
  24179. * Add a hook to a rope impostor
  24180. * @param otherImpostor rigid impostor to anchor to
  24181. * @param length ratio across rope from 0 to 1
  24182. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24183. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24184. * @returns impostor the rope imposter
  24185. */
  24186. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24187. /**
  24188. * Will keep this body still, in a sleep mode.
  24189. * @returns the physics imposter
  24190. */
  24191. sleep(): PhysicsImpostor;
  24192. /**
  24193. * Wake the body up.
  24194. * @returns The physics imposter
  24195. */
  24196. wakeUp(): PhysicsImpostor;
  24197. /**
  24198. * Clones the physics imposter
  24199. * @param newObject The physics imposter clones to this physics-enabled object
  24200. * @returns A nullable physics imposter
  24201. */
  24202. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24203. /**
  24204. * Disposes the physics imposter
  24205. */
  24206. dispose(): void;
  24207. /**
  24208. * Sets the delta position
  24209. * @param position The delta position amount
  24210. */
  24211. setDeltaPosition(position: Vector3): void;
  24212. /**
  24213. * Sets the delta rotation
  24214. * @param rotation The delta rotation amount
  24215. */
  24216. setDeltaRotation(rotation: Quaternion): void;
  24217. /**
  24218. * Gets the box size of the physics imposter and stores the result in the input parameter
  24219. * @param result Stores the box size
  24220. * @returns The physics imposter
  24221. */
  24222. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24223. /**
  24224. * Gets the radius of the physics imposter
  24225. * @returns Radius of the physics imposter
  24226. */
  24227. getRadius(): number;
  24228. /**
  24229. * Sync a bone with this impostor
  24230. * @param bone The bone to sync to the impostor.
  24231. * @param boneMesh The mesh that the bone is influencing.
  24232. * @param jointPivot The pivot of the joint / bone in local space.
  24233. * @param distToJoint Optional distance from the impostor to the joint.
  24234. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24235. */
  24236. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24237. /**
  24238. * Sync impostor to a bone
  24239. * @param bone The bone that the impostor will be synced to.
  24240. * @param boneMesh The mesh that the bone is influencing.
  24241. * @param jointPivot The pivot of the joint / bone in local space.
  24242. * @param distToJoint Optional distance from the impostor to the joint.
  24243. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24244. * @param boneAxis Optional vector3 axis the bone is aligned with
  24245. */
  24246. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24247. /**
  24248. * No-Imposter type
  24249. */
  24250. static NoImpostor: number;
  24251. /**
  24252. * Sphere-Imposter type
  24253. */
  24254. static SphereImpostor: number;
  24255. /**
  24256. * Box-Imposter type
  24257. */
  24258. static BoxImpostor: number;
  24259. /**
  24260. * Plane-Imposter type
  24261. */
  24262. static PlaneImpostor: number;
  24263. /**
  24264. * Mesh-imposter type
  24265. */
  24266. static MeshImpostor: number;
  24267. /**
  24268. * Capsule-Impostor type (Ammo.js plugin only)
  24269. */
  24270. static CapsuleImpostor: number;
  24271. /**
  24272. * Cylinder-Imposter type
  24273. */
  24274. static CylinderImpostor: number;
  24275. /**
  24276. * Particle-Imposter type
  24277. */
  24278. static ParticleImpostor: number;
  24279. /**
  24280. * Heightmap-Imposter type
  24281. */
  24282. static HeightmapImpostor: number;
  24283. /**
  24284. * ConvexHull-Impostor type (Ammo.js plugin only)
  24285. */
  24286. static ConvexHullImpostor: number;
  24287. /**
  24288. * Rope-Imposter type
  24289. */
  24290. static RopeImpostor: number;
  24291. /**
  24292. * Cloth-Imposter type
  24293. */
  24294. static ClothImpostor: number;
  24295. /**
  24296. * Softbody-Imposter type
  24297. */
  24298. static SoftbodyImpostor: number;
  24299. }
  24300. }
  24301. declare module "babylonjs/Meshes/mesh" {
  24302. import { Observable } from "babylonjs/Misc/observable";
  24303. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24304. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24305. import { Camera } from "babylonjs/Cameras/camera";
  24306. import { Scene } from "babylonjs/scene";
  24307. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24308. import { Color4 } from "babylonjs/Maths/math.color";
  24309. import { Engine } from "babylonjs/Engines/engine";
  24310. import { Node } from "babylonjs/node";
  24311. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24312. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24313. import { Buffer } from "babylonjs/Meshes/buffer";
  24314. import { Geometry } from "babylonjs/Meshes/geometry";
  24315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24316. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24317. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24318. import { Effect } from "babylonjs/Materials/effect";
  24319. import { Material } from "babylonjs/Materials/material";
  24320. import { Skeleton } from "babylonjs/Bones/skeleton";
  24321. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24322. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24323. import { Path3D } from "babylonjs/Maths/math.path";
  24324. import { Plane } from "babylonjs/Maths/math.plane";
  24325. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24326. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24327. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24328. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24329. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24330. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24331. /**
  24332. * @hidden
  24333. **/
  24334. export class _CreationDataStorage {
  24335. closePath?: boolean;
  24336. closeArray?: boolean;
  24337. idx: number[];
  24338. dashSize: number;
  24339. gapSize: number;
  24340. path3D: Path3D;
  24341. pathArray: Vector3[][];
  24342. arc: number;
  24343. radius: number;
  24344. cap: number;
  24345. tessellation: number;
  24346. }
  24347. /**
  24348. * @hidden
  24349. **/
  24350. class _InstanceDataStorage {
  24351. visibleInstances: any;
  24352. batchCache: _InstancesBatch;
  24353. instancesBufferSize: number;
  24354. instancesBuffer: Nullable<Buffer>;
  24355. instancesData: Float32Array;
  24356. overridenInstanceCount: number;
  24357. isFrozen: boolean;
  24358. previousBatch: Nullable<_InstancesBatch>;
  24359. hardwareInstancedRendering: boolean;
  24360. sideOrientation: number;
  24361. }
  24362. /**
  24363. * @hidden
  24364. **/
  24365. export class _InstancesBatch {
  24366. mustReturn: boolean;
  24367. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24368. renderSelf: boolean[];
  24369. hardwareInstancedRendering: boolean[];
  24370. }
  24371. /**
  24372. * Class used to represent renderable models
  24373. */
  24374. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24375. /**
  24376. * Mesh side orientation : usually the external or front surface
  24377. */
  24378. static readonly FRONTSIDE: number;
  24379. /**
  24380. * Mesh side orientation : usually the internal or back surface
  24381. */
  24382. static readonly BACKSIDE: number;
  24383. /**
  24384. * Mesh side orientation : both internal and external or front and back surfaces
  24385. */
  24386. static readonly DOUBLESIDE: number;
  24387. /**
  24388. * Mesh side orientation : by default, `FRONTSIDE`
  24389. */
  24390. static readonly DEFAULTSIDE: number;
  24391. /**
  24392. * Mesh cap setting : no cap
  24393. */
  24394. static readonly NO_CAP: number;
  24395. /**
  24396. * Mesh cap setting : one cap at the beginning of the mesh
  24397. */
  24398. static readonly CAP_START: number;
  24399. /**
  24400. * Mesh cap setting : one cap at the end of the mesh
  24401. */
  24402. static readonly CAP_END: number;
  24403. /**
  24404. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24405. */
  24406. static readonly CAP_ALL: number;
  24407. /**
  24408. * Mesh pattern setting : no flip or rotate
  24409. */
  24410. static readonly NO_FLIP: number;
  24411. /**
  24412. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24413. */
  24414. static readonly FLIP_TILE: number;
  24415. /**
  24416. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24417. */
  24418. static readonly ROTATE_TILE: number;
  24419. /**
  24420. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24421. */
  24422. static readonly FLIP_ROW: number;
  24423. /**
  24424. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24425. */
  24426. static readonly ROTATE_ROW: number;
  24427. /**
  24428. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24429. */
  24430. static readonly FLIP_N_ROTATE_TILE: number;
  24431. /**
  24432. * Mesh pattern setting : rotate pattern and rotate
  24433. */
  24434. static readonly FLIP_N_ROTATE_ROW: number;
  24435. /**
  24436. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24437. */
  24438. static readonly CENTER: number;
  24439. /**
  24440. * Mesh tile positioning : part tiles on left
  24441. */
  24442. static readonly LEFT: number;
  24443. /**
  24444. * Mesh tile positioning : part tiles on right
  24445. */
  24446. static readonly RIGHT: number;
  24447. /**
  24448. * Mesh tile positioning : part tiles on top
  24449. */
  24450. static readonly TOP: number;
  24451. /**
  24452. * Mesh tile positioning : part tiles on bottom
  24453. */
  24454. static readonly BOTTOM: number;
  24455. /**
  24456. * Gets the default side orientation.
  24457. * @param orientation the orientation to value to attempt to get
  24458. * @returns the default orientation
  24459. * @hidden
  24460. */
  24461. static _GetDefaultSideOrientation(orientation?: number): number;
  24462. private _internalMeshDataInfo;
  24463. /**
  24464. * An event triggered before rendering the mesh
  24465. */
  24466. readonly onBeforeRenderObservable: Observable<Mesh>;
  24467. /**
  24468. * An event triggered before binding the mesh
  24469. */
  24470. readonly onBeforeBindObservable: Observable<Mesh>;
  24471. /**
  24472. * An event triggered after rendering the mesh
  24473. */
  24474. readonly onAfterRenderObservable: Observable<Mesh>;
  24475. /**
  24476. * An event triggered before drawing the mesh
  24477. */
  24478. readonly onBeforeDrawObservable: Observable<Mesh>;
  24479. private _onBeforeDrawObserver;
  24480. /**
  24481. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24482. */
  24483. onBeforeDraw: () => void;
  24484. readonly hasInstances: boolean;
  24485. /**
  24486. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24487. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24488. */
  24489. delayLoadState: number;
  24490. /**
  24491. * Gets the list of instances created from this mesh
  24492. * it is not supposed to be modified manually.
  24493. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24494. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24495. */
  24496. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24497. /**
  24498. * Gets the file containing delay loading data for this mesh
  24499. */
  24500. delayLoadingFile: string;
  24501. /** @hidden */
  24502. _binaryInfo: any;
  24503. /**
  24504. * User defined function used to change how LOD level selection is done
  24505. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24506. */
  24507. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24508. /**
  24509. * Gets or sets the morph target manager
  24510. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24511. */
  24512. morphTargetManager: Nullable<MorphTargetManager>;
  24513. /** @hidden */
  24514. _creationDataStorage: Nullable<_CreationDataStorage>;
  24515. /** @hidden */
  24516. _geometry: Nullable<Geometry>;
  24517. /** @hidden */
  24518. _delayInfo: Array<string>;
  24519. /** @hidden */
  24520. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24521. /** @hidden */
  24522. _instanceDataStorage: _InstanceDataStorage;
  24523. private _effectiveMaterial;
  24524. /** @hidden */
  24525. _shouldGenerateFlatShading: boolean;
  24526. /** @hidden */
  24527. _originalBuilderSideOrientation: number;
  24528. /**
  24529. * Use this property to change the original side orientation defined at construction time
  24530. */
  24531. overrideMaterialSideOrientation: Nullable<number>;
  24532. /**
  24533. * Gets the source mesh (the one used to clone this one from)
  24534. */
  24535. readonly source: Nullable<Mesh>;
  24536. /**
  24537. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24538. */
  24539. isUnIndexed: boolean;
  24540. /**
  24541. * @constructor
  24542. * @param name The value used by scene.getMeshByName() to do a lookup.
  24543. * @param scene The scene to add this mesh to.
  24544. * @param parent The parent of this mesh, if it has one
  24545. * @param source An optional Mesh from which geometry is shared, cloned.
  24546. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24547. * When false, achieved by calling a clone(), also passing False.
  24548. * This will make creation of children, recursive.
  24549. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24550. */
  24551. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24552. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24553. doNotInstantiate: boolean;
  24554. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24555. /**
  24556. * Gets the class name
  24557. * @returns the string "Mesh".
  24558. */
  24559. getClassName(): string;
  24560. /** @hidden */
  24561. readonly _isMesh: boolean;
  24562. /**
  24563. * Returns a description of this mesh
  24564. * @param fullDetails define if full details about this mesh must be used
  24565. * @returns a descriptive string representing this mesh
  24566. */
  24567. toString(fullDetails?: boolean): string;
  24568. /** @hidden */
  24569. _unBindEffect(): void;
  24570. /**
  24571. * Gets a boolean indicating if this mesh has LOD
  24572. */
  24573. readonly hasLODLevels: boolean;
  24574. /**
  24575. * Gets the list of MeshLODLevel associated with the current mesh
  24576. * @returns an array of MeshLODLevel
  24577. */
  24578. getLODLevels(): MeshLODLevel[];
  24579. private _sortLODLevels;
  24580. /**
  24581. * Add a mesh as LOD level triggered at the given distance.
  24582. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24583. * @param distance The distance from the center of the object to show this level
  24584. * @param mesh The mesh to be added as LOD level (can be null)
  24585. * @return This mesh (for chaining)
  24586. */
  24587. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24588. /**
  24589. * Returns the LOD level mesh at the passed distance or null if not found.
  24590. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24591. * @param distance The distance from the center of the object to show this level
  24592. * @returns a Mesh or `null`
  24593. */
  24594. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24595. /**
  24596. * Remove a mesh from the LOD array
  24597. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24598. * @param mesh defines the mesh to be removed
  24599. * @return This mesh (for chaining)
  24600. */
  24601. removeLODLevel(mesh: Mesh): Mesh;
  24602. /**
  24603. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24604. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24605. * @param camera defines the camera to use to compute distance
  24606. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24607. * @return This mesh (for chaining)
  24608. */
  24609. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24610. /**
  24611. * Gets the mesh internal Geometry object
  24612. */
  24613. readonly geometry: Nullable<Geometry>;
  24614. /**
  24615. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24616. * @returns the total number of vertices
  24617. */
  24618. getTotalVertices(): number;
  24619. /**
  24620. * Returns the content of an associated vertex buffer
  24621. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24622. * - VertexBuffer.PositionKind
  24623. * - VertexBuffer.UVKind
  24624. * - VertexBuffer.UV2Kind
  24625. * - VertexBuffer.UV3Kind
  24626. * - VertexBuffer.UV4Kind
  24627. * - VertexBuffer.UV5Kind
  24628. * - VertexBuffer.UV6Kind
  24629. * - VertexBuffer.ColorKind
  24630. * - VertexBuffer.MatricesIndicesKind
  24631. * - VertexBuffer.MatricesIndicesExtraKind
  24632. * - VertexBuffer.MatricesWeightsKind
  24633. * - VertexBuffer.MatricesWeightsExtraKind
  24634. * @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
  24635. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24636. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24637. */
  24638. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24639. /**
  24640. * Returns the mesh VertexBuffer object from the requested `kind`
  24641. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24642. * - VertexBuffer.PositionKind
  24643. * - VertexBuffer.NormalKind
  24644. * - VertexBuffer.UVKind
  24645. * - VertexBuffer.UV2Kind
  24646. * - VertexBuffer.UV3Kind
  24647. * - VertexBuffer.UV4Kind
  24648. * - VertexBuffer.UV5Kind
  24649. * - VertexBuffer.UV6Kind
  24650. * - VertexBuffer.ColorKind
  24651. * - VertexBuffer.MatricesIndicesKind
  24652. * - VertexBuffer.MatricesIndicesExtraKind
  24653. * - VertexBuffer.MatricesWeightsKind
  24654. * - VertexBuffer.MatricesWeightsExtraKind
  24655. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24656. */
  24657. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24658. /**
  24659. * Tests if a specific vertex buffer is associated with this mesh
  24660. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24661. * - VertexBuffer.PositionKind
  24662. * - VertexBuffer.NormalKind
  24663. * - VertexBuffer.UVKind
  24664. * - VertexBuffer.UV2Kind
  24665. * - VertexBuffer.UV3Kind
  24666. * - VertexBuffer.UV4Kind
  24667. * - VertexBuffer.UV5Kind
  24668. * - VertexBuffer.UV6Kind
  24669. * - VertexBuffer.ColorKind
  24670. * - VertexBuffer.MatricesIndicesKind
  24671. * - VertexBuffer.MatricesIndicesExtraKind
  24672. * - VertexBuffer.MatricesWeightsKind
  24673. * - VertexBuffer.MatricesWeightsExtraKind
  24674. * @returns a boolean
  24675. */
  24676. isVerticesDataPresent(kind: string): boolean;
  24677. /**
  24678. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24679. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24680. * - VertexBuffer.PositionKind
  24681. * - VertexBuffer.UVKind
  24682. * - VertexBuffer.UV2Kind
  24683. * - VertexBuffer.UV3Kind
  24684. * - VertexBuffer.UV4Kind
  24685. * - VertexBuffer.UV5Kind
  24686. * - VertexBuffer.UV6Kind
  24687. * - VertexBuffer.ColorKind
  24688. * - VertexBuffer.MatricesIndicesKind
  24689. * - VertexBuffer.MatricesIndicesExtraKind
  24690. * - VertexBuffer.MatricesWeightsKind
  24691. * - VertexBuffer.MatricesWeightsExtraKind
  24692. * @returns a boolean
  24693. */
  24694. isVertexBufferUpdatable(kind: string): boolean;
  24695. /**
  24696. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24697. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24698. * - VertexBuffer.PositionKind
  24699. * - VertexBuffer.NormalKind
  24700. * - VertexBuffer.UVKind
  24701. * - VertexBuffer.UV2Kind
  24702. * - VertexBuffer.UV3Kind
  24703. * - VertexBuffer.UV4Kind
  24704. * - VertexBuffer.UV5Kind
  24705. * - VertexBuffer.UV6Kind
  24706. * - VertexBuffer.ColorKind
  24707. * - VertexBuffer.MatricesIndicesKind
  24708. * - VertexBuffer.MatricesIndicesExtraKind
  24709. * - VertexBuffer.MatricesWeightsKind
  24710. * - VertexBuffer.MatricesWeightsExtraKind
  24711. * @returns an array of strings
  24712. */
  24713. getVerticesDataKinds(): string[];
  24714. /**
  24715. * Returns a positive integer : the total number of indices in this mesh geometry.
  24716. * @returns the numner of indices or zero if the mesh has no geometry.
  24717. */
  24718. getTotalIndices(): number;
  24719. /**
  24720. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24721. * @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.
  24722. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24723. * @returns the indices array or an empty array if the mesh has no geometry
  24724. */
  24725. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24726. readonly isBlocked: boolean;
  24727. /**
  24728. * Determine if the current mesh is ready to be rendered
  24729. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24730. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24731. * @returns true if all associated assets are ready (material, textures, shaders)
  24732. */
  24733. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24734. /**
  24735. * 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.
  24736. */
  24737. readonly areNormalsFrozen: boolean;
  24738. /**
  24739. * 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.
  24740. * @returns the current mesh
  24741. */
  24742. freezeNormals(): Mesh;
  24743. /**
  24744. * 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
  24745. * @returns the current mesh
  24746. */
  24747. unfreezeNormals(): Mesh;
  24748. /**
  24749. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24750. */
  24751. overridenInstanceCount: number;
  24752. /** @hidden */
  24753. _preActivate(): Mesh;
  24754. /** @hidden */
  24755. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24756. /** @hidden */
  24757. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24758. /**
  24759. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24760. * This means the mesh underlying bounding box and sphere are recomputed.
  24761. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24762. * @returns the current mesh
  24763. */
  24764. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24765. /** @hidden */
  24766. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24767. /**
  24768. * This function will subdivide the mesh into multiple submeshes
  24769. * @param count defines the expected number of submeshes
  24770. */
  24771. subdivide(count: number): void;
  24772. /**
  24773. * Copy a FloatArray into a specific associated vertex buffer
  24774. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24775. * - VertexBuffer.PositionKind
  24776. * - VertexBuffer.UVKind
  24777. * - VertexBuffer.UV2Kind
  24778. * - VertexBuffer.UV3Kind
  24779. * - VertexBuffer.UV4Kind
  24780. * - VertexBuffer.UV5Kind
  24781. * - VertexBuffer.UV6Kind
  24782. * - VertexBuffer.ColorKind
  24783. * - VertexBuffer.MatricesIndicesKind
  24784. * - VertexBuffer.MatricesIndicesExtraKind
  24785. * - VertexBuffer.MatricesWeightsKind
  24786. * - VertexBuffer.MatricesWeightsExtraKind
  24787. * @param data defines the data source
  24788. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24789. * @param stride defines the data stride size (can be null)
  24790. * @returns the current mesh
  24791. */
  24792. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24793. /**
  24794. * Delete a vertex buffer associated with this mesh
  24795. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24796. * - VertexBuffer.PositionKind
  24797. * - VertexBuffer.UVKind
  24798. * - VertexBuffer.UV2Kind
  24799. * - VertexBuffer.UV3Kind
  24800. * - VertexBuffer.UV4Kind
  24801. * - VertexBuffer.UV5Kind
  24802. * - VertexBuffer.UV6Kind
  24803. * - VertexBuffer.ColorKind
  24804. * - VertexBuffer.MatricesIndicesKind
  24805. * - VertexBuffer.MatricesIndicesExtraKind
  24806. * - VertexBuffer.MatricesWeightsKind
  24807. * - VertexBuffer.MatricesWeightsExtraKind
  24808. */
  24809. removeVerticesData(kind: string): void;
  24810. /**
  24811. * Flags an associated vertex buffer as updatable
  24812. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24813. * - VertexBuffer.PositionKind
  24814. * - VertexBuffer.UVKind
  24815. * - VertexBuffer.UV2Kind
  24816. * - VertexBuffer.UV3Kind
  24817. * - VertexBuffer.UV4Kind
  24818. * - VertexBuffer.UV5Kind
  24819. * - VertexBuffer.UV6Kind
  24820. * - VertexBuffer.ColorKind
  24821. * - VertexBuffer.MatricesIndicesKind
  24822. * - VertexBuffer.MatricesIndicesExtraKind
  24823. * - VertexBuffer.MatricesWeightsKind
  24824. * - VertexBuffer.MatricesWeightsExtraKind
  24825. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24826. */
  24827. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24828. /**
  24829. * Sets the mesh global Vertex Buffer
  24830. * @param buffer defines the buffer to use
  24831. * @returns the current mesh
  24832. */
  24833. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24834. /**
  24835. * Update a specific associated vertex buffer
  24836. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24837. * - VertexBuffer.PositionKind
  24838. * - VertexBuffer.UVKind
  24839. * - VertexBuffer.UV2Kind
  24840. * - VertexBuffer.UV3Kind
  24841. * - VertexBuffer.UV4Kind
  24842. * - VertexBuffer.UV5Kind
  24843. * - VertexBuffer.UV6Kind
  24844. * - VertexBuffer.ColorKind
  24845. * - VertexBuffer.MatricesIndicesKind
  24846. * - VertexBuffer.MatricesIndicesExtraKind
  24847. * - VertexBuffer.MatricesWeightsKind
  24848. * - VertexBuffer.MatricesWeightsExtraKind
  24849. * @param data defines the data source
  24850. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24851. * @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)
  24852. * @returns the current mesh
  24853. */
  24854. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24855. /**
  24856. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24857. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24858. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24859. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24860. * @returns the current mesh
  24861. */
  24862. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24863. /**
  24864. * Creates a un-shared specific occurence of the geometry for the mesh.
  24865. * @returns the current mesh
  24866. */
  24867. makeGeometryUnique(): Mesh;
  24868. /**
  24869. * Set the index buffer of this mesh
  24870. * @param indices defines the source data
  24871. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24872. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24873. * @returns the current mesh
  24874. */
  24875. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24876. /**
  24877. * Update the current index buffer
  24878. * @param indices defines the source data
  24879. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24880. * @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)
  24881. * @returns the current mesh
  24882. */
  24883. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24884. /**
  24885. * Invert the geometry to move from a right handed system to a left handed one.
  24886. * @returns the current mesh
  24887. */
  24888. toLeftHanded(): Mesh;
  24889. /** @hidden */
  24890. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24891. /** @hidden */
  24892. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24893. /**
  24894. * Registers for this mesh a javascript function called just before the rendering process
  24895. * @param func defines the function to call before rendering this mesh
  24896. * @returns the current mesh
  24897. */
  24898. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24899. /**
  24900. * Disposes a previously registered javascript function called before the rendering
  24901. * @param func defines the function to remove
  24902. * @returns the current mesh
  24903. */
  24904. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24905. /**
  24906. * Registers for this mesh a javascript function called just after the rendering is complete
  24907. * @param func defines the function to call after rendering this mesh
  24908. * @returns the current mesh
  24909. */
  24910. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24911. /**
  24912. * Disposes a previously registered javascript function called after the rendering.
  24913. * @param func defines the function to remove
  24914. * @returns the current mesh
  24915. */
  24916. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24917. /** @hidden */
  24918. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24919. /** @hidden */
  24920. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24921. /** @hidden */
  24922. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24923. /** @hidden */
  24924. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24925. /** @hidden */
  24926. _rebuild(): void;
  24927. /** @hidden */
  24928. _freeze(): void;
  24929. /** @hidden */
  24930. _unFreeze(): void;
  24931. /**
  24932. * 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
  24933. * @param subMesh defines the subMesh to render
  24934. * @param enableAlphaMode defines if alpha mode can be changed
  24935. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24936. * @returns the current mesh
  24937. */
  24938. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24939. private _onBeforeDraw;
  24940. /**
  24941. * Renormalize the mesh and patch it up if there are no weights
  24942. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24943. * However in the case of zero weights then we set just a single influence to 1.
  24944. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24945. */
  24946. cleanMatrixWeights(): void;
  24947. private normalizeSkinFourWeights;
  24948. private normalizeSkinWeightsAndExtra;
  24949. /**
  24950. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24951. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24952. * the user know there was an issue with importing the mesh
  24953. * @returns a validation object with skinned, valid and report string
  24954. */
  24955. validateSkinning(): {
  24956. skinned: boolean;
  24957. valid: boolean;
  24958. report: string;
  24959. };
  24960. /** @hidden */
  24961. _checkDelayState(): Mesh;
  24962. private _queueLoad;
  24963. /**
  24964. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24965. * A mesh is in the frustum if its bounding box intersects the frustum
  24966. * @param frustumPlanes defines the frustum to test
  24967. * @returns true if the mesh is in the frustum planes
  24968. */
  24969. isInFrustum(frustumPlanes: Plane[]): boolean;
  24970. /**
  24971. * Sets the mesh material by the material or multiMaterial `id` property
  24972. * @param id is a string identifying the material or the multiMaterial
  24973. * @returns the current mesh
  24974. */
  24975. setMaterialByID(id: string): Mesh;
  24976. /**
  24977. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24978. * @returns an array of IAnimatable
  24979. */
  24980. getAnimatables(): IAnimatable[];
  24981. /**
  24982. * Modifies the mesh geometry according to the passed transformation matrix.
  24983. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24984. * The mesh normals are modified using the same transformation.
  24985. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24986. * @param transform defines the transform matrix to use
  24987. * @see http://doc.babylonjs.com/resources/baking_transformations
  24988. * @returns the current mesh
  24989. */
  24990. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24991. /**
  24992. * Modifies the mesh geometry according to its own current World Matrix.
  24993. * The mesh World Matrix is then reset.
  24994. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24995. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24996. * @see http://doc.babylonjs.com/resources/baking_transformations
  24997. * @returns the current mesh
  24998. */
  24999. bakeCurrentTransformIntoVertices(): Mesh;
  25000. /** @hidden */
  25001. readonly _positions: Nullable<Vector3[]>;
  25002. /** @hidden */
  25003. _resetPointsArrayCache(): Mesh;
  25004. /** @hidden */
  25005. _generatePointsArray(): boolean;
  25006. /**
  25007. * Returns a new Mesh object generated from the current mesh properties.
  25008. * This method must not get confused with createInstance()
  25009. * @param name is a string, the name given to the new mesh
  25010. * @param newParent can be any Node object (default `null`)
  25011. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25012. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25013. * @returns a new mesh
  25014. */
  25015. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25016. /**
  25017. * Releases resources associated with this mesh.
  25018. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25019. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25020. */
  25021. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25022. /** @hidden */
  25023. _disposeInstanceSpecificData(): void;
  25024. /**
  25025. * Modifies the mesh geometry according to a displacement map.
  25026. * 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.
  25027. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25028. * @param url is a string, the URL from the image file is to be downloaded.
  25029. * @param minHeight is the lower limit of the displacement.
  25030. * @param maxHeight is the upper limit of the displacement.
  25031. * @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.
  25032. * @param uvOffset is an optional vector2 used to offset UV.
  25033. * @param uvScale is an optional vector2 used to scale UV.
  25034. * @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.
  25035. * @returns the Mesh.
  25036. */
  25037. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25038. /**
  25039. * Modifies the mesh geometry according to a displacementMap buffer.
  25040. * 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.
  25041. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25042. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25043. * @param heightMapWidth is the width of the buffer image.
  25044. * @param heightMapHeight is the height of the buffer image.
  25045. * @param minHeight is the lower limit of the displacement.
  25046. * @param maxHeight is the upper limit of the displacement.
  25047. * @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.
  25048. * @param uvOffset is an optional vector2 used to offset UV.
  25049. * @param uvScale is an optional vector2 used to scale UV.
  25050. * @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.
  25051. * @returns the Mesh.
  25052. */
  25053. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25054. /**
  25055. * Modify the mesh to get a flat shading rendering.
  25056. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25057. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25058. * @returns current mesh
  25059. */
  25060. convertToFlatShadedMesh(): Mesh;
  25061. /**
  25062. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25063. * In other words, more vertices, no more indices and a single bigger VBO.
  25064. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25065. * @returns current mesh
  25066. */
  25067. convertToUnIndexedMesh(): Mesh;
  25068. /**
  25069. * Inverses facet orientations.
  25070. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25071. * @param flipNormals will also inverts the normals
  25072. * @returns current mesh
  25073. */
  25074. flipFaces(flipNormals?: boolean): Mesh;
  25075. /**
  25076. * Increase the number of facets and hence vertices in a mesh
  25077. * Vertex normals are interpolated from existing vertex normals
  25078. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25079. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25080. */
  25081. increaseVertices(numberPerEdge: number): void;
  25082. /**
  25083. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25084. * This will undo any application of covertToFlatShadedMesh
  25085. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25086. */
  25087. forceSharedVertices(): void;
  25088. /** @hidden */
  25089. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25090. /** @hidden */
  25091. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25092. /**
  25093. * Creates a new InstancedMesh object from the mesh model.
  25094. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25095. * @param name defines the name of the new instance
  25096. * @returns a new InstancedMesh
  25097. */
  25098. createInstance(name: string): InstancedMesh;
  25099. /**
  25100. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25101. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25102. * @returns the current mesh
  25103. */
  25104. synchronizeInstances(): Mesh;
  25105. /**
  25106. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25107. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25108. * This should be used together with the simplification to avoid disappearing triangles.
  25109. * @param successCallback an optional success callback to be called after the optimization finished.
  25110. * @returns the current mesh
  25111. */
  25112. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25113. /**
  25114. * Serialize current mesh
  25115. * @param serializationObject defines the object which will receive the serialization data
  25116. */
  25117. serialize(serializationObject: any): void;
  25118. /** @hidden */
  25119. _syncGeometryWithMorphTargetManager(): void;
  25120. /** @hidden */
  25121. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25122. /**
  25123. * Returns a new Mesh object parsed from the source provided.
  25124. * @param parsedMesh is the source
  25125. * @param scene defines the hosting scene
  25126. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25127. * @returns a new Mesh
  25128. */
  25129. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25130. /**
  25131. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25132. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25133. * @param name defines the name of the mesh to create
  25134. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25135. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25136. * @param closePath creates a seam between the first and the last points of each path of the path array
  25137. * @param offset is taken in account only if the `pathArray` is containing a single path
  25138. * @param scene defines the hosting scene
  25139. * @param updatable defines if the mesh must be flagged as updatable
  25140. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25141. * @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)
  25142. * @returns a new Mesh
  25143. */
  25144. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25145. /**
  25146. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25147. * @param name defines the name of the mesh to create
  25148. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25149. * @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
  25150. * @param scene defines the hosting scene
  25151. * @param updatable defines if the mesh must be flagged as updatable
  25152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25153. * @returns a new Mesh
  25154. */
  25155. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25156. /**
  25157. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25158. * @param name defines the name of the mesh to create
  25159. * @param size sets the size (float) of each box side (default 1)
  25160. * @param scene defines the hosting scene
  25161. * @param updatable defines if the mesh must be flagged as updatable
  25162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25163. * @returns a new Mesh
  25164. */
  25165. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25166. /**
  25167. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25168. * @param name defines the name of the mesh to create
  25169. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25170. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25171. * @param scene defines the hosting scene
  25172. * @param updatable defines if the mesh must be flagged as updatable
  25173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25174. * @returns a new Mesh
  25175. */
  25176. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25177. /**
  25178. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25179. * @param name defines the name of the mesh to create
  25180. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25181. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25182. * @param scene defines the hosting scene
  25183. * @returns a new Mesh
  25184. */
  25185. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25186. /**
  25187. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25188. * @param name defines the name of the mesh to create
  25189. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25190. * @param diameterTop set the top cap diameter (floats, default 1)
  25191. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25192. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25193. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25194. * @param scene defines the hosting scene
  25195. * @param updatable defines if the mesh must be flagged as updatable
  25196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25197. * @returns a new Mesh
  25198. */
  25199. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25200. /**
  25201. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25202. * @param name defines the name of the mesh to create
  25203. * @param diameter sets the diameter size (float) of the torus (default 1)
  25204. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25205. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25206. * @param scene defines the hosting scene
  25207. * @param updatable defines if the mesh must be flagged as updatable
  25208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25209. * @returns a new Mesh
  25210. */
  25211. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25212. /**
  25213. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25214. * @param name defines the name of the mesh to create
  25215. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25216. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25217. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25218. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25219. * @param p the number of windings on X axis (positive integers, default 2)
  25220. * @param q the number of windings on Y axis (positive integers, default 3)
  25221. * @param scene defines the hosting scene
  25222. * @param updatable defines if the mesh must be flagged as updatable
  25223. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25224. * @returns a new Mesh
  25225. */
  25226. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25227. /**
  25228. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25229. * @param name defines the name of the mesh to create
  25230. * @param points is an array successive Vector3
  25231. * @param scene defines the hosting scene
  25232. * @param updatable defines if the mesh must be flagged as updatable
  25233. * @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).
  25234. * @returns a new Mesh
  25235. */
  25236. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25237. /**
  25238. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25239. * @param name defines the name of the mesh to create
  25240. * @param points is an array successive Vector3
  25241. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25242. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25243. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25244. * @param scene defines the hosting scene
  25245. * @param updatable defines if the mesh must be flagged as updatable
  25246. * @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)
  25247. * @returns a new Mesh
  25248. */
  25249. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25250. /**
  25251. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25252. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25253. * 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.
  25254. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25255. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25256. * Remember you can only change the shape positions, not their number when updating a polygon.
  25257. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25258. * @param name defines the name of the mesh to create
  25259. * @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
  25260. * @param scene defines the hosting scene
  25261. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25262. * @param updatable defines if the mesh must be flagged as updatable
  25263. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25264. * @param earcutInjection can be used to inject your own earcut reference
  25265. * @returns a new Mesh
  25266. */
  25267. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25268. /**
  25269. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25270. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25271. * @param name defines the name of the mesh to create
  25272. * @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
  25273. * @param depth defines the height of extrusion
  25274. * @param scene defines the hosting scene
  25275. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25276. * @param updatable defines if the mesh must be flagged as updatable
  25277. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25278. * @param earcutInjection can be used to inject your own earcut reference
  25279. * @returns a new Mesh
  25280. */
  25281. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25282. /**
  25283. * Creates an extruded shape mesh.
  25284. * 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
  25285. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25286. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25287. * @param name defines the name of the mesh to create
  25288. * @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
  25289. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25290. * @param scale is the value to scale the shape
  25291. * @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
  25292. * @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
  25293. * @param scene defines the hosting scene
  25294. * @param updatable defines if the mesh must be flagged as updatable
  25295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25296. * @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)
  25297. * @returns a new Mesh
  25298. */
  25299. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25300. /**
  25301. * Creates an custom extruded shape mesh.
  25302. * The custom extrusion is a parametric shape.
  25303. * It has no predefined shape. Its final shape will depend on the input parameters.
  25304. * Please consider using the same method from the MeshBuilder class instead
  25305. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25306. * @param name defines the name of the mesh to create
  25307. * @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
  25308. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25309. * @param scaleFunction is a custom Javascript function called on each path point
  25310. * @param rotationFunction is a custom Javascript function called on each path point
  25311. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25312. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25313. * @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
  25314. * @param scene defines the hosting scene
  25315. * @param updatable defines if the mesh must be flagged as updatable
  25316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25317. * @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)
  25318. * @returns a new Mesh
  25319. */
  25320. 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;
  25321. /**
  25322. * Creates lathe mesh.
  25323. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25324. * Please consider using the same method from the MeshBuilder class instead
  25325. * @param name defines the name of the mesh to create
  25326. * @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
  25327. * @param radius is the radius value of the lathe
  25328. * @param tessellation is the side number of the lathe.
  25329. * @param scene defines the hosting scene
  25330. * @param updatable defines if the mesh must be flagged as updatable
  25331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25332. * @returns a new Mesh
  25333. */
  25334. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25335. /**
  25336. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25337. * @param name defines the name of the mesh to create
  25338. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25339. * @param scene defines the hosting scene
  25340. * @param updatable defines if the mesh must be flagged as updatable
  25341. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25342. * @returns a new Mesh
  25343. */
  25344. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25345. /**
  25346. * Creates a ground mesh.
  25347. * Please consider using the same method from the MeshBuilder class instead
  25348. * @param name defines the name of the mesh to create
  25349. * @param width set the width of the ground
  25350. * @param height set the height of the ground
  25351. * @param subdivisions sets the number of subdivisions per side
  25352. * @param scene defines the hosting scene
  25353. * @param updatable defines if the mesh must be flagged as updatable
  25354. * @returns a new Mesh
  25355. */
  25356. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25357. /**
  25358. * Creates a tiled ground mesh.
  25359. * Please consider using the same method from the MeshBuilder class instead
  25360. * @param name defines the name of the mesh to create
  25361. * @param xmin set the ground minimum X coordinate
  25362. * @param zmin set the ground minimum Y coordinate
  25363. * @param xmax set the ground maximum X coordinate
  25364. * @param zmax set the ground maximum Z coordinate
  25365. * @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
  25366. * @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
  25367. * @param scene defines the hosting scene
  25368. * @param updatable defines if the mesh must be flagged as updatable
  25369. * @returns a new Mesh
  25370. */
  25371. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25372. w: number;
  25373. h: number;
  25374. }, precision: {
  25375. w: number;
  25376. h: number;
  25377. }, scene: Scene, updatable?: boolean): Mesh;
  25378. /**
  25379. * Creates a ground mesh from a height map.
  25380. * Please consider using the same method from the MeshBuilder class instead
  25381. * @see http://doc.babylonjs.com/babylon101/height_map
  25382. * @param name defines the name of the mesh to create
  25383. * @param url sets the URL of the height map image resource
  25384. * @param width set the ground width size
  25385. * @param height set the ground height size
  25386. * @param subdivisions sets the number of subdivision per side
  25387. * @param minHeight is the minimum altitude on the ground
  25388. * @param maxHeight is the maximum altitude on the ground
  25389. * @param scene defines the hosting scene
  25390. * @param updatable defines if the mesh must be flagged as updatable
  25391. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25392. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25393. * @returns a new Mesh
  25394. */
  25395. 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;
  25396. /**
  25397. * Creates a tube mesh.
  25398. * The tube is a parametric shape.
  25399. * It has no predefined shape. Its final shape will depend on the input parameters.
  25400. * Please consider using the same method from the MeshBuilder class instead
  25401. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25402. * @param name defines the name of the mesh to create
  25403. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25404. * @param radius sets the tube radius size
  25405. * @param tessellation is the number of sides on the tubular surface
  25406. * @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
  25407. * @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
  25408. * @param scene defines the hosting scene
  25409. * @param updatable defines if the mesh must be flagged as updatable
  25410. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25411. * @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)
  25412. * @returns a new Mesh
  25413. */
  25414. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25415. (i: number, distance: number): number;
  25416. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25417. /**
  25418. * Creates a polyhedron mesh.
  25419. * Please consider using the same method from the MeshBuilder class instead.
  25420. * * 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
  25421. * * The parameter `size` (positive float, default 1) sets the polygon size
  25422. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25423. * * 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`
  25424. * * 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
  25425. * * 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)`)
  25426. * * 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
  25427. * * 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
  25428. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25429. * * If you create a double-sided mesh, you can choose what parts of 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
  25430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25431. * @param name defines the name of the mesh to create
  25432. * @param options defines the options used to create the mesh
  25433. * @param scene defines the hosting scene
  25434. * @returns a new Mesh
  25435. */
  25436. static CreatePolyhedron(name: string, options: {
  25437. type?: number;
  25438. size?: number;
  25439. sizeX?: number;
  25440. sizeY?: number;
  25441. sizeZ?: number;
  25442. custom?: any;
  25443. faceUV?: Vector4[];
  25444. faceColors?: Color4[];
  25445. updatable?: boolean;
  25446. sideOrientation?: number;
  25447. }, scene: Scene): Mesh;
  25448. /**
  25449. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25450. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25451. * * 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`)
  25452. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25453. * * 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
  25454. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25455. * * If you create a double-sided mesh, you can choose what parts of 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
  25456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25457. * @param name defines the name of the mesh
  25458. * @param options defines the options used to create the mesh
  25459. * @param scene defines the hosting scene
  25460. * @returns a new Mesh
  25461. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25462. */
  25463. static CreateIcoSphere(name: string, options: {
  25464. radius?: number;
  25465. flat?: boolean;
  25466. subdivisions?: number;
  25467. sideOrientation?: number;
  25468. updatable?: boolean;
  25469. }, scene: Scene): Mesh;
  25470. /**
  25471. * Creates a decal mesh.
  25472. * Please consider using the same method from the MeshBuilder class instead.
  25473. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25474. * @param name defines the name of the mesh
  25475. * @param sourceMesh defines the mesh receiving the decal
  25476. * @param position sets the position of the decal in world coordinates
  25477. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25478. * @param size sets the decal scaling
  25479. * @param angle sets the angle to rotate the decal
  25480. * @returns a new Mesh
  25481. */
  25482. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25483. /**
  25484. * Prepare internal position array for software CPU skinning
  25485. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25486. */
  25487. setPositionsForCPUSkinning(): Float32Array;
  25488. /**
  25489. * Prepare internal normal array for software CPU skinning
  25490. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25491. */
  25492. setNormalsForCPUSkinning(): Float32Array;
  25493. /**
  25494. * Updates the vertex buffer by applying transformation from the bones
  25495. * @param skeleton defines the skeleton to apply to current mesh
  25496. * @returns the current mesh
  25497. */
  25498. applySkeleton(skeleton: Skeleton): Mesh;
  25499. /**
  25500. * 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
  25501. * @param meshes defines the list of meshes to scan
  25502. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25503. */
  25504. static MinMax(meshes: AbstractMesh[]): {
  25505. min: Vector3;
  25506. max: Vector3;
  25507. };
  25508. /**
  25509. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25510. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25511. * @returns a vector3
  25512. */
  25513. static Center(meshesOrMinMaxVector: {
  25514. min: Vector3;
  25515. max: Vector3;
  25516. } | AbstractMesh[]): Vector3;
  25517. /**
  25518. * Merge the array of meshes into a single mesh for performance reasons.
  25519. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25520. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25521. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25522. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25523. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25524. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25525. * @returns a new mesh
  25526. */
  25527. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25528. /** @hidden */
  25529. addInstance(instance: InstancedMesh): void;
  25530. /** @hidden */
  25531. removeInstance(instance: InstancedMesh): void;
  25532. }
  25533. }
  25534. declare module "babylonjs/Cameras/camera" {
  25535. import { SmartArray } from "babylonjs/Misc/smartArray";
  25536. import { Observable } from "babylonjs/Misc/observable";
  25537. import { Nullable } from "babylonjs/types";
  25538. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25539. import { Scene } from "babylonjs/scene";
  25540. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25541. import { Node } from "babylonjs/node";
  25542. import { Mesh } from "babylonjs/Meshes/mesh";
  25543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25544. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25545. import { Viewport } from "babylonjs/Maths/math.viewport";
  25546. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25547. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25548. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25549. import { Ray } from "babylonjs/Culling/ray";
  25550. /**
  25551. * This is the base class of all the camera used in the application.
  25552. * @see http://doc.babylonjs.com/features/cameras
  25553. */
  25554. export class Camera extends Node {
  25555. /** @hidden */
  25556. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25557. /**
  25558. * This is the default projection mode used by the cameras.
  25559. * It helps recreating a feeling of perspective and better appreciate depth.
  25560. * This is the best way to simulate real life cameras.
  25561. */
  25562. static readonly PERSPECTIVE_CAMERA: number;
  25563. /**
  25564. * This helps creating camera with an orthographic mode.
  25565. * 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.
  25566. */
  25567. static readonly ORTHOGRAPHIC_CAMERA: number;
  25568. /**
  25569. * This is the default FOV mode for perspective cameras.
  25570. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25571. */
  25572. static readonly FOVMODE_VERTICAL_FIXED: number;
  25573. /**
  25574. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25575. */
  25576. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25577. /**
  25578. * This specifies ther is no need for a camera rig.
  25579. * Basically only one eye is rendered corresponding to the camera.
  25580. */
  25581. static readonly RIG_MODE_NONE: number;
  25582. /**
  25583. * Simulates a camera Rig with one blue eye and one red eye.
  25584. * This can be use with 3d blue and red glasses.
  25585. */
  25586. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25587. /**
  25588. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25589. */
  25590. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25591. /**
  25592. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25593. */
  25594. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25595. /**
  25596. * Defines that both eyes of the camera will be rendered over under each other.
  25597. */
  25598. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25599. /**
  25600. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25601. */
  25602. static readonly RIG_MODE_VR: number;
  25603. /**
  25604. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25605. */
  25606. static readonly RIG_MODE_WEBVR: number;
  25607. /**
  25608. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25609. */
  25610. static readonly RIG_MODE_CUSTOM: number;
  25611. /**
  25612. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25613. */
  25614. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25615. /**
  25616. * Define the input manager associated with the camera.
  25617. */
  25618. inputs: CameraInputsManager<Camera>;
  25619. /** @hidden */
  25620. _position: Vector3;
  25621. /**
  25622. * Define the current local position of the camera in the scene
  25623. */
  25624. position: Vector3;
  25625. /**
  25626. * The vector the camera should consider as up.
  25627. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25628. */
  25629. upVector: Vector3;
  25630. /**
  25631. * Define the current limit on the left side for an orthographic camera
  25632. * In scene unit
  25633. */
  25634. orthoLeft: Nullable<number>;
  25635. /**
  25636. * Define the current limit on the right side for an orthographic camera
  25637. * In scene unit
  25638. */
  25639. orthoRight: Nullable<number>;
  25640. /**
  25641. * Define the current limit on the bottom side for an orthographic camera
  25642. * In scene unit
  25643. */
  25644. orthoBottom: Nullable<number>;
  25645. /**
  25646. * Define the current limit on the top side for an orthographic camera
  25647. * In scene unit
  25648. */
  25649. orthoTop: Nullable<number>;
  25650. /**
  25651. * Field Of View is set in Radians. (default is 0.8)
  25652. */
  25653. fov: number;
  25654. /**
  25655. * Define the minimum distance the camera can see from.
  25656. * This is important to note that the depth buffer are not infinite and the closer it starts
  25657. * the more your scene might encounter depth fighting issue.
  25658. */
  25659. minZ: number;
  25660. /**
  25661. * Define the maximum distance the camera can see to.
  25662. * This is important to note that the depth buffer are not infinite and the further it end
  25663. * the more your scene might encounter depth fighting issue.
  25664. */
  25665. maxZ: number;
  25666. /**
  25667. * Define the default inertia of the camera.
  25668. * This helps giving a smooth feeling to the camera movement.
  25669. */
  25670. inertia: number;
  25671. /**
  25672. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25673. */
  25674. mode: number;
  25675. /**
  25676. * Define wether the camera is intermediate.
  25677. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25678. */
  25679. isIntermediate: boolean;
  25680. /**
  25681. * Define the viewport of the camera.
  25682. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25683. */
  25684. viewport: Viewport;
  25685. /**
  25686. * Restricts the camera to viewing objects with the same layerMask.
  25687. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25688. */
  25689. layerMask: number;
  25690. /**
  25691. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25692. */
  25693. fovMode: number;
  25694. /**
  25695. * Rig mode of the camera.
  25696. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25697. * This is normally controlled byt the camera themselves as internal use.
  25698. */
  25699. cameraRigMode: number;
  25700. /**
  25701. * Defines the distance between both "eyes" in case of a RIG
  25702. */
  25703. interaxialDistance: number;
  25704. /**
  25705. * Defines if stereoscopic rendering is done side by side or over under.
  25706. */
  25707. isStereoscopicSideBySide: boolean;
  25708. /**
  25709. * 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
  25710. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25711. * else in the scene. (Eg. security camera)
  25712. *
  25713. * 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)
  25714. */
  25715. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25716. /**
  25717. * When set, the camera will render to this render target instead of the default canvas
  25718. *
  25719. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25720. */
  25721. outputRenderTarget: Nullable<RenderTargetTexture>;
  25722. /**
  25723. * Observable triggered when the camera view matrix has changed.
  25724. */
  25725. onViewMatrixChangedObservable: Observable<Camera>;
  25726. /**
  25727. * Observable triggered when the camera Projection matrix has changed.
  25728. */
  25729. onProjectionMatrixChangedObservable: Observable<Camera>;
  25730. /**
  25731. * Observable triggered when the inputs have been processed.
  25732. */
  25733. onAfterCheckInputsObservable: Observable<Camera>;
  25734. /**
  25735. * Observable triggered when reset has been called and applied to the camera.
  25736. */
  25737. onRestoreStateObservable: Observable<Camera>;
  25738. /** @hidden */
  25739. _cameraRigParams: any;
  25740. /** @hidden */
  25741. _rigCameras: Camera[];
  25742. /** @hidden */
  25743. _rigPostProcess: Nullable<PostProcess>;
  25744. protected _webvrViewMatrix: Matrix;
  25745. /** @hidden */
  25746. _skipRendering: boolean;
  25747. /** @hidden */
  25748. _projectionMatrix: Matrix;
  25749. /** @hidden */
  25750. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25751. /** @hidden */
  25752. _activeMeshes: SmartArray<AbstractMesh>;
  25753. protected _globalPosition: Vector3;
  25754. /** @hidden */
  25755. _computedViewMatrix: Matrix;
  25756. private _doNotComputeProjectionMatrix;
  25757. private _transformMatrix;
  25758. private _frustumPlanes;
  25759. private _refreshFrustumPlanes;
  25760. private _storedFov;
  25761. private _stateStored;
  25762. /**
  25763. * Instantiates a new camera object.
  25764. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25765. * @see http://doc.babylonjs.com/features/cameras
  25766. * @param name Defines the name of the camera in the scene
  25767. * @param position Defines the position of the camera
  25768. * @param scene Defines the scene the camera belongs too
  25769. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25770. */
  25771. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25772. /**
  25773. * Store current camera state (fov, position, etc..)
  25774. * @returns the camera
  25775. */
  25776. storeState(): Camera;
  25777. /**
  25778. * Restores the camera state values if it has been stored. You must call storeState() first
  25779. */
  25780. protected _restoreStateValues(): boolean;
  25781. /**
  25782. * Restored camera state. You must call storeState() first.
  25783. * @returns true if restored and false otherwise
  25784. */
  25785. restoreState(): boolean;
  25786. /**
  25787. * Gets the class name of the camera.
  25788. * @returns the class name
  25789. */
  25790. getClassName(): string;
  25791. /** @hidden */
  25792. readonly _isCamera: boolean;
  25793. /**
  25794. * Gets a string representation of the camera useful for debug purpose.
  25795. * @param fullDetails Defines that a more verboe level of logging is required
  25796. * @returns the string representation
  25797. */
  25798. toString(fullDetails?: boolean): string;
  25799. /**
  25800. * Gets the current world space position of the camera.
  25801. */
  25802. readonly globalPosition: Vector3;
  25803. /**
  25804. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25805. * @returns the active meshe list
  25806. */
  25807. getActiveMeshes(): SmartArray<AbstractMesh>;
  25808. /**
  25809. * Check wether a mesh is part of the current active mesh list of the camera
  25810. * @param mesh Defines the mesh to check
  25811. * @returns true if active, false otherwise
  25812. */
  25813. isActiveMesh(mesh: Mesh): boolean;
  25814. /**
  25815. * Is this camera ready to be used/rendered
  25816. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25817. * @return true if the camera is ready
  25818. */
  25819. isReady(completeCheck?: boolean): boolean;
  25820. /** @hidden */
  25821. _initCache(): void;
  25822. /** @hidden */
  25823. _updateCache(ignoreParentClass?: boolean): void;
  25824. /** @hidden */
  25825. _isSynchronized(): boolean;
  25826. /** @hidden */
  25827. _isSynchronizedViewMatrix(): boolean;
  25828. /** @hidden */
  25829. _isSynchronizedProjectionMatrix(): boolean;
  25830. /**
  25831. * Attach the input controls to a specific dom element to get the input from.
  25832. * @param element Defines the element the controls should be listened from
  25833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25834. */
  25835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25836. /**
  25837. * Detach the current controls from the specified dom element.
  25838. * @param element Defines the element to stop listening the inputs from
  25839. */
  25840. detachControl(element: HTMLElement): void;
  25841. /**
  25842. * Update the camera state according to the different inputs gathered during the frame.
  25843. */
  25844. update(): void;
  25845. /** @hidden */
  25846. _checkInputs(): void;
  25847. /** @hidden */
  25848. readonly rigCameras: Camera[];
  25849. /**
  25850. * Gets the post process used by the rig cameras
  25851. */
  25852. readonly rigPostProcess: Nullable<PostProcess>;
  25853. /**
  25854. * Internal, gets the first post proces.
  25855. * @returns the first post process to be run on this camera.
  25856. */
  25857. _getFirstPostProcess(): Nullable<PostProcess>;
  25858. private _cascadePostProcessesToRigCams;
  25859. /**
  25860. * Attach a post process to the camera.
  25861. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25862. * @param postProcess The post process to attach to the camera
  25863. * @param insertAt The position of the post process in case several of them are in use in the scene
  25864. * @returns the position the post process has been inserted at
  25865. */
  25866. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25867. /**
  25868. * Detach a post process to the camera.
  25869. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25870. * @param postProcess The post process to detach from the camera
  25871. */
  25872. detachPostProcess(postProcess: PostProcess): void;
  25873. /**
  25874. * Gets the current world matrix of the camera
  25875. */
  25876. getWorldMatrix(): Matrix;
  25877. /** @hidden */
  25878. _getViewMatrix(): Matrix;
  25879. /**
  25880. * Gets the current view matrix of the camera.
  25881. * @param force forces the camera to recompute the matrix without looking at the cached state
  25882. * @returns the view matrix
  25883. */
  25884. getViewMatrix(force?: boolean): Matrix;
  25885. /**
  25886. * Freeze the projection matrix.
  25887. * It will prevent the cache check of the camera projection compute and can speed up perf
  25888. * if no parameter of the camera are meant to change
  25889. * @param projection Defines manually a projection if necessary
  25890. */
  25891. freezeProjectionMatrix(projection?: Matrix): void;
  25892. /**
  25893. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25894. */
  25895. unfreezeProjectionMatrix(): void;
  25896. /**
  25897. * Gets the current projection matrix of the camera.
  25898. * @param force forces the camera to recompute the matrix without looking at the cached state
  25899. * @returns the projection matrix
  25900. */
  25901. getProjectionMatrix(force?: boolean): Matrix;
  25902. /**
  25903. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25904. * @returns a Matrix
  25905. */
  25906. getTransformationMatrix(): Matrix;
  25907. private _updateFrustumPlanes;
  25908. /**
  25909. * Checks if a cullable object (mesh...) is in the camera frustum
  25910. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25911. * @param target The object to check
  25912. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25913. * @returns true if the object is in frustum otherwise false
  25914. */
  25915. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25916. /**
  25917. * Checks if a cullable object (mesh...) is in the camera frustum
  25918. * Unlike isInFrustum this cheks the full bounding box
  25919. * @param target The object to check
  25920. * @returns true if the object is in frustum otherwise false
  25921. */
  25922. isCompletelyInFrustum(target: ICullable): boolean;
  25923. /**
  25924. * Gets a ray in the forward direction from the camera.
  25925. * @param length Defines the length of the ray to create
  25926. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25927. * @param origin Defines the start point of the ray which defaults to the camera position
  25928. * @returns the forward ray
  25929. */
  25930. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25931. /**
  25932. * Releases resources associated with this node.
  25933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25935. */
  25936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25937. /** @hidden */
  25938. _isLeftCamera: boolean;
  25939. /**
  25940. * Gets the left camera of a rig setup in case of Rigged Camera
  25941. */
  25942. readonly isLeftCamera: boolean;
  25943. /** @hidden */
  25944. _isRightCamera: boolean;
  25945. /**
  25946. * Gets the right camera of a rig setup in case of Rigged Camera
  25947. */
  25948. readonly isRightCamera: boolean;
  25949. /**
  25950. * Gets the left camera of a rig setup in case of Rigged Camera
  25951. */
  25952. readonly leftCamera: Nullable<FreeCamera>;
  25953. /**
  25954. * Gets the right camera of a rig setup in case of Rigged Camera
  25955. */
  25956. readonly rightCamera: Nullable<FreeCamera>;
  25957. /**
  25958. * Gets the left camera target of a rig setup in case of Rigged Camera
  25959. * @returns the target position
  25960. */
  25961. getLeftTarget(): Nullable<Vector3>;
  25962. /**
  25963. * Gets the right camera target of a rig setup in case of Rigged Camera
  25964. * @returns the target position
  25965. */
  25966. getRightTarget(): Nullable<Vector3>;
  25967. /**
  25968. * @hidden
  25969. */
  25970. setCameraRigMode(mode: number, rigParams: any): void;
  25971. /** @hidden */
  25972. static _setStereoscopicRigMode(camera: Camera): void;
  25973. /** @hidden */
  25974. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25975. /** @hidden */
  25976. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25977. /** @hidden */
  25978. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25979. /** @hidden */
  25980. _getVRProjectionMatrix(): Matrix;
  25981. protected _updateCameraRotationMatrix(): void;
  25982. protected _updateWebVRCameraRotationMatrix(): void;
  25983. /**
  25984. * This function MUST be overwritten by the different WebVR cameras available.
  25985. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25986. * @hidden
  25987. */
  25988. _getWebVRProjectionMatrix(): Matrix;
  25989. /**
  25990. * This function MUST be overwritten by the different WebVR cameras available.
  25991. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25992. * @hidden
  25993. */
  25994. _getWebVRViewMatrix(): Matrix;
  25995. /** @hidden */
  25996. setCameraRigParameter(name: string, value: any): void;
  25997. /**
  25998. * needs to be overridden by children so sub has required properties to be copied
  25999. * @hidden
  26000. */
  26001. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26002. /**
  26003. * May need to be overridden by children
  26004. * @hidden
  26005. */
  26006. _updateRigCameras(): void;
  26007. /** @hidden */
  26008. _setupInputs(): void;
  26009. /**
  26010. * Serialiaze the camera setup to a json represention
  26011. * @returns the JSON representation
  26012. */
  26013. serialize(): any;
  26014. /**
  26015. * Clones the current camera.
  26016. * @param name The cloned camera name
  26017. * @returns the cloned camera
  26018. */
  26019. clone(name: string): Camera;
  26020. /**
  26021. * Gets the direction of the camera relative to a given local axis.
  26022. * @param localAxis Defines the reference axis to provide a relative direction.
  26023. * @return the direction
  26024. */
  26025. getDirection(localAxis: Vector3): Vector3;
  26026. /**
  26027. * Returns the current camera absolute rotation
  26028. */
  26029. readonly absoluteRotation: Quaternion;
  26030. /**
  26031. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26032. * @param localAxis Defines the reference axis to provide a relative direction.
  26033. * @param result Defines the vector to store the result in
  26034. */
  26035. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26036. /**
  26037. * Gets a camera constructor for a given camera type
  26038. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26039. * @param name The name of the camera the result will be able to instantiate
  26040. * @param scene The scene the result will construct the camera in
  26041. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26042. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26043. * @returns a factory method to construc the camera
  26044. */
  26045. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26046. /**
  26047. * Compute the world matrix of the camera.
  26048. * @returns the camera world matrix
  26049. */
  26050. computeWorldMatrix(): Matrix;
  26051. /**
  26052. * Parse a JSON and creates the camera from the parsed information
  26053. * @param parsedCamera The JSON to parse
  26054. * @param scene The scene to instantiate the camera in
  26055. * @returns the newly constructed camera
  26056. */
  26057. static Parse(parsedCamera: any, scene: Scene): Camera;
  26058. }
  26059. }
  26060. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26061. import { Nullable } from "babylonjs/types";
  26062. import { Scene } from "babylonjs/scene";
  26063. import { Vector4 } from "babylonjs/Maths/math.vector";
  26064. import { Mesh } from "babylonjs/Meshes/mesh";
  26065. /**
  26066. * Class containing static functions to help procedurally build meshes
  26067. */
  26068. export class DiscBuilder {
  26069. /**
  26070. * Creates a plane polygonal mesh. By default, this is a disc
  26071. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26072. * * 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
  26073. * * 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
  26074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26077. * @param name defines the name of the mesh
  26078. * @param options defines the options used to create the mesh
  26079. * @param scene defines the hosting scene
  26080. * @returns the plane polygonal mesh
  26081. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26082. */
  26083. static CreateDisc(name: string, options: {
  26084. radius?: number;
  26085. tessellation?: number;
  26086. arc?: number;
  26087. updatable?: boolean;
  26088. sideOrientation?: number;
  26089. frontUVs?: Vector4;
  26090. backUVs?: Vector4;
  26091. }, scene?: Nullable<Scene>): Mesh;
  26092. }
  26093. }
  26094. declare module "babylonjs/Particles/solidParticleSystem" {
  26095. import { Vector3 } from "babylonjs/Maths/math.vector";
  26096. import { Mesh } from "babylonjs/Meshes/mesh";
  26097. import { Scene, IDisposable } from "babylonjs/scene";
  26098. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26099. /**
  26100. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26101. *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.
  26102. * The SPS is also a particle system. It provides some methods to manage the particles.
  26103. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26104. *
  26105. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26106. */
  26107. export class SolidParticleSystem implements IDisposable {
  26108. /**
  26109. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26110. * Example : var p = SPS.particles[i];
  26111. */
  26112. particles: SolidParticle[];
  26113. /**
  26114. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26115. */
  26116. nbParticles: number;
  26117. /**
  26118. * If the particles must ever face the camera (default false). Useful for planar particles.
  26119. */
  26120. billboard: boolean;
  26121. /**
  26122. * Recompute normals when adding a shape
  26123. */
  26124. recomputeNormals: boolean;
  26125. /**
  26126. * This a counter ofr your own usage. It's not set by any SPS functions.
  26127. */
  26128. counter: number;
  26129. /**
  26130. * The SPS name. This name is also given to the underlying mesh.
  26131. */
  26132. name: string;
  26133. /**
  26134. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26135. */
  26136. mesh: Mesh;
  26137. /**
  26138. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26139. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26140. */
  26141. vars: any;
  26142. /**
  26143. * This array is populated when the SPS is set as 'pickable'.
  26144. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26145. * Each element of this array is an object `{idx: int, faceId: int}`.
  26146. * `idx` is the picked particle index in the `SPS.particles` array
  26147. * `faceId` is the picked face index counted within this particle.
  26148. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26149. */
  26150. pickedParticles: {
  26151. idx: number;
  26152. faceId: number;
  26153. }[];
  26154. /**
  26155. * This array is populated when `enableDepthSort` is set to true.
  26156. * Each element of this array is an instance of the class DepthSortedParticle.
  26157. */
  26158. depthSortedParticles: DepthSortedParticle[];
  26159. /**
  26160. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26161. * @hidden
  26162. */
  26163. _bSphereOnly: boolean;
  26164. /**
  26165. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26166. * @hidden
  26167. */
  26168. _bSphereRadiusFactor: number;
  26169. private _scene;
  26170. private _positions;
  26171. private _indices;
  26172. private _normals;
  26173. private _colors;
  26174. private _uvs;
  26175. private _indices32;
  26176. private _positions32;
  26177. private _normals32;
  26178. private _fixedNormal32;
  26179. private _colors32;
  26180. private _uvs32;
  26181. private _index;
  26182. private _updatable;
  26183. private _pickable;
  26184. private _isVisibilityBoxLocked;
  26185. private _alwaysVisible;
  26186. private _depthSort;
  26187. private _expandable;
  26188. private _shapeCounter;
  26189. private _copy;
  26190. private _color;
  26191. private _computeParticleColor;
  26192. private _computeParticleTexture;
  26193. private _computeParticleRotation;
  26194. private _computeParticleVertex;
  26195. private _computeBoundingBox;
  26196. private _depthSortParticles;
  26197. private _camera;
  26198. private _mustUnrotateFixedNormals;
  26199. private _particlesIntersect;
  26200. private _needs32Bits;
  26201. private _isNotBuilt;
  26202. /**
  26203. * Creates a SPS (Solid Particle System) object.
  26204. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26205. * @param scene (Scene) is the scene in which the SPS is added.
  26206. * @param options defines the options of the sps e.g.
  26207. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26208. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26209. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26210. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26211. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26212. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26213. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26214. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26215. */
  26216. constructor(name: string, scene: Scene, options?: {
  26217. updatable?: boolean;
  26218. isPickable?: boolean;
  26219. enableDepthSort?: boolean;
  26220. particleIntersection?: boolean;
  26221. boundingSphereOnly?: boolean;
  26222. bSphereRadiusFactor?: number;
  26223. expandable?: boolean;
  26224. });
  26225. /**
  26226. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26227. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26228. * @returns the created mesh
  26229. */
  26230. buildMesh(): Mesh;
  26231. /**
  26232. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26233. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26234. * Thus the particles generated from `digest()` have their property `position` set yet.
  26235. * @param mesh ( Mesh ) is the mesh to be digested
  26236. * @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
  26237. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26238. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26239. * @returns the current SPS
  26240. */
  26241. digest(mesh: Mesh, options?: {
  26242. facetNb?: number;
  26243. number?: number;
  26244. delta?: number;
  26245. }): SolidParticleSystem;
  26246. private _unrotateFixedNormals;
  26247. private _resetCopy;
  26248. private _meshBuilder;
  26249. private _posToShape;
  26250. private _uvsToShapeUV;
  26251. private _addParticle;
  26252. /**
  26253. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26254. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26255. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26256. * @param nb (positive integer) the number of particles to be created from this model
  26257. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26258. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26259. * @returns the number of shapes in the system
  26260. */
  26261. addShape(mesh: Mesh, nb: number, options?: {
  26262. positionFunction?: any;
  26263. vertexFunction?: any;
  26264. }): number;
  26265. private _rebuildParticle;
  26266. /**
  26267. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26268. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26269. * @returns the SPS.
  26270. */
  26271. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26272. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26273. * Returns an array with the removed particles.
  26274. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26275. * The SPS can't be empty so at least one particle needs to remain in place.
  26276. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26277. * @param start index of the first particle to remove
  26278. * @param end index of the last particle to remove (included)
  26279. * @returns an array populated with the removed particles
  26280. */
  26281. removeParticles(start: number, end: number): SolidParticle[];
  26282. /**
  26283. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26284. * This method calls `updateParticle()` for each particle of the SPS.
  26285. * For an animated SPS, it is usually called within the render loop.
  26286. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26287. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26288. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26289. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26290. * @returns the SPS.
  26291. */
  26292. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26293. /**
  26294. * Disposes the SPS.
  26295. */
  26296. dispose(): void;
  26297. /**
  26298. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26299. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26300. * @returns the SPS.
  26301. */
  26302. refreshVisibleSize(): SolidParticleSystem;
  26303. /**
  26304. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26305. * @param size the size (float) of the visibility box
  26306. * note : this doesn't lock the SPS mesh bounding box.
  26307. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26308. */
  26309. setVisibilityBox(size: number): void;
  26310. /**
  26311. * Gets whether the SPS as always visible or not
  26312. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26313. */
  26314. /**
  26315. * Sets the SPS as always visible or not
  26316. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26317. */
  26318. isAlwaysVisible: boolean;
  26319. /**
  26320. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26321. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26322. */
  26323. /**
  26324. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26325. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26326. */
  26327. isVisibilityBoxLocked: boolean;
  26328. /**
  26329. * Tells to `setParticles()` to compute the particle rotations or not.
  26330. * Default value : true. The SPS is faster when it's set to false.
  26331. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26332. */
  26333. /**
  26334. * Gets if `setParticles()` computes the particle rotations or not.
  26335. * Default value : true. The SPS is faster when it's set to false.
  26336. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26337. */
  26338. computeParticleRotation: boolean;
  26339. /**
  26340. * Tells to `setParticles()` to compute the particle colors or not.
  26341. * Default value : true. The SPS is faster when it's set to false.
  26342. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26343. */
  26344. /**
  26345. * Gets if `setParticles()` computes the particle colors or not.
  26346. * Default value : true. The SPS is faster when it's set to false.
  26347. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26348. */
  26349. computeParticleColor: boolean;
  26350. /**
  26351. * Gets if `setParticles()` computes the particle textures or not.
  26352. * Default value : true. The SPS is faster when it's set to false.
  26353. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26354. */
  26355. computeParticleTexture: boolean;
  26356. /**
  26357. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26358. * Default value : false. The SPS is faster when it's set to false.
  26359. * Note : the particle custom vertex positions aren't stored values.
  26360. */
  26361. /**
  26362. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26363. * Default value : false. The SPS is faster when it's set to false.
  26364. * Note : the particle custom vertex positions aren't stored values.
  26365. */
  26366. computeParticleVertex: boolean;
  26367. /**
  26368. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26369. */
  26370. /**
  26371. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26372. */
  26373. computeBoundingBox: boolean;
  26374. /**
  26375. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26376. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26377. * Default : `true`
  26378. */
  26379. /**
  26380. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26381. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26382. * Default : `true`
  26383. */
  26384. depthSortParticles: boolean;
  26385. /**
  26386. * Gets if the SPS is created as expandable at construction time.
  26387. * Default : `false`
  26388. */
  26389. readonly expandable: boolean;
  26390. /**
  26391. * This function does nothing. It may be overwritten to set all the particle first values.
  26392. * The SPS doesn't call this function, you may have to call it by your own.
  26393. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26394. */
  26395. initParticles(): void;
  26396. /**
  26397. * This function does nothing. It may be overwritten to recycle a particle.
  26398. * The SPS doesn't call this function, you may have to call it by your own.
  26399. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26400. * @param particle The particle to recycle
  26401. * @returns the recycled particle
  26402. */
  26403. recycleParticle(particle: SolidParticle): SolidParticle;
  26404. /**
  26405. * Updates a particle : this function should be overwritten by the user.
  26406. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26408. * @example : just set a particle position or velocity and recycle conditions
  26409. * @param particle The particle to update
  26410. * @returns the updated particle
  26411. */
  26412. updateParticle(particle: SolidParticle): SolidParticle;
  26413. /**
  26414. * Updates a vertex of a particle : it can be overwritten by the user.
  26415. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26416. * @param particle the current particle
  26417. * @param vertex the current index of the current particle
  26418. * @param pt the index of the current vertex in the particle shape
  26419. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26420. * @example : just set a vertex particle position
  26421. * @returns the updated vertex
  26422. */
  26423. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26424. /**
  26425. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26426. * This does nothing and may be overwritten by the user.
  26427. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26428. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26429. * @param update the boolean update value actually passed to setParticles()
  26430. */
  26431. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26432. /**
  26433. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26434. * This will be passed three parameters.
  26435. * This does nothing and may be overwritten by the user.
  26436. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26437. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26438. * @param update the boolean update value actually passed to setParticles()
  26439. */
  26440. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26441. }
  26442. }
  26443. declare module "babylonjs/Particles/solidParticle" {
  26444. import { Nullable } from "babylonjs/types";
  26445. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26446. import { Color4 } from "babylonjs/Maths/math.color";
  26447. import { Mesh } from "babylonjs/Meshes/mesh";
  26448. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26449. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26450. import { Plane } from "babylonjs/Maths/math.plane";
  26451. /**
  26452. * Represents one particle of a solid particle system.
  26453. */
  26454. export class SolidParticle {
  26455. /**
  26456. * particle global index
  26457. */
  26458. idx: number;
  26459. /**
  26460. * The color of the particle
  26461. */
  26462. color: Nullable<Color4>;
  26463. /**
  26464. * The world space position of the particle.
  26465. */
  26466. position: Vector3;
  26467. /**
  26468. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26469. */
  26470. rotation: Vector3;
  26471. /**
  26472. * The world space rotation quaternion of the particle.
  26473. */
  26474. rotationQuaternion: Nullable<Quaternion>;
  26475. /**
  26476. * The scaling of the particle.
  26477. */
  26478. scaling: Vector3;
  26479. /**
  26480. * The uvs of the particle.
  26481. */
  26482. uvs: Vector4;
  26483. /**
  26484. * The current speed of the particle.
  26485. */
  26486. velocity: Vector3;
  26487. /**
  26488. * The pivot point in the particle local space.
  26489. */
  26490. pivot: Vector3;
  26491. /**
  26492. * Must the particle be translated from its pivot point in its local space ?
  26493. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26494. * Default : false
  26495. */
  26496. translateFromPivot: boolean;
  26497. /**
  26498. * Is the particle active or not ?
  26499. */
  26500. alive: boolean;
  26501. /**
  26502. * Is the particle visible or not ?
  26503. */
  26504. isVisible: boolean;
  26505. /**
  26506. * Index of this particle in the global "positions" array (Internal use)
  26507. * @hidden
  26508. */
  26509. _pos: number;
  26510. /**
  26511. * @hidden Index of this particle in the global "indices" array (Internal use)
  26512. */
  26513. _ind: number;
  26514. /**
  26515. * @hidden ModelShape of this particle (Internal use)
  26516. */
  26517. _model: ModelShape;
  26518. /**
  26519. * ModelShape id of this particle
  26520. */
  26521. shapeId: number;
  26522. /**
  26523. * Index of the particle in its shape id
  26524. */
  26525. idxInShape: number;
  26526. /**
  26527. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26528. */
  26529. _modelBoundingInfo: BoundingInfo;
  26530. /**
  26531. * @hidden Particle BoundingInfo object (Internal use)
  26532. */
  26533. _boundingInfo: BoundingInfo;
  26534. /**
  26535. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26536. */
  26537. _sps: SolidParticleSystem;
  26538. /**
  26539. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26540. */
  26541. _stillInvisible: boolean;
  26542. /**
  26543. * @hidden Last computed particle rotation matrix
  26544. */
  26545. _rotationMatrix: number[];
  26546. /**
  26547. * Parent particle Id, if any.
  26548. * Default null.
  26549. */
  26550. parentId: Nullable<number>;
  26551. /**
  26552. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26553. * The possible values are :
  26554. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26555. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26557. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26558. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26559. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26560. * */
  26561. cullingStrategy: number;
  26562. /**
  26563. * @hidden Internal global position in the SPS.
  26564. */
  26565. _globalPosition: Vector3;
  26566. /**
  26567. * Creates a Solid Particle object.
  26568. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26569. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26570. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26571. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26572. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26573. * @param shapeId (integer) is the model shape identifier in the SPS.
  26574. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26575. * @param sps defines the sps it is associated to
  26576. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26577. */
  26578. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26579. /**
  26580. * Legacy support, changed scale to scaling
  26581. */
  26582. /**
  26583. * Legacy support, changed scale to scaling
  26584. */
  26585. scale: Vector3;
  26586. /**
  26587. * Legacy support, changed quaternion to rotationQuaternion
  26588. */
  26589. /**
  26590. * Legacy support, changed quaternion to rotationQuaternion
  26591. */
  26592. quaternion: Nullable<Quaternion>;
  26593. /**
  26594. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26595. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26596. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26597. * @returns true if it intersects
  26598. */
  26599. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26600. /**
  26601. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26602. * A particle is in the frustum if its bounding box intersects the frustum
  26603. * @param frustumPlanes defines the frustum to test
  26604. * @returns true if the particle is in the frustum planes
  26605. */
  26606. isInFrustum(frustumPlanes: Plane[]): boolean;
  26607. /**
  26608. * get the rotation matrix of the particle
  26609. * @hidden
  26610. */
  26611. getRotationMatrix(m: Matrix): void;
  26612. }
  26613. /**
  26614. * Represents the shape of the model used by one particle of a solid particle system.
  26615. * SPS internal tool, don't use it manually.
  26616. */
  26617. export class ModelShape {
  26618. /**
  26619. * The shape id
  26620. * @hidden
  26621. */
  26622. shapeID: number;
  26623. /**
  26624. * flat array of model positions (internal use)
  26625. * @hidden
  26626. */
  26627. _shape: Vector3[];
  26628. /**
  26629. * flat array of model UVs (internal use)
  26630. * @hidden
  26631. */
  26632. _shapeUV: number[];
  26633. /**
  26634. * color array of the model
  26635. * @hidden
  26636. */
  26637. _shapeColors: number[];
  26638. /**
  26639. * indices array of the model
  26640. * @hidden
  26641. */
  26642. _indices: number[];
  26643. /**
  26644. * normals array of the model
  26645. * @hidden
  26646. */
  26647. _normals: number[];
  26648. /**
  26649. * length of the shape in the model indices array (internal use)
  26650. * @hidden
  26651. */
  26652. _indicesLength: number;
  26653. /**
  26654. * Custom position function (internal use)
  26655. * @hidden
  26656. */
  26657. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26658. /**
  26659. * Custom vertex function (internal use)
  26660. * @hidden
  26661. */
  26662. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26663. /**
  26664. * 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.
  26665. * SPS internal tool, don't use it manually.
  26666. * @hidden
  26667. */
  26668. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26669. }
  26670. /**
  26671. * Represents a Depth Sorted Particle in the solid particle system.
  26672. */
  26673. export class DepthSortedParticle {
  26674. /**
  26675. * Index of the particle in the "indices" array
  26676. */
  26677. ind: number;
  26678. /**
  26679. * Length of the particle shape in the "indices" array
  26680. */
  26681. indicesLength: number;
  26682. /**
  26683. * Squared distance from the particle to the camera
  26684. */
  26685. sqDistance: number;
  26686. }
  26687. }
  26688. declare module "babylonjs/Collisions/meshCollisionData" {
  26689. import { Collider } from "babylonjs/Collisions/collider";
  26690. import { Vector3 } from "babylonjs/Maths/math.vector";
  26691. import { Nullable } from "babylonjs/types";
  26692. import { Observer } from "babylonjs/Misc/observable";
  26693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26694. /**
  26695. * @hidden
  26696. */
  26697. export class _MeshCollisionData {
  26698. _checkCollisions: boolean;
  26699. _collisionMask: number;
  26700. _collisionGroup: number;
  26701. _collider: Nullable<Collider>;
  26702. _oldPositionForCollisions: Vector3;
  26703. _diffPositionForCollisions: Vector3;
  26704. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26705. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26706. }
  26707. }
  26708. declare module "babylonjs/Meshes/abstractMesh" {
  26709. import { Observable } from "babylonjs/Misc/observable";
  26710. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26711. import { Camera } from "babylonjs/Cameras/camera";
  26712. import { Scene, IDisposable } from "babylonjs/scene";
  26713. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26714. import { Node } from "babylonjs/node";
  26715. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26716. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26718. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26719. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26720. import { Material } from "babylonjs/Materials/material";
  26721. import { Light } from "babylonjs/Lights/light";
  26722. import { Skeleton } from "babylonjs/Bones/skeleton";
  26723. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26724. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26725. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26726. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26727. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26728. import { Plane } from "babylonjs/Maths/math.plane";
  26729. import { Ray } from "babylonjs/Culling/ray";
  26730. import { Collider } from "babylonjs/Collisions/collider";
  26731. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26732. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26733. /** @hidden */
  26734. class _FacetDataStorage {
  26735. facetPositions: Vector3[];
  26736. facetNormals: Vector3[];
  26737. facetPartitioning: number[][];
  26738. facetNb: number;
  26739. partitioningSubdivisions: number;
  26740. partitioningBBoxRatio: number;
  26741. facetDataEnabled: boolean;
  26742. facetParameters: any;
  26743. bbSize: Vector3;
  26744. subDiv: {
  26745. max: number;
  26746. X: number;
  26747. Y: number;
  26748. Z: number;
  26749. };
  26750. facetDepthSort: boolean;
  26751. facetDepthSortEnabled: boolean;
  26752. depthSortedIndices: IndicesArray;
  26753. depthSortedFacets: {
  26754. ind: number;
  26755. sqDistance: number;
  26756. }[];
  26757. facetDepthSortFunction: (f1: {
  26758. ind: number;
  26759. sqDistance: number;
  26760. }, f2: {
  26761. ind: number;
  26762. sqDistance: number;
  26763. }) => number;
  26764. facetDepthSortFrom: Vector3;
  26765. facetDepthSortOrigin: Vector3;
  26766. invertedMatrix: Matrix;
  26767. }
  26768. /**
  26769. * @hidden
  26770. **/
  26771. class _InternalAbstractMeshDataInfo {
  26772. _hasVertexAlpha: boolean;
  26773. _useVertexColors: boolean;
  26774. _numBoneInfluencers: number;
  26775. _applyFog: boolean;
  26776. _receiveShadows: boolean;
  26777. _facetData: _FacetDataStorage;
  26778. _visibility: number;
  26779. _skeleton: Nullable<Skeleton>;
  26780. _layerMask: number;
  26781. _computeBonesUsingShaders: boolean;
  26782. _isActive: boolean;
  26783. _onlyForInstances: boolean;
  26784. _isActiveIntermediate: boolean;
  26785. _onlyForInstancesIntermediate: boolean;
  26786. _actAsRegularMesh: boolean;
  26787. }
  26788. /**
  26789. * Class used to store all common mesh properties
  26790. */
  26791. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26792. /** No occlusion */
  26793. static OCCLUSION_TYPE_NONE: number;
  26794. /** Occlusion set to optimisitic */
  26795. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26796. /** Occlusion set to strict */
  26797. static OCCLUSION_TYPE_STRICT: number;
  26798. /** Use an accurante occlusion algorithm */
  26799. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26800. /** Use a conservative occlusion algorithm */
  26801. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26802. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26803. * Test order :
  26804. * Is the bounding sphere outside the frustum ?
  26805. * If not, are the bounding box vertices outside the frustum ?
  26806. * It not, then the cullable object is in the frustum.
  26807. */
  26808. static readonly CULLINGSTRATEGY_STANDARD: number;
  26809. /** Culling strategy : Bounding Sphere Only.
  26810. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26811. * It's also less accurate than the standard because some not visible objects can still be selected.
  26812. * Test : is the bounding sphere outside the frustum ?
  26813. * If not, then the cullable object is in the frustum.
  26814. */
  26815. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26816. /** Culling strategy : Optimistic Inclusion.
  26817. * This in an inclusion test first, then the standard exclusion test.
  26818. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26819. * 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.
  26820. * Anyway, it's as accurate as the standard strategy.
  26821. * Test :
  26822. * Is the cullable object bounding sphere center in the frustum ?
  26823. * If not, apply the default culling strategy.
  26824. */
  26825. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26826. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26827. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26828. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26829. * 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.
  26830. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26831. * Test :
  26832. * Is the cullable object bounding sphere center in the frustum ?
  26833. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26834. */
  26835. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26836. /**
  26837. * No billboard
  26838. */
  26839. static readonly BILLBOARDMODE_NONE: number;
  26840. /** Billboard on X axis */
  26841. static readonly BILLBOARDMODE_X: number;
  26842. /** Billboard on Y axis */
  26843. static readonly BILLBOARDMODE_Y: number;
  26844. /** Billboard on Z axis */
  26845. static readonly BILLBOARDMODE_Z: number;
  26846. /** Billboard on all axes */
  26847. static readonly BILLBOARDMODE_ALL: number;
  26848. /** Billboard on using position instead of orientation */
  26849. static readonly BILLBOARDMODE_USE_POSITION: number;
  26850. /** @hidden */
  26851. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26852. /**
  26853. * The culling strategy to use to check whether the mesh must be rendered or not.
  26854. * This value can be changed at any time and will be used on the next render mesh selection.
  26855. * The possible values are :
  26856. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26857. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26858. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26859. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26860. * Please read each static variable documentation to get details about the culling process.
  26861. * */
  26862. cullingStrategy: number;
  26863. /**
  26864. * Gets the number of facets in the mesh
  26865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26866. */
  26867. readonly facetNb: number;
  26868. /**
  26869. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26871. */
  26872. partitioningSubdivisions: number;
  26873. /**
  26874. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26875. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26877. */
  26878. partitioningBBoxRatio: number;
  26879. /**
  26880. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26881. * Works only for updatable meshes.
  26882. * Doesn't work with multi-materials
  26883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26884. */
  26885. mustDepthSortFacets: boolean;
  26886. /**
  26887. * The location (Vector3) where the facet depth sort must be computed from.
  26888. * By default, the active camera position.
  26889. * Used only when facet depth sort is enabled
  26890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26891. */
  26892. facetDepthSortFrom: Vector3;
  26893. /**
  26894. * gets a boolean indicating if facetData is enabled
  26895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26896. */
  26897. readonly isFacetDataEnabled: boolean;
  26898. /** @hidden */
  26899. _updateNonUniformScalingState(value: boolean): boolean;
  26900. /**
  26901. * An event triggered when this mesh collides with another one
  26902. */
  26903. onCollideObservable: Observable<AbstractMesh>;
  26904. /** Set a function to call when this mesh collides with another one */
  26905. onCollide: () => void;
  26906. /**
  26907. * An event triggered when the collision's position changes
  26908. */
  26909. onCollisionPositionChangeObservable: Observable<Vector3>;
  26910. /** Set a function to call when the collision's position changes */
  26911. onCollisionPositionChange: () => void;
  26912. /**
  26913. * An event triggered when material is changed
  26914. */
  26915. onMaterialChangedObservable: Observable<AbstractMesh>;
  26916. /**
  26917. * Gets or sets the orientation for POV movement & rotation
  26918. */
  26919. definedFacingForward: boolean;
  26920. /** @hidden */
  26921. _occlusionQuery: Nullable<WebGLQuery>;
  26922. /** @hidden */
  26923. _renderingGroup: Nullable<RenderingGroup>;
  26924. /**
  26925. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26926. */
  26927. /**
  26928. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26929. */
  26930. visibility: number;
  26931. /** Gets or sets the alpha index used to sort transparent meshes
  26932. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26933. */
  26934. alphaIndex: number;
  26935. /**
  26936. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26937. */
  26938. isVisible: boolean;
  26939. /**
  26940. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26941. */
  26942. isPickable: boolean;
  26943. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26944. showSubMeshesBoundingBox: boolean;
  26945. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26946. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26947. */
  26948. isBlocker: boolean;
  26949. /**
  26950. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26951. */
  26952. enablePointerMoveEvents: boolean;
  26953. /**
  26954. * Specifies the rendering group id for this mesh (0 by default)
  26955. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26956. */
  26957. renderingGroupId: number;
  26958. private _material;
  26959. /** Gets or sets current material */
  26960. material: Nullable<Material>;
  26961. /**
  26962. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26963. * @see http://doc.babylonjs.com/babylon101/shadows
  26964. */
  26965. receiveShadows: boolean;
  26966. /** Defines color to use when rendering outline */
  26967. outlineColor: Color3;
  26968. /** Define width to use when rendering outline */
  26969. outlineWidth: number;
  26970. /** Defines color to use when rendering overlay */
  26971. overlayColor: Color3;
  26972. /** Defines alpha to use when rendering overlay */
  26973. overlayAlpha: number;
  26974. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26975. hasVertexAlpha: boolean;
  26976. /** 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) */
  26977. useVertexColors: boolean;
  26978. /**
  26979. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26980. */
  26981. computeBonesUsingShaders: boolean;
  26982. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26983. numBoneInfluencers: number;
  26984. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26985. applyFog: boolean;
  26986. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26987. useOctreeForRenderingSelection: boolean;
  26988. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26989. useOctreeForPicking: boolean;
  26990. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26991. useOctreeForCollisions: boolean;
  26992. /**
  26993. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26994. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26995. */
  26996. layerMask: number;
  26997. /**
  26998. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26999. */
  27000. alwaysSelectAsActiveMesh: boolean;
  27001. /**
  27002. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27003. */
  27004. doNotSyncBoundingInfo: boolean;
  27005. /**
  27006. * Gets or sets the current action manager
  27007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27008. */
  27009. actionManager: Nullable<AbstractActionManager>;
  27010. private _meshCollisionData;
  27011. /**
  27012. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27014. */
  27015. ellipsoid: Vector3;
  27016. /**
  27017. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27019. */
  27020. ellipsoidOffset: Vector3;
  27021. /**
  27022. * Gets or sets a collision mask used to mask collisions (default is -1).
  27023. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27024. */
  27025. collisionMask: number;
  27026. /**
  27027. * Gets or sets the current collision group mask (-1 by default).
  27028. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27029. */
  27030. collisionGroup: number;
  27031. /**
  27032. * Defines edge width used when edgesRenderer is enabled
  27033. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27034. */
  27035. edgesWidth: number;
  27036. /**
  27037. * Defines edge color used when edgesRenderer is enabled
  27038. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27039. */
  27040. edgesColor: Color4;
  27041. /** @hidden */
  27042. _edgesRenderer: Nullable<IEdgesRenderer>;
  27043. /** @hidden */
  27044. _masterMesh: Nullable<AbstractMesh>;
  27045. /** @hidden */
  27046. _boundingInfo: Nullable<BoundingInfo>;
  27047. /** @hidden */
  27048. _renderId: number;
  27049. /**
  27050. * Gets or sets the list of subMeshes
  27051. * @see http://doc.babylonjs.com/how_to/multi_materials
  27052. */
  27053. subMeshes: SubMesh[];
  27054. /** @hidden */
  27055. _intersectionsInProgress: AbstractMesh[];
  27056. /** @hidden */
  27057. _unIndexed: boolean;
  27058. /** @hidden */
  27059. _lightSources: Light[];
  27060. /** Gets the list of lights affecting that mesh */
  27061. readonly lightSources: Light[];
  27062. /** @hidden */
  27063. readonly _positions: Nullable<Vector3[]>;
  27064. /** @hidden */
  27065. _waitingData: {
  27066. lods: Nullable<any>;
  27067. actions: Nullable<any>;
  27068. freezeWorldMatrix: Nullable<boolean>;
  27069. };
  27070. /** @hidden */
  27071. _bonesTransformMatrices: Nullable<Float32Array>;
  27072. /** @hidden */
  27073. _transformMatrixTexture: Nullable<RawTexture>;
  27074. /**
  27075. * Gets or sets a skeleton to apply skining transformations
  27076. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27077. */
  27078. skeleton: Nullable<Skeleton>;
  27079. /**
  27080. * An event triggered when the mesh is rebuilt.
  27081. */
  27082. onRebuildObservable: Observable<AbstractMesh>;
  27083. /**
  27084. * Creates a new AbstractMesh
  27085. * @param name defines the name of the mesh
  27086. * @param scene defines the hosting scene
  27087. */
  27088. constructor(name: string, scene?: Nullable<Scene>);
  27089. /**
  27090. * Returns the string "AbstractMesh"
  27091. * @returns "AbstractMesh"
  27092. */
  27093. getClassName(): string;
  27094. /**
  27095. * Gets a string representation of the current mesh
  27096. * @param fullDetails defines a boolean indicating if full details must be included
  27097. * @returns a string representation of the current mesh
  27098. */
  27099. toString(fullDetails?: boolean): string;
  27100. /**
  27101. * @hidden
  27102. */
  27103. protected _getEffectiveParent(): Nullable<Node>;
  27104. /** @hidden */
  27105. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27106. /** @hidden */
  27107. _rebuild(): void;
  27108. /** @hidden */
  27109. _resyncLightSources(): void;
  27110. /** @hidden */
  27111. _resyncLighSource(light: Light): void;
  27112. /** @hidden */
  27113. _unBindEffect(): void;
  27114. /** @hidden */
  27115. _removeLightSource(light: Light, dispose: boolean): void;
  27116. private _markSubMeshesAsDirty;
  27117. /** @hidden */
  27118. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27119. /** @hidden */
  27120. _markSubMeshesAsAttributesDirty(): void;
  27121. /** @hidden */
  27122. _markSubMeshesAsMiscDirty(): void;
  27123. /**
  27124. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27125. */
  27126. scaling: Vector3;
  27127. /**
  27128. * Returns true if the mesh is blocked. Implemented by child classes
  27129. */
  27130. readonly isBlocked: boolean;
  27131. /**
  27132. * Returns the mesh itself by default. Implemented by child classes
  27133. * @param camera defines the camera to use to pick the right LOD level
  27134. * @returns the currentAbstractMesh
  27135. */
  27136. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27137. /**
  27138. * Returns 0 by default. Implemented by child classes
  27139. * @returns an integer
  27140. */
  27141. getTotalVertices(): number;
  27142. /**
  27143. * Returns a positive integer : the total number of indices in this mesh geometry.
  27144. * @returns the numner of indices or zero if the mesh has no geometry.
  27145. */
  27146. getTotalIndices(): number;
  27147. /**
  27148. * Returns null by default. Implemented by child classes
  27149. * @returns null
  27150. */
  27151. getIndices(): Nullable<IndicesArray>;
  27152. /**
  27153. * Returns the array of the requested vertex data kind. Implemented by child classes
  27154. * @param kind defines the vertex data kind to use
  27155. * @returns null
  27156. */
  27157. getVerticesData(kind: string): Nullable<FloatArray>;
  27158. /**
  27159. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27160. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27161. * Note that a new underlying VertexBuffer object is created each call.
  27162. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27163. * @param kind defines vertex data kind:
  27164. * * VertexBuffer.PositionKind
  27165. * * VertexBuffer.UVKind
  27166. * * VertexBuffer.UV2Kind
  27167. * * VertexBuffer.UV3Kind
  27168. * * VertexBuffer.UV4Kind
  27169. * * VertexBuffer.UV5Kind
  27170. * * VertexBuffer.UV6Kind
  27171. * * VertexBuffer.ColorKind
  27172. * * VertexBuffer.MatricesIndicesKind
  27173. * * VertexBuffer.MatricesIndicesExtraKind
  27174. * * VertexBuffer.MatricesWeightsKind
  27175. * * VertexBuffer.MatricesWeightsExtraKind
  27176. * @param data defines the data source
  27177. * @param updatable defines if the data must be flagged as updatable (or static)
  27178. * @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
  27179. * @returns the current mesh
  27180. */
  27181. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27182. /**
  27183. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27184. * If the mesh has no geometry, it is simply returned as it is.
  27185. * @param kind defines vertex data kind:
  27186. * * VertexBuffer.PositionKind
  27187. * * VertexBuffer.UVKind
  27188. * * VertexBuffer.UV2Kind
  27189. * * VertexBuffer.UV3Kind
  27190. * * VertexBuffer.UV4Kind
  27191. * * VertexBuffer.UV5Kind
  27192. * * VertexBuffer.UV6Kind
  27193. * * VertexBuffer.ColorKind
  27194. * * VertexBuffer.MatricesIndicesKind
  27195. * * VertexBuffer.MatricesIndicesExtraKind
  27196. * * VertexBuffer.MatricesWeightsKind
  27197. * * VertexBuffer.MatricesWeightsExtraKind
  27198. * @param data defines the data source
  27199. * @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
  27200. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27201. * @returns the current mesh
  27202. */
  27203. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27204. /**
  27205. * Sets the mesh indices,
  27206. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27207. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27208. * @param totalVertices Defines the total number of vertices
  27209. * @returns the current mesh
  27210. */
  27211. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27212. /**
  27213. * Gets a boolean indicating if specific vertex data is present
  27214. * @param kind defines the vertex data kind to use
  27215. * @returns true is data kind is present
  27216. */
  27217. isVerticesDataPresent(kind: string): boolean;
  27218. /**
  27219. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27220. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27221. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27222. * @returns a BoundingInfo
  27223. */
  27224. getBoundingInfo(): BoundingInfo;
  27225. /**
  27226. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27227. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27228. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27229. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27230. * @returns the current mesh
  27231. */
  27232. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27233. /**
  27234. * Overwrite the current bounding info
  27235. * @param boundingInfo defines the new bounding info
  27236. * @returns the current mesh
  27237. */
  27238. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27239. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27240. readonly useBones: boolean;
  27241. /** @hidden */
  27242. _preActivate(): void;
  27243. /** @hidden */
  27244. _preActivateForIntermediateRendering(renderId: number): void;
  27245. /** @hidden */
  27246. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27247. /** @hidden */
  27248. _postActivate(): void;
  27249. /** @hidden */
  27250. _freeze(): void;
  27251. /** @hidden */
  27252. _unFreeze(): void;
  27253. /**
  27254. * Gets the current world matrix
  27255. * @returns a Matrix
  27256. */
  27257. getWorldMatrix(): Matrix;
  27258. /** @hidden */
  27259. _getWorldMatrixDeterminant(): number;
  27260. /**
  27261. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27262. */
  27263. readonly isAnInstance: boolean;
  27264. /**
  27265. * Gets a boolean indicating if this mesh has instances
  27266. */
  27267. readonly hasInstances: boolean;
  27268. /**
  27269. * Perform relative position change from the point of view of behind the front of the mesh.
  27270. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27271. * Supports definition of mesh facing forward or backward
  27272. * @param amountRight defines the distance on the right axis
  27273. * @param amountUp defines the distance on the up axis
  27274. * @param amountForward defines the distance on the forward axis
  27275. * @returns the current mesh
  27276. */
  27277. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27278. /**
  27279. * Calculate relative position change from the point of view of behind the front of the mesh.
  27280. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27281. * Supports definition of mesh facing forward or backward
  27282. * @param amountRight defines the distance on the right axis
  27283. * @param amountUp defines the distance on the up axis
  27284. * @param amountForward defines the distance on the forward axis
  27285. * @returns the new displacement vector
  27286. */
  27287. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27288. /**
  27289. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27290. * Supports definition of mesh facing forward or backward
  27291. * @param flipBack defines the flip
  27292. * @param twirlClockwise defines the twirl
  27293. * @param tiltRight defines the tilt
  27294. * @returns the current mesh
  27295. */
  27296. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27297. /**
  27298. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27299. * Supports definition of mesh facing forward or backward.
  27300. * @param flipBack defines the flip
  27301. * @param twirlClockwise defines the twirl
  27302. * @param tiltRight defines the tilt
  27303. * @returns the new rotation vector
  27304. */
  27305. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27306. /**
  27307. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27308. * This means the mesh underlying bounding box and sphere are recomputed.
  27309. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27310. * @returns the current mesh
  27311. */
  27312. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27313. /** @hidden */
  27314. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27315. /** @hidden */
  27316. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27317. /** @hidden */
  27318. _updateBoundingInfo(): AbstractMesh;
  27319. /** @hidden */
  27320. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27321. /** @hidden */
  27322. protected _afterComputeWorldMatrix(): void;
  27323. /** @hidden */
  27324. readonly _effectiveMesh: AbstractMesh;
  27325. /**
  27326. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27327. * A mesh is in the frustum if its bounding box intersects the frustum
  27328. * @param frustumPlanes defines the frustum to test
  27329. * @returns true if the mesh is in the frustum planes
  27330. */
  27331. isInFrustum(frustumPlanes: Plane[]): boolean;
  27332. /**
  27333. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27334. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27335. * @param frustumPlanes defines the frustum to test
  27336. * @returns true if the mesh is completely in the frustum planes
  27337. */
  27338. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27339. /**
  27340. * True if the mesh intersects another mesh or a SolidParticle object
  27341. * @param mesh defines a target mesh or SolidParticle to test
  27342. * @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)
  27343. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27344. * @returns true if there is an intersection
  27345. */
  27346. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27347. /**
  27348. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27349. * @param point defines the point to test
  27350. * @returns true if there is an intersection
  27351. */
  27352. intersectsPoint(point: Vector3): boolean;
  27353. /**
  27354. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27355. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27356. */
  27357. checkCollisions: boolean;
  27358. /**
  27359. * Gets Collider object used to compute collisions (not physics)
  27360. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27361. */
  27362. readonly collider: Nullable<Collider>;
  27363. /**
  27364. * Move the mesh using collision engine
  27365. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27366. * @param displacement defines the requested displacement vector
  27367. * @returns the current mesh
  27368. */
  27369. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27370. private _onCollisionPositionChange;
  27371. /** @hidden */
  27372. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27373. /** @hidden */
  27374. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27375. /** @hidden */
  27376. _checkCollision(collider: Collider): AbstractMesh;
  27377. /** @hidden */
  27378. _generatePointsArray(): boolean;
  27379. /**
  27380. * Checks if the passed Ray intersects with the mesh
  27381. * @param ray defines the ray to use
  27382. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27383. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27384. * @returns the picking info
  27385. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27386. */
  27387. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27388. /**
  27389. * Clones the current mesh
  27390. * @param name defines the mesh name
  27391. * @param newParent defines the new mesh parent
  27392. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27393. * @returns the new mesh
  27394. */
  27395. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27396. /**
  27397. * Disposes all the submeshes of the current meshnp
  27398. * @returns the current mesh
  27399. */
  27400. releaseSubMeshes(): AbstractMesh;
  27401. /**
  27402. * Releases resources associated with this abstract mesh.
  27403. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27404. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27405. */
  27406. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27407. /**
  27408. * Adds the passed mesh as a child to the current mesh
  27409. * @param mesh defines the child mesh
  27410. * @returns the current mesh
  27411. */
  27412. addChild(mesh: AbstractMesh): AbstractMesh;
  27413. /**
  27414. * Removes the passed mesh from the current mesh children list
  27415. * @param mesh defines the child mesh
  27416. * @returns the current mesh
  27417. */
  27418. removeChild(mesh: AbstractMesh): AbstractMesh;
  27419. /** @hidden */
  27420. private _initFacetData;
  27421. /**
  27422. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27423. * This method can be called within the render loop.
  27424. * 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
  27425. * @returns the current mesh
  27426. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27427. */
  27428. updateFacetData(): AbstractMesh;
  27429. /**
  27430. * Returns the facetLocalNormals array.
  27431. * The normals are expressed in the mesh local spac
  27432. * @returns an array of Vector3
  27433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27434. */
  27435. getFacetLocalNormals(): Vector3[];
  27436. /**
  27437. * Returns the facetLocalPositions array.
  27438. * The facet positions are expressed in the mesh local space
  27439. * @returns an array of Vector3
  27440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27441. */
  27442. getFacetLocalPositions(): Vector3[];
  27443. /**
  27444. * Returns the facetLocalPartioning array
  27445. * @returns an array of array of numbers
  27446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27447. */
  27448. getFacetLocalPartitioning(): number[][];
  27449. /**
  27450. * Returns the i-th facet position in the world system.
  27451. * This method allocates a new Vector3 per call
  27452. * @param i defines the facet index
  27453. * @returns a new Vector3
  27454. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27455. */
  27456. getFacetPosition(i: number): Vector3;
  27457. /**
  27458. * Sets the reference Vector3 with the i-th facet position in the world system
  27459. * @param i defines the facet index
  27460. * @param ref defines the target vector
  27461. * @returns the current mesh
  27462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27463. */
  27464. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27465. /**
  27466. * Returns the i-th facet normal in the world system.
  27467. * This method allocates a new Vector3 per call
  27468. * @param i defines the facet index
  27469. * @returns a new Vector3
  27470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27471. */
  27472. getFacetNormal(i: number): Vector3;
  27473. /**
  27474. * Sets the reference Vector3 with the i-th facet normal in the world system
  27475. * @param i defines the facet index
  27476. * @param ref defines the target vector
  27477. * @returns the current mesh
  27478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27479. */
  27480. getFacetNormalToRef(i: number, ref: Vector3): this;
  27481. /**
  27482. * 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)
  27483. * @param x defines x coordinate
  27484. * @param y defines y coordinate
  27485. * @param z defines z coordinate
  27486. * @returns the array of facet indexes
  27487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27488. */
  27489. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27490. /**
  27491. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27492. * @param projected sets as the (x,y,z) world projection on the facet
  27493. * @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
  27494. * @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
  27495. * @param x defines x coordinate
  27496. * @param y defines y coordinate
  27497. * @param z defines z coordinate
  27498. * @returns the face index if found (or null instead)
  27499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27500. */
  27501. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27502. /**
  27503. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27504. * @param projected sets as the (x,y,z) local projection on the facet
  27505. * @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
  27506. * @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
  27507. * @param x defines x coordinate
  27508. * @param y defines y coordinate
  27509. * @param z defines z coordinate
  27510. * @returns the face index if found (or null instead)
  27511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27512. */
  27513. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27514. /**
  27515. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27516. * @returns the parameters
  27517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27518. */
  27519. getFacetDataParameters(): any;
  27520. /**
  27521. * Disables the feature FacetData and frees the related memory
  27522. * @returns the current mesh
  27523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27524. */
  27525. disableFacetData(): AbstractMesh;
  27526. /**
  27527. * Updates the AbstractMesh indices array
  27528. * @param indices defines the data source
  27529. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27530. * @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)
  27531. * @returns the current mesh
  27532. */
  27533. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27534. /**
  27535. * Creates new normals data for the mesh
  27536. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27537. * @returns the current mesh
  27538. */
  27539. createNormals(updatable: boolean): AbstractMesh;
  27540. /**
  27541. * Align the mesh with a normal
  27542. * @param normal defines the normal to use
  27543. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27544. * @returns the current mesh
  27545. */
  27546. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27547. /** @hidden */
  27548. _checkOcclusionQuery(): boolean;
  27549. /**
  27550. * Disables the mesh edge rendering mode
  27551. * @returns the currentAbstractMesh
  27552. */
  27553. disableEdgesRendering(): AbstractMesh;
  27554. /**
  27555. * Enables the edge rendering mode on the mesh.
  27556. * This mode makes the mesh edges visible
  27557. * @param epsilon defines the maximal distance between two angles to detect a face
  27558. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27559. * @returns the currentAbstractMesh
  27560. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27561. */
  27562. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27563. }
  27564. }
  27565. declare module "babylonjs/Actions/actionEvent" {
  27566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27567. import { Nullable } from "babylonjs/types";
  27568. import { Sprite } from "babylonjs/Sprites/sprite";
  27569. import { Scene } from "babylonjs/scene";
  27570. import { Vector2 } from "babylonjs/Maths/math.vector";
  27571. /**
  27572. * Interface used to define ActionEvent
  27573. */
  27574. export interface IActionEvent {
  27575. /** The mesh or sprite that triggered the action */
  27576. source: any;
  27577. /** The X mouse cursor position at the time of the event */
  27578. pointerX: number;
  27579. /** The Y mouse cursor position at the time of the event */
  27580. pointerY: number;
  27581. /** The mesh that is currently pointed at (can be null) */
  27582. meshUnderPointer: Nullable<AbstractMesh>;
  27583. /** the original (browser) event that triggered the ActionEvent */
  27584. sourceEvent?: any;
  27585. /** additional data for the event */
  27586. additionalData?: any;
  27587. }
  27588. /**
  27589. * ActionEvent is the event being sent when an action is triggered.
  27590. */
  27591. export class ActionEvent implements IActionEvent {
  27592. /** The mesh or sprite that triggered the action */
  27593. source: any;
  27594. /** The X mouse cursor position at the time of the event */
  27595. pointerX: number;
  27596. /** The Y mouse cursor position at the time of the event */
  27597. pointerY: number;
  27598. /** The mesh that is currently pointed at (can be null) */
  27599. meshUnderPointer: Nullable<AbstractMesh>;
  27600. /** the original (browser) event that triggered the ActionEvent */
  27601. sourceEvent?: any;
  27602. /** additional data for the event */
  27603. additionalData?: any;
  27604. /**
  27605. * Creates a new ActionEvent
  27606. * @param source The mesh or sprite that triggered the action
  27607. * @param pointerX The X mouse cursor position at the time of the event
  27608. * @param pointerY The Y mouse cursor position at the time of the event
  27609. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27610. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27611. * @param additionalData additional data for the event
  27612. */
  27613. constructor(
  27614. /** The mesh or sprite that triggered the action */
  27615. source: any,
  27616. /** The X mouse cursor position at the time of the event */
  27617. pointerX: number,
  27618. /** The Y mouse cursor position at the time of the event */
  27619. pointerY: number,
  27620. /** The mesh that is currently pointed at (can be null) */
  27621. meshUnderPointer: Nullable<AbstractMesh>,
  27622. /** the original (browser) event that triggered the ActionEvent */
  27623. sourceEvent?: any,
  27624. /** additional data for the event */
  27625. additionalData?: any);
  27626. /**
  27627. * Helper function to auto-create an ActionEvent from a source mesh.
  27628. * @param source The source mesh that triggered the event
  27629. * @param evt The original (browser) event
  27630. * @param additionalData additional data for the event
  27631. * @returns the new ActionEvent
  27632. */
  27633. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27634. /**
  27635. * Helper function to auto-create an ActionEvent from a source sprite
  27636. * @param source The source sprite that triggered the event
  27637. * @param scene Scene associated with the sprite
  27638. * @param evt The original (browser) event
  27639. * @param additionalData additional data for the event
  27640. * @returns the new ActionEvent
  27641. */
  27642. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27643. /**
  27644. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27645. * @param scene the scene where the event occurred
  27646. * @param evt The original (browser) event
  27647. * @returns the new ActionEvent
  27648. */
  27649. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27650. /**
  27651. * Helper function to auto-create an ActionEvent from a primitive
  27652. * @param prim defines the target primitive
  27653. * @param pointerPos defines the pointer position
  27654. * @param evt The original (browser) event
  27655. * @param additionalData additional data for the event
  27656. * @returns the new ActionEvent
  27657. */
  27658. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27659. }
  27660. }
  27661. declare module "babylonjs/Actions/abstractActionManager" {
  27662. import { IDisposable } from "babylonjs/scene";
  27663. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27664. import { IAction } from "babylonjs/Actions/action";
  27665. import { Nullable } from "babylonjs/types";
  27666. /**
  27667. * Abstract class used to decouple action Manager from scene and meshes.
  27668. * Do not instantiate.
  27669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27670. */
  27671. export abstract class AbstractActionManager implements IDisposable {
  27672. /** Gets the list of active triggers */
  27673. static Triggers: {
  27674. [key: string]: number;
  27675. };
  27676. /** Gets the cursor to use when hovering items */
  27677. hoverCursor: string;
  27678. /** Gets the list of actions */
  27679. actions: IAction[];
  27680. /**
  27681. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27682. */
  27683. isRecursive: boolean;
  27684. /**
  27685. * Releases all associated resources
  27686. */
  27687. abstract dispose(): void;
  27688. /**
  27689. * Does this action manager has pointer triggers
  27690. */
  27691. abstract readonly hasPointerTriggers: boolean;
  27692. /**
  27693. * Does this action manager has pick triggers
  27694. */
  27695. abstract readonly hasPickTriggers: boolean;
  27696. /**
  27697. * Process a specific trigger
  27698. * @param trigger defines the trigger to process
  27699. * @param evt defines the event details to be processed
  27700. */
  27701. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27702. /**
  27703. * Does this action manager handles actions of any of the given triggers
  27704. * @param triggers defines the triggers to be tested
  27705. * @return a boolean indicating whether one (or more) of the triggers is handled
  27706. */
  27707. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27708. /**
  27709. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27710. * speed.
  27711. * @param triggerA defines the trigger to be tested
  27712. * @param triggerB defines the trigger to be tested
  27713. * @return a boolean indicating whether one (or more) of the triggers is handled
  27714. */
  27715. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27716. /**
  27717. * Does this action manager handles actions of a given trigger
  27718. * @param trigger defines the trigger to be tested
  27719. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27720. * @return whether the trigger is handled
  27721. */
  27722. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27723. /**
  27724. * Serialize this manager to a JSON object
  27725. * @param name defines the property name to store this manager
  27726. * @returns a JSON representation of this manager
  27727. */
  27728. abstract serialize(name: string): any;
  27729. /**
  27730. * Registers an action to this action manager
  27731. * @param action defines the action to be registered
  27732. * @return the action amended (prepared) after registration
  27733. */
  27734. abstract registerAction(action: IAction): Nullable<IAction>;
  27735. /**
  27736. * Unregisters an action to this action manager
  27737. * @param action defines the action to be unregistered
  27738. * @return a boolean indicating whether the action has been unregistered
  27739. */
  27740. abstract unregisterAction(action: IAction): Boolean;
  27741. /**
  27742. * Does exist one action manager with at least one trigger
  27743. **/
  27744. static readonly HasTriggers: boolean;
  27745. /**
  27746. * Does exist one action manager with at least one pick trigger
  27747. **/
  27748. static readonly HasPickTriggers: boolean;
  27749. /**
  27750. * Does exist one action manager that handles actions of a given trigger
  27751. * @param trigger defines the trigger to be tested
  27752. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27753. **/
  27754. static HasSpecificTrigger(trigger: number): boolean;
  27755. }
  27756. }
  27757. declare module "babylonjs/node" {
  27758. import { Scene } from "babylonjs/scene";
  27759. import { Nullable } from "babylonjs/types";
  27760. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27761. import { Engine } from "babylonjs/Engines/engine";
  27762. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27763. import { Observable } from "babylonjs/Misc/observable";
  27764. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27765. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27766. import { Animatable } from "babylonjs/Animations/animatable";
  27767. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27768. import { Animation } from "babylonjs/Animations/animation";
  27769. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27771. /**
  27772. * Defines how a node can be built from a string name.
  27773. */
  27774. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27775. /**
  27776. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27777. */
  27778. export class Node implements IBehaviorAware<Node> {
  27779. /** @hidden */
  27780. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27781. private static _NodeConstructors;
  27782. /**
  27783. * Add a new node constructor
  27784. * @param type defines the type name of the node to construct
  27785. * @param constructorFunc defines the constructor function
  27786. */
  27787. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27788. /**
  27789. * Returns a node constructor based on type name
  27790. * @param type defines the type name
  27791. * @param name defines the new node name
  27792. * @param scene defines the hosting scene
  27793. * @param options defines optional options to transmit to constructors
  27794. * @returns the new constructor or null
  27795. */
  27796. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27797. /**
  27798. * Gets or sets the name of the node
  27799. */
  27800. name: string;
  27801. /**
  27802. * Gets or sets the id of the node
  27803. */
  27804. id: string;
  27805. /**
  27806. * Gets or sets the unique id of the node
  27807. */
  27808. uniqueId: number;
  27809. /**
  27810. * Gets or sets a string used to store user defined state for the node
  27811. */
  27812. state: string;
  27813. /**
  27814. * Gets or sets an object used to store user defined information for the node
  27815. */
  27816. metadata: any;
  27817. /**
  27818. * For internal use only. Please do not use.
  27819. */
  27820. reservedDataStore: any;
  27821. /**
  27822. * List of inspectable custom properties (used by the Inspector)
  27823. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27824. */
  27825. inspectableCustomProperties: IInspectable[];
  27826. private _doNotSerialize;
  27827. /**
  27828. * Gets or sets a boolean used to define if the node must be serialized
  27829. */
  27830. doNotSerialize: boolean;
  27831. /** @hidden */
  27832. _isDisposed: boolean;
  27833. /**
  27834. * Gets a list of Animations associated with the node
  27835. */
  27836. animations: import("babylonjs/Animations/animation").Animation[];
  27837. protected _ranges: {
  27838. [name: string]: Nullable<AnimationRange>;
  27839. };
  27840. /**
  27841. * Callback raised when the node is ready to be used
  27842. */
  27843. onReady: Nullable<(node: Node) => void>;
  27844. private _isEnabled;
  27845. private _isParentEnabled;
  27846. private _isReady;
  27847. /** @hidden */
  27848. _currentRenderId: number;
  27849. private _parentUpdateId;
  27850. /** @hidden */
  27851. _childUpdateId: number;
  27852. /** @hidden */
  27853. _waitingParentId: Nullable<string>;
  27854. /** @hidden */
  27855. _scene: Scene;
  27856. /** @hidden */
  27857. _cache: any;
  27858. private _parentNode;
  27859. private _children;
  27860. /** @hidden */
  27861. _worldMatrix: Matrix;
  27862. /** @hidden */
  27863. _worldMatrixDeterminant: number;
  27864. /** @hidden */
  27865. _worldMatrixDeterminantIsDirty: boolean;
  27866. /** @hidden */
  27867. private _sceneRootNodesIndex;
  27868. /**
  27869. * Gets a boolean indicating if the node has been disposed
  27870. * @returns true if the node was disposed
  27871. */
  27872. isDisposed(): boolean;
  27873. /**
  27874. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27875. * @see https://doc.babylonjs.com/how_to/parenting
  27876. */
  27877. parent: Nullable<Node>;
  27878. /** @hidden */
  27879. _addToSceneRootNodes(): void;
  27880. /** @hidden */
  27881. _removeFromSceneRootNodes(): void;
  27882. private _animationPropertiesOverride;
  27883. /**
  27884. * Gets or sets the animation properties override
  27885. */
  27886. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27887. /**
  27888. * Gets a string idenfifying the name of the class
  27889. * @returns "Node" string
  27890. */
  27891. getClassName(): string;
  27892. /** @hidden */
  27893. readonly _isNode: boolean;
  27894. /**
  27895. * An event triggered when the mesh is disposed
  27896. */
  27897. onDisposeObservable: Observable<Node>;
  27898. private _onDisposeObserver;
  27899. /**
  27900. * Sets a callback that will be raised when the node will be disposed
  27901. */
  27902. onDispose: () => void;
  27903. /**
  27904. * Creates a new Node
  27905. * @param name the name and id to be given to this node
  27906. * @param scene the scene this node will be added to
  27907. */
  27908. constructor(name: string, scene?: Nullable<Scene>);
  27909. /**
  27910. * Gets the scene of the node
  27911. * @returns a scene
  27912. */
  27913. getScene(): Scene;
  27914. /**
  27915. * Gets the engine of the node
  27916. * @returns a Engine
  27917. */
  27918. getEngine(): Engine;
  27919. private _behaviors;
  27920. /**
  27921. * Attach a behavior to the node
  27922. * @see http://doc.babylonjs.com/features/behaviour
  27923. * @param behavior defines the behavior to attach
  27924. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27925. * @returns the current Node
  27926. */
  27927. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27928. /**
  27929. * Remove an attached behavior
  27930. * @see http://doc.babylonjs.com/features/behaviour
  27931. * @param behavior defines the behavior to attach
  27932. * @returns the current Node
  27933. */
  27934. removeBehavior(behavior: Behavior<Node>): Node;
  27935. /**
  27936. * Gets the list of attached behaviors
  27937. * @see http://doc.babylonjs.com/features/behaviour
  27938. */
  27939. readonly behaviors: Behavior<Node>[];
  27940. /**
  27941. * Gets an attached behavior by name
  27942. * @param name defines the name of the behavior to look for
  27943. * @see http://doc.babylonjs.com/features/behaviour
  27944. * @returns null if behavior was not found else the requested behavior
  27945. */
  27946. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27947. /**
  27948. * Returns the latest update of the World matrix
  27949. * @returns a Matrix
  27950. */
  27951. getWorldMatrix(): Matrix;
  27952. /** @hidden */
  27953. _getWorldMatrixDeterminant(): number;
  27954. /**
  27955. * Returns directly the latest state of the mesh World matrix.
  27956. * A Matrix is returned.
  27957. */
  27958. readonly worldMatrixFromCache: Matrix;
  27959. /** @hidden */
  27960. _initCache(): void;
  27961. /** @hidden */
  27962. updateCache(force?: boolean): void;
  27963. /** @hidden */
  27964. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27965. /** @hidden */
  27966. _updateCache(ignoreParentClass?: boolean): void;
  27967. /** @hidden */
  27968. _isSynchronized(): boolean;
  27969. /** @hidden */
  27970. _markSyncedWithParent(): void;
  27971. /** @hidden */
  27972. isSynchronizedWithParent(): boolean;
  27973. /** @hidden */
  27974. isSynchronized(): boolean;
  27975. /**
  27976. * Is this node ready to be used/rendered
  27977. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27978. * @return true if the node is ready
  27979. */
  27980. isReady(completeCheck?: boolean): boolean;
  27981. /**
  27982. * Is this node enabled?
  27983. * 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
  27984. * @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
  27985. * @return whether this node (and its parent) is enabled
  27986. */
  27987. isEnabled(checkAncestors?: boolean): boolean;
  27988. /** @hidden */
  27989. protected _syncParentEnabledState(): void;
  27990. /**
  27991. * Set the enabled state of this node
  27992. * @param value defines the new enabled state
  27993. */
  27994. setEnabled(value: boolean): void;
  27995. /**
  27996. * Is this node a descendant of the given node?
  27997. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27998. * @param ancestor defines the parent node to inspect
  27999. * @returns a boolean indicating if this node is a descendant of the given node
  28000. */
  28001. isDescendantOf(ancestor: Node): boolean;
  28002. /** @hidden */
  28003. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28004. /**
  28005. * Will return all nodes that have this node as ascendant
  28006. * @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
  28007. * @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
  28008. * @return all children nodes of all types
  28009. */
  28010. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28011. /**
  28012. * Get all child-meshes of this node
  28013. * @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)
  28014. * @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
  28015. * @returns an array of AbstractMesh
  28016. */
  28017. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28018. /**
  28019. * Get all direct children of this node
  28020. * @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
  28021. * @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)
  28022. * @returns an array of Node
  28023. */
  28024. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28025. /** @hidden */
  28026. _setReady(state: boolean): void;
  28027. /**
  28028. * Get an animation by name
  28029. * @param name defines the name of the animation to look for
  28030. * @returns null if not found else the requested animation
  28031. */
  28032. getAnimationByName(name: string): Nullable<Animation>;
  28033. /**
  28034. * Creates an animation range for this node
  28035. * @param name defines the name of the range
  28036. * @param from defines the starting key
  28037. * @param to defines the end key
  28038. */
  28039. createAnimationRange(name: string, from: number, to: number): void;
  28040. /**
  28041. * Delete a specific animation range
  28042. * @param name defines the name of the range to delete
  28043. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28044. */
  28045. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28046. /**
  28047. * Get an animation range by name
  28048. * @param name defines the name of the animation range to look for
  28049. * @returns null if not found else the requested animation range
  28050. */
  28051. getAnimationRange(name: string): Nullable<AnimationRange>;
  28052. /**
  28053. * Gets the list of all animation ranges defined on this node
  28054. * @returns an array
  28055. */
  28056. getAnimationRanges(): Nullable<AnimationRange>[];
  28057. /**
  28058. * Will start the animation sequence
  28059. * @param name defines the range frames for animation sequence
  28060. * @param loop defines if the animation should loop (false by default)
  28061. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28062. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28063. * @returns the object created for this animation. If range does not exist, it will return null
  28064. */
  28065. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28066. /**
  28067. * Serialize animation ranges into a JSON compatible object
  28068. * @returns serialization object
  28069. */
  28070. serializeAnimationRanges(): any;
  28071. /**
  28072. * Computes the world matrix of the node
  28073. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28074. * @returns the world matrix
  28075. */
  28076. computeWorldMatrix(force?: boolean): Matrix;
  28077. /**
  28078. * Releases resources associated with this node.
  28079. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28080. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28081. */
  28082. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28083. /**
  28084. * Parse animation range data from a serialization object and store them into a given node
  28085. * @param node defines where to store the animation ranges
  28086. * @param parsedNode defines the serialization object to read data from
  28087. * @param scene defines the hosting scene
  28088. */
  28089. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28090. /**
  28091. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28092. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28093. * @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
  28094. * @returns the new bounding vectors
  28095. */
  28096. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28097. min: Vector3;
  28098. max: Vector3;
  28099. };
  28100. }
  28101. }
  28102. declare module "babylonjs/Animations/animation" {
  28103. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28104. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28105. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28106. import { Nullable } from "babylonjs/types";
  28107. import { Scene } from "babylonjs/scene";
  28108. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28109. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28110. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28111. import { Node } from "babylonjs/node";
  28112. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28113. import { Size } from "babylonjs/Maths/math.size";
  28114. import { Animatable } from "babylonjs/Animations/animatable";
  28115. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28116. /**
  28117. * @hidden
  28118. */
  28119. export class _IAnimationState {
  28120. key: number;
  28121. repeatCount: number;
  28122. workValue?: any;
  28123. loopMode?: number;
  28124. offsetValue?: any;
  28125. highLimitValue?: any;
  28126. }
  28127. /**
  28128. * Class used to store any kind of animation
  28129. */
  28130. export class Animation {
  28131. /**Name of the animation */
  28132. name: string;
  28133. /**Property to animate */
  28134. targetProperty: string;
  28135. /**The frames per second of the animation */
  28136. framePerSecond: number;
  28137. /**The data type of the animation */
  28138. dataType: number;
  28139. /**The loop mode of the animation */
  28140. loopMode?: number | undefined;
  28141. /**Specifies if blending should be enabled */
  28142. enableBlending?: boolean | undefined;
  28143. /**
  28144. * Use matrix interpolation instead of using direct key value when animating matrices
  28145. */
  28146. static AllowMatricesInterpolation: boolean;
  28147. /**
  28148. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28149. */
  28150. static AllowMatrixDecomposeForInterpolation: boolean;
  28151. /**
  28152. * Stores the key frames of the animation
  28153. */
  28154. private _keys;
  28155. /**
  28156. * Stores the easing function of the animation
  28157. */
  28158. private _easingFunction;
  28159. /**
  28160. * @hidden Internal use only
  28161. */
  28162. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28163. /**
  28164. * The set of event that will be linked to this animation
  28165. */
  28166. private _events;
  28167. /**
  28168. * Stores an array of target property paths
  28169. */
  28170. targetPropertyPath: string[];
  28171. /**
  28172. * Stores the blending speed of the animation
  28173. */
  28174. blendingSpeed: number;
  28175. /**
  28176. * Stores the animation ranges for the animation
  28177. */
  28178. private _ranges;
  28179. /**
  28180. * @hidden Internal use
  28181. */
  28182. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28183. /**
  28184. * Sets up an animation
  28185. * @param property The property to animate
  28186. * @param animationType The animation type to apply
  28187. * @param framePerSecond The frames per second of the animation
  28188. * @param easingFunction The easing function used in the animation
  28189. * @returns The created animation
  28190. */
  28191. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28192. /**
  28193. * Create and start an animation on a node
  28194. * @param name defines the name of the global animation that will be run on all nodes
  28195. * @param node defines the root node where the animation will take place
  28196. * @param targetProperty defines property to animate
  28197. * @param framePerSecond defines the number of frame per second yo use
  28198. * @param totalFrame defines the number of frames in total
  28199. * @param from defines the initial value
  28200. * @param to defines the final value
  28201. * @param loopMode defines which loop mode you want to use (off by default)
  28202. * @param easingFunction defines the easing function to use (linear by default)
  28203. * @param onAnimationEnd defines the callback to call when animation end
  28204. * @returns the animatable created for this animation
  28205. */
  28206. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28207. /**
  28208. * Create and start an animation on a node and its descendants
  28209. * @param name defines the name of the global animation that will be run on all nodes
  28210. * @param node defines the root node where the animation will take place
  28211. * @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
  28212. * @param targetProperty defines property to animate
  28213. * @param framePerSecond defines the number of frame per second to use
  28214. * @param totalFrame defines the number of frames in total
  28215. * @param from defines the initial value
  28216. * @param to defines the final value
  28217. * @param loopMode defines which loop mode you want to use (off by default)
  28218. * @param easingFunction defines the easing function to use (linear by default)
  28219. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28220. * @returns the list of animatables created for all nodes
  28221. * @example https://www.babylonjs-playground.com/#MH0VLI
  28222. */
  28223. 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[]>;
  28224. /**
  28225. * Creates a new animation, merges it with the existing animations and starts it
  28226. * @param name Name of the animation
  28227. * @param node Node which contains the scene that begins the animations
  28228. * @param targetProperty Specifies which property to animate
  28229. * @param framePerSecond The frames per second of the animation
  28230. * @param totalFrame The total number of frames
  28231. * @param from The frame at the beginning of the animation
  28232. * @param to The frame at the end of the animation
  28233. * @param loopMode Specifies the loop mode of the animation
  28234. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28235. * @param onAnimationEnd Callback to run once the animation is complete
  28236. * @returns Nullable animation
  28237. */
  28238. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28239. /**
  28240. * Transition property of an host to the target Value
  28241. * @param property The property to transition
  28242. * @param targetValue The target Value of the property
  28243. * @param host The object where the property to animate belongs
  28244. * @param scene Scene used to run the animation
  28245. * @param frameRate Framerate (in frame/s) to use
  28246. * @param transition The transition type we want to use
  28247. * @param duration The duration of the animation, in milliseconds
  28248. * @param onAnimationEnd Callback trigger at the end of the animation
  28249. * @returns Nullable animation
  28250. */
  28251. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28252. /**
  28253. * Return the array of runtime animations currently using this animation
  28254. */
  28255. readonly runtimeAnimations: RuntimeAnimation[];
  28256. /**
  28257. * Specifies if any of the runtime animations are currently running
  28258. */
  28259. readonly hasRunningRuntimeAnimations: boolean;
  28260. /**
  28261. * Initializes the animation
  28262. * @param name Name of the animation
  28263. * @param targetProperty Property to animate
  28264. * @param framePerSecond The frames per second of the animation
  28265. * @param dataType The data type of the animation
  28266. * @param loopMode The loop mode of the animation
  28267. * @param enableBlending Specifies if blending should be enabled
  28268. */
  28269. constructor(
  28270. /**Name of the animation */
  28271. name: string,
  28272. /**Property to animate */
  28273. targetProperty: string,
  28274. /**The frames per second of the animation */
  28275. framePerSecond: number,
  28276. /**The data type of the animation */
  28277. dataType: number,
  28278. /**The loop mode of the animation */
  28279. loopMode?: number | undefined,
  28280. /**Specifies if blending should be enabled */
  28281. enableBlending?: boolean | undefined);
  28282. /**
  28283. * Converts the animation to a string
  28284. * @param fullDetails support for multiple levels of logging within scene loading
  28285. * @returns String form of the animation
  28286. */
  28287. toString(fullDetails?: boolean): string;
  28288. /**
  28289. * Add an event to this animation
  28290. * @param event Event to add
  28291. */
  28292. addEvent(event: AnimationEvent): void;
  28293. /**
  28294. * Remove all events found at the given frame
  28295. * @param frame The frame to remove events from
  28296. */
  28297. removeEvents(frame: number): void;
  28298. /**
  28299. * Retrieves all the events from the animation
  28300. * @returns Events from the animation
  28301. */
  28302. getEvents(): AnimationEvent[];
  28303. /**
  28304. * Creates an animation range
  28305. * @param name Name of the animation range
  28306. * @param from Starting frame of the animation range
  28307. * @param to Ending frame of the animation
  28308. */
  28309. createRange(name: string, from: number, to: number): void;
  28310. /**
  28311. * Deletes an animation range by name
  28312. * @param name Name of the animation range to delete
  28313. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28314. */
  28315. deleteRange(name: string, deleteFrames?: boolean): void;
  28316. /**
  28317. * Gets the animation range by name, or null if not defined
  28318. * @param name Name of the animation range
  28319. * @returns Nullable animation range
  28320. */
  28321. getRange(name: string): Nullable<AnimationRange>;
  28322. /**
  28323. * Gets the key frames from the animation
  28324. * @returns The key frames of the animation
  28325. */
  28326. getKeys(): Array<IAnimationKey>;
  28327. /**
  28328. * Gets the highest frame rate of the animation
  28329. * @returns Highest frame rate of the animation
  28330. */
  28331. getHighestFrame(): number;
  28332. /**
  28333. * Gets the easing function of the animation
  28334. * @returns Easing function of the animation
  28335. */
  28336. getEasingFunction(): IEasingFunction;
  28337. /**
  28338. * Sets the easing function of the animation
  28339. * @param easingFunction A custom mathematical formula for animation
  28340. */
  28341. setEasingFunction(easingFunction: EasingFunction): void;
  28342. /**
  28343. * Interpolates a scalar linearly
  28344. * @param startValue Start value of the animation curve
  28345. * @param endValue End value of the animation curve
  28346. * @param gradient Scalar amount to interpolate
  28347. * @returns Interpolated scalar value
  28348. */
  28349. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28350. /**
  28351. * Interpolates a scalar cubically
  28352. * @param startValue Start value of the animation curve
  28353. * @param outTangent End tangent of the animation
  28354. * @param endValue End value of the animation curve
  28355. * @param inTangent Start tangent of the animation curve
  28356. * @param gradient Scalar amount to interpolate
  28357. * @returns Interpolated scalar value
  28358. */
  28359. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28360. /**
  28361. * Interpolates a quaternion using a spherical linear interpolation
  28362. * @param startValue Start value of the animation curve
  28363. * @param endValue End value of the animation curve
  28364. * @param gradient Scalar amount to interpolate
  28365. * @returns Interpolated quaternion value
  28366. */
  28367. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28368. /**
  28369. * Interpolates a quaternion cubically
  28370. * @param startValue Start value of the animation curve
  28371. * @param outTangent End tangent of the animation curve
  28372. * @param endValue End value of the animation curve
  28373. * @param inTangent Start tangent of the animation curve
  28374. * @param gradient Scalar amount to interpolate
  28375. * @returns Interpolated quaternion value
  28376. */
  28377. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28378. /**
  28379. * Interpolates a Vector3 linearl
  28380. * @param startValue Start value of the animation curve
  28381. * @param endValue End value of the animation curve
  28382. * @param gradient Scalar amount to interpolate
  28383. * @returns Interpolated scalar value
  28384. */
  28385. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28386. /**
  28387. * Interpolates a Vector3 cubically
  28388. * @param startValue Start value of the animation curve
  28389. * @param outTangent End tangent of the animation
  28390. * @param endValue End value of the animation curve
  28391. * @param inTangent Start tangent of the animation curve
  28392. * @param gradient Scalar amount to interpolate
  28393. * @returns InterpolatedVector3 value
  28394. */
  28395. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28396. /**
  28397. * Interpolates a Vector2 linearly
  28398. * @param startValue Start value of the animation curve
  28399. * @param endValue End value of the animation curve
  28400. * @param gradient Scalar amount to interpolate
  28401. * @returns Interpolated Vector2 value
  28402. */
  28403. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28404. /**
  28405. * Interpolates a Vector2 cubically
  28406. * @param startValue Start value of the animation curve
  28407. * @param outTangent End tangent of the animation
  28408. * @param endValue End value of the animation curve
  28409. * @param inTangent Start tangent of the animation curve
  28410. * @param gradient Scalar amount to interpolate
  28411. * @returns Interpolated Vector2 value
  28412. */
  28413. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28414. /**
  28415. * Interpolates a size linearly
  28416. * @param startValue Start value of the animation curve
  28417. * @param endValue End value of the animation curve
  28418. * @param gradient Scalar amount to interpolate
  28419. * @returns Interpolated Size value
  28420. */
  28421. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28422. /**
  28423. * Interpolates a Color3 linearly
  28424. * @param startValue Start value of the animation curve
  28425. * @param endValue End value of the animation curve
  28426. * @param gradient Scalar amount to interpolate
  28427. * @returns Interpolated Color3 value
  28428. */
  28429. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28430. /**
  28431. * Interpolates a Color4 linearly
  28432. * @param startValue Start value of the animation curve
  28433. * @param endValue End value of the animation curve
  28434. * @param gradient Scalar amount to interpolate
  28435. * @returns Interpolated Color3 value
  28436. */
  28437. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28438. /**
  28439. * @hidden Internal use only
  28440. */
  28441. _getKeyValue(value: any): any;
  28442. /**
  28443. * @hidden Internal use only
  28444. */
  28445. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28446. /**
  28447. * Defines the function to use to interpolate matrices
  28448. * @param startValue defines the start matrix
  28449. * @param endValue defines the end matrix
  28450. * @param gradient defines the gradient between both matrices
  28451. * @param result defines an optional target matrix where to store the interpolation
  28452. * @returns the interpolated matrix
  28453. */
  28454. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28455. /**
  28456. * Makes a copy of the animation
  28457. * @returns Cloned animation
  28458. */
  28459. clone(): Animation;
  28460. /**
  28461. * Sets the key frames of the animation
  28462. * @param values The animation key frames to set
  28463. */
  28464. setKeys(values: Array<IAnimationKey>): void;
  28465. /**
  28466. * Serializes the animation to an object
  28467. * @returns Serialized object
  28468. */
  28469. serialize(): any;
  28470. /**
  28471. * Float animation type
  28472. */
  28473. static readonly ANIMATIONTYPE_FLOAT: number;
  28474. /**
  28475. * Vector3 animation type
  28476. */
  28477. static readonly ANIMATIONTYPE_VECTOR3: number;
  28478. /**
  28479. * Quaternion animation type
  28480. */
  28481. static readonly ANIMATIONTYPE_QUATERNION: number;
  28482. /**
  28483. * Matrix animation type
  28484. */
  28485. static readonly ANIMATIONTYPE_MATRIX: number;
  28486. /**
  28487. * Color3 animation type
  28488. */
  28489. static readonly ANIMATIONTYPE_COLOR3: number;
  28490. /**
  28491. * Color3 animation type
  28492. */
  28493. static readonly ANIMATIONTYPE_COLOR4: number;
  28494. /**
  28495. * Vector2 animation type
  28496. */
  28497. static readonly ANIMATIONTYPE_VECTOR2: number;
  28498. /**
  28499. * Size animation type
  28500. */
  28501. static readonly ANIMATIONTYPE_SIZE: number;
  28502. /**
  28503. * Relative Loop Mode
  28504. */
  28505. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28506. /**
  28507. * Cycle Loop Mode
  28508. */
  28509. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28510. /**
  28511. * Constant Loop Mode
  28512. */
  28513. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28514. /** @hidden */
  28515. static _UniversalLerp(left: any, right: any, amount: number): any;
  28516. /**
  28517. * Parses an animation object and creates an animation
  28518. * @param parsedAnimation Parsed animation object
  28519. * @returns Animation object
  28520. */
  28521. static Parse(parsedAnimation: any): Animation;
  28522. /**
  28523. * Appends the serialized animations from the source animations
  28524. * @param source Source containing the animations
  28525. * @param destination Target to store the animations
  28526. */
  28527. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28528. }
  28529. }
  28530. declare module "babylonjs/Animations/animatable.interface" {
  28531. import { Nullable } from "babylonjs/types";
  28532. import { Animation } from "babylonjs/Animations/animation";
  28533. /**
  28534. * Interface containing an array of animations
  28535. */
  28536. export interface IAnimatable {
  28537. /**
  28538. * Array of animations
  28539. */
  28540. animations: Nullable<Array<Animation>>;
  28541. }
  28542. }
  28543. declare module "babylonjs/Materials/fresnelParameters" {
  28544. import { Color3 } from "babylonjs/Maths/math.color";
  28545. /**
  28546. * This represents all the required information to add a fresnel effect on a material:
  28547. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28548. */
  28549. export class FresnelParameters {
  28550. private _isEnabled;
  28551. /**
  28552. * Define if the fresnel effect is enable or not.
  28553. */
  28554. isEnabled: boolean;
  28555. /**
  28556. * Define the color used on edges (grazing angle)
  28557. */
  28558. leftColor: Color3;
  28559. /**
  28560. * Define the color used on center
  28561. */
  28562. rightColor: Color3;
  28563. /**
  28564. * Define bias applied to computed fresnel term
  28565. */
  28566. bias: number;
  28567. /**
  28568. * Defined the power exponent applied to fresnel term
  28569. */
  28570. power: number;
  28571. /**
  28572. * Clones the current fresnel and its valuues
  28573. * @returns a clone fresnel configuration
  28574. */
  28575. clone(): FresnelParameters;
  28576. /**
  28577. * Serializes the current fresnel parameters to a JSON representation.
  28578. * @return the JSON serialization
  28579. */
  28580. serialize(): any;
  28581. /**
  28582. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28583. * @param parsedFresnelParameters Define the JSON representation
  28584. * @returns the parsed parameters
  28585. */
  28586. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28587. }
  28588. }
  28589. declare module "babylonjs/Misc/decorators" {
  28590. import { Nullable } from "babylonjs/types";
  28591. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28592. import { Scene } from "babylonjs/scene";
  28593. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28594. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28595. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28596. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28597. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28598. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28599. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28600. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28601. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28602. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28603. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28604. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28605. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28606. /**
  28607. * Decorator used to define property that can be serialized as reference to a camera
  28608. * @param sourceName defines the name of the property to decorate
  28609. */
  28610. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28611. /**
  28612. * Class used to help serialization objects
  28613. */
  28614. export class SerializationHelper {
  28615. /** @hidden */
  28616. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28617. /** @hidden */
  28618. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28619. /** @hidden */
  28620. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28621. /** @hidden */
  28622. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28623. /**
  28624. * Appends the serialized animations from the source animations
  28625. * @param source Source containing the animations
  28626. * @param destination Target to store the animations
  28627. */
  28628. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28629. /**
  28630. * Static function used to serialized a specific entity
  28631. * @param entity defines the entity to serialize
  28632. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28633. * @returns a JSON compatible object representing the serialization of the entity
  28634. */
  28635. static Serialize<T>(entity: T, serializationObject?: any): any;
  28636. /**
  28637. * Creates a new entity from a serialization data object
  28638. * @param creationFunction defines a function used to instanciated the new entity
  28639. * @param source defines the source serialization data
  28640. * @param scene defines the hosting scene
  28641. * @param rootUrl defines the root url for resources
  28642. * @returns a new entity
  28643. */
  28644. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28645. /**
  28646. * Clones an object
  28647. * @param creationFunction defines the function used to instanciate the new object
  28648. * @param source defines the source object
  28649. * @returns the cloned object
  28650. */
  28651. static Clone<T>(creationFunction: () => T, source: T): T;
  28652. /**
  28653. * Instanciates a new object based on a source one (some data will be shared between both object)
  28654. * @param creationFunction defines the function used to instanciate the new object
  28655. * @param source defines the source object
  28656. * @returns the new object
  28657. */
  28658. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28659. }
  28660. }
  28661. declare module "babylonjs/Misc/guid" {
  28662. /**
  28663. * Class used to manipulate GUIDs
  28664. */
  28665. export class GUID {
  28666. /**
  28667. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28668. * Be aware Math.random() could cause collisions, but:
  28669. * "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"
  28670. * @returns a pseudo random id
  28671. */
  28672. static RandomId(): string;
  28673. }
  28674. }
  28675. declare module "babylonjs/Materials/Textures/baseTexture" {
  28676. import { Observable } from "babylonjs/Misc/observable";
  28677. import { Nullable } from "babylonjs/types";
  28678. import { Scene } from "babylonjs/scene";
  28679. import { Matrix } from "babylonjs/Maths/math.vector";
  28680. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28681. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28682. import { ISize } from "babylonjs/Maths/math.size";
  28683. /**
  28684. * Base class of all the textures in babylon.
  28685. * It groups all the common properties the materials, post process, lights... might need
  28686. * in order to make a correct use of the texture.
  28687. */
  28688. export class BaseTexture implements IAnimatable {
  28689. /**
  28690. * Default anisotropic filtering level for the application.
  28691. * It is set to 4 as a good tradeoff between perf and quality.
  28692. */
  28693. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28694. /**
  28695. * Gets or sets the unique id of the texture
  28696. */
  28697. uniqueId: number;
  28698. /**
  28699. * Define the name of the texture.
  28700. */
  28701. name: string;
  28702. /**
  28703. * Gets or sets an object used to store user defined information.
  28704. */
  28705. metadata: any;
  28706. /**
  28707. * For internal use only. Please do not use.
  28708. */
  28709. reservedDataStore: any;
  28710. private _hasAlpha;
  28711. /**
  28712. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28713. */
  28714. hasAlpha: boolean;
  28715. /**
  28716. * Defines if the alpha value should be determined via the rgb values.
  28717. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28718. */
  28719. getAlphaFromRGB: boolean;
  28720. /**
  28721. * Intensity or strength of the texture.
  28722. * It is commonly used by materials to fine tune the intensity of the texture
  28723. */
  28724. level: number;
  28725. /**
  28726. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28727. * This is part of the texture as textures usually maps to one uv set.
  28728. */
  28729. coordinatesIndex: number;
  28730. private _coordinatesMode;
  28731. /**
  28732. * How a texture is mapped.
  28733. *
  28734. * | Value | Type | Description |
  28735. * | ----- | ----------------------------------- | ----------- |
  28736. * | 0 | EXPLICIT_MODE | |
  28737. * | 1 | SPHERICAL_MODE | |
  28738. * | 2 | PLANAR_MODE | |
  28739. * | 3 | CUBIC_MODE | |
  28740. * | 4 | PROJECTION_MODE | |
  28741. * | 5 | SKYBOX_MODE | |
  28742. * | 6 | INVCUBIC_MODE | |
  28743. * | 7 | EQUIRECTANGULAR_MODE | |
  28744. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28745. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28746. */
  28747. coordinatesMode: number;
  28748. /**
  28749. * | Value | Type | Description |
  28750. * | ----- | ------------------ | ----------- |
  28751. * | 0 | CLAMP_ADDRESSMODE | |
  28752. * | 1 | WRAP_ADDRESSMODE | |
  28753. * | 2 | MIRROR_ADDRESSMODE | |
  28754. */
  28755. wrapU: number;
  28756. /**
  28757. * | Value | Type | Description |
  28758. * | ----- | ------------------ | ----------- |
  28759. * | 0 | CLAMP_ADDRESSMODE | |
  28760. * | 1 | WRAP_ADDRESSMODE | |
  28761. * | 2 | MIRROR_ADDRESSMODE | |
  28762. */
  28763. wrapV: number;
  28764. /**
  28765. * | Value | Type | Description |
  28766. * | ----- | ------------------ | ----------- |
  28767. * | 0 | CLAMP_ADDRESSMODE | |
  28768. * | 1 | WRAP_ADDRESSMODE | |
  28769. * | 2 | MIRROR_ADDRESSMODE | |
  28770. */
  28771. wrapR: number;
  28772. /**
  28773. * With compliant hardware and browser (supporting anisotropic filtering)
  28774. * this defines the level of anisotropic filtering in the texture.
  28775. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28776. */
  28777. anisotropicFilteringLevel: number;
  28778. /**
  28779. * Define if the texture is a cube texture or if false a 2d texture.
  28780. */
  28781. isCube: boolean;
  28782. /**
  28783. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28784. */
  28785. is3D: boolean;
  28786. /**
  28787. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  28788. */
  28789. is2DArray: boolean;
  28790. /**
  28791. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28792. * HDR texture are usually stored in linear space.
  28793. * This only impacts the PBR and Background materials
  28794. */
  28795. gammaSpace: boolean;
  28796. /**
  28797. * Gets or sets whether or not the texture contains RGBD data.
  28798. */
  28799. isRGBD: boolean;
  28800. /**
  28801. * Is Z inverted in the texture (useful in a cube texture).
  28802. */
  28803. invertZ: boolean;
  28804. /**
  28805. * Are mip maps generated for this texture or not.
  28806. */
  28807. readonly noMipmap: boolean;
  28808. /**
  28809. * @hidden
  28810. */
  28811. lodLevelInAlpha: boolean;
  28812. /**
  28813. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28814. */
  28815. lodGenerationOffset: number;
  28816. /**
  28817. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28818. */
  28819. lodGenerationScale: number;
  28820. /**
  28821. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28822. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28823. * average roughness values.
  28824. */
  28825. linearSpecularLOD: boolean;
  28826. /**
  28827. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28828. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28829. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28830. */
  28831. irradianceTexture: Nullable<BaseTexture>;
  28832. /**
  28833. * Define if the texture is a render target.
  28834. */
  28835. isRenderTarget: boolean;
  28836. /**
  28837. * Define the unique id of the texture in the scene.
  28838. */
  28839. readonly uid: string;
  28840. /**
  28841. * Return a string representation of the texture.
  28842. * @returns the texture as a string
  28843. */
  28844. toString(): string;
  28845. /**
  28846. * Get the class name of the texture.
  28847. * @returns "BaseTexture"
  28848. */
  28849. getClassName(): string;
  28850. /**
  28851. * Define the list of animation attached to the texture.
  28852. */
  28853. animations: import("babylonjs/Animations/animation").Animation[];
  28854. /**
  28855. * An event triggered when the texture is disposed.
  28856. */
  28857. onDisposeObservable: Observable<BaseTexture>;
  28858. private _onDisposeObserver;
  28859. /**
  28860. * Callback triggered when the texture has been disposed.
  28861. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28862. */
  28863. onDispose: () => void;
  28864. /**
  28865. * Define the current state of the loading sequence when in delayed load mode.
  28866. */
  28867. delayLoadState: number;
  28868. private _scene;
  28869. /** @hidden */
  28870. _texture: Nullable<InternalTexture>;
  28871. private _uid;
  28872. /**
  28873. * Define if the texture is preventinga material to render or not.
  28874. * If not and the texture is not ready, the engine will use a default black texture instead.
  28875. */
  28876. readonly isBlocking: boolean;
  28877. /**
  28878. * Instantiates a new BaseTexture.
  28879. * Base class of all the textures in babylon.
  28880. * It groups all the common properties the materials, post process, lights... might need
  28881. * in order to make a correct use of the texture.
  28882. * @param scene Define the scene the texture blongs to
  28883. */
  28884. constructor(scene: Nullable<Scene>);
  28885. /**
  28886. * Get the scene the texture belongs to.
  28887. * @returns the scene or null if undefined
  28888. */
  28889. getScene(): Nullable<Scene>;
  28890. /**
  28891. * Get the texture transform matrix used to offset tile the texture for istance.
  28892. * @returns the transformation matrix
  28893. */
  28894. getTextureMatrix(): Matrix;
  28895. /**
  28896. * Get the texture reflection matrix used to rotate/transform the reflection.
  28897. * @returns the reflection matrix
  28898. */
  28899. getReflectionTextureMatrix(): Matrix;
  28900. /**
  28901. * Get the underlying lower level texture from Babylon.
  28902. * @returns the insternal texture
  28903. */
  28904. getInternalTexture(): Nullable<InternalTexture>;
  28905. /**
  28906. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28907. * @returns true if ready or not blocking
  28908. */
  28909. isReadyOrNotBlocking(): boolean;
  28910. /**
  28911. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28912. * @returns true if fully ready
  28913. */
  28914. isReady(): boolean;
  28915. private _cachedSize;
  28916. /**
  28917. * Get the size of the texture.
  28918. * @returns the texture size.
  28919. */
  28920. getSize(): ISize;
  28921. /**
  28922. * Get the base size of the texture.
  28923. * It can be different from the size if the texture has been resized for POT for instance
  28924. * @returns the base size
  28925. */
  28926. getBaseSize(): ISize;
  28927. /**
  28928. * Update the sampling mode of the texture.
  28929. * Default is Trilinear mode.
  28930. *
  28931. * | Value | Type | Description |
  28932. * | ----- | ------------------ | ----------- |
  28933. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28934. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28935. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28936. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28937. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28938. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28939. * | 7 | NEAREST_LINEAR | |
  28940. * | 8 | NEAREST_NEAREST | |
  28941. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28942. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28943. * | 11 | LINEAR_LINEAR | |
  28944. * | 12 | LINEAR_NEAREST | |
  28945. *
  28946. * > _mag_: magnification filter (close to the viewer)
  28947. * > _min_: minification filter (far from the viewer)
  28948. * > _mip_: filter used between mip map levels
  28949. *@param samplingMode Define the new sampling mode of the texture
  28950. */
  28951. updateSamplingMode(samplingMode: number): void;
  28952. /**
  28953. * Scales the texture if is `canRescale()`
  28954. * @param ratio the resize factor we want to use to rescale
  28955. */
  28956. scale(ratio: number): void;
  28957. /**
  28958. * Get if the texture can rescale.
  28959. */
  28960. readonly canRescale: boolean;
  28961. /** @hidden */
  28962. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28963. /** @hidden */
  28964. _rebuild(): void;
  28965. /**
  28966. * Triggers the load sequence in delayed load mode.
  28967. */
  28968. delayLoad(): void;
  28969. /**
  28970. * Clones the texture.
  28971. * @returns the cloned texture
  28972. */
  28973. clone(): Nullable<BaseTexture>;
  28974. /**
  28975. * Get the texture underlying type (INT, FLOAT...)
  28976. */
  28977. readonly textureType: number;
  28978. /**
  28979. * Get the texture underlying format (RGB, RGBA...)
  28980. */
  28981. readonly textureFormat: number;
  28982. /**
  28983. * Indicates that textures need to be re-calculated for all materials
  28984. */
  28985. protected _markAllSubMeshesAsTexturesDirty(): void;
  28986. /**
  28987. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28988. * This will returns an RGBA array buffer containing either in values (0-255) or
  28989. * float values (0-1) depending of the underlying buffer type.
  28990. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28991. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28992. * @param buffer defines a user defined buffer to fill with data (can be null)
  28993. * @returns The Array buffer containing the pixels data.
  28994. */
  28995. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28996. /**
  28997. * Release and destroy the underlying lower level texture aka internalTexture.
  28998. */
  28999. releaseInternalTexture(): void;
  29000. /** @hidden */
  29001. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29002. /** @hidden */
  29003. readonly _lodTextureMid: Nullable<BaseTexture>;
  29004. /** @hidden */
  29005. readonly _lodTextureLow: Nullable<BaseTexture>;
  29006. /**
  29007. * Dispose the texture and release its associated resources.
  29008. */
  29009. dispose(): void;
  29010. /**
  29011. * Serialize the texture into a JSON representation that can be parsed later on.
  29012. * @returns the JSON representation of the texture
  29013. */
  29014. serialize(): any;
  29015. /**
  29016. * Helper function to be called back once a list of texture contains only ready textures.
  29017. * @param textures Define the list of textures to wait for
  29018. * @param callback Define the callback triggered once the entire list will be ready
  29019. */
  29020. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29021. }
  29022. }
  29023. declare module "babylonjs/Materials/effect" {
  29024. import { Observable } from "babylonjs/Misc/observable";
  29025. import { Nullable } from "babylonjs/types";
  29026. import { IDisposable } from "babylonjs/scene";
  29027. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29028. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29029. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29030. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29031. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29032. import { Engine } from "babylonjs/Engines/engine";
  29033. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29035. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29036. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29037. /**
  29038. * Options to be used when creating an effect.
  29039. */
  29040. export interface IEffectCreationOptions {
  29041. /**
  29042. * Atrributes that will be used in the shader.
  29043. */
  29044. attributes: string[];
  29045. /**
  29046. * Uniform varible names that will be set in the shader.
  29047. */
  29048. uniformsNames: string[];
  29049. /**
  29050. * Uniform buffer varible names that will be set in the shader.
  29051. */
  29052. uniformBuffersNames: string[];
  29053. /**
  29054. * Sampler texture variable names that will be set in the shader.
  29055. */
  29056. samplers: string[];
  29057. /**
  29058. * Define statements that will be set in the shader.
  29059. */
  29060. defines: any;
  29061. /**
  29062. * Possible fallbacks for this effect to improve performance when needed.
  29063. */
  29064. fallbacks: Nullable<IEffectFallbacks>;
  29065. /**
  29066. * Callback that will be called when the shader is compiled.
  29067. */
  29068. onCompiled: Nullable<(effect: Effect) => void>;
  29069. /**
  29070. * Callback that will be called if an error occurs during shader compilation.
  29071. */
  29072. onError: Nullable<(effect: Effect, errors: string) => void>;
  29073. /**
  29074. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29075. */
  29076. indexParameters?: any;
  29077. /**
  29078. * Max number of lights that can be used in the shader.
  29079. */
  29080. maxSimultaneousLights?: number;
  29081. /**
  29082. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29083. */
  29084. transformFeedbackVaryings?: Nullable<string[]>;
  29085. }
  29086. /**
  29087. * Effect containing vertex and fragment shader that can be executed on an object.
  29088. */
  29089. export class Effect implements IDisposable {
  29090. /**
  29091. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29092. */
  29093. static ShadersRepository: string;
  29094. /**
  29095. * Name of the effect.
  29096. */
  29097. name: any;
  29098. /**
  29099. * String container all the define statements that should be set on the shader.
  29100. */
  29101. defines: string;
  29102. /**
  29103. * Callback that will be called when the shader is compiled.
  29104. */
  29105. onCompiled: Nullable<(effect: Effect) => void>;
  29106. /**
  29107. * Callback that will be called if an error occurs during shader compilation.
  29108. */
  29109. onError: Nullable<(effect: Effect, errors: string) => void>;
  29110. /**
  29111. * Callback that will be called when effect is bound.
  29112. */
  29113. onBind: Nullable<(effect: Effect) => void>;
  29114. /**
  29115. * Unique ID of the effect.
  29116. */
  29117. uniqueId: number;
  29118. /**
  29119. * Observable that will be called when the shader is compiled.
  29120. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29121. */
  29122. onCompileObservable: Observable<Effect>;
  29123. /**
  29124. * Observable that will be called if an error occurs during shader compilation.
  29125. */
  29126. onErrorObservable: Observable<Effect>;
  29127. /** @hidden */
  29128. _onBindObservable: Nullable<Observable<Effect>>;
  29129. /**
  29130. * Observable that will be called when effect is bound.
  29131. */
  29132. readonly onBindObservable: Observable<Effect>;
  29133. /** @hidden */
  29134. _bonesComputationForcedToCPU: boolean;
  29135. private static _uniqueIdSeed;
  29136. private _engine;
  29137. private _uniformBuffersNames;
  29138. private _uniformsNames;
  29139. private _samplerList;
  29140. private _samplers;
  29141. private _isReady;
  29142. private _compilationError;
  29143. private _allFallbacksProcessed;
  29144. private _attributesNames;
  29145. private _attributes;
  29146. private _uniforms;
  29147. /**
  29148. * Key for the effect.
  29149. * @hidden
  29150. */
  29151. _key: string;
  29152. private _indexParameters;
  29153. private _fallbacks;
  29154. private _vertexSourceCode;
  29155. private _fragmentSourceCode;
  29156. private _vertexSourceCodeOverride;
  29157. private _fragmentSourceCodeOverride;
  29158. private _transformFeedbackVaryings;
  29159. /**
  29160. * Compiled shader to webGL program.
  29161. * @hidden
  29162. */
  29163. _pipelineContext: Nullable<IPipelineContext>;
  29164. private _valueCache;
  29165. private static _baseCache;
  29166. /**
  29167. * Instantiates an effect.
  29168. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29169. * @param baseName Name of the effect.
  29170. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29171. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29172. * @param samplers List of sampler variables that will be passed to the shader.
  29173. * @param engine Engine to be used to render the effect
  29174. * @param defines Define statements to be added to the shader.
  29175. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29176. * @param onCompiled Callback that will be called when the shader is compiled.
  29177. * @param onError Callback that will be called if an error occurs during shader compilation.
  29178. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29179. */
  29180. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29181. private _useFinalCode;
  29182. /**
  29183. * Unique key for this effect
  29184. */
  29185. readonly key: string;
  29186. /**
  29187. * If the effect has been compiled and prepared.
  29188. * @returns if the effect is compiled and prepared.
  29189. */
  29190. isReady(): boolean;
  29191. private _isReadyInternal;
  29192. /**
  29193. * The engine the effect was initialized with.
  29194. * @returns the engine.
  29195. */
  29196. getEngine(): Engine;
  29197. /**
  29198. * The pipeline context for this effect
  29199. * @returns the associated pipeline context
  29200. */
  29201. getPipelineContext(): Nullable<IPipelineContext>;
  29202. /**
  29203. * The set of names of attribute variables for the shader.
  29204. * @returns An array of attribute names.
  29205. */
  29206. getAttributesNames(): string[];
  29207. /**
  29208. * Returns the attribute at the given index.
  29209. * @param index The index of the attribute.
  29210. * @returns The location of the attribute.
  29211. */
  29212. getAttributeLocation(index: number): number;
  29213. /**
  29214. * Returns the attribute based on the name of the variable.
  29215. * @param name of the attribute to look up.
  29216. * @returns the attribute location.
  29217. */
  29218. getAttributeLocationByName(name: string): number;
  29219. /**
  29220. * The number of attributes.
  29221. * @returns the numnber of attributes.
  29222. */
  29223. getAttributesCount(): number;
  29224. /**
  29225. * Gets the index of a uniform variable.
  29226. * @param uniformName of the uniform to look up.
  29227. * @returns the index.
  29228. */
  29229. getUniformIndex(uniformName: string): number;
  29230. /**
  29231. * Returns the attribute based on the name of the variable.
  29232. * @param uniformName of the uniform to look up.
  29233. * @returns the location of the uniform.
  29234. */
  29235. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29236. /**
  29237. * Returns an array of sampler variable names
  29238. * @returns The array of sampler variable neames.
  29239. */
  29240. getSamplers(): string[];
  29241. /**
  29242. * The error from the last compilation.
  29243. * @returns the error string.
  29244. */
  29245. getCompilationError(): string;
  29246. /**
  29247. * Gets a boolean indicating that all fallbacks were used during compilation
  29248. * @returns true if all fallbacks were used
  29249. */
  29250. allFallbacksProcessed(): boolean;
  29251. /**
  29252. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29253. * @param func The callback to be used.
  29254. */
  29255. executeWhenCompiled(func: (effect: Effect) => void): void;
  29256. private _checkIsReady;
  29257. private _loadShader;
  29258. /**
  29259. * Recompiles the webGL program
  29260. * @param vertexSourceCode The source code for the vertex shader.
  29261. * @param fragmentSourceCode The source code for the fragment shader.
  29262. * @param onCompiled Callback called when completed.
  29263. * @param onError Callback called on error.
  29264. * @hidden
  29265. */
  29266. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29267. /**
  29268. * Prepares the effect
  29269. * @hidden
  29270. */
  29271. _prepareEffect(): void;
  29272. private _processCompilationErrors;
  29273. /**
  29274. * Checks if the effect is supported. (Must be called after compilation)
  29275. */
  29276. readonly isSupported: boolean;
  29277. /**
  29278. * Binds a texture to the engine to be used as output of the shader.
  29279. * @param channel Name of the output variable.
  29280. * @param texture Texture to bind.
  29281. * @hidden
  29282. */
  29283. _bindTexture(channel: string, texture: InternalTexture): void;
  29284. /**
  29285. * Sets a texture on the engine to be used in the shader.
  29286. * @param channel Name of the sampler variable.
  29287. * @param texture Texture to set.
  29288. */
  29289. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29290. /**
  29291. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29292. * @param channel Name of the sampler variable.
  29293. * @param texture Texture to set.
  29294. */
  29295. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29296. /**
  29297. * Sets an array of textures on the engine to be used in the shader.
  29298. * @param channel Name of the variable.
  29299. * @param textures Textures to set.
  29300. */
  29301. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29302. /**
  29303. * 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)
  29304. * @param channel Name of the sampler variable.
  29305. * @param postProcess Post process to get the input texture from.
  29306. */
  29307. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29308. /**
  29309. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29310. * 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)
  29311. * @param channel Name of the sampler variable.
  29312. * @param postProcess Post process to get the output texture from.
  29313. */
  29314. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29315. /** @hidden */
  29316. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29317. /** @hidden */
  29318. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29319. /** @hidden */
  29320. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29321. /** @hidden */
  29322. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29323. /**
  29324. * Binds a buffer to a uniform.
  29325. * @param buffer Buffer to bind.
  29326. * @param name Name of the uniform variable to bind to.
  29327. */
  29328. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29329. /**
  29330. * Binds block to a uniform.
  29331. * @param blockName Name of the block to bind.
  29332. * @param index Index to bind.
  29333. */
  29334. bindUniformBlock(blockName: string, index: number): void;
  29335. /**
  29336. * Sets an interger value on a uniform variable.
  29337. * @param uniformName Name of the variable.
  29338. * @param value Value to be set.
  29339. * @returns this effect.
  29340. */
  29341. setInt(uniformName: string, value: number): Effect;
  29342. /**
  29343. * Sets an int array on a uniform variable.
  29344. * @param uniformName Name of the variable.
  29345. * @param array array to be set.
  29346. * @returns this effect.
  29347. */
  29348. setIntArray(uniformName: string, array: Int32Array): Effect;
  29349. /**
  29350. * 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)
  29351. * @param uniformName Name of the variable.
  29352. * @param array array to be set.
  29353. * @returns this effect.
  29354. */
  29355. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29356. /**
  29357. * 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)
  29358. * @param uniformName Name of the variable.
  29359. * @param array array to be set.
  29360. * @returns this effect.
  29361. */
  29362. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29363. /**
  29364. * 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)
  29365. * @param uniformName Name of the variable.
  29366. * @param array array to be set.
  29367. * @returns this effect.
  29368. */
  29369. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29370. /**
  29371. * Sets an float array on a uniform variable.
  29372. * @param uniformName Name of the variable.
  29373. * @param array array to be set.
  29374. * @returns this effect.
  29375. */
  29376. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29377. /**
  29378. * 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)
  29379. * @param uniformName Name of the variable.
  29380. * @param array array to be set.
  29381. * @returns this effect.
  29382. */
  29383. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29384. /**
  29385. * 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)
  29386. * @param uniformName Name of the variable.
  29387. * @param array array to be set.
  29388. * @returns this effect.
  29389. */
  29390. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29391. /**
  29392. * 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)
  29393. * @param uniformName Name of the variable.
  29394. * @param array array to be set.
  29395. * @returns this effect.
  29396. */
  29397. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29398. /**
  29399. * Sets an array on a uniform variable.
  29400. * @param uniformName Name of the variable.
  29401. * @param array array to be set.
  29402. * @returns this effect.
  29403. */
  29404. setArray(uniformName: string, array: number[]): Effect;
  29405. /**
  29406. * 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)
  29407. * @param uniformName Name of the variable.
  29408. * @param array array to be set.
  29409. * @returns this effect.
  29410. */
  29411. setArray2(uniformName: string, array: number[]): Effect;
  29412. /**
  29413. * 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)
  29414. * @param uniformName Name of the variable.
  29415. * @param array array to be set.
  29416. * @returns this effect.
  29417. */
  29418. setArray3(uniformName: string, array: number[]): Effect;
  29419. /**
  29420. * 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)
  29421. * @param uniformName Name of the variable.
  29422. * @param array array to be set.
  29423. * @returns this effect.
  29424. */
  29425. setArray4(uniformName: string, array: number[]): Effect;
  29426. /**
  29427. * Sets matrices on a uniform variable.
  29428. * @param uniformName Name of the variable.
  29429. * @param matrices matrices to be set.
  29430. * @returns this effect.
  29431. */
  29432. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29433. /**
  29434. * Sets matrix on a uniform variable.
  29435. * @param uniformName Name of the variable.
  29436. * @param matrix matrix to be set.
  29437. * @returns this effect.
  29438. */
  29439. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29440. /**
  29441. * 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)
  29442. * @param uniformName Name of the variable.
  29443. * @param matrix matrix to be set.
  29444. * @returns this effect.
  29445. */
  29446. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29447. /**
  29448. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29449. * @param uniformName Name of the variable.
  29450. * @param matrix matrix to be set.
  29451. * @returns this effect.
  29452. */
  29453. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29454. /**
  29455. * Sets a float on a uniform variable.
  29456. * @param uniformName Name of the variable.
  29457. * @param value value to be set.
  29458. * @returns this effect.
  29459. */
  29460. setFloat(uniformName: string, value: number): Effect;
  29461. /**
  29462. * Sets a boolean on a uniform variable.
  29463. * @param uniformName Name of the variable.
  29464. * @param bool value to be set.
  29465. * @returns this effect.
  29466. */
  29467. setBool(uniformName: string, bool: boolean): Effect;
  29468. /**
  29469. * Sets a Vector2 on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param vector2 vector2 to be set.
  29472. * @returns this effect.
  29473. */
  29474. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29475. /**
  29476. * Sets a float2 on a uniform variable.
  29477. * @param uniformName Name of the variable.
  29478. * @param x First float in float2.
  29479. * @param y Second float in float2.
  29480. * @returns this effect.
  29481. */
  29482. setFloat2(uniformName: string, x: number, y: number): Effect;
  29483. /**
  29484. * Sets a Vector3 on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param vector3 Value to be set.
  29487. * @returns this effect.
  29488. */
  29489. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29490. /**
  29491. * Sets a float3 on a uniform variable.
  29492. * @param uniformName Name of the variable.
  29493. * @param x First float in float3.
  29494. * @param y Second float in float3.
  29495. * @param z Third float in float3.
  29496. * @returns this effect.
  29497. */
  29498. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29499. /**
  29500. * Sets a Vector4 on a uniform variable.
  29501. * @param uniformName Name of the variable.
  29502. * @param vector4 Value to be set.
  29503. * @returns this effect.
  29504. */
  29505. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29506. /**
  29507. * Sets a float4 on a uniform variable.
  29508. * @param uniformName Name of the variable.
  29509. * @param x First float in float4.
  29510. * @param y Second float in float4.
  29511. * @param z Third float in float4.
  29512. * @param w Fourth float in float4.
  29513. * @returns this effect.
  29514. */
  29515. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29516. /**
  29517. * Sets a Color3 on a uniform variable.
  29518. * @param uniformName Name of the variable.
  29519. * @param color3 Value to be set.
  29520. * @returns this effect.
  29521. */
  29522. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29523. /**
  29524. * Sets a Color4 on a uniform variable.
  29525. * @param uniformName Name of the variable.
  29526. * @param color3 Value to be set.
  29527. * @param alpha Alpha value to be set.
  29528. * @returns this effect.
  29529. */
  29530. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29531. /**
  29532. * Sets a Color4 on a uniform variable
  29533. * @param uniformName defines the name of the variable
  29534. * @param color4 defines the value to be set
  29535. * @returns this effect.
  29536. */
  29537. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29538. /** Release all associated resources */
  29539. dispose(): void;
  29540. /**
  29541. * This function will add a new shader to the shader store
  29542. * @param name the name of the shader
  29543. * @param pixelShader optional pixel shader content
  29544. * @param vertexShader optional vertex shader content
  29545. */
  29546. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29547. /**
  29548. * Store of each shader (The can be looked up using effect.key)
  29549. */
  29550. static ShadersStore: {
  29551. [key: string]: string;
  29552. };
  29553. /**
  29554. * Store of each included file for a shader (The can be looked up using effect.key)
  29555. */
  29556. static IncludesShadersStore: {
  29557. [key: string]: string;
  29558. };
  29559. /**
  29560. * Resets the cache of effects.
  29561. */
  29562. static ResetCache(): void;
  29563. }
  29564. }
  29565. declare module "babylonjs/Engines/engineCapabilities" {
  29566. /**
  29567. * Interface used to describe the capabilities of the engine relatively to the current browser
  29568. */
  29569. export interface EngineCapabilities {
  29570. /** Maximum textures units per fragment shader */
  29571. maxTexturesImageUnits: number;
  29572. /** Maximum texture units per vertex shader */
  29573. maxVertexTextureImageUnits: number;
  29574. /** Maximum textures units in the entire pipeline */
  29575. maxCombinedTexturesImageUnits: number;
  29576. /** Maximum texture size */
  29577. maxTextureSize: number;
  29578. /** Maximum cube texture size */
  29579. maxCubemapTextureSize: number;
  29580. /** Maximum render texture size */
  29581. maxRenderTextureSize: number;
  29582. /** Maximum number of vertex attributes */
  29583. maxVertexAttribs: number;
  29584. /** Maximum number of varyings */
  29585. maxVaryingVectors: number;
  29586. /** Maximum number of uniforms per vertex shader */
  29587. maxVertexUniformVectors: number;
  29588. /** Maximum number of uniforms per fragment shader */
  29589. maxFragmentUniformVectors: number;
  29590. /** Defines if standard derivates (dx/dy) are supported */
  29591. standardDerivatives: boolean;
  29592. /** Defines if s3tc texture compression is supported */
  29593. s3tc?: WEBGL_compressed_texture_s3tc;
  29594. /** Defines if pvrtc texture compression is supported */
  29595. pvrtc: any;
  29596. /** Defines if etc1 texture compression is supported */
  29597. etc1: any;
  29598. /** Defines if etc2 texture compression is supported */
  29599. etc2: any;
  29600. /** Defines if astc texture compression is supported */
  29601. astc: any;
  29602. /** Defines if float textures are supported */
  29603. textureFloat: boolean;
  29604. /** Defines if vertex array objects are supported */
  29605. vertexArrayObject: boolean;
  29606. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29607. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29608. /** Gets the maximum level of anisotropy supported */
  29609. maxAnisotropy: number;
  29610. /** Defines if instancing is supported */
  29611. instancedArrays: boolean;
  29612. /** Defines if 32 bits indices are supported */
  29613. uintIndices: boolean;
  29614. /** Defines if high precision shaders are supported */
  29615. highPrecisionShaderSupported: boolean;
  29616. /** Defines if depth reading in the fragment shader is supported */
  29617. fragmentDepthSupported: boolean;
  29618. /** Defines if float texture linear filtering is supported*/
  29619. textureFloatLinearFiltering: boolean;
  29620. /** Defines if rendering to float textures is supported */
  29621. textureFloatRender: boolean;
  29622. /** Defines if half float textures are supported*/
  29623. textureHalfFloat: boolean;
  29624. /** Defines if half float texture linear filtering is supported*/
  29625. textureHalfFloatLinearFiltering: boolean;
  29626. /** Defines if rendering to half float textures is supported */
  29627. textureHalfFloatRender: boolean;
  29628. /** Defines if textureLOD shader command is supported */
  29629. textureLOD: boolean;
  29630. /** Defines if draw buffers extension is supported */
  29631. drawBuffersExtension: boolean;
  29632. /** Defines if depth textures are supported */
  29633. depthTextureExtension: boolean;
  29634. /** Defines if float color buffer are supported */
  29635. colorBufferFloat: boolean;
  29636. /** Gets disjoint timer query extension (null if not supported) */
  29637. timerQuery?: EXT_disjoint_timer_query;
  29638. /** Defines if timestamp can be used with timer query */
  29639. canUseTimestampForTimerQuery: boolean;
  29640. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29641. multiview?: any;
  29642. /** Function used to let the system compiles shaders in background */
  29643. parallelShaderCompile?: {
  29644. COMPLETION_STATUS_KHR: number;
  29645. };
  29646. /** Max number of texture samples for MSAA */
  29647. maxMSAASamples: number;
  29648. /** Defines if the blend min max extension is supported */
  29649. blendMinMax: boolean;
  29650. }
  29651. }
  29652. declare module "babylonjs/States/depthCullingState" {
  29653. import { Nullable } from "babylonjs/types";
  29654. /**
  29655. * @hidden
  29656. **/
  29657. export class DepthCullingState {
  29658. private _isDepthTestDirty;
  29659. private _isDepthMaskDirty;
  29660. private _isDepthFuncDirty;
  29661. private _isCullFaceDirty;
  29662. private _isCullDirty;
  29663. private _isZOffsetDirty;
  29664. private _isFrontFaceDirty;
  29665. private _depthTest;
  29666. private _depthMask;
  29667. private _depthFunc;
  29668. private _cull;
  29669. private _cullFace;
  29670. private _zOffset;
  29671. private _frontFace;
  29672. /**
  29673. * Initializes the state.
  29674. */
  29675. constructor();
  29676. readonly isDirty: boolean;
  29677. zOffset: number;
  29678. cullFace: Nullable<number>;
  29679. cull: Nullable<boolean>;
  29680. depthFunc: Nullable<number>;
  29681. depthMask: boolean;
  29682. depthTest: boolean;
  29683. frontFace: Nullable<number>;
  29684. reset(): void;
  29685. apply(gl: WebGLRenderingContext): void;
  29686. }
  29687. }
  29688. declare module "babylonjs/States/stencilState" {
  29689. /**
  29690. * @hidden
  29691. **/
  29692. export class StencilState {
  29693. /** 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 */
  29694. static readonly ALWAYS: number;
  29695. /** Passed to stencilOperation to specify that stencil value must be kept */
  29696. static readonly KEEP: number;
  29697. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29698. static readonly REPLACE: number;
  29699. private _isStencilTestDirty;
  29700. private _isStencilMaskDirty;
  29701. private _isStencilFuncDirty;
  29702. private _isStencilOpDirty;
  29703. private _stencilTest;
  29704. private _stencilMask;
  29705. private _stencilFunc;
  29706. private _stencilFuncRef;
  29707. private _stencilFuncMask;
  29708. private _stencilOpStencilFail;
  29709. private _stencilOpDepthFail;
  29710. private _stencilOpStencilDepthPass;
  29711. readonly isDirty: boolean;
  29712. stencilFunc: number;
  29713. stencilFuncRef: number;
  29714. stencilFuncMask: number;
  29715. stencilOpStencilFail: number;
  29716. stencilOpDepthFail: number;
  29717. stencilOpStencilDepthPass: number;
  29718. stencilMask: number;
  29719. stencilTest: boolean;
  29720. constructor();
  29721. reset(): void;
  29722. apply(gl: WebGLRenderingContext): void;
  29723. }
  29724. }
  29725. declare module "babylonjs/States/alphaCullingState" {
  29726. /**
  29727. * @hidden
  29728. **/
  29729. export class AlphaState {
  29730. private _isAlphaBlendDirty;
  29731. private _isBlendFunctionParametersDirty;
  29732. private _isBlendEquationParametersDirty;
  29733. private _isBlendConstantsDirty;
  29734. private _alphaBlend;
  29735. private _blendFunctionParameters;
  29736. private _blendEquationParameters;
  29737. private _blendConstants;
  29738. /**
  29739. * Initializes the state.
  29740. */
  29741. constructor();
  29742. readonly isDirty: boolean;
  29743. alphaBlend: boolean;
  29744. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29745. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29746. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29747. reset(): void;
  29748. apply(gl: WebGLRenderingContext): void;
  29749. }
  29750. }
  29751. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29752. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29753. /** @hidden */
  29754. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29755. attributeProcessor(attribute: string): string;
  29756. varyingProcessor(varying: string, isFragment: boolean): string;
  29757. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29758. }
  29759. }
  29760. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29761. /**
  29762. * Interface for attribute information associated with buffer instanciation
  29763. */
  29764. export interface InstancingAttributeInfo {
  29765. /**
  29766. * Index/offset of the attribute in the vertex shader
  29767. */
  29768. index: number;
  29769. /**
  29770. * size of the attribute, 1, 2, 3 or 4
  29771. */
  29772. attributeSize: number;
  29773. /**
  29774. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29775. * default is FLOAT
  29776. */
  29777. attributeType: number;
  29778. /**
  29779. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29780. */
  29781. normalized: boolean;
  29782. /**
  29783. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29784. */
  29785. offset: number;
  29786. /**
  29787. * Name of the GLSL attribute, for debugging purpose only
  29788. */
  29789. attributeName: string;
  29790. }
  29791. }
  29792. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29793. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29794. import { Nullable } from "babylonjs/types";
  29795. module "babylonjs/Engines/thinEngine" {
  29796. interface ThinEngine {
  29797. /**
  29798. * Update a video texture
  29799. * @param texture defines the texture to update
  29800. * @param video defines the video element to use
  29801. * @param invertY defines if data must be stored with Y axis inverted
  29802. */
  29803. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29804. }
  29805. }
  29806. }
  29807. declare module "babylonjs/Materials/Textures/videoTexture" {
  29808. import { Observable } from "babylonjs/Misc/observable";
  29809. import { Nullable } from "babylonjs/types";
  29810. import { Scene } from "babylonjs/scene";
  29811. import { Texture } from "babylonjs/Materials/Textures/texture";
  29812. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29813. /**
  29814. * Settings for finer control over video usage
  29815. */
  29816. export interface VideoTextureSettings {
  29817. /**
  29818. * Applies `autoplay` to video, if specified
  29819. */
  29820. autoPlay?: boolean;
  29821. /**
  29822. * Applies `loop` to video, if specified
  29823. */
  29824. loop?: boolean;
  29825. /**
  29826. * Automatically updates internal texture from video at every frame in the render loop
  29827. */
  29828. autoUpdateTexture: boolean;
  29829. /**
  29830. * Image src displayed during the video loading or until the user interacts with the video.
  29831. */
  29832. poster?: string;
  29833. }
  29834. /**
  29835. * If you want to display a video in your scene, this is the special texture for that.
  29836. * This special texture works similar to other textures, with the exception of a few parameters.
  29837. * @see https://doc.babylonjs.com/how_to/video_texture
  29838. */
  29839. export class VideoTexture extends Texture {
  29840. /**
  29841. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29842. */
  29843. readonly autoUpdateTexture: boolean;
  29844. /**
  29845. * The video instance used by the texture internally
  29846. */
  29847. readonly video: HTMLVideoElement;
  29848. private _onUserActionRequestedObservable;
  29849. /**
  29850. * Event triggerd when a dom action is required by the user to play the video.
  29851. * This happens due to recent changes in browser policies preventing video to auto start.
  29852. */
  29853. readonly onUserActionRequestedObservable: Observable<Texture>;
  29854. private _generateMipMaps;
  29855. private _engine;
  29856. private _stillImageCaptured;
  29857. private _displayingPosterTexture;
  29858. private _settings;
  29859. private _createInternalTextureOnEvent;
  29860. private _frameId;
  29861. /**
  29862. * Creates a video texture.
  29863. * If you want to display a video in your scene, this is the special texture for that.
  29864. * This special texture works similar to other textures, with the exception of a few parameters.
  29865. * @see https://doc.babylonjs.com/how_to/video_texture
  29866. * @param name optional name, will detect from video source, if not defined
  29867. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29868. * @param scene is obviously the current scene.
  29869. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29870. * @param invertY is false by default but can be used to invert video on Y axis
  29871. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29872. * @param settings allows finer control over video usage
  29873. */
  29874. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29875. private _getName;
  29876. private _getVideo;
  29877. private _createInternalTexture;
  29878. private reset;
  29879. /**
  29880. * @hidden Internal method to initiate `update`.
  29881. */
  29882. _rebuild(): void;
  29883. /**
  29884. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29885. */
  29886. update(): void;
  29887. /**
  29888. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29889. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29890. */
  29891. updateTexture(isVisible: boolean): void;
  29892. protected _updateInternalTexture: () => void;
  29893. /**
  29894. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29895. * @param url New url.
  29896. */
  29897. updateURL(url: string): void;
  29898. /**
  29899. * Dispose the texture and release its associated resources.
  29900. */
  29901. dispose(): void;
  29902. /**
  29903. * Creates a video texture straight from a stream.
  29904. * @param scene Define the scene the texture should be created in
  29905. * @param stream Define the stream the texture should be created from
  29906. * @returns The created video texture as a promise
  29907. */
  29908. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29909. /**
  29910. * Creates a video texture straight from your WebCam video feed.
  29911. * @param scene Define the scene the texture should be created in
  29912. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29913. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29914. * @returns The created video texture as a promise
  29915. */
  29916. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29917. minWidth: number;
  29918. maxWidth: number;
  29919. minHeight: number;
  29920. maxHeight: number;
  29921. deviceId: string;
  29922. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29923. /**
  29924. * Creates a video texture straight from your WebCam video feed.
  29925. * @param scene Define the scene the texture should be created in
  29926. * @param onReady Define a callback to triggered once the texture will be ready
  29927. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29928. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29929. */
  29930. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29931. minWidth: number;
  29932. maxWidth: number;
  29933. minHeight: number;
  29934. maxHeight: number;
  29935. deviceId: string;
  29936. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29937. }
  29938. }
  29939. declare module "babylonjs/Engines/thinEngine" {
  29940. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29941. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29942. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29943. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29944. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29945. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29946. import { Observable } from "babylonjs/Misc/observable";
  29947. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29948. import { StencilState } from "babylonjs/States/stencilState";
  29949. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29950. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29951. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29952. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29953. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29954. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29955. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29956. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29957. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29959. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29960. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29961. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29962. /**
  29963. * Defines the interface used by objects working like Scene
  29964. * @hidden
  29965. */
  29966. interface ISceneLike {
  29967. _addPendingData(data: any): void;
  29968. _removePendingData(data: any): void;
  29969. offlineProvider: IOfflineProvider;
  29970. }
  29971. /** Interface defining initialization parameters for Engine class */
  29972. export interface EngineOptions extends WebGLContextAttributes {
  29973. /**
  29974. * Defines if the engine should no exceed a specified device ratio
  29975. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29976. */
  29977. limitDeviceRatio?: number;
  29978. /**
  29979. * Defines if webvr should be enabled automatically
  29980. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29981. */
  29982. autoEnableWebVR?: boolean;
  29983. /**
  29984. * Defines if webgl2 should be turned off even if supported
  29985. * @see http://doc.babylonjs.com/features/webgl2
  29986. */
  29987. disableWebGL2Support?: boolean;
  29988. /**
  29989. * Defines if webaudio should be initialized as well
  29990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29991. */
  29992. audioEngine?: boolean;
  29993. /**
  29994. * Defines if animations should run using a deterministic lock step
  29995. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29996. */
  29997. deterministicLockstep?: boolean;
  29998. /** Defines the maximum steps to use with deterministic lock step mode */
  29999. lockstepMaxSteps?: number;
  30000. /**
  30001. * Defines that engine should ignore context lost events
  30002. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30003. */
  30004. doNotHandleContextLost?: boolean;
  30005. /**
  30006. * Defines that engine should ignore modifying touch action attribute and style
  30007. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30008. */
  30009. doNotHandleTouchAction?: boolean;
  30010. /**
  30011. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30012. */
  30013. useHighPrecisionFloats?: boolean;
  30014. }
  30015. /**
  30016. * The base engine class (root of all engines)
  30017. */
  30018. export class ThinEngine {
  30019. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30020. static ExceptionList: ({
  30021. key: string;
  30022. capture: string;
  30023. captureConstraint: number;
  30024. targets: string[];
  30025. } | {
  30026. key: string;
  30027. capture: null;
  30028. captureConstraint: null;
  30029. targets: string[];
  30030. })[];
  30031. /** @hidden */
  30032. static _TextureLoaders: IInternalTextureLoader[];
  30033. /**
  30034. * Returns the current npm package of the sdk
  30035. */
  30036. static readonly NpmPackage: string;
  30037. /**
  30038. * Returns the current version of the framework
  30039. */
  30040. static readonly Version: string;
  30041. /**
  30042. * Returns a string describing the current engine
  30043. */
  30044. readonly description: string;
  30045. /**
  30046. * Gets or sets the epsilon value used by collision engine
  30047. */
  30048. static CollisionsEpsilon: number;
  30049. /**
  30050. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30051. */
  30052. static ShadersRepository: string;
  30053. /** @hidden */
  30054. _shaderProcessor: IShaderProcessor;
  30055. /**
  30056. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30057. */
  30058. forcePOTTextures: boolean;
  30059. /**
  30060. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30061. */
  30062. isFullscreen: boolean;
  30063. /**
  30064. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30065. */
  30066. cullBackFaces: boolean;
  30067. /**
  30068. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30069. */
  30070. renderEvenInBackground: boolean;
  30071. /**
  30072. * Gets or sets a boolean indicating that cache can be kept between frames
  30073. */
  30074. preventCacheWipeBetweenFrames: boolean;
  30075. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30076. validateShaderPrograms: boolean;
  30077. /**
  30078. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30079. */
  30080. disableUniformBuffers: boolean;
  30081. /** @hidden */
  30082. _uniformBuffers: UniformBuffer[];
  30083. /**
  30084. * Gets a boolean indicating that the engine supports uniform buffers
  30085. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30086. */
  30087. readonly supportsUniformBuffers: boolean;
  30088. /** @hidden */
  30089. _gl: WebGLRenderingContext;
  30090. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30091. protected _windowIsBackground: boolean;
  30092. protected _webGLVersion: number;
  30093. protected _creationOptions: EngineOptions;
  30094. protected _highPrecisionShadersAllowed: boolean;
  30095. /** @hidden */
  30096. readonly _shouldUseHighPrecisionShader: boolean;
  30097. /**
  30098. * Gets a boolean indicating that only power of 2 textures are supported
  30099. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30100. */
  30101. readonly needPOTTextures: boolean;
  30102. /** @hidden */
  30103. _badOS: boolean;
  30104. /** @hidden */
  30105. _badDesktopOS: boolean;
  30106. private _hardwareScalingLevel;
  30107. /** @hidden */
  30108. _caps: EngineCapabilities;
  30109. private _isStencilEnable;
  30110. protected _colorWrite: boolean;
  30111. private _glVersion;
  30112. private _glRenderer;
  30113. private _glVendor;
  30114. /** @hidden */
  30115. _videoTextureSupported: boolean;
  30116. protected _renderingQueueLaunched: boolean;
  30117. protected _activeRenderLoops: (() => void)[];
  30118. /**
  30119. * Observable signaled when a context lost event is raised
  30120. */
  30121. onContextLostObservable: Observable<ThinEngine>;
  30122. /**
  30123. * Observable signaled when a context restored event is raised
  30124. */
  30125. onContextRestoredObservable: Observable<ThinEngine>;
  30126. private _onContextLost;
  30127. private _onContextRestored;
  30128. protected _contextWasLost: boolean;
  30129. /** @hidden */
  30130. _doNotHandleContextLost: boolean;
  30131. /**
  30132. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30134. */
  30135. doNotHandleContextLost: boolean;
  30136. /**
  30137. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30138. */
  30139. disableVertexArrayObjects: boolean;
  30140. /** @hidden */
  30141. protected _depthCullingState: DepthCullingState;
  30142. /** @hidden */
  30143. protected _stencilState: StencilState;
  30144. /** @hidden */
  30145. protected _alphaState: AlphaState;
  30146. /** @hidden */
  30147. _internalTexturesCache: InternalTexture[];
  30148. /** @hidden */
  30149. protected _activeChannel: number;
  30150. private _currentTextureChannel;
  30151. /** @hidden */
  30152. protected _boundTexturesCache: {
  30153. [key: string]: Nullable<InternalTexture>;
  30154. };
  30155. /** @hidden */
  30156. protected _currentEffect: Nullable<Effect>;
  30157. /** @hidden */
  30158. protected _currentProgram: Nullable<WebGLProgram>;
  30159. private _compiledEffects;
  30160. private _vertexAttribArraysEnabled;
  30161. /** @hidden */
  30162. protected _cachedViewport: Nullable<IViewportLike>;
  30163. private _cachedVertexArrayObject;
  30164. /** @hidden */
  30165. protected _cachedVertexBuffers: any;
  30166. /** @hidden */
  30167. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30168. /** @hidden */
  30169. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30170. /** @hidden */
  30171. _currentRenderTarget: Nullable<InternalTexture>;
  30172. private _uintIndicesCurrentlySet;
  30173. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30174. /** @hidden */
  30175. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30176. private _currentBufferPointers;
  30177. private _currentInstanceLocations;
  30178. private _currentInstanceBuffers;
  30179. private _textureUnits;
  30180. /** @hidden */
  30181. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30182. /** @hidden */
  30183. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30184. /** @hidden */
  30185. _boundRenderFunction: any;
  30186. private _vaoRecordInProgress;
  30187. private _mustWipeVertexAttributes;
  30188. private _emptyTexture;
  30189. private _emptyCubeTexture;
  30190. private _emptyTexture3D;
  30191. private _emptyTexture2DArray;
  30192. /** @hidden */
  30193. _frameHandler: number;
  30194. private _nextFreeTextureSlots;
  30195. private _maxSimultaneousTextures;
  30196. private _activeRequests;
  30197. protected _texturesSupported: string[];
  30198. /** @hidden */
  30199. _textureFormatInUse: Nullable<string>;
  30200. protected readonly _supportsHardwareTextureRescaling: boolean;
  30201. /**
  30202. * Gets the list of texture formats supported
  30203. */
  30204. readonly texturesSupported: Array<string>;
  30205. /**
  30206. * Gets the list of texture formats in use
  30207. */
  30208. readonly textureFormatInUse: Nullable<string>;
  30209. /**
  30210. * Gets the current viewport
  30211. */
  30212. readonly currentViewport: Nullable<IViewportLike>;
  30213. /**
  30214. * Gets the default empty texture
  30215. */
  30216. readonly emptyTexture: InternalTexture;
  30217. /**
  30218. * Gets the default empty 3D texture
  30219. */
  30220. readonly emptyTexture3D: InternalTexture;
  30221. /**
  30222. * Gets the default empty 2D array texture
  30223. */
  30224. readonly emptyTexture2DArray: InternalTexture;
  30225. /**
  30226. * Gets the default empty cube texture
  30227. */
  30228. readonly emptyCubeTexture: InternalTexture;
  30229. /**
  30230. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30231. */
  30232. readonly premultipliedAlpha: boolean;
  30233. /**
  30234. * Observable event triggered before each texture is initialized
  30235. */
  30236. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30237. /**
  30238. * Creates a new engine
  30239. * @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
  30240. * @param antialias defines enable antialiasing (default: false)
  30241. * @param options defines further options to be sent to the getContext() function
  30242. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30243. */
  30244. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30245. private _rebuildInternalTextures;
  30246. private _rebuildEffects;
  30247. /**
  30248. * Gets a boolean indicating if all created effects are ready
  30249. * @returns true if all effects are ready
  30250. */
  30251. areAllEffectsReady(): boolean;
  30252. protected _rebuildBuffers(): void;
  30253. private _initGLContext;
  30254. /**
  30255. * Gets version of the current webGL context
  30256. */
  30257. readonly webGLVersion: number;
  30258. /**
  30259. * Gets a string idenfifying the name of the class
  30260. * @returns "Engine" string
  30261. */
  30262. getClassName(): string;
  30263. /**
  30264. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30265. */
  30266. readonly isStencilEnable: boolean;
  30267. /** @hidden */
  30268. _prepareWorkingCanvas(): void;
  30269. /**
  30270. * Reset the texture cache to empty state
  30271. */
  30272. resetTextureCache(): void;
  30273. /**
  30274. * Gets an object containing information about the current webGL context
  30275. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30276. */
  30277. getGlInfo(): {
  30278. vendor: string;
  30279. renderer: string;
  30280. version: string;
  30281. };
  30282. /**
  30283. * Defines the hardware scaling level.
  30284. * By default the hardware scaling level is computed from the window device ratio.
  30285. * 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.
  30286. * @param level defines the level to use
  30287. */
  30288. setHardwareScalingLevel(level: number): void;
  30289. /**
  30290. * Gets the current hardware scaling level.
  30291. * By default the hardware scaling level is computed from the window device ratio.
  30292. * 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.
  30293. * @returns a number indicating the current hardware scaling level
  30294. */
  30295. getHardwareScalingLevel(): number;
  30296. /**
  30297. * Gets the list of loaded textures
  30298. * @returns an array containing all loaded textures
  30299. */
  30300. getLoadedTexturesCache(): InternalTexture[];
  30301. /**
  30302. * Gets the object containing all engine capabilities
  30303. * @returns the EngineCapabilities object
  30304. */
  30305. getCaps(): EngineCapabilities;
  30306. /**
  30307. * stop executing a render loop function and remove it from the execution array
  30308. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30309. */
  30310. stopRenderLoop(renderFunction?: () => void): void;
  30311. /** @hidden */
  30312. _renderLoop(): void;
  30313. /**
  30314. * Gets the HTML canvas attached with the current webGL context
  30315. * @returns a HTML canvas
  30316. */
  30317. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30318. /**
  30319. * Gets host window
  30320. * @returns the host window object
  30321. */
  30322. getHostWindow(): Nullable<Window>;
  30323. /**
  30324. * Gets the current render width
  30325. * @param useScreen defines if screen size must be used (or the current render target if any)
  30326. * @returns a number defining the current render width
  30327. */
  30328. getRenderWidth(useScreen?: boolean): number;
  30329. /**
  30330. * Gets the current render height
  30331. * @param useScreen defines if screen size must be used (or the current render target if any)
  30332. * @returns a number defining the current render height
  30333. */
  30334. getRenderHeight(useScreen?: boolean): number;
  30335. /**
  30336. * Can be used to override the current requestAnimationFrame requester.
  30337. * @hidden
  30338. */
  30339. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30340. /**
  30341. * Register and execute a render loop. The engine can have more than one render function
  30342. * @param renderFunction defines the function to continuously execute
  30343. */
  30344. runRenderLoop(renderFunction: () => void): void;
  30345. /**
  30346. * Clear the current render buffer or the current render target (if any is set up)
  30347. * @param color defines the color to use
  30348. * @param backBuffer defines if the back buffer must be cleared
  30349. * @param depth defines if the depth buffer must be cleared
  30350. * @param stencil defines if the stencil buffer must be cleared
  30351. */
  30352. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30353. private _viewportCached;
  30354. /** @hidden */
  30355. _viewport(x: number, y: number, width: number, height: number): void;
  30356. /**
  30357. * Set the WebGL's viewport
  30358. * @param viewport defines the viewport element to be used
  30359. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30360. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30361. */
  30362. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30363. /**
  30364. * Begin a new frame
  30365. */
  30366. beginFrame(): void;
  30367. /**
  30368. * Enf the current frame
  30369. */
  30370. endFrame(): void;
  30371. /**
  30372. * Resize the view according to the canvas' size
  30373. */
  30374. resize(): void;
  30375. /**
  30376. * Force a specific size of the canvas
  30377. * @param width defines the new canvas' width
  30378. * @param height defines the new canvas' height
  30379. */
  30380. setSize(width: number, height: number): void;
  30381. /**
  30382. * Binds the frame buffer to the specified texture.
  30383. * @param texture The texture to render to or null for the default canvas
  30384. * @param faceIndex The face of the texture to render to in case of cube texture
  30385. * @param requiredWidth The width of the target to render to
  30386. * @param requiredHeight The height of the target to render to
  30387. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30388. * @param depthStencilTexture The depth stencil texture to use to render
  30389. * @param lodLevel defines le lod level to bind to the frame buffer
  30390. */
  30391. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30392. /** @hidden */
  30393. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30394. /**
  30395. * Unbind the current render target texture from the webGL context
  30396. * @param texture defines the render target texture to unbind
  30397. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30398. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30399. */
  30400. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30401. /**
  30402. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30403. */
  30404. flushFramebuffer(): void;
  30405. /**
  30406. * Unbind the current render target and bind the default framebuffer
  30407. */
  30408. restoreDefaultFramebuffer(): void;
  30409. /** @hidden */
  30410. protected _resetVertexBufferBinding(): void;
  30411. /**
  30412. * Creates a vertex buffer
  30413. * @param data the data for the vertex buffer
  30414. * @returns the new WebGL static buffer
  30415. */
  30416. createVertexBuffer(data: DataArray): DataBuffer;
  30417. private _createVertexBuffer;
  30418. /**
  30419. * Creates a dynamic vertex buffer
  30420. * @param data the data for the dynamic vertex buffer
  30421. * @returns the new WebGL dynamic buffer
  30422. */
  30423. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30424. protected _resetIndexBufferBinding(): void;
  30425. /**
  30426. * Creates a new index buffer
  30427. * @param indices defines the content of the index buffer
  30428. * @param updatable defines if the index buffer must be updatable
  30429. * @returns a new webGL buffer
  30430. */
  30431. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30432. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30433. /**
  30434. * Bind a webGL buffer to the webGL context
  30435. * @param buffer defines the buffer to bind
  30436. */
  30437. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30438. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30439. private bindBuffer;
  30440. /**
  30441. * update the bound buffer with the given data
  30442. * @param data defines the data to update
  30443. */
  30444. updateArrayBuffer(data: Float32Array): void;
  30445. private _vertexAttribPointer;
  30446. private _bindIndexBufferWithCache;
  30447. private _bindVertexBuffersAttributes;
  30448. /**
  30449. * Records a vertex array object
  30450. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30451. * @param vertexBuffers defines the list of vertex buffers to store
  30452. * @param indexBuffer defines the index buffer to store
  30453. * @param effect defines the effect to store
  30454. * @returns the new vertex array object
  30455. */
  30456. recordVertexArrayObject(vertexBuffers: {
  30457. [key: string]: VertexBuffer;
  30458. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30459. /**
  30460. * Bind a specific vertex array object
  30461. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30462. * @param vertexArrayObject defines the vertex array object to bind
  30463. * @param indexBuffer defines the index buffer to bind
  30464. */
  30465. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30466. /**
  30467. * Bind webGl buffers directly to the webGL context
  30468. * @param vertexBuffer defines the vertex buffer to bind
  30469. * @param indexBuffer defines the index buffer to bind
  30470. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30471. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30472. * @param effect defines the effect associated with the vertex buffer
  30473. */
  30474. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30475. private _unbindVertexArrayObject;
  30476. /**
  30477. * Bind a list of vertex buffers to the webGL context
  30478. * @param vertexBuffers defines the list of vertex buffers to bind
  30479. * @param indexBuffer defines the index buffer to bind
  30480. * @param effect defines the effect associated with the vertex buffers
  30481. */
  30482. bindBuffers(vertexBuffers: {
  30483. [key: string]: Nullable<VertexBuffer>;
  30484. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30485. /**
  30486. * Unbind all instance attributes
  30487. */
  30488. unbindInstanceAttributes(): void;
  30489. /**
  30490. * Release and free the memory of a vertex array object
  30491. * @param vao defines the vertex array object to delete
  30492. */
  30493. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30494. /** @hidden */
  30495. _releaseBuffer(buffer: DataBuffer): boolean;
  30496. protected _deleteBuffer(buffer: DataBuffer): void;
  30497. /**
  30498. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30499. * @param instancesBuffer defines the webGL buffer to update and bind
  30500. * @param data defines the data to store in the buffer
  30501. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30502. */
  30503. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30504. /**
  30505. * Apply all cached states (depth, culling, stencil and alpha)
  30506. */
  30507. applyStates(): void;
  30508. /**
  30509. * Send a draw order
  30510. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30511. * @param indexStart defines the starting index
  30512. * @param indexCount defines the number of index to draw
  30513. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30514. */
  30515. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30516. /**
  30517. * Draw a list of points
  30518. * @param verticesStart defines the index of first vertex to draw
  30519. * @param verticesCount defines the count of vertices to draw
  30520. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30521. */
  30522. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30523. /**
  30524. * Draw a list of unindexed primitives
  30525. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30526. * @param verticesStart defines the index of first vertex to draw
  30527. * @param verticesCount defines the count of vertices to draw
  30528. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30529. */
  30530. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30531. /**
  30532. * Draw a list of indexed primitives
  30533. * @param fillMode defines the primitive to use
  30534. * @param indexStart defines the starting index
  30535. * @param indexCount defines the number of index to draw
  30536. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30537. */
  30538. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30539. /**
  30540. * Draw a list of unindexed primitives
  30541. * @param fillMode defines the primitive to use
  30542. * @param verticesStart defines the index of first vertex to draw
  30543. * @param verticesCount defines the count of vertices to draw
  30544. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30545. */
  30546. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30547. private _drawMode;
  30548. /** @hidden */
  30549. protected _reportDrawCall(): void;
  30550. /** @hidden */
  30551. _releaseEffect(effect: Effect): void;
  30552. /** @hidden */
  30553. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30554. /**
  30555. * Create a new effect (used to store vertex/fragment shaders)
  30556. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30557. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30558. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30559. * @param samplers defines an array of string used to represent textures
  30560. * @param defines defines the string containing the defines to use to compile the shaders
  30561. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30562. * @param onCompiled defines a function to call when the effect creation is successful
  30563. * @param onError defines a function to call when the effect creation has failed
  30564. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30565. * @returns the new Effect
  30566. */
  30567. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30568. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30569. private _compileShader;
  30570. private _compileRawShader;
  30571. /**
  30572. * Directly creates a webGL program
  30573. * @param pipelineContext defines the pipeline context to attach to
  30574. * @param vertexCode defines the vertex shader code to use
  30575. * @param fragmentCode defines the fragment shader code to use
  30576. * @param context defines the webGL context to use (if not set, the current one will be used)
  30577. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30578. * @returns the new webGL program
  30579. */
  30580. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30581. /**
  30582. * Creates a webGL program
  30583. * @param pipelineContext defines the pipeline context to attach to
  30584. * @param vertexCode defines the vertex shader code to use
  30585. * @param fragmentCode defines the fragment shader code to use
  30586. * @param defines defines the string containing the defines to use to compile the shaders
  30587. * @param context defines the webGL context to use (if not set, the current one will be used)
  30588. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30589. * @returns the new webGL program
  30590. */
  30591. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30592. /**
  30593. * Creates a new pipeline context
  30594. * @returns the new pipeline
  30595. */
  30596. createPipelineContext(): IPipelineContext;
  30597. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30598. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30599. /** @hidden */
  30600. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30601. /** @hidden */
  30602. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30603. /** @hidden */
  30604. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30605. /**
  30606. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30607. * @param pipelineContext defines the pipeline context to use
  30608. * @param uniformsNames defines the list of uniform names
  30609. * @returns an array of webGL uniform locations
  30610. */
  30611. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30612. /**
  30613. * Gets the lsit of active attributes for a given webGL program
  30614. * @param pipelineContext defines the pipeline context to use
  30615. * @param attributesNames defines the list of attribute names to get
  30616. * @returns an array of indices indicating the offset of each attribute
  30617. */
  30618. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30619. /**
  30620. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30621. * @param effect defines the effect to activate
  30622. */
  30623. enableEffect(effect: Nullable<Effect>): void;
  30624. /**
  30625. * Set the value of an uniform to a number (int)
  30626. * @param uniform defines the webGL uniform location where to store the value
  30627. * @param value defines the int number to store
  30628. */
  30629. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30630. /**
  30631. * Set the value of an uniform to an array of int32
  30632. * @param uniform defines the webGL uniform location where to store the value
  30633. * @param array defines the array of int32 to store
  30634. */
  30635. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30636. /**
  30637. * Set the value of an uniform to an array of int32 (stored as vec2)
  30638. * @param uniform defines the webGL uniform location where to store the value
  30639. * @param array defines the array of int32 to store
  30640. */
  30641. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30642. /**
  30643. * Set the value of an uniform to an array of int32 (stored as vec3)
  30644. * @param uniform defines the webGL uniform location where to store the value
  30645. * @param array defines the array of int32 to store
  30646. */
  30647. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30648. /**
  30649. * Set the value of an uniform to an array of int32 (stored as vec4)
  30650. * @param uniform defines the webGL uniform location where to store the value
  30651. * @param array defines the array of int32 to store
  30652. */
  30653. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30654. /**
  30655. * Set the value of an uniform to an array of number
  30656. * @param uniform defines the webGL uniform location where to store the value
  30657. * @param array defines the array of number to store
  30658. */
  30659. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30660. /**
  30661. * Set the value of an uniform to an array of number (stored as vec2)
  30662. * @param uniform defines the webGL uniform location where to store the value
  30663. * @param array defines the array of number to store
  30664. */
  30665. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30666. /**
  30667. * Set the value of an uniform to an array of number (stored as vec3)
  30668. * @param uniform defines the webGL uniform location where to store the value
  30669. * @param array defines the array of number to store
  30670. */
  30671. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30672. /**
  30673. * Set the value of an uniform to an array of number (stored as vec4)
  30674. * @param uniform defines the webGL uniform location where to store the value
  30675. * @param array defines the array of number to store
  30676. */
  30677. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30678. /**
  30679. * Set the value of an uniform to an array of float32 (stored as matrices)
  30680. * @param uniform defines the webGL uniform location where to store the value
  30681. * @param matrices defines the array of float32 to store
  30682. */
  30683. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30684. /**
  30685. * Set the value of an uniform to a matrix (3x3)
  30686. * @param uniform defines the webGL uniform location where to store the value
  30687. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30688. */
  30689. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30690. /**
  30691. * Set the value of an uniform to a matrix (2x2)
  30692. * @param uniform defines the webGL uniform location where to store the value
  30693. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30694. */
  30695. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30696. /**
  30697. * Set the value of an uniform to a number (float)
  30698. * @param uniform defines the webGL uniform location where to store the value
  30699. * @param value defines the float number to store
  30700. */
  30701. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30702. /**
  30703. * Set the value of an uniform to a vec2
  30704. * @param uniform defines the webGL uniform location where to store the value
  30705. * @param x defines the 1st component of the value
  30706. * @param y defines the 2nd component of the value
  30707. */
  30708. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30709. /**
  30710. * Set the value of an uniform to a vec3
  30711. * @param uniform defines the webGL uniform location where to store the value
  30712. * @param x defines the 1st component of the value
  30713. * @param y defines the 2nd component of the value
  30714. * @param z defines the 3rd component of the value
  30715. */
  30716. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30717. /**
  30718. * Set the value of an uniform to a vec4
  30719. * @param uniform defines the webGL uniform location where to store the value
  30720. * @param x defines the 1st component of the value
  30721. * @param y defines the 2nd component of the value
  30722. * @param z defines the 3rd component of the value
  30723. * @param w defines the 4th component of the value
  30724. */
  30725. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30726. /**
  30727. * Gets the depth culling state manager
  30728. */
  30729. readonly depthCullingState: DepthCullingState;
  30730. /**
  30731. * Gets the alpha state manager
  30732. */
  30733. readonly alphaState: AlphaState;
  30734. /**
  30735. * Gets the stencil state manager
  30736. */
  30737. readonly stencilState: StencilState;
  30738. /**
  30739. * Clears the list of texture accessible through engine.
  30740. * This can help preventing texture load conflict due to name collision.
  30741. */
  30742. clearInternalTexturesCache(): void;
  30743. /**
  30744. * Force the entire cache to be cleared
  30745. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30746. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30747. */
  30748. wipeCaches(bruteForce?: boolean): void;
  30749. /** @hidden */
  30750. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30751. min: number;
  30752. mag: number;
  30753. };
  30754. /** @hidden */
  30755. _createTexture(): WebGLTexture;
  30756. /**
  30757. * Usually called from Texture.ts.
  30758. * Passed information to create a WebGLTexture
  30759. * @param urlArg defines a value which contains one of the following:
  30760. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30761. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30762. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30763. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30764. * @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)
  30765. * @param scene needed for loading to the correct scene
  30766. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30767. * @param onLoad optional callback to be called upon successful completion
  30768. * @param onError optional callback to be called upon failure
  30769. * @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
  30770. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30771. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30772. * @param forcedExtension defines the extension to use to pick the right loader
  30773. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30774. * @param mimeType defines an optional mime type
  30775. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30776. */
  30777. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30778. /**
  30779. * @hidden
  30780. */
  30781. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30782. /**
  30783. * Creates a raw texture
  30784. * @param data defines the data to store in the texture
  30785. * @param width defines the width of the texture
  30786. * @param height defines the height of the texture
  30787. * @param format defines the format of the data
  30788. * @param generateMipMaps defines if the engine should generate the mip levels
  30789. * @param invertY defines if data must be stored with Y axis inverted
  30790. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30791. * @param compression defines the compression used (null by default)
  30792. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30793. * @returns the raw texture inside an InternalTexture
  30794. */
  30795. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30796. /**
  30797. * Creates a new raw cube texture
  30798. * @param data defines the array of data to use to create each face
  30799. * @param size defines the size of the textures
  30800. * @param format defines the format of the data
  30801. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30802. * @param generateMipMaps defines if the engine should generate the mip levels
  30803. * @param invertY defines if data must be stored with Y axis inverted
  30804. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30805. * @param compression defines the compression used (null by default)
  30806. * @returns the cube texture as an InternalTexture
  30807. */
  30808. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30809. /**
  30810. * Creates a new raw 3D texture
  30811. * @param data defines the data used to create the texture
  30812. * @param width defines the width of the texture
  30813. * @param height defines the height of the texture
  30814. * @param depth defines the depth of the texture
  30815. * @param format defines the format of the texture
  30816. * @param generateMipMaps defines if the engine must generate mip levels
  30817. * @param invertY defines if data must be stored with Y axis inverted
  30818. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30819. * @param compression defines the compressed used (can be null)
  30820. * @param textureType defines the compressed used (can be null)
  30821. * @returns a new raw 3D texture (stored in an InternalTexture)
  30822. */
  30823. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30824. /**
  30825. * Creates a new raw 2D array texture
  30826. * @param data defines the data used to create the texture
  30827. * @param width defines the width of the texture
  30828. * @param height defines the height of the texture
  30829. * @param depth defines the number of layers of the texture
  30830. * @param format defines the format of the texture
  30831. * @param generateMipMaps defines if the engine must generate mip levels
  30832. * @param invertY defines if data must be stored with Y axis inverted
  30833. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30834. * @param compression defines the compressed used (can be null)
  30835. * @param textureType defines the compressed used (can be null)
  30836. * @returns a new raw 2D array texture (stored in an InternalTexture)
  30837. */
  30838. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30839. private _unpackFlipYCached;
  30840. /**
  30841. * In case you are sharing the context with other applications, it might
  30842. * be interested to not cache the unpack flip y state to ensure a consistent
  30843. * value would be set.
  30844. */
  30845. enableUnpackFlipYCached: boolean;
  30846. /** @hidden */
  30847. _unpackFlipY(value: boolean): void;
  30848. /** @hidden */
  30849. _getUnpackAlignement(): number;
  30850. /**
  30851. * Update the sampling mode of a given texture
  30852. * @param samplingMode defines the required sampling mode
  30853. * @param texture defines the texture to update
  30854. */
  30855. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30856. /** @hidden */
  30857. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30858. width: number;
  30859. height: number;
  30860. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30861. /** @hidden */
  30862. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30863. /** @hidden */
  30864. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30865. /** @hidden */
  30866. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30867. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30868. private _prepareWebGLTexture;
  30869. /** @hidden */
  30870. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30871. /** @hidden */
  30872. _releaseFramebufferObjects(texture: InternalTexture): void;
  30873. /** @hidden */
  30874. _releaseTexture(texture: InternalTexture): void;
  30875. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30876. protected _setProgram(program: WebGLProgram): void;
  30877. protected _boundUniforms: {
  30878. [key: number]: WebGLUniformLocation;
  30879. };
  30880. /**
  30881. * Binds an effect to the webGL context
  30882. * @param effect defines the effect to bind
  30883. */
  30884. bindSamplers(effect: Effect): void;
  30885. private _activateCurrentTexture;
  30886. /** @hidden */
  30887. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30888. /** @hidden */
  30889. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30890. /**
  30891. * Unbind all textures from the webGL context
  30892. */
  30893. unbindAllTextures(): void;
  30894. /**
  30895. * Sets a texture to the according uniform.
  30896. * @param channel The texture channel
  30897. * @param uniform The uniform to set
  30898. * @param texture The texture to apply
  30899. */
  30900. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30901. private _bindSamplerUniformToChannel;
  30902. private _getTextureWrapMode;
  30903. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30904. /**
  30905. * Sets an array of texture to the webGL context
  30906. * @param channel defines the channel where the texture array must be set
  30907. * @param uniform defines the associated uniform location
  30908. * @param textures defines the array of textures to bind
  30909. */
  30910. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30911. /** @hidden */
  30912. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30913. private _setTextureParameterFloat;
  30914. private _setTextureParameterInteger;
  30915. /**
  30916. * Unbind all vertex attributes from the webGL context
  30917. */
  30918. unbindAllAttributes(): void;
  30919. /**
  30920. * 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
  30921. */
  30922. releaseEffects(): void;
  30923. /**
  30924. * Dispose and release all associated resources
  30925. */
  30926. dispose(): void;
  30927. /**
  30928. * Attach a new callback raised when context lost event is fired
  30929. * @param callback defines the callback to call
  30930. */
  30931. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30932. /**
  30933. * Attach a new callback raised when context restored event is fired
  30934. * @param callback defines the callback to call
  30935. */
  30936. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30937. /**
  30938. * Get the current error code of the webGL context
  30939. * @returns the error code
  30940. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30941. */
  30942. getError(): number;
  30943. private _canRenderToFloatFramebuffer;
  30944. private _canRenderToHalfFloatFramebuffer;
  30945. private _canRenderToFramebuffer;
  30946. /** @hidden */
  30947. _getWebGLTextureType(type: number): number;
  30948. /** @hidden */
  30949. _getInternalFormat(format: number): number;
  30950. /** @hidden */
  30951. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30952. /** @hidden */
  30953. _getRGBAMultiSampleBufferFormat(type: number): number;
  30954. /** @hidden */
  30955. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30956. /**
  30957. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30958. * @returns true if the engine can be created
  30959. * @ignorenaming
  30960. */
  30961. static isSupported(): boolean;
  30962. /**
  30963. * Find the next highest power of two.
  30964. * @param x Number to start search from.
  30965. * @return Next highest power of two.
  30966. */
  30967. static CeilingPOT(x: number): number;
  30968. /**
  30969. * Find the next lowest power of two.
  30970. * @param x Number to start search from.
  30971. * @return Next lowest power of two.
  30972. */
  30973. static FloorPOT(x: number): number;
  30974. /**
  30975. * Find the nearest power of two.
  30976. * @param x Number to start search from.
  30977. * @return Next nearest power of two.
  30978. */
  30979. static NearestPOT(x: number): number;
  30980. /**
  30981. * Get the closest exponent of two
  30982. * @param value defines the value to approximate
  30983. * @param max defines the maximum value to return
  30984. * @param mode defines how to define the closest value
  30985. * @returns closest exponent of two of the given value
  30986. */
  30987. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30988. /**
  30989. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30990. * @param func - the function to be called
  30991. * @param requester - the object that will request the next frame. Falls back to window.
  30992. * @returns frame number
  30993. */
  30994. static QueueNewFrame(func: () => void, requester?: any): number;
  30995. }
  30996. }
  30997. declare module "babylonjs/Maths/sphericalPolynomial" {
  30998. import { Vector3 } from "babylonjs/Maths/math.vector";
  30999. import { Color3 } from "babylonjs/Maths/math.color";
  31000. /**
  31001. * Class representing spherical harmonics coefficients to the 3rd degree
  31002. */
  31003. export class SphericalHarmonics {
  31004. /**
  31005. * Defines whether or not the harmonics have been prescaled for rendering.
  31006. */
  31007. preScaled: boolean;
  31008. /**
  31009. * The l0,0 coefficients of the spherical harmonics
  31010. */
  31011. l00: Vector3;
  31012. /**
  31013. * The l1,-1 coefficients of the spherical harmonics
  31014. */
  31015. l1_1: Vector3;
  31016. /**
  31017. * The l1,0 coefficients of the spherical harmonics
  31018. */
  31019. l10: Vector3;
  31020. /**
  31021. * The l1,1 coefficients of the spherical harmonics
  31022. */
  31023. l11: Vector3;
  31024. /**
  31025. * The l2,-2 coefficients of the spherical harmonics
  31026. */
  31027. l2_2: Vector3;
  31028. /**
  31029. * The l2,-1 coefficients of the spherical harmonics
  31030. */
  31031. l2_1: Vector3;
  31032. /**
  31033. * The l2,0 coefficients of the spherical harmonics
  31034. */
  31035. l20: Vector3;
  31036. /**
  31037. * The l2,1 coefficients of the spherical harmonics
  31038. */
  31039. l21: Vector3;
  31040. /**
  31041. * The l2,2 coefficients of the spherical harmonics
  31042. */
  31043. l22: Vector3;
  31044. /**
  31045. * Adds a light to the spherical harmonics
  31046. * @param direction the direction of the light
  31047. * @param color the color of the light
  31048. * @param deltaSolidAngle the delta solid angle of the light
  31049. */
  31050. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31051. /**
  31052. * Scales the spherical harmonics by the given amount
  31053. * @param scale the amount to scale
  31054. */
  31055. scaleInPlace(scale: number): void;
  31056. /**
  31057. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31058. *
  31059. * ```
  31060. * E_lm = A_l * L_lm
  31061. * ```
  31062. *
  31063. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31064. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31065. * the scaling factors are given in equation 9.
  31066. */
  31067. convertIncidentRadianceToIrradiance(): void;
  31068. /**
  31069. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31070. *
  31071. * ```
  31072. * L = (1/pi) * E * rho
  31073. * ```
  31074. *
  31075. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31076. */
  31077. convertIrradianceToLambertianRadiance(): void;
  31078. /**
  31079. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31080. * required operations at run time.
  31081. *
  31082. * This is simply done by scaling back the SH with Ylm constants parameter.
  31083. * The trigonometric part being applied by the shader at run time.
  31084. */
  31085. preScaleForRendering(): void;
  31086. /**
  31087. * Constructs a spherical harmonics from an array.
  31088. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31089. * @returns the spherical harmonics
  31090. */
  31091. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31092. /**
  31093. * Gets the spherical harmonics from polynomial
  31094. * @param polynomial the spherical polynomial
  31095. * @returns the spherical harmonics
  31096. */
  31097. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31098. }
  31099. /**
  31100. * Class representing spherical polynomial coefficients to the 3rd degree
  31101. */
  31102. export class SphericalPolynomial {
  31103. private _harmonics;
  31104. /**
  31105. * The spherical harmonics used to create the polynomials.
  31106. */
  31107. readonly preScaledHarmonics: SphericalHarmonics;
  31108. /**
  31109. * The x coefficients of the spherical polynomial
  31110. */
  31111. x: Vector3;
  31112. /**
  31113. * The y coefficients of the spherical polynomial
  31114. */
  31115. y: Vector3;
  31116. /**
  31117. * The z coefficients of the spherical polynomial
  31118. */
  31119. z: Vector3;
  31120. /**
  31121. * The xx coefficients of the spherical polynomial
  31122. */
  31123. xx: Vector3;
  31124. /**
  31125. * The yy coefficients of the spherical polynomial
  31126. */
  31127. yy: Vector3;
  31128. /**
  31129. * The zz coefficients of the spherical polynomial
  31130. */
  31131. zz: Vector3;
  31132. /**
  31133. * The xy coefficients of the spherical polynomial
  31134. */
  31135. xy: Vector3;
  31136. /**
  31137. * The yz coefficients of the spherical polynomial
  31138. */
  31139. yz: Vector3;
  31140. /**
  31141. * The zx coefficients of the spherical polynomial
  31142. */
  31143. zx: Vector3;
  31144. /**
  31145. * Adds an ambient color to the spherical polynomial
  31146. * @param color the color to add
  31147. */
  31148. addAmbient(color: Color3): void;
  31149. /**
  31150. * Scales the spherical polynomial by the given amount
  31151. * @param scale the amount to scale
  31152. */
  31153. scaleInPlace(scale: number): void;
  31154. /**
  31155. * Gets the spherical polynomial from harmonics
  31156. * @param harmonics the spherical harmonics
  31157. * @returns the spherical polynomial
  31158. */
  31159. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31160. /**
  31161. * Constructs a spherical polynomial from an array.
  31162. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31163. * @returns the spherical polynomial
  31164. */
  31165. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31166. }
  31167. }
  31168. declare module "babylonjs/Materials/Textures/internalTexture" {
  31169. import { Observable } from "babylonjs/Misc/observable";
  31170. import { Nullable, int } from "babylonjs/types";
  31171. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31172. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31173. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31174. /**
  31175. * Defines the source of the internal texture
  31176. */
  31177. export enum InternalTextureSource {
  31178. /**
  31179. * The source of the texture data is unknown
  31180. */
  31181. Unknown = 0,
  31182. /**
  31183. * Texture data comes from an URL
  31184. */
  31185. Url = 1,
  31186. /**
  31187. * Texture data is only used for temporary storage
  31188. */
  31189. Temp = 2,
  31190. /**
  31191. * Texture data comes from raw data (ArrayBuffer)
  31192. */
  31193. Raw = 3,
  31194. /**
  31195. * Texture content is dynamic (video or dynamic texture)
  31196. */
  31197. Dynamic = 4,
  31198. /**
  31199. * Texture content is generated by rendering to it
  31200. */
  31201. RenderTarget = 5,
  31202. /**
  31203. * Texture content is part of a multi render target process
  31204. */
  31205. MultiRenderTarget = 6,
  31206. /**
  31207. * Texture data comes from a cube data file
  31208. */
  31209. Cube = 7,
  31210. /**
  31211. * Texture data comes from a raw cube data
  31212. */
  31213. CubeRaw = 8,
  31214. /**
  31215. * Texture data come from a prefiltered cube data file
  31216. */
  31217. CubePrefiltered = 9,
  31218. /**
  31219. * Texture content is raw 3D data
  31220. */
  31221. Raw3D = 10,
  31222. /**
  31223. * Texture content is raw 2D array data
  31224. */
  31225. Raw2DArray = 11,
  31226. /**
  31227. * Texture content is a depth texture
  31228. */
  31229. Depth = 12,
  31230. /**
  31231. * Texture data comes from a raw cube data encoded with RGBD
  31232. */
  31233. CubeRawRGBD = 13
  31234. }
  31235. /**
  31236. * Class used to store data associated with WebGL texture data for the engine
  31237. * This class should not be used directly
  31238. */
  31239. export class InternalTexture {
  31240. /** @hidden */
  31241. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31242. /**
  31243. * Defines if the texture is ready
  31244. */
  31245. isReady: boolean;
  31246. /**
  31247. * Defines if the texture is a cube texture
  31248. */
  31249. isCube: boolean;
  31250. /**
  31251. * Defines if the texture contains 3D data
  31252. */
  31253. is3D: boolean;
  31254. /**
  31255. * Defines if the texture contains 2D array data
  31256. */
  31257. is2DArray: boolean;
  31258. /**
  31259. * Defines if the texture contains multiview data
  31260. */
  31261. isMultiview: boolean;
  31262. /**
  31263. * Gets the URL used to load this texture
  31264. */
  31265. url: string;
  31266. /**
  31267. * Gets the sampling mode of the texture
  31268. */
  31269. samplingMode: number;
  31270. /**
  31271. * Gets a boolean indicating if the texture needs mipmaps generation
  31272. */
  31273. generateMipMaps: boolean;
  31274. /**
  31275. * Gets the number of samples used by the texture (WebGL2+ only)
  31276. */
  31277. samples: number;
  31278. /**
  31279. * Gets the type of the texture (int, float...)
  31280. */
  31281. type: number;
  31282. /**
  31283. * Gets the format of the texture (RGB, RGBA...)
  31284. */
  31285. format: number;
  31286. /**
  31287. * Observable called when the texture is loaded
  31288. */
  31289. onLoadedObservable: Observable<InternalTexture>;
  31290. /**
  31291. * Gets the width of the texture
  31292. */
  31293. width: number;
  31294. /**
  31295. * Gets the height of the texture
  31296. */
  31297. height: number;
  31298. /**
  31299. * Gets the depth of the texture
  31300. */
  31301. depth: number;
  31302. /**
  31303. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31304. */
  31305. baseWidth: number;
  31306. /**
  31307. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31308. */
  31309. baseHeight: number;
  31310. /**
  31311. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31312. */
  31313. baseDepth: number;
  31314. /**
  31315. * Gets a boolean indicating if the texture is inverted on Y axis
  31316. */
  31317. invertY: boolean;
  31318. /** @hidden */
  31319. _invertVScale: boolean;
  31320. /** @hidden */
  31321. _associatedChannel: number;
  31322. /** @hidden */
  31323. _source: InternalTextureSource;
  31324. /** @hidden */
  31325. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31326. /** @hidden */
  31327. _bufferView: Nullable<ArrayBufferView>;
  31328. /** @hidden */
  31329. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31330. /** @hidden */
  31331. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31332. /** @hidden */
  31333. _size: number;
  31334. /** @hidden */
  31335. _extension: string;
  31336. /** @hidden */
  31337. _files: Nullable<string[]>;
  31338. /** @hidden */
  31339. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31340. /** @hidden */
  31341. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31342. /** @hidden */
  31343. _framebuffer: Nullable<WebGLFramebuffer>;
  31344. /** @hidden */
  31345. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31346. /** @hidden */
  31347. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31348. /** @hidden */
  31349. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31350. /** @hidden */
  31351. _attachments: Nullable<number[]>;
  31352. /** @hidden */
  31353. _cachedCoordinatesMode: Nullable<number>;
  31354. /** @hidden */
  31355. _cachedWrapU: Nullable<number>;
  31356. /** @hidden */
  31357. _cachedWrapV: Nullable<number>;
  31358. /** @hidden */
  31359. _cachedWrapR: Nullable<number>;
  31360. /** @hidden */
  31361. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31362. /** @hidden */
  31363. _isDisabled: boolean;
  31364. /** @hidden */
  31365. _compression: Nullable<string>;
  31366. /** @hidden */
  31367. _generateStencilBuffer: boolean;
  31368. /** @hidden */
  31369. _generateDepthBuffer: boolean;
  31370. /** @hidden */
  31371. _comparisonFunction: number;
  31372. /** @hidden */
  31373. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31374. /** @hidden */
  31375. _lodGenerationScale: number;
  31376. /** @hidden */
  31377. _lodGenerationOffset: number;
  31378. /** @hidden */
  31379. _colorTextureArray: Nullable<WebGLTexture>;
  31380. /** @hidden */
  31381. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31382. /** @hidden */
  31383. _lodTextureHigh: Nullable<BaseTexture>;
  31384. /** @hidden */
  31385. _lodTextureMid: Nullable<BaseTexture>;
  31386. /** @hidden */
  31387. _lodTextureLow: Nullable<BaseTexture>;
  31388. /** @hidden */
  31389. _isRGBD: boolean;
  31390. /** @hidden */
  31391. _linearSpecularLOD: boolean;
  31392. /** @hidden */
  31393. _irradianceTexture: Nullable<BaseTexture>;
  31394. /** @hidden */
  31395. _webGLTexture: Nullable<WebGLTexture>;
  31396. /** @hidden */
  31397. _references: number;
  31398. private _engine;
  31399. /**
  31400. * Gets the Engine the texture belongs to.
  31401. * @returns The babylon engine
  31402. */
  31403. getEngine(): ThinEngine;
  31404. /**
  31405. * Gets the data source type of the texture
  31406. */
  31407. readonly source: InternalTextureSource;
  31408. /**
  31409. * Creates a new InternalTexture
  31410. * @param engine defines the engine to use
  31411. * @param source defines the type of data that will be used
  31412. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31413. */
  31414. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31415. /**
  31416. * Increments the number of references (ie. the number of Texture that point to it)
  31417. */
  31418. incrementReferences(): void;
  31419. /**
  31420. * Change the size of the texture (not the size of the content)
  31421. * @param width defines the new width
  31422. * @param height defines the new height
  31423. * @param depth defines the new depth (1 by default)
  31424. */
  31425. updateSize(width: int, height: int, depth?: int): void;
  31426. /** @hidden */
  31427. _rebuild(): void;
  31428. /** @hidden */
  31429. _swapAndDie(target: InternalTexture): void;
  31430. /**
  31431. * Dispose the current allocated resources
  31432. */
  31433. dispose(): void;
  31434. }
  31435. }
  31436. declare module "babylonjs/Audio/analyser" {
  31437. import { Scene } from "babylonjs/scene";
  31438. /**
  31439. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31441. */
  31442. export class Analyser {
  31443. /**
  31444. * Gets or sets the smoothing
  31445. * @ignorenaming
  31446. */
  31447. SMOOTHING: number;
  31448. /**
  31449. * Gets or sets the FFT table size
  31450. * @ignorenaming
  31451. */
  31452. FFT_SIZE: number;
  31453. /**
  31454. * Gets or sets the bar graph amplitude
  31455. * @ignorenaming
  31456. */
  31457. BARGRAPHAMPLITUDE: number;
  31458. /**
  31459. * Gets or sets the position of the debug canvas
  31460. * @ignorenaming
  31461. */
  31462. DEBUGCANVASPOS: {
  31463. x: number;
  31464. y: number;
  31465. };
  31466. /**
  31467. * Gets or sets the debug canvas size
  31468. * @ignorenaming
  31469. */
  31470. DEBUGCANVASSIZE: {
  31471. width: number;
  31472. height: number;
  31473. };
  31474. private _byteFreqs;
  31475. private _byteTime;
  31476. private _floatFreqs;
  31477. private _webAudioAnalyser;
  31478. private _debugCanvas;
  31479. private _debugCanvasContext;
  31480. private _scene;
  31481. private _registerFunc;
  31482. private _audioEngine;
  31483. /**
  31484. * Creates a new analyser
  31485. * @param scene defines hosting scene
  31486. */
  31487. constructor(scene: Scene);
  31488. /**
  31489. * Get the number of data values you will have to play with for the visualization
  31490. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31491. * @returns a number
  31492. */
  31493. getFrequencyBinCount(): number;
  31494. /**
  31495. * Gets the current frequency data as a byte array
  31496. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31497. * @returns a Uint8Array
  31498. */
  31499. getByteFrequencyData(): Uint8Array;
  31500. /**
  31501. * Gets the current waveform as a byte array
  31502. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31503. * @returns a Uint8Array
  31504. */
  31505. getByteTimeDomainData(): Uint8Array;
  31506. /**
  31507. * Gets the current frequency data as a float array
  31508. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31509. * @returns a Float32Array
  31510. */
  31511. getFloatFrequencyData(): Float32Array;
  31512. /**
  31513. * Renders the debug canvas
  31514. */
  31515. drawDebugCanvas(): void;
  31516. /**
  31517. * Stops rendering the debug canvas and removes it
  31518. */
  31519. stopDebugCanvas(): void;
  31520. /**
  31521. * Connects two audio nodes
  31522. * @param inputAudioNode defines first node to connect
  31523. * @param outputAudioNode defines second node to connect
  31524. */
  31525. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31526. /**
  31527. * Releases all associated resources
  31528. */
  31529. dispose(): void;
  31530. }
  31531. }
  31532. declare module "babylonjs/Audio/audioEngine" {
  31533. import { IDisposable } from "babylonjs/scene";
  31534. import { Analyser } from "babylonjs/Audio/analyser";
  31535. import { Nullable } from "babylonjs/types";
  31536. import { Observable } from "babylonjs/Misc/observable";
  31537. /**
  31538. * This represents an audio engine and it is responsible
  31539. * to play, synchronize and analyse sounds throughout the application.
  31540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31541. */
  31542. export interface IAudioEngine extends IDisposable {
  31543. /**
  31544. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31545. */
  31546. readonly canUseWebAudio: boolean;
  31547. /**
  31548. * Gets the current AudioContext if available.
  31549. */
  31550. readonly audioContext: Nullable<AudioContext>;
  31551. /**
  31552. * The master gain node defines the global audio volume of your audio engine.
  31553. */
  31554. readonly masterGain: GainNode;
  31555. /**
  31556. * Gets whether or not mp3 are supported by your browser.
  31557. */
  31558. readonly isMP3supported: boolean;
  31559. /**
  31560. * Gets whether or not ogg are supported by your browser.
  31561. */
  31562. readonly isOGGsupported: boolean;
  31563. /**
  31564. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31565. * @ignoreNaming
  31566. */
  31567. WarnedWebAudioUnsupported: boolean;
  31568. /**
  31569. * Defines if the audio engine relies on a custom unlocked button.
  31570. * In this case, the embedded button will not be displayed.
  31571. */
  31572. useCustomUnlockedButton: boolean;
  31573. /**
  31574. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31575. */
  31576. readonly unlocked: boolean;
  31577. /**
  31578. * Event raised when audio has been unlocked on the browser.
  31579. */
  31580. onAudioUnlockedObservable: Observable<AudioEngine>;
  31581. /**
  31582. * Event raised when audio has been locked on the browser.
  31583. */
  31584. onAudioLockedObservable: Observable<AudioEngine>;
  31585. /**
  31586. * Flags the audio engine in Locked state.
  31587. * This happens due to new browser policies preventing audio to autoplay.
  31588. */
  31589. lock(): void;
  31590. /**
  31591. * Unlocks the audio engine once a user action has been done on the dom.
  31592. * This is helpful to resume play once browser policies have been satisfied.
  31593. */
  31594. unlock(): void;
  31595. }
  31596. /**
  31597. * This represents the default audio engine used in babylon.
  31598. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31600. */
  31601. export class AudioEngine implements IAudioEngine {
  31602. private _audioContext;
  31603. private _audioContextInitialized;
  31604. private _muteButton;
  31605. private _hostElement;
  31606. /**
  31607. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31608. */
  31609. canUseWebAudio: boolean;
  31610. /**
  31611. * The master gain node defines the global audio volume of your audio engine.
  31612. */
  31613. masterGain: GainNode;
  31614. /**
  31615. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31616. * @ignoreNaming
  31617. */
  31618. WarnedWebAudioUnsupported: boolean;
  31619. /**
  31620. * Gets whether or not mp3 are supported by your browser.
  31621. */
  31622. isMP3supported: boolean;
  31623. /**
  31624. * Gets whether or not ogg are supported by your browser.
  31625. */
  31626. isOGGsupported: boolean;
  31627. /**
  31628. * Gets whether audio has been unlocked on the device.
  31629. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31630. * a user interaction has happened.
  31631. */
  31632. unlocked: boolean;
  31633. /**
  31634. * Defines if the audio engine relies on a custom unlocked button.
  31635. * In this case, the embedded button will not be displayed.
  31636. */
  31637. useCustomUnlockedButton: boolean;
  31638. /**
  31639. * Event raised when audio has been unlocked on the browser.
  31640. */
  31641. onAudioUnlockedObservable: Observable<AudioEngine>;
  31642. /**
  31643. * Event raised when audio has been locked on the browser.
  31644. */
  31645. onAudioLockedObservable: Observable<AudioEngine>;
  31646. /**
  31647. * Gets the current AudioContext if available.
  31648. */
  31649. readonly audioContext: Nullable<AudioContext>;
  31650. private _connectedAnalyser;
  31651. /**
  31652. * Instantiates a new audio engine.
  31653. *
  31654. * There should be only one per page as some browsers restrict the number
  31655. * of audio contexts you can create.
  31656. * @param hostElement defines the host element where to display the mute icon if necessary
  31657. */
  31658. constructor(hostElement?: Nullable<HTMLElement>);
  31659. /**
  31660. * Flags the audio engine in Locked state.
  31661. * This happens due to new browser policies preventing audio to autoplay.
  31662. */
  31663. lock(): void;
  31664. /**
  31665. * Unlocks the audio engine once a user action has been done on the dom.
  31666. * This is helpful to resume play once browser policies have been satisfied.
  31667. */
  31668. unlock(): void;
  31669. private _resumeAudioContext;
  31670. private _initializeAudioContext;
  31671. private _tryToRun;
  31672. private _triggerRunningState;
  31673. private _triggerSuspendedState;
  31674. private _displayMuteButton;
  31675. private _moveButtonToTopLeft;
  31676. private _onResize;
  31677. private _hideMuteButton;
  31678. /**
  31679. * Destroy and release the resources associated with the audio ccontext.
  31680. */
  31681. dispose(): void;
  31682. /**
  31683. * Gets the global volume sets on the master gain.
  31684. * @returns the global volume if set or -1 otherwise
  31685. */
  31686. getGlobalVolume(): number;
  31687. /**
  31688. * Sets the global volume of your experience (sets on the master gain).
  31689. * @param newVolume Defines the new global volume of the application
  31690. */
  31691. setGlobalVolume(newVolume: number): void;
  31692. /**
  31693. * Connect the audio engine to an audio analyser allowing some amazing
  31694. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31696. * @param analyser The analyser to connect to the engine
  31697. */
  31698. connectToAnalyser(analyser: Analyser): void;
  31699. }
  31700. }
  31701. declare module "babylonjs/Loading/loadingScreen" {
  31702. /**
  31703. * Interface used to present a loading screen while loading a scene
  31704. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31705. */
  31706. export interface ILoadingScreen {
  31707. /**
  31708. * Function called to display the loading screen
  31709. */
  31710. displayLoadingUI: () => void;
  31711. /**
  31712. * Function called to hide the loading screen
  31713. */
  31714. hideLoadingUI: () => void;
  31715. /**
  31716. * Gets or sets the color to use for the background
  31717. */
  31718. loadingUIBackgroundColor: string;
  31719. /**
  31720. * Gets or sets the text to display while loading
  31721. */
  31722. loadingUIText: string;
  31723. }
  31724. /**
  31725. * Class used for the default loading screen
  31726. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31727. */
  31728. export class DefaultLoadingScreen implements ILoadingScreen {
  31729. private _renderingCanvas;
  31730. private _loadingText;
  31731. private _loadingDivBackgroundColor;
  31732. private _loadingDiv;
  31733. private _loadingTextDiv;
  31734. /** Gets or sets the logo url to use for the default loading screen */
  31735. static DefaultLogoUrl: string;
  31736. /** Gets or sets the spinner url to use for the default loading screen */
  31737. static DefaultSpinnerUrl: string;
  31738. /**
  31739. * Creates a new default loading screen
  31740. * @param _renderingCanvas defines the canvas used to render the scene
  31741. * @param _loadingText defines the default text to display
  31742. * @param _loadingDivBackgroundColor defines the default background color
  31743. */
  31744. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31745. /**
  31746. * Function called to display the loading screen
  31747. */
  31748. displayLoadingUI(): void;
  31749. /**
  31750. * Function called to hide the loading screen
  31751. */
  31752. hideLoadingUI(): void;
  31753. /**
  31754. * Gets or sets the text to display while loading
  31755. */
  31756. loadingUIText: string;
  31757. /**
  31758. * Gets or sets the color to use for the background
  31759. */
  31760. loadingUIBackgroundColor: string;
  31761. private _resizeLoadingUI;
  31762. }
  31763. }
  31764. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31765. /**
  31766. * Interface for any object that can request an animation frame
  31767. */
  31768. export interface ICustomAnimationFrameRequester {
  31769. /**
  31770. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31771. */
  31772. renderFunction?: Function;
  31773. /**
  31774. * Called to request the next frame to render to
  31775. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31776. */
  31777. requestAnimationFrame: Function;
  31778. /**
  31779. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31780. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31781. */
  31782. requestID?: number;
  31783. }
  31784. }
  31785. declare module "babylonjs/Misc/performanceMonitor" {
  31786. /**
  31787. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31788. */
  31789. export class PerformanceMonitor {
  31790. private _enabled;
  31791. private _rollingFrameTime;
  31792. private _lastFrameTimeMs;
  31793. /**
  31794. * constructor
  31795. * @param frameSampleSize The number of samples required to saturate the sliding window
  31796. */
  31797. constructor(frameSampleSize?: number);
  31798. /**
  31799. * Samples current frame
  31800. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31801. */
  31802. sampleFrame(timeMs?: number): void;
  31803. /**
  31804. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31805. */
  31806. readonly averageFrameTime: number;
  31807. /**
  31808. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31809. */
  31810. readonly averageFrameTimeVariance: number;
  31811. /**
  31812. * Returns the frame time of the most recent frame
  31813. */
  31814. readonly instantaneousFrameTime: number;
  31815. /**
  31816. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31817. */
  31818. readonly averageFPS: number;
  31819. /**
  31820. * Returns the average framerate in frames per second using the most recent frame time
  31821. */
  31822. readonly instantaneousFPS: number;
  31823. /**
  31824. * Returns true if enough samples have been taken to completely fill the sliding window
  31825. */
  31826. readonly isSaturated: boolean;
  31827. /**
  31828. * Enables contributions to the sliding window sample set
  31829. */
  31830. enable(): void;
  31831. /**
  31832. * Disables contributions to the sliding window sample set
  31833. * Samples will not be interpolated over the disabled period
  31834. */
  31835. disable(): void;
  31836. /**
  31837. * Returns true if sampling is enabled
  31838. */
  31839. readonly isEnabled: boolean;
  31840. /**
  31841. * Resets performance monitor
  31842. */
  31843. reset(): void;
  31844. }
  31845. /**
  31846. * RollingAverage
  31847. *
  31848. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31849. */
  31850. export class RollingAverage {
  31851. /**
  31852. * Current average
  31853. */
  31854. average: number;
  31855. /**
  31856. * Current variance
  31857. */
  31858. variance: number;
  31859. protected _samples: Array<number>;
  31860. protected _sampleCount: number;
  31861. protected _pos: number;
  31862. protected _m2: number;
  31863. /**
  31864. * constructor
  31865. * @param length The number of samples required to saturate the sliding window
  31866. */
  31867. constructor(length: number);
  31868. /**
  31869. * Adds a sample to the sample set
  31870. * @param v The sample value
  31871. */
  31872. add(v: number): void;
  31873. /**
  31874. * Returns previously added values or null if outside of history or outside the sliding window domain
  31875. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31876. * @return Value previously recorded with add() or null if outside of range
  31877. */
  31878. history(i: number): number;
  31879. /**
  31880. * Returns true if enough samples have been taken to completely fill the sliding window
  31881. * @return true if sample-set saturated
  31882. */
  31883. isSaturated(): boolean;
  31884. /**
  31885. * Resets the rolling average (equivalent to 0 samples taken so far)
  31886. */
  31887. reset(): void;
  31888. /**
  31889. * Wraps a value around the sample range boundaries
  31890. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31891. * @return Wrapped position in sample range
  31892. */
  31893. protected _wrapPosition(i: number): number;
  31894. }
  31895. }
  31896. declare module "babylonjs/Misc/perfCounter" {
  31897. /**
  31898. * This class is used to track a performance counter which is number based.
  31899. * The user has access to many properties which give statistics of different nature.
  31900. *
  31901. * The implementer can track two kinds of Performance Counter: time and count.
  31902. * 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.
  31903. * 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.
  31904. */
  31905. export class PerfCounter {
  31906. /**
  31907. * Gets or sets a global boolean to turn on and off all the counters
  31908. */
  31909. static Enabled: boolean;
  31910. /**
  31911. * Returns the smallest value ever
  31912. */
  31913. readonly min: number;
  31914. /**
  31915. * Returns the biggest value ever
  31916. */
  31917. readonly max: number;
  31918. /**
  31919. * Returns the average value since the performance counter is running
  31920. */
  31921. readonly average: number;
  31922. /**
  31923. * Returns the average value of the last second the counter was monitored
  31924. */
  31925. readonly lastSecAverage: number;
  31926. /**
  31927. * Returns the current value
  31928. */
  31929. readonly current: number;
  31930. /**
  31931. * Gets the accumulated total
  31932. */
  31933. readonly total: number;
  31934. /**
  31935. * Gets the total value count
  31936. */
  31937. readonly count: number;
  31938. /**
  31939. * Creates a new counter
  31940. */
  31941. constructor();
  31942. /**
  31943. * Call this method to start monitoring a new frame.
  31944. * 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.
  31945. */
  31946. fetchNewFrame(): void;
  31947. /**
  31948. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31949. * @param newCount the count value to add to the monitored count
  31950. * @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.
  31951. */
  31952. addCount(newCount: number, fetchResult: boolean): void;
  31953. /**
  31954. * Start monitoring this performance counter
  31955. */
  31956. beginMonitoring(): void;
  31957. /**
  31958. * Compute the time lapsed since the previous beginMonitoring() call.
  31959. * @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
  31960. */
  31961. endMonitoring(newFrame?: boolean): void;
  31962. private _fetchResult;
  31963. private _startMonitoringTime;
  31964. private _min;
  31965. private _max;
  31966. private _average;
  31967. private _current;
  31968. private _totalValueCount;
  31969. private _totalAccumulated;
  31970. private _lastSecAverage;
  31971. private _lastSecAccumulated;
  31972. private _lastSecTime;
  31973. private _lastSecValueCount;
  31974. }
  31975. }
  31976. declare module "babylonjs/Engines/engine" {
  31977. import { Observable } from "babylonjs/Misc/observable";
  31978. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  31979. import { Scene } from "babylonjs/scene";
  31980. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31981. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31982. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31983. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31984. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31985. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31986. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31987. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31988. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31989. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31990. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31991. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31992. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31993. import { Material } from "babylonjs/Materials/material";
  31994. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31995. /**
  31996. * Defines the interface used by display changed events
  31997. */
  31998. export interface IDisplayChangedEventArgs {
  31999. /** Gets the vrDisplay object (if any) */
  32000. vrDisplay: Nullable<any>;
  32001. /** Gets a boolean indicating if webVR is supported */
  32002. vrSupported: boolean;
  32003. }
  32004. /**
  32005. * Defines the interface used by objects containing a viewport (like a camera)
  32006. */
  32007. interface IViewportOwnerLike {
  32008. /**
  32009. * Gets or sets the viewport
  32010. */
  32011. viewport: IViewportLike;
  32012. }
  32013. /**
  32014. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32015. */
  32016. export class Engine extends ThinEngine {
  32017. /** Defines that alpha blending is disabled */
  32018. static readonly ALPHA_DISABLE: number;
  32019. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32020. static readonly ALPHA_ADD: number;
  32021. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32022. static readonly ALPHA_COMBINE: number;
  32023. /** Defines that alpha blending to DEST - SRC * DEST */
  32024. static readonly ALPHA_SUBTRACT: number;
  32025. /** Defines that alpha blending to SRC * DEST */
  32026. static readonly ALPHA_MULTIPLY: number;
  32027. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32028. static readonly ALPHA_MAXIMIZED: number;
  32029. /** Defines that alpha blending to SRC + DEST */
  32030. static readonly ALPHA_ONEONE: number;
  32031. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32032. static readonly ALPHA_PREMULTIPLIED: number;
  32033. /**
  32034. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32035. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32036. */
  32037. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32038. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32039. static readonly ALPHA_INTERPOLATE: number;
  32040. /**
  32041. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32042. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32043. */
  32044. static readonly ALPHA_SCREENMODE: number;
  32045. /** Defines that the ressource is not delayed*/
  32046. static readonly DELAYLOADSTATE_NONE: number;
  32047. /** Defines that the ressource was successfully delay loaded */
  32048. static readonly DELAYLOADSTATE_LOADED: number;
  32049. /** Defines that the ressource is currently delay loading */
  32050. static readonly DELAYLOADSTATE_LOADING: number;
  32051. /** Defines that the ressource is delayed and has not started loading */
  32052. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32053. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32054. static readonly NEVER: number;
  32055. /** 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 */
  32056. static readonly ALWAYS: number;
  32057. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32058. static readonly LESS: number;
  32059. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32060. static readonly EQUAL: number;
  32061. /** 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 */
  32062. static readonly LEQUAL: number;
  32063. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32064. static readonly GREATER: number;
  32065. /** 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 */
  32066. static readonly GEQUAL: number;
  32067. /** 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 */
  32068. static readonly NOTEQUAL: number;
  32069. /** Passed to stencilOperation to specify that stencil value must be kept */
  32070. static readonly KEEP: number;
  32071. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32072. static readonly REPLACE: number;
  32073. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32074. static readonly INCR: number;
  32075. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32076. static readonly DECR: number;
  32077. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32078. static readonly INVERT: number;
  32079. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32080. static readonly INCR_WRAP: number;
  32081. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32082. static readonly DECR_WRAP: number;
  32083. /** Texture is not repeating outside of 0..1 UVs */
  32084. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32085. /** Texture is repeating outside of 0..1 UVs */
  32086. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32087. /** Texture is repeating and mirrored */
  32088. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32089. /** ALPHA */
  32090. static readonly TEXTUREFORMAT_ALPHA: number;
  32091. /** LUMINANCE */
  32092. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32093. /** LUMINANCE_ALPHA */
  32094. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32095. /** RGB */
  32096. static readonly TEXTUREFORMAT_RGB: number;
  32097. /** RGBA */
  32098. static readonly TEXTUREFORMAT_RGBA: number;
  32099. /** RED */
  32100. static readonly TEXTUREFORMAT_RED: number;
  32101. /** RED (2nd reference) */
  32102. static readonly TEXTUREFORMAT_R: number;
  32103. /** RG */
  32104. static readonly TEXTUREFORMAT_RG: number;
  32105. /** RED_INTEGER */
  32106. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32107. /** RED_INTEGER (2nd reference) */
  32108. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32109. /** RG_INTEGER */
  32110. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32111. /** RGB_INTEGER */
  32112. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32113. /** RGBA_INTEGER */
  32114. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32115. /** UNSIGNED_BYTE */
  32116. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32117. /** UNSIGNED_BYTE (2nd reference) */
  32118. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32119. /** FLOAT */
  32120. static readonly TEXTURETYPE_FLOAT: number;
  32121. /** HALF_FLOAT */
  32122. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32123. /** BYTE */
  32124. static readonly TEXTURETYPE_BYTE: number;
  32125. /** SHORT */
  32126. static readonly TEXTURETYPE_SHORT: number;
  32127. /** UNSIGNED_SHORT */
  32128. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32129. /** INT */
  32130. static readonly TEXTURETYPE_INT: number;
  32131. /** UNSIGNED_INT */
  32132. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32133. /** UNSIGNED_SHORT_4_4_4_4 */
  32134. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32135. /** UNSIGNED_SHORT_5_5_5_1 */
  32136. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32137. /** UNSIGNED_SHORT_5_6_5 */
  32138. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32139. /** UNSIGNED_INT_2_10_10_10_REV */
  32140. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32141. /** UNSIGNED_INT_24_8 */
  32142. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32143. /** UNSIGNED_INT_10F_11F_11F_REV */
  32144. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32145. /** UNSIGNED_INT_5_9_9_9_REV */
  32146. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32147. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32148. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32149. /** nearest is mag = nearest and min = nearest and mip = linear */
  32150. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32151. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32152. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32153. /** Trilinear is mag = linear and min = linear and mip = linear */
  32154. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32155. /** nearest is mag = nearest and min = nearest and mip = linear */
  32156. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32157. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32158. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32159. /** Trilinear is mag = linear and min = linear and mip = linear */
  32160. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32161. /** mag = nearest and min = nearest and mip = nearest */
  32162. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32163. /** mag = nearest and min = linear and mip = nearest */
  32164. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32165. /** mag = nearest and min = linear and mip = linear */
  32166. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32167. /** mag = nearest and min = linear and mip = none */
  32168. static readonly TEXTURE_NEAREST_LINEAR: number;
  32169. /** mag = nearest and min = nearest and mip = none */
  32170. static readonly TEXTURE_NEAREST_NEAREST: number;
  32171. /** mag = linear and min = nearest and mip = nearest */
  32172. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32173. /** mag = linear and min = nearest and mip = linear */
  32174. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32175. /** mag = linear and min = linear and mip = none */
  32176. static readonly TEXTURE_LINEAR_LINEAR: number;
  32177. /** mag = linear and min = nearest and mip = none */
  32178. static readonly TEXTURE_LINEAR_NEAREST: number;
  32179. /** Explicit coordinates mode */
  32180. static readonly TEXTURE_EXPLICIT_MODE: number;
  32181. /** Spherical coordinates mode */
  32182. static readonly TEXTURE_SPHERICAL_MODE: number;
  32183. /** Planar coordinates mode */
  32184. static readonly TEXTURE_PLANAR_MODE: number;
  32185. /** Cubic coordinates mode */
  32186. static readonly TEXTURE_CUBIC_MODE: number;
  32187. /** Projection coordinates mode */
  32188. static readonly TEXTURE_PROJECTION_MODE: number;
  32189. /** Skybox coordinates mode */
  32190. static readonly TEXTURE_SKYBOX_MODE: number;
  32191. /** Inverse Cubic coordinates mode */
  32192. static readonly TEXTURE_INVCUBIC_MODE: number;
  32193. /** Equirectangular coordinates mode */
  32194. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32195. /** Equirectangular Fixed coordinates mode */
  32196. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32197. /** Equirectangular Fixed Mirrored coordinates mode */
  32198. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32199. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32200. static readonly SCALEMODE_FLOOR: number;
  32201. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32202. static readonly SCALEMODE_NEAREST: number;
  32203. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32204. static readonly SCALEMODE_CEILING: number;
  32205. /**
  32206. * Returns the current npm package of the sdk
  32207. */
  32208. static readonly NpmPackage: string;
  32209. /**
  32210. * Returns the current version of the framework
  32211. */
  32212. static readonly Version: string;
  32213. /** Gets the list of created engines */
  32214. static readonly Instances: Engine[];
  32215. /**
  32216. * Gets the latest created engine
  32217. */
  32218. static readonly LastCreatedEngine: Nullable<Engine>;
  32219. /**
  32220. * Gets the latest created scene
  32221. */
  32222. static readonly LastCreatedScene: Nullable<Scene>;
  32223. /**
  32224. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32225. * @param flag defines which part of the materials must be marked as dirty
  32226. * @param predicate defines a predicate used to filter which materials should be affected
  32227. */
  32228. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32229. /**
  32230. * Method called to create the default loading screen.
  32231. * This can be overriden in your own app.
  32232. * @param canvas The rendering canvas element
  32233. * @returns The loading screen
  32234. */
  32235. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32236. /**
  32237. * Method called to create the default rescale post process on each engine.
  32238. */
  32239. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32240. /**
  32241. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32242. **/
  32243. enableOfflineSupport: boolean;
  32244. /**
  32245. * 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)
  32246. **/
  32247. disableManifestCheck: boolean;
  32248. /**
  32249. * Gets the list of created scenes
  32250. */
  32251. scenes: Scene[];
  32252. /**
  32253. * Event raised when a new scene is created
  32254. */
  32255. onNewSceneAddedObservable: Observable<Scene>;
  32256. /**
  32257. * Gets the list of created postprocesses
  32258. */
  32259. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32260. /**
  32261. * Gets a boolean indicating if the pointer is currently locked
  32262. */
  32263. isPointerLock: boolean;
  32264. /**
  32265. * Observable event triggered each time the rendering canvas is resized
  32266. */
  32267. onResizeObservable: Observable<Engine>;
  32268. /**
  32269. * Observable event triggered each time the canvas loses focus
  32270. */
  32271. onCanvasBlurObservable: Observable<Engine>;
  32272. /**
  32273. * Observable event triggered each time the canvas gains focus
  32274. */
  32275. onCanvasFocusObservable: Observable<Engine>;
  32276. /**
  32277. * Observable event triggered each time the canvas receives pointerout event
  32278. */
  32279. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32280. /**
  32281. * Observable raised when the engine begins a new frame
  32282. */
  32283. onBeginFrameObservable: Observable<Engine>;
  32284. /**
  32285. * If set, will be used to request the next animation frame for the render loop
  32286. */
  32287. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32288. /**
  32289. * Observable raised when the engine ends the current frame
  32290. */
  32291. onEndFrameObservable: Observable<Engine>;
  32292. /**
  32293. * Observable raised when the engine is about to compile a shader
  32294. */
  32295. onBeforeShaderCompilationObservable: Observable<Engine>;
  32296. /**
  32297. * Observable raised when the engine has jsut compiled a shader
  32298. */
  32299. onAfterShaderCompilationObservable: Observable<Engine>;
  32300. /**
  32301. * Gets the audio engine
  32302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32303. * @ignorenaming
  32304. */
  32305. static audioEngine: IAudioEngine;
  32306. /**
  32307. * Default AudioEngine factory responsible of creating the Audio Engine.
  32308. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32309. */
  32310. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32311. /**
  32312. * Default offline support factory responsible of creating a tool used to store data locally.
  32313. * By default, this will create a Database object if the workload has been embedded.
  32314. */
  32315. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32316. private _loadingScreen;
  32317. private _pointerLockRequested;
  32318. private _dummyFramebuffer;
  32319. private _rescalePostProcess;
  32320. /** @hidden */
  32321. protected _alphaMode: number;
  32322. /** @hidden */
  32323. protected _alphaEquation: number;
  32324. private _deterministicLockstep;
  32325. private _lockstepMaxSteps;
  32326. protected readonly _supportsHardwareTextureRescaling: boolean;
  32327. private _fps;
  32328. private _deltaTime;
  32329. /** @hidden */
  32330. _drawCalls: PerfCounter;
  32331. /**
  32332. * Turn this value on if you want to pause FPS computation when in background
  32333. */
  32334. disablePerformanceMonitorInBackground: boolean;
  32335. private _performanceMonitor;
  32336. /**
  32337. * Gets the performance monitor attached to this engine
  32338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32339. */
  32340. readonly performanceMonitor: PerformanceMonitor;
  32341. private _onFocus;
  32342. private _onBlur;
  32343. private _onCanvasPointerOut;
  32344. private _onCanvasBlur;
  32345. private _onCanvasFocus;
  32346. private _onFullscreenChange;
  32347. private _onPointerLockChange;
  32348. /**
  32349. * Gets the HTML element used to attach event listeners
  32350. * @returns a HTML element
  32351. */
  32352. getInputElement(): Nullable<HTMLElement>;
  32353. /**
  32354. * Creates a new engine
  32355. * @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
  32356. * @param antialias defines enable antialiasing (default: false)
  32357. * @param options defines further options to be sent to the getContext() function
  32358. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32359. */
  32360. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32361. /**
  32362. * Gets current aspect ratio
  32363. * @param viewportOwner defines the camera to use to get the aspect ratio
  32364. * @param useScreen defines if screen size must be used (or the current render target if any)
  32365. * @returns a number defining the aspect ratio
  32366. */
  32367. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32368. /**
  32369. * Gets current screen aspect ratio
  32370. * @returns a number defining the aspect ratio
  32371. */
  32372. getScreenAspectRatio(): number;
  32373. /**
  32374. * Gets host document
  32375. * @returns the host document object
  32376. */
  32377. getHostDocument(): Document;
  32378. /**
  32379. * Gets the client rect of the HTML canvas attached with the current webGL context
  32380. * @returns a client rectanglee
  32381. */
  32382. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32383. /**
  32384. * Gets the client rect of the HTML element used for events
  32385. * @returns a client rectanglee
  32386. */
  32387. getInputElementClientRect(): Nullable<ClientRect>;
  32388. /**
  32389. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32390. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32391. * @returns true if engine is in deterministic lock step mode
  32392. */
  32393. isDeterministicLockStep(): boolean;
  32394. /**
  32395. * Gets the max steps when engine is running in deterministic lock step
  32396. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32397. * @returns the max steps
  32398. */
  32399. getLockstepMaxSteps(): number;
  32400. /**
  32401. * Force the mipmap generation for the given render target texture
  32402. * @param texture defines the render target texture to use
  32403. */
  32404. generateMipMapsForCubemap(texture: InternalTexture): void;
  32405. /** States */
  32406. /**
  32407. * Set various states to the webGL context
  32408. * @param culling defines backface culling state
  32409. * @param zOffset defines the value to apply to zOffset (0 by default)
  32410. * @param force defines if states must be applied even if cache is up to date
  32411. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32412. */
  32413. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32414. /**
  32415. * Set the z offset to apply to current rendering
  32416. * @param value defines the offset to apply
  32417. */
  32418. setZOffset(value: number): void;
  32419. /**
  32420. * Gets the current value of the zOffset
  32421. * @returns the current zOffset state
  32422. */
  32423. getZOffset(): number;
  32424. /**
  32425. * Enable or disable depth buffering
  32426. * @param enable defines the state to set
  32427. */
  32428. setDepthBuffer(enable: boolean): void;
  32429. /**
  32430. * Gets a boolean indicating if depth writing is enabled
  32431. * @returns the current depth writing state
  32432. */
  32433. getDepthWrite(): boolean;
  32434. /**
  32435. * Enable or disable depth writing
  32436. * @param enable defines the state to set
  32437. */
  32438. setDepthWrite(enable: boolean): void;
  32439. /**
  32440. * Enable or disable color writing
  32441. * @param enable defines the state to set
  32442. */
  32443. setColorWrite(enable: boolean): void;
  32444. /**
  32445. * Gets a boolean indicating if color writing is enabled
  32446. * @returns the current color writing state
  32447. */
  32448. getColorWrite(): boolean;
  32449. /**
  32450. * Sets alpha constants used by some alpha blending modes
  32451. * @param r defines the red component
  32452. * @param g defines the green component
  32453. * @param b defines the blue component
  32454. * @param a defines the alpha component
  32455. */
  32456. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32457. /**
  32458. * Sets the current alpha mode
  32459. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32460. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32461. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32462. */
  32463. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32464. /**
  32465. * Gets the current alpha mode
  32466. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32467. * @returns the current alpha mode
  32468. */
  32469. getAlphaMode(): number;
  32470. /**
  32471. * Sets the current alpha equation
  32472. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32473. */
  32474. setAlphaEquation(equation: number): void;
  32475. /**
  32476. * Gets the current alpha equation.
  32477. * @returns the current alpha equation
  32478. */
  32479. getAlphaEquation(): number;
  32480. /**
  32481. * Gets a boolean indicating if stencil buffer is enabled
  32482. * @returns the current stencil buffer state
  32483. */
  32484. getStencilBuffer(): boolean;
  32485. /**
  32486. * Enable or disable the stencil buffer
  32487. * @param enable defines if the stencil buffer must be enabled or disabled
  32488. */
  32489. setStencilBuffer(enable: boolean): void;
  32490. /**
  32491. * Gets the current stencil mask
  32492. * @returns a number defining the new stencil mask to use
  32493. */
  32494. getStencilMask(): number;
  32495. /**
  32496. * Sets the current stencil mask
  32497. * @param mask defines the new stencil mask to use
  32498. */
  32499. setStencilMask(mask: number): void;
  32500. /**
  32501. * Gets the current stencil function
  32502. * @returns a number defining the stencil function to use
  32503. */
  32504. getStencilFunction(): number;
  32505. /**
  32506. * Gets the current stencil reference value
  32507. * @returns a number defining the stencil reference value to use
  32508. */
  32509. getStencilFunctionReference(): number;
  32510. /**
  32511. * Gets the current stencil mask
  32512. * @returns a number defining the stencil mask to use
  32513. */
  32514. getStencilFunctionMask(): number;
  32515. /**
  32516. * Sets the current stencil function
  32517. * @param stencilFunc defines the new stencil function to use
  32518. */
  32519. setStencilFunction(stencilFunc: number): void;
  32520. /**
  32521. * Sets the current stencil reference
  32522. * @param reference defines the new stencil reference to use
  32523. */
  32524. setStencilFunctionReference(reference: number): void;
  32525. /**
  32526. * Sets the current stencil mask
  32527. * @param mask defines the new stencil mask to use
  32528. */
  32529. setStencilFunctionMask(mask: number): void;
  32530. /**
  32531. * Gets the current stencil operation when stencil fails
  32532. * @returns a number defining stencil operation to use when stencil fails
  32533. */
  32534. getStencilOperationFail(): number;
  32535. /**
  32536. * Gets the current stencil operation when depth fails
  32537. * @returns a number defining stencil operation to use when depth fails
  32538. */
  32539. getStencilOperationDepthFail(): number;
  32540. /**
  32541. * Gets the current stencil operation when stencil passes
  32542. * @returns a number defining stencil operation to use when stencil passes
  32543. */
  32544. getStencilOperationPass(): number;
  32545. /**
  32546. * Sets the stencil operation to use when stencil fails
  32547. * @param operation defines the stencil operation to use when stencil fails
  32548. */
  32549. setStencilOperationFail(operation: number): void;
  32550. /**
  32551. * Sets the stencil operation to use when depth fails
  32552. * @param operation defines the stencil operation to use when depth fails
  32553. */
  32554. setStencilOperationDepthFail(operation: number): void;
  32555. /**
  32556. * Sets the stencil operation to use when stencil passes
  32557. * @param operation defines the stencil operation to use when stencil passes
  32558. */
  32559. setStencilOperationPass(operation: number): void;
  32560. /**
  32561. * Sets a boolean indicating if the dithering state is enabled or disabled
  32562. * @param value defines the dithering state
  32563. */
  32564. setDitheringState(value: boolean): void;
  32565. /**
  32566. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32567. * @param value defines the rasterizer state
  32568. */
  32569. setRasterizerState(value: boolean): void;
  32570. /**
  32571. * Gets the current depth function
  32572. * @returns a number defining the depth function
  32573. */
  32574. getDepthFunction(): Nullable<number>;
  32575. /**
  32576. * Sets the current depth function
  32577. * @param depthFunc defines the function to use
  32578. */
  32579. setDepthFunction(depthFunc: number): void;
  32580. /**
  32581. * Sets the current depth function to GREATER
  32582. */
  32583. setDepthFunctionToGreater(): void;
  32584. /**
  32585. * Sets the current depth function to GEQUAL
  32586. */
  32587. setDepthFunctionToGreaterOrEqual(): void;
  32588. /**
  32589. * Sets the current depth function to LESS
  32590. */
  32591. setDepthFunctionToLess(): void;
  32592. /**
  32593. * Sets the current depth function to LEQUAL
  32594. */
  32595. setDepthFunctionToLessOrEqual(): void;
  32596. private _cachedStencilBuffer;
  32597. private _cachedStencilFunction;
  32598. private _cachedStencilMask;
  32599. private _cachedStencilOperationPass;
  32600. private _cachedStencilOperationFail;
  32601. private _cachedStencilOperationDepthFail;
  32602. private _cachedStencilReference;
  32603. /**
  32604. * Caches the the state of the stencil buffer
  32605. */
  32606. cacheStencilState(): void;
  32607. /**
  32608. * Restores the state of the stencil buffer
  32609. */
  32610. restoreStencilState(): void;
  32611. /**
  32612. * Directly set the WebGL Viewport
  32613. * @param x defines the x coordinate of the viewport (in screen space)
  32614. * @param y defines the y coordinate of the viewport (in screen space)
  32615. * @param width defines the width of the viewport (in screen space)
  32616. * @param height defines the height of the viewport (in screen space)
  32617. * @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
  32618. */
  32619. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32620. /**
  32621. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32622. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32623. * @param y defines the y-coordinate of the corner of the clear rectangle
  32624. * @param width defines the width of the clear rectangle
  32625. * @param height defines the height of the clear rectangle
  32626. * @param clearColor defines the clear color
  32627. */
  32628. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32629. /**
  32630. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32631. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32632. * @param y defines the y-coordinate of the corner of the clear rectangle
  32633. * @param width defines the width of the clear rectangle
  32634. * @param height defines the height of the clear rectangle
  32635. */
  32636. enableScissor(x: number, y: number, width: number, height: number): void;
  32637. /**
  32638. * Disable previously set scissor test rectangle
  32639. */
  32640. disableScissor(): void;
  32641. protected _reportDrawCall(): void;
  32642. /**
  32643. * Initializes a webVR display and starts listening to display change events
  32644. * The onVRDisplayChangedObservable will be notified upon these changes
  32645. * @returns The onVRDisplayChangedObservable
  32646. */
  32647. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32648. /** @hidden */
  32649. _prepareVRComponent(): void;
  32650. /** @hidden */
  32651. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32652. /** @hidden */
  32653. _submitVRFrame(): void;
  32654. /**
  32655. * Call this function to leave webVR mode
  32656. * Will do nothing if webVR is not supported or if there is no webVR device
  32657. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32658. */
  32659. disableVR(): void;
  32660. /**
  32661. * Gets a boolean indicating that the system is in VR mode and is presenting
  32662. * @returns true if VR mode is engaged
  32663. */
  32664. isVRPresenting(): boolean;
  32665. /** @hidden */
  32666. _requestVRFrame(): void;
  32667. /** @hidden */
  32668. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32669. /**
  32670. * Gets the source code of the vertex shader associated with a specific webGL program
  32671. * @param program defines the program to use
  32672. * @returns a string containing the source code of the vertex shader associated with the program
  32673. */
  32674. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32675. /**
  32676. * Gets the source code of the fragment shader associated with a specific webGL program
  32677. * @param program defines the program to use
  32678. * @returns a string containing the source code of the fragment shader associated with the program
  32679. */
  32680. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32681. /**
  32682. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32683. * @param x defines the x coordinate of the rectangle where pixels must be read
  32684. * @param y defines the y coordinate of the rectangle where pixels must be read
  32685. * @param width defines the width of the rectangle where pixels must be read
  32686. * @param height defines the height of the rectangle where pixels must be read
  32687. * @returns a Uint8Array containing RGBA colors
  32688. */
  32689. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32690. /**
  32691. * Sets a depth stencil texture from a render target to the according uniform.
  32692. * @param channel The texture channel
  32693. * @param uniform The uniform to set
  32694. * @param texture The render target texture containing the depth stencil texture to apply
  32695. */
  32696. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32697. /**
  32698. * Sets a texture to the webGL context from a postprocess
  32699. * @param channel defines the channel to use
  32700. * @param postProcess defines the source postprocess
  32701. */
  32702. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32703. /**
  32704. * Binds the output of the passed in post process to the texture channel specified
  32705. * @param channel The channel the texture should be bound to
  32706. * @param postProcess The post process which's output should be bound
  32707. */
  32708. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32709. /** @hidden */
  32710. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32711. protected _rebuildBuffers(): void;
  32712. /** @hidden */
  32713. _renderFrame(): void;
  32714. _renderLoop(): void;
  32715. /** @hidden */
  32716. _renderViews(): boolean;
  32717. /**
  32718. * Toggle full screen mode
  32719. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32720. */
  32721. switchFullscreen(requestPointerLock: boolean): void;
  32722. /**
  32723. * Enters full screen mode
  32724. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32725. */
  32726. enterFullscreen(requestPointerLock: boolean): void;
  32727. /**
  32728. * Exits full screen mode
  32729. */
  32730. exitFullscreen(): void;
  32731. /**
  32732. * Enters Pointerlock mode
  32733. */
  32734. enterPointerlock(): void;
  32735. /**
  32736. * Exits Pointerlock mode
  32737. */
  32738. exitPointerlock(): void;
  32739. /**
  32740. * Begin a new frame
  32741. */
  32742. beginFrame(): void;
  32743. /**
  32744. * Enf the current frame
  32745. */
  32746. endFrame(): void;
  32747. resize(): void;
  32748. /**
  32749. * Set the compressed texture format to use, based on the formats you have, and the formats
  32750. * supported by the hardware / browser.
  32751. *
  32752. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32753. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32754. * to API arguments needed to compressed textures. This puts the burden on the container
  32755. * generator to house the arcane code for determining these for current & future formats.
  32756. *
  32757. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32758. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32759. *
  32760. * Note: The result of this call is not taken into account when a texture is base64.
  32761. *
  32762. * @param formatsAvailable defines the list of those format families you have created
  32763. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32764. *
  32765. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32766. * @returns The extension selected.
  32767. */
  32768. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32769. /**
  32770. * Force a specific size of the canvas
  32771. * @param width defines the new canvas' width
  32772. * @param height defines the new canvas' height
  32773. */
  32774. setSize(width: number, height: number): void;
  32775. /**
  32776. * Updates a dynamic vertex buffer.
  32777. * @param vertexBuffer the vertex buffer to update
  32778. * @param data the data used to update the vertex buffer
  32779. * @param byteOffset the byte offset of the data
  32780. * @param byteLength the byte length of the data
  32781. */
  32782. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32783. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32784. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32785. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32786. _releaseTexture(texture: InternalTexture): void;
  32787. /**
  32788. * @hidden
  32789. * Rescales a texture
  32790. * @param source input texutre
  32791. * @param destination destination texture
  32792. * @param scene scene to use to render the resize
  32793. * @param internalFormat format to use when resizing
  32794. * @param onComplete callback to be called when resize has completed
  32795. */
  32796. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32797. /**
  32798. * Gets the current framerate
  32799. * @returns a number representing the framerate
  32800. */
  32801. getFps(): number;
  32802. /**
  32803. * Gets the time spent between current and previous frame
  32804. * @returns a number representing the delta time in ms
  32805. */
  32806. getDeltaTime(): number;
  32807. private _measureFps;
  32808. /** @hidden */
  32809. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32810. /**
  32811. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32812. * @param renderTarget The render target to set the frame buffer for
  32813. */
  32814. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32815. /**
  32816. * Update a dynamic index buffer
  32817. * @param indexBuffer defines the target index buffer
  32818. * @param indices defines the data to update
  32819. * @param offset defines the offset in the target index buffer where update should start
  32820. */
  32821. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32822. /**
  32823. * Updates the sample count of a render target texture
  32824. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32825. * @param texture defines the texture to update
  32826. * @param samples defines the sample count to set
  32827. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32828. */
  32829. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32830. /**
  32831. * Updates a depth texture Comparison Mode and Function.
  32832. * If the comparison Function is equal to 0, the mode will be set to none.
  32833. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32834. * @param texture The texture to set the comparison function for
  32835. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32836. */
  32837. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32838. /**
  32839. * Creates a webGL buffer to use with instanciation
  32840. * @param capacity defines the size of the buffer
  32841. * @returns the webGL buffer
  32842. */
  32843. createInstancesBuffer(capacity: number): DataBuffer;
  32844. /**
  32845. * Delete a webGL buffer used with instanciation
  32846. * @param buffer defines the webGL buffer to delete
  32847. */
  32848. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32849. /** @hidden */
  32850. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32851. dispose(): void;
  32852. private _disableTouchAction;
  32853. /**
  32854. * Display the loading screen
  32855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32856. */
  32857. displayLoadingUI(): void;
  32858. /**
  32859. * Hide the loading screen
  32860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32861. */
  32862. hideLoadingUI(): void;
  32863. /**
  32864. * Gets the current loading screen object
  32865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32866. */
  32867. /**
  32868. * Sets the current loading screen object
  32869. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32870. */
  32871. loadingScreen: ILoadingScreen;
  32872. /**
  32873. * Sets the current loading screen text
  32874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32875. */
  32876. loadingUIText: string;
  32877. /**
  32878. * Sets the current loading screen background color
  32879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32880. */
  32881. loadingUIBackgroundColor: string;
  32882. /** Pointerlock and fullscreen */
  32883. /**
  32884. * Ask the browser to promote the current element to pointerlock mode
  32885. * @param element defines the DOM element to promote
  32886. */
  32887. static _RequestPointerlock(element: HTMLElement): void;
  32888. /**
  32889. * Asks the browser to exit pointerlock mode
  32890. */
  32891. static _ExitPointerlock(): void;
  32892. /**
  32893. * Ask the browser to promote the current element to fullscreen rendering mode
  32894. * @param element defines the DOM element to promote
  32895. */
  32896. static _RequestFullscreen(element: HTMLElement): void;
  32897. /**
  32898. * Asks the browser to exit fullscreen mode
  32899. */
  32900. static _ExitFullscreen(): void;
  32901. }
  32902. }
  32903. declare module "babylonjs/Engines/engineStore" {
  32904. import { Nullable } from "babylonjs/types";
  32905. import { Engine } from "babylonjs/Engines/engine";
  32906. import { Scene } from "babylonjs/scene";
  32907. /**
  32908. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32909. * during the life time of the application.
  32910. */
  32911. export class EngineStore {
  32912. /** Gets the list of created engines */
  32913. static Instances: import("babylonjs/Engines/engine").Engine[];
  32914. /** @hidden */
  32915. static _LastCreatedScene: Nullable<Scene>;
  32916. /**
  32917. * Gets the latest created engine
  32918. */
  32919. static readonly LastCreatedEngine: Nullable<Engine>;
  32920. /**
  32921. * Gets the latest created scene
  32922. */
  32923. static readonly LastCreatedScene: Nullable<Scene>;
  32924. /**
  32925. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32926. * @ignorenaming
  32927. */
  32928. static UseFallbackTexture: boolean;
  32929. /**
  32930. * Texture content used if a texture cannot loaded
  32931. * @ignorenaming
  32932. */
  32933. static FallbackTexture: string;
  32934. }
  32935. }
  32936. declare module "babylonjs/Misc/promise" {
  32937. /**
  32938. * Helper class that provides a small promise polyfill
  32939. */
  32940. export class PromisePolyfill {
  32941. /**
  32942. * Static function used to check if the polyfill is required
  32943. * If this is the case then the function will inject the polyfill to window.Promise
  32944. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32945. */
  32946. static Apply(force?: boolean): void;
  32947. }
  32948. }
  32949. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32950. /**
  32951. * Interface for screenshot methods with describe argument called `size` as object with options
  32952. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32953. */
  32954. export interface IScreenshotSize {
  32955. /**
  32956. * number in pixels for canvas height
  32957. */
  32958. height?: number;
  32959. /**
  32960. * multiplier allowing render at a higher or lower resolution
  32961. * If value is defined then height and width will be ignored and taken from camera
  32962. */
  32963. precision?: number;
  32964. /**
  32965. * number in pixels for canvas width
  32966. */
  32967. width?: number;
  32968. }
  32969. }
  32970. declare module "babylonjs/Misc/tools" {
  32971. import { Nullable, float } from "babylonjs/types";
  32972. import { DomManagement } from "babylonjs/Misc/domManagement";
  32973. import { WebRequest } from "babylonjs/Misc/webRequest";
  32974. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32975. import { ReadFileError } from "babylonjs/Misc/fileTools";
  32976. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32977. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32978. import { Camera } from "babylonjs/Cameras/camera";
  32979. import { Engine } from "babylonjs/Engines/engine";
  32980. interface IColor4Like {
  32981. r: float;
  32982. g: float;
  32983. b: float;
  32984. a: float;
  32985. }
  32986. /**
  32987. * Class containing a set of static utilities functions
  32988. */
  32989. export class Tools {
  32990. /**
  32991. * Gets or sets the base URL to use to load assets
  32992. */
  32993. static BaseUrl: string;
  32994. /**
  32995. * Enable/Disable Custom HTTP Request Headers globally.
  32996. * default = false
  32997. * @see CustomRequestHeaders
  32998. */
  32999. static UseCustomRequestHeaders: boolean;
  33000. /**
  33001. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33002. * i.e. when loading files, where the server/service expects an Authorization header
  33003. */
  33004. static CustomRequestHeaders: {
  33005. [key: string]: string;
  33006. };
  33007. /**
  33008. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33009. */
  33010. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33011. /**
  33012. * Default behaviour for cors in the application.
  33013. * It can be a string if the expected behavior is identical in the entire app.
  33014. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33015. */
  33016. static CorsBehavior: string | ((url: string | string[]) => string);
  33017. /**
  33018. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33019. * @ignorenaming
  33020. */
  33021. static UseFallbackTexture: boolean;
  33022. /**
  33023. * Use this object to register external classes like custom textures or material
  33024. * to allow the laoders to instantiate them
  33025. */
  33026. static RegisteredExternalClasses: {
  33027. [key: string]: Object;
  33028. };
  33029. /**
  33030. * Texture content used if a texture cannot loaded
  33031. * @ignorenaming
  33032. */
  33033. static fallbackTexture: string;
  33034. /**
  33035. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33036. * @param u defines the coordinate on X axis
  33037. * @param v defines the coordinate on Y axis
  33038. * @param width defines the width of the source data
  33039. * @param height defines the height of the source data
  33040. * @param pixels defines the source byte array
  33041. * @param color defines the output color
  33042. */
  33043. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33044. /**
  33045. * Interpolates between a and b via alpha
  33046. * @param a The lower value (returned when alpha = 0)
  33047. * @param b The upper value (returned when alpha = 1)
  33048. * @param alpha The interpolation-factor
  33049. * @return The mixed value
  33050. */
  33051. static Mix(a: number, b: number, alpha: number): number;
  33052. /**
  33053. * Tries to instantiate a new object from a given class name
  33054. * @param className defines the class name to instantiate
  33055. * @returns the new object or null if the system was not able to do the instantiation
  33056. */
  33057. static Instantiate(className: string): any;
  33058. /**
  33059. * Provides a slice function that will work even on IE
  33060. * @param data defines the array to slice
  33061. * @param start defines the start of the data (optional)
  33062. * @param end defines the end of the data (optional)
  33063. * @returns the new sliced array
  33064. */
  33065. static Slice<T>(data: T, start?: number, end?: number): T;
  33066. /**
  33067. * Polyfill for setImmediate
  33068. * @param action defines the action to execute after the current execution block
  33069. */
  33070. static SetImmediate(action: () => void): void;
  33071. /**
  33072. * Function indicating if a number is an exponent of 2
  33073. * @param value defines the value to test
  33074. * @returns true if the value is an exponent of 2
  33075. */
  33076. static IsExponentOfTwo(value: number): boolean;
  33077. private static _tmpFloatArray;
  33078. /**
  33079. * Returns the nearest 32-bit single precision float representation of a Number
  33080. * @param value A Number. If the parameter is of a different type, it will get converted
  33081. * to a number or to NaN if it cannot be converted
  33082. * @returns number
  33083. */
  33084. static FloatRound(value: number): number;
  33085. /**
  33086. * Extracts the filename from a path
  33087. * @param path defines the path to use
  33088. * @returns the filename
  33089. */
  33090. static GetFilename(path: string): string;
  33091. /**
  33092. * Extracts the "folder" part of a path (everything before the filename).
  33093. * @param uri The URI to extract the info from
  33094. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33095. * @returns The "folder" part of the path
  33096. */
  33097. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33098. /**
  33099. * Extracts text content from a DOM element hierarchy
  33100. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33101. */
  33102. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33103. /**
  33104. * Convert an angle in radians to degrees
  33105. * @param angle defines the angle to convert
  33106. * @returns the angle in degrees
  33107. */
  33108. static ToDegrees(angle: number): number;
  33109. /**
  33110. * Convert an angle in degrees to radians
  33111. * @param angle defines the angle to convert
  33112. * @returns the angle in radians
  33113. */
  33114. static ToRadians(angle: number): number;
  33115. /**
  33116. * Returns an array if obj is not an array
  33117. * @param obj defines the object to evaluate as an array
  33118. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33119. * @returns either obj directly if obj is an array or a new array containing obj
  33120. */
  33121. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33122. /**
  33123. * Gets the pointer prefix to use
  33124. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33125. */
  33126. static GetPointerPrefix(): string;
  33127. /**
  33128. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33129. * @param url define the url we are trying
  33130. * @param element define the dom element where to configure the cors policy
  33131. */
  33132. static SetCorsBehavior(url: string | string[], element: {
  33133. crossOrigin: string | null;
  33134. }): void;
  33135. /**
  33136. * Removes unwanted characters from an url
  33137. * @param url defines the url to clean
  33138. * @returns the cleaned url
  33139. */
  33140. static CleanUrl(url: string): string;
  33141. /**
  33142. * Gets or sets a function used to pre-process url before using them to load assets
  33143. */
  33144. static PreprocessUrl: (url: string) => string;
  33145. /**
  33146. * Loads an image as an HTMLImageElement.
  33147. * @param input url string, ArrayBuffer, or Blob to load
  33148. * @param onLoad callback called when the image successfully loads
  33149. * @param onError callback called when the image fails to load
  33150. * @param offlineProvider offline provider for caching
  33151. * @param mimeType optional mime type
  33152. * @returns the HTMLImageElement of the loaded image
  33153. */
  33154. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33155. /**
  33156. * Loads a file from a url
  33157. * @param url url string, ArrayBuffer, or Blob to load
  33158. * @param onSuccess callback called when the file successfully loads
  33159. * @param onProgress callback called while file is loading (if the server supports this mode)
  33160. * @param offlineProvider defines the offline provider for caching
  33161. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33162. * @param onError callback called when the file fails to load
  33163. * @returns a file request object
  33164. */
  33165. 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;
  33166. /**
  33167. * Loads a file from a url
  33168. * @param url the file url to load
  33169. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33170. */
  33171. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33172. /**
  33173. * Load a script (identified by an url). When the url returns, the
  33174. * content of this file is added into a new script element, attached to the DOM (body element)
  33175. * @param scriptUrl defines the url of the script to laod
  33176. * @param onSuccess defines the callback called when the script is loaded
  33177. * @param onError defines the callback to call if an error occurs
  33178. * @param scriptId defines the id of the script element
  33179. */
  33180. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33181. /**
  33182. * Load an asynchronous script (identified by an url). When the url returns, the
  33183. * content of this file is added into a new script element, attached to the DOM (body element)
  33184. * @param scriptUrl defines the url of the script to laod
  33185. * @param scriptId defines the id of the script element
  33186. * @returns a promise request object
  33187. */
  33188. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33189. /**
  33190. * Loads a file from a blob
  33191. * @param fileToLoad defines the blob to use
  33192. * @param callback defines the callback to call when data is loaded
  33193. * @param progressCallback defines the callback to call during loading process
  33194. * @returns a file request object
  33195. */
  33196. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33197. /**
  33198. * Reads a file from a File object
  33199. * @param file defines the file to load
  33200. * @param onSuccess defines the callback to call when data is loaded
  33201. * @param onProgress defines the callback to call during loading process
  33202. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33203. * @param onError defines the callback to call when an error occurs
  33204. * @returns a file request object
  33205. */
  33206. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33207. /**
  33208. * Creates a data url from a given string content
  33209. * @param content defines the content to convert
  33210. * @returns the new data url link
  33211. */
  33212. static FileAsURL(content: string): string;
  33213. /**
  33214. * Format the given number to a specific decimal format
  33215. * @param value defines the number to format
  33216. * @param decimals defines the number of decimals to use
  33217. * @returns the formatted string
  33218. */
  33219. static Format(value: number, decimals?: number): string;
  33220. /**
  33221. * Tries to copy an object by duplicating every property
  33222. * @param source defines the source object
  33223. * @param destination defines the target object
  33224. * @param doNotCopyList defines a list of properties to avoid
  33225. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33226. */
  33227. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33228. /**
  33229. * Gets a boolean indicating if the given object has no own property
  33230. * @param obj defines the object to test
  33231. * @returns true if object has no own property
  33232. */
  33233. static IsEmpty(obj: any): boolean;
  33234. /**
  33235. * Function used to register events at window level
  33236. * @param windowElement defines the Window object to use
  33237. * @param events defines the events to register
  33238. */
  33239. static RegisterTopRootEvents(windowElement: Window, events: {
  33240. name: string;
  33241. handler: Nullable<(e: FocusEvent) => any>;
  33242. }[]): void;
  33243. /**
  33244. * Function used to unregister events from window level
  33245. * @param windowElement defines the Window object to use
  33246. * @param events defines the events to unregister
  33247. */
  33248. static UnregisterTopRootEvents(windowElement: Window, events: {
  33249. name: string;
  33250. handler: Nullable<(e: FocusEvent) => any>;
  33251. }[]): void;
  33252. /**
  33253. * @ignore
  33254. */
  33255. static _ScreenshotCanvas: HTMLCanvasElement;
  33256. /**
  33257. * Dumps the current bound framebuffer
  33258. * @param width defines the rendering width
  33259. * @param height defines the rendering height
  33260. * @param engine defines the hosting engine
  33261. * @param successCallback defines the callback triggered once the data are available
  33262. * @param mimeType defines the mime type of the result
  33263. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33264. */
  33265. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33266. /**
  33267. * Converts the canvas data to blob.
  33268. * This acts as a polyfill for browsers not supporting the to blob function.
  33269. * @param canvas Defines the canvas to extract the data from
  33270. * @param successCallback Defines the callback triggered once the data are available
  33271. * @param mimeType Defines the mime type of the result
  33272. */
  33273. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33274. /**
  33275. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33276. * @param successCallback defines the callback triggered once the data are available
  33277. * @param mimeType defines the mime type of the result
  33278. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33279. */
  33280. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33281. /**
  33282. * Downloads a blob in the browser
  33283. * @param blob defines the blob to download
  33284. * @param fileName defines the name of the downloaded file
  33285. */
  33286. static Download(blob: Blob, fileName: string): void;
  33287. /**
  33288. * Captures a screenshot of the current rendering
  33289. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33290. * @param engine defines the rendering engine
  33291. * @param camera defines the source camera
  33292. * @param size This parameter can be set to a single number or to an object with the
  33293. * following (optional) properties: precision, width, height. If a single number is passed,
  33294. * it will be used for both width and height. If an object is passed, the screenshot size
  33295. * will be derived from the parameters. The precision property is a multiplier allowing
  33296. * rendering at a higher or lower resolution
  33297. * @param successCallback defines the callback receives a single parameter which contains the
  33298. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33299. * src parameter of an <img> to display it
  33300. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33301. * Check your browser for supported MIME types
  33302. */
  33303. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33304. /**
  33305. * Captures a screenshot of the current rendering
  33306. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33307. * @param engine defines the rendering engine
  33308. * @param camera defines the source camera
  33309. * @param size This parameter can be set to a single number or to an object with the
  33310. * following (optional) properties: precision, width, height. If a single number is passed,
  33311. * it will be used for both width and height. If an object is passed, the screenshot size
  33312. * will be derived from the parameters. The precision property is a multiplier allowing
  33313. * rendering at a higher or lower resolution
  33314. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33315. * Check your browser for supported MIME types
  33316. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33317. * to the src parameter of an <img> to display it
  33318. */
  33319. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33320. /**
  33321. * Generates an image screenshot from the specified camera.
  33322. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33323. * @param engine The engine to use for rendering
  33324. * @param camera The camera to use for rendering
  33325. * @param size This parameter can be set to a single number or to an object with the
  33326. * following (optional) properties: precision, width, height. If a single number is passed,
  33327. * it will be used for both width and height. If an object is passed, the screenshot size
  33328. * will be derived from the parameters. The precision property is a multiplier allowing
  33329. * rendering at a higher or lower resolution
  33330. * @param successCallback The callback receives a single parameter which contains the
  33331. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33332. * src parameter of an <img> to display it
  33333. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33334. * Check your browser for supported MIME types
  33335. * @param samples Texture samples (default: 1)
  33336. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33337. * @param fileName A name for for the downloaded file.
  33338. */
  33339. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33340. /**
  33341. * Generates an image screenshot from the specified camera.
  33342. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33343. * @param engine The engine to use for rendering
  33344. * @param camera The camera to use for rendering
  33345. * @param size This parameter can be set to a single number or to an object with the
  33346. * following (optional) properties: precision, width, height. If a single number is passed,
  33347. * it will be used for both width and height. If an object is passed, the screenshot size
  33348. * will be derived from the parameters. The precision property is a multiplier allowing
  33349. * rendering at a higher or lower resolution
  33350. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33351. * Check your browser for supported MIME types
  33352. * @param samples Texture samples (default: 1)
  33353. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33354. * @param fileName A name for for the downloaded file.
  33355. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33356. * to the src parameter of an <img> to display it
  33357. */
  33358. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33359. /**
  33360. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33361. * Be aware Math.random() could cause collisions, but:
  33362. * "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"
  33363. * @returns a pseudo random id
  33364. */
  33365. static RandomId(): string;
  33366. /**
  33367. * Test if the given uri is a base64 string
  33368. * @param uri The uri to test
  33369. * @return True if the uri is a base64 string or false otherwise
  33370. */
  33371. static IsBase64(uri: string): boolean;
  33372. /**
  33373. * Decode the given base64 uri.
  33374. * @param uri The uri to decode
  33375. * @return The decoded base64 data.
  33376. */
  33377. static DecodeBase64(uri: string): ArrayBuffer;
  33378. /**
  33379. * Gets the absolute url.
  33380. * @param url the input url
  33381. * @return the absolute url
  33382. */
  33383. static GetAbsoluteUrl(url: string): string;
  33384. /**
  33385. * No log
  33386. */
  33387. static readonly NoneLogLevel: number;
  33388. /**
  33389. * Only message logs
  33390. */
  33391. static readonly MessageLogLevel: number;
  33392. /**
  33393. * Only warning logs
  33394. */
  33395. static readonly WarningLogLevel: number;
  33396. /**
  33397. * Only error logs
  33398. */
  33399. static readonly ErrorLogLevel: number;
  33400. /**
  33401. * All logs
  33402. */
  33403. static readonly AllLogLevel: number;
  33404. /**
  33405. * Gets a value indicating the number of loading errors
  33406. * @ignorenaming
  33407. */
  33408. static readonly errorsCount: number;
  33409. /**
  33410. * Callback called when a new log is added
  33411. */
  33412. static OnNewCacheEntry: (entry: string) => void;
  33413. /**
  33414. * Log a message to the console
  33415. * @param message defines the message to log
  33416. */
  33417. static Log(message: string): void;
  33418. /**
  33419. * Write a warning message to the console
  33420. * @param message defines the message to log
  33421. */
  33422. static Warn(message: string): void;
  33423. /**
  33424. * Write an error message to the console
  33425. * @param message defines the message to log
  33426. */
  33427. static Error(message: string): void;
  33428. /**
  33429. * Gets current log cache (list of logs)
  33430. */
  33431. static readonly LogCache: string;
  33432. /**
  33433. * Clears the log cache
  33434. */
  33435. static ClearLogCache(): void;
  33436. /**
  33437. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33438. */
  33439. static LogLevels: number;
  33440. /**
  33441. * Checks if the window object exists
  33442. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33443. */
  33444. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33445. /**
  33446. * No performance log
  33447. */
  33448. static readonly PerformanceNoneLogLevel: number;
  33449. /**
  33450. * Use user marks to log performance
  33451. */
  33452. static readonly PerformanceUserMarkLogLevel: number;
  33453. /**
  33454. * Log performance to the console
  33455. */
  33456. static readonly PerformanceConsoleLogLevel: number;
  33457. private static _performance;
  33458. /**
  33459. * Sets the current performance log level
  33460. */
  33461. static PerformanceLogLevel: number;
  33462. private static _StartPerformanceCounterDisabled;
  33463. private static _EndPerformanceCounterDisabled;
  33464. private static _StartUserMark;
  33465. private static _EndUserMark;
  33466. private static _StartPerformanceConsole;
  33467. private static _EndPerformanceConsole;
  33468. /**
  33469. * Starts a performance counter
  33470. */
  33471. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33472. /**
  33473. * Ends a specific performance coutner
  33474. */
  33475. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33476. /**
  33477. * Gets either window.performance.now() if supported or Date.now() else
  33478. */
  33479. static readonly Now: number;
  33480. /**
  33481. * This method will return the name of the class used to create the instance of the given object.
  33482. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33483. * @param object the object to get the class name from
  33484. * @param isType defines if the object is actually a type
  33485. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33486. */
  33487. static GetClassName(object: any, isType?: boolean): string;
  33488. /**
  33489. * Gets the first element of an array satisfying a given predicate
  33490. * @param array defines the array to browse
  33491. * @param predicate defines the predicate to use
  33492. * @returns null if not found or the element
  33493. */
  33494. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33495. /**
  33496. * This method will return the name of the full name of the class, including its owning module (if any).
  33497. * 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).
  33498. * @param object the object to get the class name from
  33499. * @param isType defines if the object is actually a type
  33500. * @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.
  33501. * @ignorenaming
  33502. */
  33503. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33504. /**
  33505. * Returns a promise that resolves after the given amount of time.
  33506. * @param delay Number of milliseconds to delay
  33507. * @returns Promise that resolves after the given amount of time
  33508. */
  33509. static DelayAsync(delay: number): Promise<void>;
  33510. }
  33511. /**
  33512. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33513. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33514. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33515. * @param name The name of the class, case should be preserved
  33516. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33517. */
  33518. export function className(name: string, module?: string): (target: Object) => void;
  33519. /**
  33520. * An implementation of a loop for asynchronous functions.
  33521. */
  33522. export class AsyncLoop {
  33523. /**
  33524. * Defines the number of iterations for the loop
  33525. */
  33526. iterations: number;
  33527. /**
  33528. * Defines the current index of the loop.
  33529. */
  33530. index: number;
  33531. private _done;
  33532. private _fn;
  33533. private _successCallback;
  33534. /**
  33535. * Constructor.
  33536. * @param iterations the number of iterations.
  33537. * @param func the function to run each iteration
  33538. * @param successCallback the callback that will be called upon succesful execution
  33539. * @param offset starting offset.
  33540. */
  33541. constructor(
  33542. /**
  33543. * Defines the number of iterations for the loop
  33544. */
  33545. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33546. /**
  33547. * Execute the next iteration. Must be called after the last iteration was finished.
  33548. */
  33549. executeNext(): void;
  33550. /**
  33551. * Break the loop and run the success callback.
  33552. */
  33553. breakLoop(): void;
  33554. /**
  33555. * Create and run an async loop.
  33556. * @param iterations the number of iterations.
  33557. * @param fn the function to run each iteration
  33558. * @param successCallback the callback that will be called upon succesful execution
  33559. * @param offset starting offset.
  33560. * @returns the created async loop object
  33561. */
  33562. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33563. /**
  33564. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33565. * @param iterations total number of iterations
  33566. * @param syncedIterations number of synchronous iterations in each async iteration.
  33567. * @param fn the function to call each iteration.
  33568. * @param callback a success call back that will be called when iterating stops.
  33569. * @param breakFunction a break condition (optional)
  33570. * @param timeout timeout settings for the setTimeout function. default - 0.
  33571. * @returns the created async loop object
  33572. */
  33573. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33574. }
  33575. }
  33576. declare module "babylonjs/Misc/stringDictionary" {
  33577. import { Nullable } from "babylonjs/types";
  33578. /**
  33579. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33580. * The underlying implementation relies on an associative array to ensure the best performances.
  33581. * The value can be anything including 'null' but except 'undefined'
  33582. */
  33583. export class StringDictionary<T> {
  33584. /**
  33585. * This will clear this dictionary and copy the content from the 'source' one.
  33586. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33587. * @param source the dictionary to take the content from and copy to this dictionary
  33588. */
  33589. copyFrom(source: StringDictionary<T>): void;
  33590. /**
  33591. * Get a value based from its key
  33592. * @param key the given key to get the matching value from
  33593. * @return the value if found, otherwise undefined is returned
  33594. */
  33595. get(key: string): T | undefined;
  33596. /**
  33597. * Get a value from its key or add it if it doesn't exist.
  33598. * This method will ensure you that a given key/data will be present in the dictionary.
  33599. * @param key the given key to get the matching value from
  33600. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33601. * The factory will only be invoked if there's no data for the given key.
  33602. * @return the value corresponding to the key.
  33603. */
  33604. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33605. /**
  33606. * Get a value from its key if present in the dictionary otherwise add it
  33607. * @param key the key to get the value from
  33608. * @param val if there's no such key/value pair in the dictionary add it with this value
  33609. * @return the value corresponding to the key
  33610. */
  33611. getOrAdd(key: string, val: T): T;
  33612. /**
  33613. * Check if there's a given key in the dictionary
  33614. * @param key the key to check for
  33615. * @return true if the key is present, false otherwise
  33616. */
  33617. contains(key: string): boolean;
  33618. /**
  33619. * Add a new key and its corresponding value
  33620. * @param key the key to add
  33621. * @param value the value corresponding to the key
  33622. * @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
  33623. */
  33624. add(key: string, value: T): boolean;
  33625. /**
  33626. * Update a specific value associated to a key
  33627. * @param key defines the key to use
  33628. * @param value defines the value to store
  33629. * @returns true if the value was updated (or false if the key was not found)
  33630. */
  33631. set(key: string, value: T): boolean;
  33632. /**
  33633. * Get the element of the given key and remove it from the dictionary
  33634. * @param key defines the key to search
  33635. * @returns the value associated with the key or null if not found
  33636. */
  33637. getAndRemove(key: string): Nullable<T>;
  33638. /**
  33639. * Remove a key/value from the dictionary.
  33640. * @param key the key to remove
  33641. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33642. */
  33643. remove(key: string): boolean;
  33644. /**
  33645. * Clear the whole content of the dictionary
  33646. */
  33647. clear(): void;
  33648. /**
  33649. * Gets the current count
  33650. */
  33651. readonly count: number;
  33652. /**
  33653. * Execute a callback on each key/val of the dictionary.
  33654. * Note that you can remove any element in this dictionary in the callback implementation
  33655. * @param callback the callback to execute on a given key/value pair
  33656. */
  33657. forEach(callback: (key: string, val: T) => void): void;
  33658. /**
  33659. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33660. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33661. * Note that you can remove any element in this dictionary in the callback implementation
  33662. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33663. * @returns the first item
  33664. */
  33665. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33666. private _count;
  33667. private _data;
  33668. }
  33669. }
  33670. declare module "babylonjs/Collisions/collisionCoordinator" {
  33671. import { Nullable } from "babylonjs/types";
  33672. import { Scene } from "babylonjs/scene";
  33673. import { Vector3 } from "babylonjs/Maths/math.vector";
  33674. import { Collider } from "babylonjs/Collisions/collider";
  33675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33676. /** @hidden */
  33677. export interface ICollisionCoordinator {
  33678. createCollider(): Collider;
  33679. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33680. init(scene: Scene): void;
  33681. }
  33682. /** @hidden */
  33683. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33684. private _scene;
  33685. private _scaledPosition;
  33686. private _scaledVelocity;
  33687. private _finalPosition;
  33688. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33689. createCollider(): Collider;
  33690. init(scene: Scene): void;
  33691. private _collideWithWorld;
  33692. }
  33693. }
  33694. declare module "babylonjs/Inputs/scene.inputManager" {
  33695. import { Nullable } from "babylonjs/types";
  33696. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33697. import { Vector2 } from "babylonjs/Maths/math.vector";
  33698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33699. import { Scene } from "babylonjs/scene";
  33700. /**
  33701. * Class used to manage all inputs for the scene.
  33702. */
  33703. export class InputManager {
  33704. /** The distance in pixel that you have to move to prevent some events */
  33705. static DragMovementThreshold: number;
  33706. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33707. static LongPressDelay: number;
  33708. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33709. static DoubleClickDelay: number;
  33710. /** If you need to check double click without raising a single click at first click, enable this flag */
  33711. static ExclusiveDoubleClickMode: boolean;
  33712. private _wheelEventName;
  33713. private _onPointerMove;
  33714. private _onPointerDown;
  33715. private _onPointerUp;
  33716. private _initClickEvent;
  33717. private _initActionManager;
  33718. private _delayedSimpleClick;
  33719. private _delayedSimpleClickTimeout;
  33720. private _previousDelayedSimpleClickTimeout;
  33721. private _meshPickProceed;
  33722. private _previousButtonPressed;
  33723. private _currentPickResult;
  33724. private _previousPickResult;
  33725. private _totalPointersPressed;
  33726. private _doubleClickOccured;
  33727. private _pointerOverMesh;
  33728. private _pickedDownMesh;
  33729. private _pickedUpMesh;
  33730. private _pointerX;
  33731. private _pointerY;
  33732. private _unTranslatedPointerX;
  33733. private _unTranslatedPointerY;
  33734. private _startingPointerPosition;
  33735. private _previousStartingPointerPosition;
  33736. private _startingPointerTime;
  33737. private _previousStartingPointerTime;
  33738. private _pointerCaptures;
  33739. private _onKeyDown;
  33740. private _onKeyUp;
  33741. private _onCanvasFocusObserver;
  33742. private _onCanvasBlurObserver;
  33743. private _scene;
  33744. /**
  33745. * Creates a new InputManager
  33746. * @param scene defines the hosting scene
  33747. */
  33748. constructor(scene: Scene);
  33749. /**
  33750. * Gets the mesh that is currently under the pointer
  33751. */
  33752. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33753. /**
  33754. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33755. */
  33756. readonly unTranslatedPointer: Vector2;
  33757. /**
  33758. * Gets or sets the current on-screen X position of the pointer
  33759. */
  33760. pointerX: number;
  33761. /**
  33762. * Gets or sets the current on-screen Y position of the pointer
  33763. */
  33764. pointerY: number;
  33765. private _updatePointerPosition;
  33766. private _processPointerMove;
  33767. private _setRayOnPointerInfo;
  33768. private _checkPrePointerObservable;
  33769. /**
  33770. * Use this method to simulate a pointer move on a mesh
  33771. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33772. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33773. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33774. */
  33775. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33776. /**
  33777. * Use this method to simulate a pointer down on a mesh
  33778. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33779. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33780. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33781. */
  33782. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33783. private _processPointerDown;
  33784. /** @hidden */
  33785. _isPointerSwiping(): boolean;
  33786. /**
  33787. * Use this method to simulate a pointer up on a mesh
  33788. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33789. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33790. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33791. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33792. */
  33793. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33794. private _processPointerUp;
  33795. /**
  33796. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33797. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33798. * @returns true if the pointer was captured
  33799. */
  33800. isPointerCaptured(pointerId?: number): boolean;
  33801. /**
  33802. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33803. * @param attachUp defines if you want to attach events to pointerup
  33804. * @param attachDown defines if you want to attach events to pointerdown
  33805. * @param attachMove defines if you want to attach events to pointermove
  33806. */
  33807. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33808. /**
  33809. * Detaches all event handlers
  33810. */
  33811. detachControl(): void;
  33812. /**
  33813. * Force the value of meshUnderPointer
  33814. * @param mesh defines the mesh to use
  33815. */
  33816. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33817. /**
  33818. * Gets the mesh under the pointer
  33819. * @returns a Mesh or null if no mesh is under the pointer
  33820. */
  33821. getPointerOverMesh(): Nullable<AbstractMesh>;
  33822. }
  33823. }
  33824. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33825. /**
  33826. * Helper class used to generate session unique ID
  33827. */
  33828. export class UniqueIdGenerator {
  33829. private static _UniqueIdCounter;
  33830. /**
  33831. * Gets an unique (relatively to the current scene) Id
  33832. */
  33833. static readonly UniqueId: number;
  33834. }
  33835. }
  33836. declare module "babylonjs/Animations/animationGroup" {
  33837. import { Animatable } from "babylonjs/Animations/animatable";
  33838. import { Animation } from "babylonjs/Animations/animation";
  33839. import { Scene, IDisposable } from "babylonjs/scene";
  33840. import { Observable } from "babylonjs/Misc/observable";
  33841. import { Nullable } from "babylonjs/types";
  33842. import "babylonjs/Animations/animatable";
  33843. /**
  33844. * This class defines the direct association between an animation and a target
  33845. */
  33846. export class TargetedAnimation {
  33847. /**
  33848. * Animation to perform
  33849. */
  33850. animation: Animation;
  33851. /**
  33852. * Target to animate
  33853. */
  33854. target: any;
  33855. /**
  33856. * Serialize the object
  33857. * @returns the JSON object representing the current entity
  33858. */
  33859. serialize(): any;
  33860. }
  33861. /**
  33862. * Use this class to create coordinated animations on multiple targets
  33863. */
  33864. export class AnimationGroup implements IDisposable {
  33865. /** The name of the animation group */
  33866. name: string;
  33867. private _scene;
  33868. private _targetedAnimations;
  33869. private _animatables;
  33870. private _from;
  33871. private _to;
  33872. private _isStarted;
  33873. private _isPaused;
  33874. private _speedRatio;
  33875. private _loopAnimation;
  33876. /**
  33877. * Gets or sets the unique id of the node
  33878. */
  33879. uniqueId: number;
  33880. /**
  33881. * This observable will notify when one animation have ended
  33882. */
  33883. onAnimationEndObservable: Observable<TargetedAnimation>;
  33884. /**
  33885. * Observer raised when one animation loops
  33886. */
  33887. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33888. /**
  33889. * Observer raised when all animations have looped
  33890. */
  33891. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  33892. /**
  33893. * This observable will notify when all animations have ended.
  33894. */
  33895. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33896. /**
  33897. * This observable will notify when all animations have paused.
  33898. */
  33899. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33900. /**
  33901. * This observable will notify when all animations are playing.
  33902. */
  33903. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33904. /**
  33905. * Gets the first frame
  33906. */
  33907. readonly from: number;
  33908. /**
  33909. * Gets the last frame
  33910. */
  33911. readonly to: number;
  33912. /**
  33913. * Define if the animations are started
  33914. */
  33915. readonly isStarted: boolean;
  33916. /**
  33917. * Gets a value indicating that the current group is playing
  33918. */
  33919. readonly isPlaying: boolean;
  33920. /**
  33921. * Gets or sets the speed ratio to use for all animations
  33922. */
  33923. /**
  33924. * Gets or sets the speed ratio to use for all animations
  33925. */
  33926. speedRatio: number;
  33927. /**
  33928. * Gets or sets if all animations should loop or not
  33929. */
  33930. loopAnimation: boolean;
  33931. /**
  33932. * Gets the targeted animations for this animation group
  33933. */
  33934. readonly targetedAnimations: Array<TargetedAnimation>;
  33935. /**
  33936. * returning the list of animatables controlled by this animation group.
  33937. */
  33938. readonly animatables: Array<Animatable>;
  33939. /**
  33940. * Instantiates a new Animation Group.
  33941. * This helps managing several animations at once.
  33942. * @see http://doc.babylonjs.com/how_to/group
  33943. * @param name Defines the name of the group
  33944. * @param scene Defines the scene the group belongs to
  33945. */
  33946. constructor(
  33947. /** The name of the animation group */
  33948. name: string, scene?: Nullable<Scene>);
  33949. /**
  33950. * Add an animation (with its target) in the group
  33951. * @param animation defines the animation we want to add
  33952. * @param target defines the target of the animation
  33953. * @returns the TargetedAnimation object
  33954. */
  33955. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33956. /**
  33957. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33958. * It can add constant keys at begin or end
  33959. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33960. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33961. * @returns the animation group
  33962. */
  33963. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33964. private _animationLoopCount;
  33965. private _animationLoopFlags;
  33966. private _processLoop;
  33967. /**
  33968. * Start all animations on given targets
  33969. * @param loop defines if animations must loop
  33970. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33971. * @param from defines the from key (optional)
  33972. * @param to defines the to key (optional)
  33973. * @returns the current animation group
  33974. */
  33975. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33976. /**
  33977. * Pause all animations
  33978. * @returns the animation group
  33979. */
  33980. pause(): AnimationGroup;
  33981. /**
  33982. * Play all animations to initial state
  33983. * This function will start() the animations if they were not started or will restart() them if they were paused
  33984. * @param loop defines if animations must loop
  33985. * @returns the animation group
  33986. */
  33987. play(loop?: boolean): AnimationGroup;
  33988. /**
  33989. * Reset all animations to initial state
  33990. * @returns the animation group
  33991. */
  33992. reset(): AnimationGroup;
  33993. /**
  33994. * Restart animations from key 0
  33995. * @returns the animation group
  33996. */
  33997. restart(): AnimationGroup;
  33998. /**
  33999. * Stop all animations
  34000. * @returns the animation group
  34001. */
  34002. stop(): AnimationGroup;
  34003. /**
  34004. * Set animation weight for all animatables
  34005. * @param weight defines the weight to use
  34006. * @return the animationGroup
  34007. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34008. */
  34009. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34010. /**
  34011. * Synchronize and normalize all animatables with a source animatable
  34012. * @param root defines the root animatable to synchronize with
  34013. * @return the animationGroup
  34014. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34015. */
  34016. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34017. /**
  34018. * Goes to a specific frame in this animation group
  34019. * @param frame the frame number to go to
  34020. * @return the animationGroup
  34021. */
  34022. goToFrame(frame: number): AnimationGroup;
  34023. /**
  34024. * Dispose all associated resources
  34025. */
  34026. dispose(): void;
  34027. private _checkAnimationGroupEnded;
  34028. /**
  34029. * Clone the current animation group and returns a copy
  34030. * @param newName defines the name of the new group
  34031. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34032. * @returns the new aniamtion group
  34033. */
  34034. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34035. /**
  34036. * Serializes the animationGroup to an object
  34037. * @returns Serialized object
  34038. */
  34039. serialize(): any;
  34040. /**
  34041. * Returns a new AnimationGroup object parsed from the source provided.
  34042. * @param parsedAnimationGroup defines the source
  34043. * @param scene defines the scene that will receive the animationGroup
  34044. * @returns a new AnimationGroup
  34045. */
  34046. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34047. /**
  34048. * Returns the string "AnimationGroup"
  34049. * @returns "AnimationGroup"
  34050. */
  34051. getClassName(): string;
  34052. /**
  34053. * Creates a detailled string about the object
  34054. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34055. * @returns a string representing the object
  34056. */
  34057. toString(fullDetails?: boolean): string;
  34058. }
  34059. }
  34060. declare module "babylonjs/scene" {
  34061. import { Nullable } from "babylonjs/types";
  34062. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34063. import { Observable } from "babylonjs/Misc/observable";
  34064. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34065. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34066. import { Geometry } from "babylonjs/Meshes/geometry";
  34067. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34068. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34070. import { Mesh } from "babylonjs/Meshes/mesh";
  34071. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34072. import { Bone } from "babylonjs/Bones/bone";
  34073. import { Skeleton } from "babylonjs/Bones/skeleton";
  34074. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34075. import { Camera } from "babylonjs/Cameras/camera";
  34076. import { AbstractScene } from "babylonjs/abstractScene";
  34077. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34078. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34079. import { Material } from "babylonjs/Materials/material";
  34080. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34081. import { Effect } from "babylonjs/Materials/effect";
  34082. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34083. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34084. import { Light } from "babylonjs/Lights/light";
  34085. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34086. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34087. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34088. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34089. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34090. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34091. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34092. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34093. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34094. import { Engine } from "babylonjs/Engines/engine";
  34095. import { Node } from "babylonjs/node";
  34096. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34097. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34098. import { WebRequest } from "babylonjs/Misc/webRequest";
  34099. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34100. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34101. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34102. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34103. import { Plane } from "babylonjs/Maths/math.plane";
  34104. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34105. import { Ray } from "babylonjs/Culling/ray";
  34106. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34107. import { Animation } from "babylonjs/Animations/animation";
  34108. import { Animatable } from "babylonjs/Animations/animatable";
  34109. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34110. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34111. import { Collider } from "babylonjs/Collisions/collider";
  34112. /**
  34113. * Define an interface for all classes that will hold resources
  34114. */
  34115. export interface IDisposable {
  34116. /**
  34117. * Releases all held resources
  34118. */
  34119. dispose(): void;
  34120. }
  34121. /** Interface defining initialization parameters for Scene class */
  34122. export interface SceneOptions {
  34123. /**
  34124. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34125. * It will improve performance when the number of geometries becomes important.
  34126. */
  34127. useGeometryUniqueIdsMap?: boolean;
  34128. /**
  34129. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34130. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34131. */
  34132. useMaterialMeshMap?: boolean;
  34133. /**
  34134. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34135. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34136. */
  34137. useClonedMeshhMap?: boolean;
  34138. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34139. virtual?: boolean;
  34140. }
  34141. /**
  34142. * Represents a scene to be rendered by the engine.
  34143. * @see http://doc.babylonjs.com/features/scene
  34144. */
  34145. export class Scene extends AbstractScene implements IAnimatable {
  34146. /** The fog is deactivated */
  34147. static readonly FOGMODE_NONE: number;
  34148. /** The fog density is following an exponential function */
  34149. static readonly FOGMODE_EXP: number;
  34150. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34151. static readonly FOGMODE_EXP2: number;
  34152. /** The fog density is following a linear function. */
  34153. static readonly FOGMODE_LINEAR: number;
  34154. /**
  34155. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34157. */
  34158. static MinDeltaTime: number;
  34159. /**
  34160. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34162. */
  34163. static MaxDeltaTime: number;
  34164. /**
  34165. * Factory used to create the default material.
  34166. * @param name The name of the material to create
  34167. * @param scene The scene to create the material for
  34168. * @returns The default material
  34169. */
  34170. static DefaultMaterialFactory(scene: Scene): Material;
  34171. /**
  34172. * Factory used to create the a collision coordinator.
  34173. * @returns The collision coordinator
  34174. */
  34175. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34176. /** @hidden */
  34177. _inputManager: InputManager;
  34178. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34179. cameraToUseForPointers: Nullable<Camera>;
  34180. /** @hidden */
  34181. readonly _isScene: boolean;
  34182. /**
  34183. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34184. */
  34185. autoClear: boolean;
  34186. /**
  34187. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34188. */
  34189. autoClearDepthAndStencil: boolean;
  34190. /**
  34191. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34192. */
  34193. clearColor: Color4;
  34194. /**
  34195. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34196. */
  34197. ambientColor: Color3;
  34198. /**
  34199. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34200. * It should only be one of the following (if not the default embedded one):
  34201. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34202. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34203. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34204. * The material properties need to be setup according to the type of texture in use.
  34205. */
  34206. environmentBRDFTexture: BaseTexture;
  34207. /** @hidden */
  34208. protected _environmentTexture: Nullable<BaseTexture>;
  34209. /**
  34210. * Texture used in all pbr material as the reflection texture.
  34211. * As in the majority of the scene they are the same (exception for multi room and so on),
  34212. * this is easier to reference from here than from all the materials.
  34213. */
  34214. /**
  34215. * Texture used in all pbr material as the reflection texture.
  34216. * As in the majority of the scene they are the same (exception for multi room and so on),
  34217. * this is easier to set here than in all the materials.
  34218. */
  34219. environmentTexture: Nullable<BaseTexture>;
  34220. /** @hidden */
  34221. protected _environmentIntensity: number;
  34222. /**
  34223. * Intensity of the environment in all pbr material.
  34224. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34225. * As in the majority of the scene they are the same (exception for multi room and so on),
  34226. * this is easier to reference from here than from all the materials.
  34227. */
  34228. /**
  34229. * Intensity of the environment in all pbr material.
  34230. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34231. * As in the majority of the scene they are the same (exception for multi room and so on),
  34232. * this is easier to set here than in all the materials.
  34233. */
  34234. environmentIntensity: number;
  34235. /** @hidden */
  34236. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34237. /**
  34238. * Default image processing configuration used either in the rendering
  34239. * Forward main pass or through the imageProcessingPostProcess if present.
  34240. * As in the majority of the scene they are the same (exception for multi camera),
  34241. * this is easier to reference from here than from all the materials and post process.
  34242. *
  34243. * No setter as we it is a shared configuration, you can set the values instead.
  34244. */
  34245. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34246. private _forceWireframe;
  34247. /**
  34248. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34249. */
  34250. forceWireframe: boolean;
  34251. private _forcePointsCloud;
  34252. /**
  34253. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34254. */
  34255. forcePointsCloud: boolean;
  34256. /**
  34257. * Gets or sets the active clipplane 1
  34258. */
  34259. clipPlane: Nullable<Plane>;
  34260. /**
  34261. * Gets or sets the active clipplane 2
  34262. */
  34263. clipPlane2: Nullable<Plane>;
  34264. /**
  34265. * Gets or sets the active clipplane 3
  34266. */
  34267. clipPlane3: Nullable<Plane>;
  34268. /**
  34269. * Gets or sets the active clipplane 4
  34270. */
  34271. clipPlane4: Nullable<Plane>;
  34272. /**
  34273. * Gets or sets a boolean indicating if animations are enabled
  34274. */
  34275. animationsEnabled: boolean;
  34276. private _animationPropertiesOverride;
  34277. /**
  34278. * Gets or sets the animation properties override
  34279. */
  34280. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34281. /**
  34282. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34283. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34284. */
  34285. useConstantAnimationDeltaTime: boolean;
  34286. /**
  34287. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34288. * Please note that it requires to run a ray cast through the scene on every frame
  34289. */
  34290. constantlyUpdateMeshUnderPointer: boolean;
  34291. /**
  34292. * Defines the HTML cursor to use when hovering over interactive elements
  34293. */
  34294. hoverCursor: string;
  34295. /**
  34296. * Defines the HTML default cursor to use (empty by default)
  34297. */
  34298. defaultCursor: string;
  34299. /**
  34300. * Defines wether cursors are handled by the scene.
  34301. */
  34302. doNotHandleCursors: boolean;
  34303. /**
  34304. * This is used to call preventDefault() on pointer down
  34305. * in order to block unwanted artifacts like system double clicks
  34306. */
  34307. preventDefaultOnPointerDown: boolean;
  34308. /**
  34309. * This is used to call preventDefault() on pointer up
  34310. * in order to block unwanted artifacts like system double clicks
  34311. */
  34312. preventDefaultOnPointerUp: boolean;
  34313. /**
  34314. * Gets or sets user defined metadata
  34315. */
  34316. metadata: any;
  34317. /**
  34318. * For internal use only. Please do not use.
  34319. */
  34320. reservedDataStore: any;
  34321. /**
  34322. * Gets the name of the plugin used to load this scene (null by default)
  34323. */
  34324. loadingPluginName: string;
  34325. /**
  34326. * Use this array to add regular expressions used to disable offline support for specific urls
  34327. */
  34328. disableOfflineSupportExceptionRules: RegExp[];
  34329. /**
  34330. * An event triggered when the scene is disposed.
  34331. */
  34332. onDisposeObservable: Observable<Scene>;
  34333. private _onDisposeObserver;
  34334. /** Sets a function to be executed when this scene is disposed. */
  34335. onDispose: () => void;
  34336. /**
  34337. * An event triggered before rendering the scene (right after animations and physics)
  34338. */
  34339. onBeforeRenderObservable: Observable<Scene>;
  34340. private _onBeforeRenderObserver;
  34341. /** Sets a function to be executed before rendering this scene */
  34342. beforeRender: Nullable<() => void>;
  34343. /**
  34344. * An event triggered after rendering the scene
  34345. */
  34346. onAfterRenderObservable: Observable<Scene>;
  34347. /**
  34348. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34349. */
  34350. onAfterRenderCameraObservable: Observable<Camera>;
  34351. private _onAfterRenderObserver;
  34352. /** Sets a function to be executed after rendering this scene */
  34353. afterRender: Nullable<() => void>;
  34354. /**
  34355. * An event triggered before animating the scene
  34356. */
  34357. onBeforeAnimationsObservable: Observable<Scene>;
  34358. /**
  34359. * An event triggered after animations processing
  34360. */
  34361. onAfterAnimationsObservable: Observable<Scene>;
  34362. /**
  34363. * An event triggered before draw calls are ready to be sent
  34364. */
  34365. onBeforeDrawPhaseObservable: Observable<Scene>;
  34366. /**
  34367. * An event triggered after draw calls have been sent
  34368. */
  34369. onAfterDrawPhaseObservable: Observable<Scene>;
  34370. /**
  34371. * An event triggered when the scene is ready
  34372. */
  34373. onReadyObservable: Observable<Scene>;
  34374. /**
  34375. * An event triggered before rendering a camera
  34376. */
  34377. onBeforeCameraRenderObservable: Observable<Camera>;
  34378. private _onBeforeCameraRenderObserver;
  34379. /** Sets a function to be executed before rendering a camera*/
  34380. beforeCameraRender: () => void;
  34381. /**
  34382. * An event triggered after rendering a camera
  34383. */
  34384. onAfterCameraRenderObservable: Observable<Camera>;
  34385. private _onAfterCameraRenderObserver;
  34386. /** Sets a function to be executed after rendering a camera*/
  34387. afterCameraRender: () => void;
  34388. /**
  34389. * An event triggered when active meshes evaluation is about to start
  34390. */
  34391. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34392. /**
  34393. * An event triggered when active meshes evaluation is done
  34394. */
  34395. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34396. /**
  34397. * An event triggered when particles rendering is about to start
  34398. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34399. */
  34400. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34401. /**
  34402. * An event triggered when particles rendering is done
  34403. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34404. */
  34405. onAfterParticlesRenderingObservable: Observable<Scene>;
  34406. /**
  34407. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34408. */
  34409. onDataLoadedObservable: Observable<Scene>;
  34410. /**
  34411. * An event triggered when a camera is created
  34412. */
  34413. onNewCameraAddedObservable: Observable<Camera>;
  34414. /**
  34415. * An event triggered when a camera is removed
  34416. */
  34417. onCameraRemovedObservable: Observable<Camera>;
  34418. /**
  34419. * An event triggered when a light is created
  34420. */
  34421. onNewLightAddedObservable: Observable<Light>;
  34422. /**
  34423. * An event triggered when a light is removed
  34424. */
  34425. onLightRemovedObservable: Observable<Light>;
  34426. /**
  34427. * An event triggered when a geometry is created
  34428. */
  34429. onNewGeometryAddedObservable: Observable<Geometry>;
  34430. /**
  34431. * An event triggered when a geometry is removed
  34432. */
  34433. onGeometryRemovedObservable: Observable<Geometry>;
  34434. /**
  34435. * An event triggered when a transform node is created
  34436. */
  34437. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34438. /**
  34439. * An event triggered when a transform node is removed
  34440. */
  34441. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34442. /**
  34443. * An event triggered when a mesh is created
  34444. */
  34445. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34446. /**
  34447. * An event triggered when a mesh is removed
  34448. */
  34449. onMeshRemovedObservable: Observable<AbstractMesh>;
  34450. /**
  34451. * An event triggered when a skeleton is created
  34452. */
  34453. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34454. /**
  34455. * An event triggered when a skeleton is removed
  34456. */
  34457. onSkeletonRemovedObservable: Observable<Skeleton>;
  34458. /**
  34459. * An event triggered when a material is created
  34460. */
  34461. onNewMaterialAddedObservable: Observable<Material>;
  34462. /**
  34463. * An event triggered when a material is removed
  34464. */
  34465. onMaterialRemovedObservable: Observable<Material>;
  34466. /**
  34467. * An event triggered when a texture is created
  34468. */
  34469. onNewTextureAddedObservable: Observable<BaseTexture>;
  34470. /**
  34471. * An event triggered when a texture is removed
  34472. */
  34473. onTextureRemovedObservable: Observable<BaseTexture>;
  34474. /**
  34475. * An event triggered when render targets are about to be rendered
  34476. * Can happen multiple times per frame.
  34477. */
  34478. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34479. /**
  34480. * An event triggered when render targets were rendered.
  34481. * Can happen multiple times per frame.
  34482. */
  34483. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34484. /**
  34485. * An event triggered before calculating deterministic simulation step
  34486. */
  34487. onBeforeStepObservable: Observable<Scene>;
  34488. /**
  34489. * An event triggered after calculating deterministic simulation step
  34490. */
  34491. onAfterStepObservable: Observable<Scene>;
  34492. /**
  34493. * An event triggered when the activeCamera property is updated
  34494. */
  34495. onActiveCameraChanged: Observable<Scene>;
  34496. /**
  34497. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34498. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34499. * 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)
  34500. */
  34501. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34502. /**
  34503. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34504. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34505. * 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)
  34506. */
  34507. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34508. /**
  34509. * This Observable will when a mesh has been imported into the scene.
  34510. */
  34511. onMeshImportedObservable: Observable<AbstractMesh>;
  34512. /**
  34513. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34514. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34515. */
  34516. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34517. /** @hidden */
  34518. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34519. /**
  34520. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34521. */
  34522. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34523. /**
  34524. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34525. */
  34526. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34527. /**
  34528. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34529. */
  34530. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34531. /** Callback called when a pointer move is detected */
  34532. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34533. /** Callback called when a pointer down is detected */
  34534. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34535. /** Callback called when a pointer up is detected */
  34536. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34537. /** Callback called when a pointer pick is detected */
  34538. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34539. /**
  34540. * 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).
  34541. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34542. */
  34543. onPrePointerObservable: Observable<PointerInfoPre>;
  34544. /**
  34545. * Observable event triggered each time an input event is received from the rendering canvas
  34546. */
  34547. onPointerObservable: Observable<PointerInfo>;
  34548. /**
  34549. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34550. */
  34551. readonly unTranslatedPointer: Vector2;
  34552. /**
  34553. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34554. */
  34555. static DragMovementThreshold: number;
  34556. /**
  34557. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34558. */
  34559. static LongPressDelay: number;
  34560. /**
  34561. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34562. */
  34563. static DoubleClickDelay: number;
  34564. /** If you need to check double click without raising a single click at first click, enable this flag */
  34565. static ExclusiveDoubleClickMode: boolean;
  34566. /** @hidden */
  34567. _mirroredCameraPosition: Nullable<Vector3>;
  34568. /**
  34569. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34570. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34571. */
  34572. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34573. /**
  34574. * Observable event triggered each time an keyboard event is received from the hosting window
  34575. */
  34576. onKeyboardObservable: Observable<KeyboardInfo>;
  34577. private _useRightHandedSystem;
  34578. /**
  34579. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34580. */
  34581. useRightHandedSystem: boolean;
  34582. private _timeAccumulator;
  34583. private _currentStepId;
  34584. private _currentInternalStep;
  34585. /**
  34586. * Sets the step Id used by deterministic lock step
  34587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34588. * @param newStepId defines the step Id
  34589. */
  34590. setStepId(newStepId: number): void;
  34591. /**
  34592. * Gets the step Id used by deterministic lock step
  34593. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34594. * @returns the step Id
  34595. */
  34596. getStepId(): number;
  34597. /**
  34598. * Gets the internal step used by deterministic lock step
  34599. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34600. * @returns the internal step
  34601. */
  34602. getInternalStep(): number;
  34603. private _fogEnabled;
  34604. /**
  34605. * Gets or sets a boolean indicating if fog is enabled on this scene
  34606. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34607. * (Default is true)
  34608. */
  34609. fogEnabled: boolean;
  34610. private _fogMode;
  34611. /**
  34612. * Gets or sets the fog mode to use
  34613. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34614. * | mode | value |
  34615. * | --- | --- |
  34616. * | FOGMODE_NONE | 0 |
  34617. * | FOGMODE_EXP | 1 |
  34618. * | FOGMODE_EXP2 | 2 |
  34619. * | FOGMODE_LINEAR | 3 |
  34620. */
  34621. fogMode: number;
  34622. /**
  34623. * Gets or sets the fog color to use
  34624. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34625. * (Default is Color3(0.2, 0.2, 0.3))
  34626. */
  34627. fogColor: Color3;
  34628. /**
  34629. * Gets or sets the fog density to use
  34630. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34631. * (Default is 0.1)
  34632. */
  34633. fogDensity: number;
  34634. /**
  34635. * Gets or sets the fog start distance to use
  34636. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34637. * (Default is 0)
  34638. */
  34639. fogStart: number;
  34640. /**
  34641. * Gets or sets the fog end distance to use
  34642. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34643. * (Default is 1000)
  34644. */
  34645. fogEnd: number;
  34646. private _shadowsEnabled;
  34647. /**
  34648. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34649. */
  34650. shadowsEnabled: boolean;
  34651. private _lightsEnabled;
  34652. /**
  34653. * Gets or sets a boolean indicating if lights are enabled on this scene
  34654. */
  34655. lightsEnabled: boolean;
  34656. /** All of the active cameras added to this scene. */
  34657. activeCameras: Camera[];
  34658. /** @hidden */
  34659. _activeCamera: Nullable<Camera>;
  34660. /** Gets or sets the current active camera */
  34661. activeCamera: Nullable<Camera>;
  34662. private _defaultMaterial;
  34663. /** The default material used on meshes when no material is affected */
  34664. /** The default material used on meshes when no material is affected */
  34665. defaultMaterial: Material;
  34666. private _texturesEnabled;
  34667. /**
  34668. * Gets or sets a boolean indicating if textures are enabled on this scene
  34669. */
  34670. texturesEnabled: boolean;
  34671. /**
  34672. * Gets or sets a boolean indicating if particles are enabled on this scene
  34673. */
  34674. particlesEnabled: boolean;
  34675. /**
  34676. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34677. */
  34678. spritesEnabled: boolean;
  34679. private _skeletonsEnabled;
  34680. /**
  34681. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34682. */
  34683. skeletonsEnabled: boolean;
  34684. /**
  34685. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34686. */
  34687. lensFlaresEnabled: boolean;
  34688. /**
  34689. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34690. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34691. */
  34692. collisionsEnabled: boolean;
  34693. private _collisionCoordinator;
  34694. /** @hidden */
  34695. readonly collisionCoordinator: ICollisionCoordinator;
  34696. /**
  34697. * Defines the gravity applied to this scene (used only for collisions)
  34698. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34699. */
  34700. gravity: Vector3;
  34701. /**
  34702. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34703. */
  34704. postProcessesEnabled: boolean;
  34705. /**
  34706. * The list of postprocesses added to the scene
  34707. */
  34708. postProcesses: PostProcess[];
  34709. /**
  34710. * Gets the current postprocess manager
  34711. */
  34712. postProcessManager: PostProcessManager;
  34713. /**
  34714. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34715. */
  34716. renderTargetsEnabled: boolean;
  34717. /**
  34718. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34719. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34720. */
  34721. dumpNextRenderTargets: boolean;
  34722. /**
  34723. * The list of user defined render targets added to the scene
  34724. */
  34725. customRenderTargets: RenderTargetTexture[];
  34726. /**
  34727. * Defines if texture loading must be delayed
  34728. * If true, textures will only be loaded when they need to be rendered
  34729. */
  34730. useDelayedTextureLoading: boolean;
  34731. /**
  34732. * Gets the list of meshes imported to the scene through SceneLoader
  34733. */
  34734. importedMeshesFiles: String[];
  34735. /**
  34736. * Gets or sets a boolean indicating if probes are enabled on this scene
  34737. */
  34738. probesEnabled: boolean;
  34739. /**
  34740. * Gets or sets the current offline provider to use to store scene data
  34741. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34742. */
  34743. offlineProvider: IOfflineProvider;
  34744. /**
  34745. * Gets or sets the action manager associated with the scene
  34746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34747. */
  34748. actionManager: AbstractActionManager;
  34749. private _meshesForIntersections;
  34750. /**
  34751. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34752. */
  34753. proceduralTexturesEnabled: boolean;
  34754. private _engine;
  34755. private _totalVertices;
  34756. /** @hidden */
  34757. _activeIndices: PerfCounter;
  34758. /** @hidden */
  34759. _activeParticles: PerfCounter;
  34760. /** @hidden */
  34761. _activeBones: PerfCounter;
  34762. private _animationRatio;
  34763. /** @hidden */
  34764. _animationTimeLast: number;
  34765. /** @hidden */
  34766. _animationTime: number;
  34767. /**
  34768. * Gets or sets a general scale for animation speed
  34769. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34770. */
  34771. animationTimeScale: number;
  34772. /** @hidden */
  34773. _cachedMaterial: Nullable<Material>;
  34774. /** @hidden */
  34775. _cachedEffect: Nullable<Effect>;
  34776. /** @hidden */
  34777. _cachedVisibility: Nullable<number>;
  34778. private _renderId;
  34779. private _frameId;
  34780. private _executeWhenReadyTimeoutId;
  34781. private _intermediateRendering;
  34782. private _viewUpdateFlag;
  34783. private _projectionUpdateFlag;
  34784. /** @hidden */
  34785. _toBeDisposed: Nullable<IDisposable>[];
  34786. private _activeRequests;
  34787. /** @hidden */
  34788. _pendingData: any[];
  34789. private _isDisposed;
  34790. /**
  34791. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34792. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34793. */
  34794. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34795. private _activeMeshes;
  34796. private _processedMaterials;
  34797. private _renderTargets;
  34798. /** @hidden */
  34799. _activeParticleSystems: SmartArray<IParticleSystem>;
  34800. private _activeSkeletons;
  34801. private _softwareSkinnedMeshes;
  34802. private _renderingManager;
  34803. /** @hidden */
  34804. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34805. private _transformMatrix;
  34806. private _sceneUbo;
  34807. /** @hidden */
  34808. _viewMatrix: Matrix;
  34809. private _projectionMatrix;
  34810. /** @hidden */
  34811. _forcedViewPosition: Nullable<Vector3>;
  34812. /** @hidden */
  34813. _frustumPlanes: Plane[];
  34814. /**
  34815. * Gets the list of frustum planes (built from the active camera)
  34816. */
  34817. readonly frustumPlanes: Plane[];
  34818. /**
  34819. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34820. * This is useful if there are more lights that the maximum simulteanous authorized
  34821. */
  34822. requireLightSorting: boolean;
  34823. /** @hidden */
  34824. readonly useMaterialMeshMap: boolean;
  34825. /** @hidden */
  34826. readonly useClonedMeshhMap: boolean;
  34827. private _externalData;
  34828. private _uid;
  34829. /**
  34830. * @hidden
  34831. * Backing store of defined scene components.
  34832. */
  34833. _components: ISceneComponent[];
  34834. /**
  34835. * @hidden
  34836. * Backing store of defined scene components.
  34837. */
  34838. _serializableComponents: ISceneSerializableComponent[];
  34839. /**
  34840. * List of components to register on the next registration step.
  34841. */
  34842. private _transientComponents;
  34843. /**
  34844. * Registers the transient components if needed.
  34845. */
  34846. private _registerTransientComponents;
  34847. /**
  34848. * @hidden
  34849. * Add a component to the scene.
  34850. * Note that the ccomponent could be registered on th next frame if this is called after
  34851. * the register component stage.
  34852. * @param component Defines the component to add to the scene
  34853. */
  34854. _addComponent(component: ISceneComponent): void;
  34855. /**
  34856. * @hidden
  34857. * Gets a component from the scene.
  34858. * @param name defines the name of the component to retrieve
  34859. * @returns the component or null if not present
  34860. */
  34861. _getComponent(name: string): Nullable<ISceneComponent>;
  34862. /**
  34863. * @hidden
  34864. * Defines the actions happening before camera updates.
  34865. */
  34866. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34867. /**
  34868. * @hidden
  34869. * Defines the actions happening before clear the canvas.
  34870. */
  34871. _beforeClearStage: Stage<SimpleStageAction>;
  34872. /**
  34873. * @hidden
  34874. * Defines the actions when collecting render targets for the frame.
  34875. */
  34876. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34877. /**
  34878. * @hidden
  34879. * Defines the actions happening for one camera in the frame.
  34880. */
  34881. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34882. /**
  34883. * @hidden
  34884. * Defines the actions happening during the per mesh ready checks.
  34885. */
  34886. _isReadyForMeshStage: Stage<MeshStageAction>;
  34887. /**
  34888. * @hidden
  34889. * Defines the actions happening before evaluate active mesh checks.
  34890. */
  34891. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34892. /**
  34893. * @hidden
  34894. * Defines the actions happening during the evaluate sub mesh checks.
  34895. */
  34896. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34897. /**
  34898. * @hidden
  34899. * Defines the actions happening during the active mesh stage.
  34900. */
  34901. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34902. /**
  34903. * @hidden
  34904. * Defines the actions happening during the per camera render target step.
  34905. */
  34906. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34907. /**
  34908. * @hidden
  34909. * Defines the actions happening just before the active camera is drawing.
  34910. */
  34911. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34912. /**
  34913. * @hidden
  34914. * Defines the actions happening just before a render target is drawing.
  34915. */
  34916. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34917. /**
  34918. * @hidden
  34919. * Defines the actions happening just before a rendering group is drawing.
  34920. */
  34921. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34922. /**
  34923. * @hidden
  34924. * Defines the actions happening just before a mesh is drawing.
  34925. */
  34926. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34927. /**
  34928. * @hidden
  34929. * Defines the actions happening just after a mesh has been drawn.
  34930. */
  34931. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34932. /**
  34933. * @hidden
  34934. * Defines the actions happening just after a rendering group has been drawn.
  34935. */
  34936. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34937. /**
  34938. * @hidden
  34939. * Defines the actions happening just after the active camera has been drawn.
  34940. */
  34941. _afterCameraDrawStage: Stage<CameraStageAction>;
  34942. /**
  34943. * @hidden
  34944. * Defines the actions happening just after a render target has been drawn.
  34945. */
  34946. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34947. /**
  34948. * @hidden
  34949. * Defines the actions happening just after rendering all cameras and computing intersections.
  34950. */
  34951. _afterRenderStage: Stage<SimpleStageAction>;
  34952. /**
  34953. * @hidden
  34954. * Defines the actions happening when a pointer move event happens.
  34955. */
  34956. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34957. /**
  34958. * @hidden
  34959. * Defines the actions happening when a pointer down event happens.
  34960. */
  34961. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34962. /**
  34963. * @hidden
  34964. * Defines the actions happening when a pointer up event happens.
  34965. */
  34966. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34967. /**
  34968. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34969. */
  34970. private geometriesByUniqueId;
  34971. /**
  34972. * Creates a new Scene
  34973. * @param engine defines the engine to use to render this scene
  34974. * @param options defines the scene options
  34975. */
  34976. constructor(engine: Engine, options?: SceneOptions);
  34977. /**
  34978. * Gets a string idenfifying the name of the class
  34979. * @returns "Scene" string
  34980. */
  34981. getClassName(): string;
  34982. private _defaultMeshCandidates;
  34983. /**
  34984. * @hidden
  34985. */
  34986. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34987. private _defaultSubMeshCandidates;
  34988. /**
  34989. * @hidden
  34990. */
  34991. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34992. /**
  34993. * Sets the default candidate providers for the scene.
  34994. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34995. * and getCollidingSubMeshCandidates to their default function
  34996. */
  34997. setDefaultCandidateProviders(): void;
  34998. /**
  34999. * Gets the mesh that is currently under the pointer
  35000. */
  35001. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35002. /**
  35003. * Gets or sets the current on-screen X position of the pointer
  35004. */
  35005. pointerX: number;
  35006. /**
  35007. * Gets or sets the current on-screen Y position of the pointer
  35008. */
  35009. pointerY: number;
  35010. /**
  35011. * Gets the cached material (ie. the latest rendered one)
  35012. * @returns the cached material
  35013. */
  35014. getCachedMaterial(): Nullable<Material>;
  35015. /**
  35016. * Gets the cached effect (ie. the latest rendered one)
  35017. * @returns the cached effect
  35018. */
  35019. getCachedEffect(): Nullable<Effect>;
  35020. /**
  35021. * Gets the cached visibility state (ie. the latest rendered one)
  35022. * @returns the cached visibility state
  35023. */
  35024. getCachedVisibility(): Nullable<number>;
  35025. /**
  35026. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35027. * @param material defines the current material
  35028. * @param effect defines the current effect
  35029. * @param visibility defines the current visibility state
  35030. * @returns true if one parameter is not cached
  35031. */
  35032. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35033. /**
  35034. * Gets the engine associated with the scene
  35035. * @returns an Engine
  35036. */
  35037. getEngine(): Engine;
  35038. /**
  35039. * Gets the total number of vertices rendered per frame
  35040. * @returns the total number of vertices rendered per frame
  35041. */
  35042. getTotalVertices(): number;
  35043. /**
  35044. * Gets the performance counter for total vertices
  35045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35046. */
  35047. readonly totalVerticesPerfCounter: PerfCounter;
  35048. /**
  35049. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35050. * @returns the total number of active indices rendered per frame
  35051. */
  35052. getActiveIndices(): number;
  35053. /**
  35054. * Gets the performance counter for active indices
  35055. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35056. */
  35057. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35058. /**
  35059. * Gets the total number of active particles rendered per frame
  35060. * @returns the total number of active particles rendered per frame
  35061. */
  35062. getActiveParticles(): number;
  35063. /**
  35064. * Gets the performance counter for active particles
  35065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35066. */
  35067. readonly activeParticlesPerfCounter: PerfCounter;
  35068. /**
  35069. * Gets the total number of active bones rendered per frame
  35070. * @returns the total number of active bones rendered per frame
  35071. */
  35072. getActiveBones(): number;
  35073. /**
  35074. * Gets the performance counter for active bones
  35075. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35076. */
  35077. readonly activeBonesPerfCounter: PerfCounter;
  35078. /**
  35079. * Gets the array of active meshes
  35080. * @returns an array of AbstractMesh
  35081. */
  35082. getActiveMeshes(): SmartArray<AbstractMesh>;
  35083. /**
  35084. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35085. * @returns a number
  35086. */
  35087. getAnimationRatio(): number;
  35088. /**
  35089. * Gets an unique Id for the current render phase
  35090. * @returns a number
  35091. */
  35092. getRenderId(): number;
  35093. /**
  35094. * Gets an unique Id for the current frame
  35095. * @returns a number
  35096. */
  35097. getFrameId(): number;
  35098. /** Call this function if you want to manually increment the render Id*/
  35099. incrementRenderId(): void;
  35100. private _createUbo;
  35101. /**
  35102. * Use this method to simulate a pointer move on a mesh
  35103. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35104. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35105. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35106. * @returns the current scene
  35107. */
  35108. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35109. /**
  35110. * Use this method to simulate a pointer down on a mesh
  35111. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35112. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35113. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35114. * @returns the current scene
  35115. */
  35116. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35117. /**
  35118. * Use this method to simulate a pointer up on a mesh
  35119. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35120. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35121. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35122. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35123. * @returns the current scene
  35124. */
  35125. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35126. /**
  35127. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35128. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35129. * @returns true if the pointer was captured
  35130. */
  35131. isPointerCaptured(pointerId?: number): boolean;
  35132. /**
  35133. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35134. * @param attachUp defines if you want to attach events to pointerup
  35135. * @param attachDown defines if you want to attach events to pointerdown
  35136. * @param attachMove defines if you want to attach events to pointermove
  35137. */
  35138. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35139. /** Detaches all event handlers*/
  35140. detachControl(): void;
  35141. /**
  35142. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35143. * Delay loaded resources are not taking in account
  35144. * @return true if all required resources are ready
  35145. */
  35146. isReady(): boolean;
  35147. /** Resets all cached information relative to material (including effect and visibility) */
  35148. resetCachedMaterial(): void;
  35149. /**
  35150. * Registers a function to be called before every frame render
  35151. * @param func defines the function to register
  35152. */
  35153. registerBeforeRender(func: () => void): void;
  35154. /**
  35155. * Unregisters a function called before every frame render
  35156. * @param func defines the function to unregister
  35157. */
  35158. unregisterBeforeRender(func: () => void): void;
  35159. /**
  35160. * Registers a function to be called after every frame render
  35161. * @param func defines the function to register
  35162. */
  35163. registerAfterRender(func: () => void): void;
  35164. /**
  35165. * Unregisters a function called after every frame render
  35166. * @param func defines the function to unregister
  35167. */
  35168. unregisterAfterRender(func: () => void): void;
  35169. private _executeOnceBeforeRender;
  35170. /**
  35171. * The provided function will run before render once and will be disposed afterwards.
  35172. * A timeout delay can be provided so that the function will be executed in N ms.
  35173. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35174. * @param func The function to be executed.
  35175. * @param timeout optional delay in ms
  35176. */
  35177. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35178. /** @hidden */
  35179. _addPendingData(data: any): void;
  35180. /** @hidden */
  35181. _removePendingData(data: any): void;
  35182. /**
  35183. * Returns the number of items waiting to be loaded
  35184. * @returns the number of items waiting to be loaded
  35185. */
  35186. getWaitingItemsCount(): number;
  35187. /**
  35188. * Returns a boolean indicating if the scene is still loading data
  35189. */
  35190. readonly isLoading: boolean;
  35191. /**
  35192. * Registers a function to be executed when the scene is ready
  35193. * @param {Function} func - the function to be executed
  35194. */
  35195. executeWhenReady(func: () => void): void;
  35196. /**
  35197. * Returns a promise that resolves when the scene is ready
  35198. * @returns A promise that resolves when the scene is ready
  35199. */
  35200. whenReadyAsync(): Promise<void>;
  35201. /** @hidden */
  35202. _checkIsReady(): void;
  35203. /**
  35204. * Gets all animatable attached to the scene
  35205. */
  35206. readonly animatables: Animatable[];
  35207. /**
  35208. * Resets the last animation time frame.
  35209. * Useful to override when animations start running when loading a scene for the first time.
  35210. */
  35211. resetLastAnimationTimeFrame(): void;
  35212. /**
  35213. * Gets the current view matrix
  35214. * @returns a Matrix
  35215. */
  35216. getViewMatrix(): Matrix;
  35217. /**
  35218. * Gets the current projection matrix
  35219. * @returns a Matrix
  35220. */
  35221. getProjectionMatrix(): Matrix;
  35222. /**
  35223. * Gets the current transform matrix
  35224. * @returns a Matrix made of View * Projection
  35225. */
  35226. getTransformMatrix(): Matrix;
  35227. /**
  35228. * Sets the current transform matrix
  35229. * @param viewL defines the View matrix to use
  35230. * @param projectionL defines the Projection matrix to use
  35231. * @param viewR defines the right View matrix to use (if provided)
  35232. * @param projectionR defines the right Projection matrix to use (if provided)
  35233. */
  35234. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35235. /**
  35236. * Gets the uniform buffer used to store scene data
  35237. * @returns a UniformBuffer
  35238. */
  35239. getSceneUniformBuffer(): UniformBuffer;
  35240. /**
  35241. * Gets an unique (relatively to the current scene) Id
  35242. * @returns an unique number for the scene
  35243. */
  35244. getUniqueId(): number;
  35245. /**
  35246. * Add a mesh to the list of scene's meshes
  35247. * @param newMesh defines the mesh to add
  35248. * @param recursive if all child meshes should also be added to the scene
  35249. */
  35250. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35251. /**
  35252. * Remove a mesh for the list of scene's meshes
  35253. * @param toRemove defines the mesh to remove
  35254. * @param recursive if all child meshes should also be removed from the scene
  35255. * @returns the index where the mesh was in the mesh list
  35256. */
  35257. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35258. /**
  35259. * Add a transform node to the list of scene's transform nodes
  35260. * @param newTransformNode defines the transform node to add
  35261. */
  35262. addTransformNode(newTransformNode: TransformNode): void;
  35263. /**
  35264. * Remove a transform node for the list of scene's transform nodes
  35265. * @param toRemove defines the transform node to remove
  35266. * @returns the index where the transform node was in the transform node list
  35267. */
  35268. removeTransformNode(toRemove: TransformNode): number;
  35269. /**
  35270. * Remove a skeleton for the list of scene's skeletons
  35271. * @param toRemove defines the skeleton to remove
  35272. * @returns the index where the skeleton was in the skeleton list
  35273. */
  35274. removeSkeleton(toRemove: Skeleton): number;
  35275. /**
  35276. * Remove a morph target for the list of scene's morph targets
  35277. * @param toRemove defines the morph target to remove
  35278. * @returns the index where the morph target was in the morph target list
  35279. */
  35280. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35281. /**
  35282. * Remove a light for the list of scene's lights
  35283. * @param toRemove defines the light to remove
  35284. * @returns the index where the light was in the light list
  35285. */
  35286. removeLight(toRemove: Light): number;
  35287. /**
  35288. * Remove a camera for the list of scene's cameras
  35289. * @param toRemove defines the camera to remove
  35290. * @returns the index where the camera was in the camera list
  35291. */
  35292. removeCamera(toRemove: Camera): number;
  35293. /**
  35294. * Remove a particle system for the list of scene's particle systems
  35295. * @param toRemove defines the particle system to remove
  35296. * @returns the index where the particle system was in the particle system list
  35297. */
  35298. removeParticleSystem(toRemove: IParticleSystem): number;
  35299. /**
  35300. * Remove a animation for the list of scene's animations
  35301. * @param toRemove defines the animation to remove
  35302. * @returns the index where the animation was in the animation list
  35303. */
  35304. removeAnimation(toRemove: Animation): number;
  35305. /**
  35306. * Will stop the animation of the given target
  35307. * @param target - the target
  35308. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35309. * @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)
  35310. */
  35311. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35312. /**
  35313. * Removes the given animation group from this scene.
  35314. * @param toRemove The animation group to remove
  35315. * @returns The index of the removed animation group
  35316. */
  35317. removeAnimationGroup(toRemove: AnimationGroup): number;
  35318. /**
  35319. * Removes the given multi-material from this scene.
  35320. * @param toRemove The multi-material to remove
  35321. * @returns The index of the removed multi-material
  35322. */
  35323. removeMultiMaterial(toRemove: MultiMaterial): number;
  35324. /**
  35325. * Removes the given material from this scene.
  35326. * @param toRemove The material to remove
  35327. * @returns The index of the removed material
  35328. */
  35329. removeMaterial(toRemove: Material): number;
  35330. /**
  35331. * Removes the given action manager from this scene.
  35332. * @param toRemove The action manager to remove
  35333. * @returns The index of the removed action manager
  35334. */
  35335. removeActionManager(toRemove: AbstractActionManager): number;
  35336. /**
  35337. * Removes the given texture from this scene.
  35338. * @param toRemove The texture to remove
  35339. * @returns The index of the removed texture
  35340. */
  35341. removeTexture(toRemove: BaseTexture): number;
  35342. /**
  35343. * Adds the given light to this scene
  35344. * @param newLight The light to add
  35345. */
  35346. addLight(newLight: Light): void;
  35347. /**
  35348. * Sorts the list list based on light priorities
  35349. */
  35350. sortLightsByPriority(): void;
  35351. /**
  35352. * Adds the given camera to this scene
  35353. * @param newCamera The camera to add
  35354. */
  35355. addCamera(newCamera: Camera): void;
  35356. /**
  35357. * Adds the given skeleton to this scene
  35358. * @param newSkeleton The skeleton to add
  35359. */
  35360. addSkeleton(newSkeleton: Skeleton): void;
  35361. /**
  35362. * Adds the given particle system to this scene
  35363. * @param newParticleSystem The particle system to add
  35364. */
  35365. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35366. /**
  35367. * Adds the given animation to this scene
  35368. * @param newAnimation The animation to add
  35369. */
  35370. addAnimation(newAnimation: Animation): void;
  35371. /**
  35372. * Adds the given animation group to this scene.
  35373. * @param newAnimationGroup The animation group to add
  35374. */
  35375. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35376. /**
  35377. * Adds the given multi-material to this scene
  35378. * @param newMultiMaterial The multi-material to add
  35379. */
  35380. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35381. /**
  35382. * Adds the given material to this scene
  35383. * @param newMaterial The material to add
  35384. */
  35385. addMaterial(newMaterial: Material): void;
  35386. /**
  35387. * Adds the given morph target to this scene
  35388. * @param newMorphTargetManager The morph target to add
  35389. */
  35390. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35391. /**
  35392. * Adds the given geometry to this scene
  35393. * @param newGeometry The geometry to add
  35394. */
  35395. addGeometry(newGeometry: Geometry): void;
  35396. /**
  35397. * Adds the given action manager to this scene
  35398. * @param newActionManager The action manager to add
  35399. */
  35400. addActionManager(newActionManager: AbstractActionManager): void;
  35401. /**
  35402. * Adds the given texture to this scene.
  35403. * @param newTexture The texture to add
  35404. */
  35405. addTexture(newTexture: BaseTexture): void;
  35406. /**
  35407. * Switch active camera
  35408. * @param newCamera defines the new active camera
  35409. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35410. */
  35411. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35412. /**
  35413. * sets the active camera of the scene using its ID
  35414. * @param id defines the camera's ID
  35415. * @return the new active camera or null if none found.
  35416. */
  35417. setActiveCameraByID(id: string): Nullable<Camera>;
  35418. /**
  35419. * sets the active camera of the scene using its name
  35420. * @param name defines the camera's name
  35421. * @returns the new active camera or null if none found.
  35422. */
  35423. setActiveCameraByName(name: string): Nullable<Camera>;
  35424. /**
  35425. * get an animation group using its name
  35426. * @param name defines the material's name
  35427. * @return the animation group or null if none found.
  35428. */
  35429. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35430. /**
  35431. * Get a material using its unique id
  35432. * @param uniqueId defines the material's unique id
  35433. * @return the material or null if none found.
  35434. */
  35435. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35436. /**
  35437. * get a material using its id
  35438. * @param id defines the material's ID
  35439. * @return the material or null if none found.
  35440. */
  35441. getMaterialByID(id: string): Nullable<Material>;
  35442. /**
  35443. * Gets a the last added material using a given id
  35444. * @param id defines the material's ID
  35445. * @return the last material with the given id or null if none found.
  35446. */
  35447. getLastMaterialByID(id: string): Nullable<Material>;
  35448. /**
  35449. * Gets a material using its name
  35450. * @param name defines the material's name
  35451. * @return the material or null if none found.
  35452. */
  35453. getMaterialByName(name: string): Nullable<Material>;
  35454. /**
  35455. * Get a texture using its unique id
  35456. * @param uniqueId defines the texture's unique id
  35457. * @return the texture or null if none found.
  35458. */
  35459. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35460. /**
  35461. * Gets a camera using its id
  35462. * @param id defines the id to look for
  35463. * @returns the camera or null if not found
  35464. */
  35465. getCameraByID(id: string): Nullable<Camera>;
  35466. /**
  35467. * Gets a camera using its unique id
  35468. * @param uniqueId defines the unique id to look for
  35469. * @returns the camera or null if not found
  35470. */
  35471. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35472. /**
  35473. * Gets a camera using its name
  35474. * @param name defines the camera's name
  35475. * @return the camera or null if none found.
  35476. */
  35477. getCameraByName(name: string): Nullable<Camera>;
  35478. /**
  35479. * Gets a bone using its id
  35480. * @param id defines the bone's id
  35481. * @return the bone or null if not found
  35482. */
  35483. getBoneByID(id: string): Nullable<Bone>;
  35484. /**
  35485. * Gets a bone using its id
  35486. * @param name defines the bone's name
  35487. * @return the bone or null if not found
  35488. */
  35489. getBoneByName(name: string): Nullable<Bone>;
  35490. /**
  35491. * Gets a light node using its name
  35492. * @param name defines the the light's name
  35493. * @return the light or null if none found.
  35494. */
  35495. getLightByName(name: string): Nullable<Light>;
  35496. /**
  35497. * Gets a light node using its id
  35498. * @param id defines the light's id
  35499. * @return the light or null if none found.
  35500. */
  35501. getLightByID(id: string): Nullable<Light>;
  35502. /**
  35503. * Gets a light node using its scene-generated unique ID
  35504. * @param uniqueId defines the light's unique id
  35505. * @return the light or null if none found.
  35506. */
  35507. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35508. /**
  35509. * Gets a particle system by id
  35510. * @param id defines the particle system id
  35511. * @return the corresponding system or null if none found
  35512. */
  35513. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35514. /**
  35515. * Gets a geometry using its ID
  35516. * @param id defines the geometry's id
  35517. * @return the geometry or null if none found.
  35518. */
  35519. getGeometryByID(id: string): Nullable<Geometry>;
  35520. private _getGeometryByUniqueID;
  35521. /**
  35522. * Add a new geometry to this scene
  35523. * @param geometry defines the geometry to be added to the scene.
  35524. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35525. * @return a boolean defining if the geometry was added or not
  35526. */
  35527. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35528. /**
  35529. * Removes an existing geometry
  35530. * @param geometry defines the geometry to be removed from the scene
  35531. * @return a boolean defining if the geometry was removed or not
  35532. */
  35533. removeGeometry(geometry: Geometry): boolean;
  35534. /**
  35535. * Gets the list of geometries attached to the scene
  35536. * @returns an array of Geometry
  35537. */
  35538. getGeometries(): Geometry[];
  35539. /**
  35540. * Gets the first added mesh found of a given ID
  35541. * @param id defines the id to search for
  35542. * @return the mesh found or null if not found at all
  35543. */
  35544. getMeshByID(id: string): Nullable<AbstractMesh>;
  35545. /**
  35546. * Gets a list of meshes using their id
  35547. * @param id defines the id to search for
  35548. * @returns a list of meshes
  35549. */
  35550. getMeshesByID(id: string): Array<AbstractMesh>;
  35551. /**
  35552. * Gets the first added transform node found of a given ID
  35553. * @param id defines the id to search for
  35554. * @return the found transform node or null if not found at all.
  35555. */
  35556. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35557. /**
  35558. * Gets a transform node with its auto-generated unique id
  35559. * @param uniqueId efines the unique id to search for
  35560. * @return the found transform node or null if not found at all.
  35561. */
  35562. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35563. /**
  35564. * Gets a list of transform nodes using their id
  35565. * @param id defines the id to search for
  35566. * @returns a list of transform nodes
  35567. */
  35568. getTransformNodesByID(id: string): Array<TransformNode>;
  35569. /**
  35570. * Gets a mesh with its auto-generated unique id
  35571. * @param uniqueId defines the unique id to search for
  35572. * @return the found mesh or null if not found at all.
  35573. */
  35574. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35575. /**
  35576. * Gets a the last added mesh using a given id
  35577. * @param id defines the id to search for
  35578. * @return the found mesh or null if not found at all.
  35579. */
  35580. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35581. /**
  35582. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35583. * @param id defines the id to search for
  35584. * @return the found node or null if not found at all
  35585. */
  35586. getLastEntryByID(id: string): Nullable<Node>;
  35587. /**
  35588. * Gets a node (Mesh, Camera, Light) using a given id
  35589. * @param id defines the id to search for
  35590. * @return the found node or null if not found at all
  35591. */
  35592. getNodeByID(id: string): Nullable<Node>;
  35593. /**
  35594. * Gets a node (Mesh, Camera, Light) using a given name
  35595. * @param name defines the name to search for
  35596. * @return the found node or null if not found at all.
  35597. */
  35598. getNodeByName(name: string): Nullable<Node>;
  35599. /**
  35600. * Gets a mesh using a given name
  35601. * @param name defines the name to search for
  35602. * @return the found mesh or null if not found at all.
  35603. */
  35604. getMeshByName(name: string): Nullable<AbstractMesh>;
  35605. /**
  35606. * Gets a transform node using a given name
  35607. * @param name defines the name to search for
  35608. * @return the found transform node or null if not found at all.
  35609. */
  35610. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35611. /**
  35612. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35613. * @param id defines the id to search for
  35614. * @return the found skeleton or null if not found at all.
  35615. */
  35616. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35617. /**
  35618. * Gets a skeleton using a given auto generated unique id
  35619. * @param uniqueId defines the unique id to search for
  35620. * @return the found skeleton or null if not found at all.
  35621. */
  35622. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35623. /**
  35624. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35625. * @param id defines the id to search for
  35626. * @return the found skeleton or null if not found at all.
  35627. */
  35628. getSkeletonById(id: string): Nullable<Skeleton>;
  35629. /**
  35630. * Gets a skeleton using a given name
  35631. * @param name defines the name to search for
  35632. * @return the found skeleton or null if not found at all.
  35633. */
  35634. getSkeletonByName(name: string): Nullable<Skeleton>;
  35635. /**
  35636. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35637. * @param id defines the id to search for
  35638. * @return the found morph target manager or null if not found at all.
  35639. */
  35640. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35641. /**
  35642. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35643. * @param id defines the id to search for
  35644. * @return the found morph target or null if not found at all.
  35645. */
  35646. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35647. /**
  35648. * Gets a boolean indicating if the given mesh is active
  35649. * @param mesh defines the mesh to look for
  35650. * @returns true if the mesh is in the active list
  35651. */
  35652. isActiveMesh(mesh: AbstractMesh): boolean;
  35653. /**
  35654. * Return a unique id as a string which can serve as an identifier for the scene
  35655. */
  35656. readonly uid: string;
  35657. /**
  35658. * Add an externaly attached data from its key.
  35659. * This method call will fail and return false, if such key already exists.
  35660. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35661. * @param key the unique key that identifies the data
  35662. * @param data the data object to associate to the key for this Engine instance
  35663. * @return true if no such key were already present and the data was added successfully, false otherwise
  35664. */
  35665. addExternalData<T>(key: string, data: T): boolean;
  35666. /**
  35667. * Get an externaly attached data from its key
  35668. * @param key the unique key that identifies the data
  35669. * @return the associated data, if present (can be null), or undefined if not present
  35670. */
  35671. getExternalData<T>(key: string): Nullable<T>;
  35672. /**
  35673. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35674. * @param key the unique key that identifies the data
  35675. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35676. * @return the associated data, can be null if the factory returned null.
  35677. */
  35678. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35679. /**
  35680. * Remove an externaly attached data from the Engine instance
  35681. * @param key the unique key that identifies the data
  35682. * @return true if the data was successfully removed, false if it doesn't exist
  35683. */
  35684. removeExternalData(key: string): boolean;
  35685. private _evaluateSubMesh;
  35686. /**
  35687. * Clear the processed materials smart array preventing retention point in material dispose.
  35688. */
  35689. freeProcessedMaterials(): void;
  35690. private _preventFreeActiveMeshesAndRenderingGroups;
  35691. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35692. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35693. * when disposing several meshes in a row or a hierarchy of meshes.
  35694. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35695. */
  35696. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35697. /**
  35698. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35699. */
  35700. freeActiveMeshes(): void;
  35701. /**
  35702. * Clear the info related to rendering groups preventing retention points during dispose.
  35703. */
  35704. freeRenderingGroups(): void;
  35705. /** @hidden */
  35706. _isInIntermediateRendering(): boolean;
  35707. /**
  35708. * Lambda returning the list of potentially active meshes.
  35709. */
  35710. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35711. /**
  35712. * Lambda returning the list of potentially active sub meshes.
  35713. */
  35714. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35715. /**
  35716. * Lambda returning the list of potentially intersecting sub meshes.
  35717. */
  35718. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35719. /**
  35720. * Lambda returning the list of potentially colliding sub meshes.
  35721. */
  35722. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35723. private _activeMeshesFrozen;
  35724. /**
  35725. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35726. * @returns the current scene
  35727. */
  35728. freezeActiveMeshes(): Scene;
  35729. /**
  35730. * Use this function to restart evaluating active meshes on every frame
  35731. * @returns the current scene
  35732. */
  35733. unfreezeActiveMeshes(): Scene;
  35734. private _evaluateActiveMeshes;
  35735. private _activeMesh;
  35736. /**
  35737. * Update the transform matrix to update from the current active camera
  35738. * @param force defines a boolean used to force the update even if cache is up to date
  35739. */
  35740. updateTransformMatrix(force?: boolean): void;
  35741. private _bindFrameBuffer;
  35742. /** @hidden */
  35743. _allowPostProcessClearColor: boolean;
  35744. /** @hidden */
  35745. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35746. private _processSubCameras;
  35747. private _checkIntersections;
  35748. /** @hidden */
  35749. _advancePhysicsEngineStep(step: number): void;
  35750. /**
  35751. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35752. */
  35753. getDeterministicFrameTime: () => number;
  35754. /** @hidden */
  35755. _animate(): void;
  35756. /** Execute all animations (for a frame) */
  35757. animate(): void;
  35758. /**
  35759. * Render the scene
  35760. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35761. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35762. */
  35763. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35764. /**
  35765. * Freeze all materials
  35766. * A frozen material will not be updatable but should be faster to render
  35767. */
  35768. freezeMaterials(): void;
  35769. /**
  35770. * Unfreeze all materials
  35771. * A frozen material will not be updatable but should be faster to render
  35772. */
  35773. unfreezeMaterials(): void;
  35774. /**
  35775. * Releases all held ressources
  35776. */
  35777. dispose(): void;
  35778. /**
  35779. * Gets if the scene is already disposed
  35780. */
  35781. readonly isDisposed: boolean;
  35782. /**
  35783. * Call this function to reduce memory footprint of the scene.
  35784. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35785. */
  35786. clearCachedVertexData(): void;
  35787. /**
  35788. * This function will remove the local cached buffer data from texture.
  35789. * It will save memory but will prevent the texture from being rebuilt
  35790. */
  35791. cleanCachedTextureBuffer(): void;
  35792. /**
  35793. * Get the world extend vectors with an optional filter
  35794. *
  35795. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35796. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35797. */
  35798. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35799. min: Vector3;
  35800. max: Vector3;
  35801. };
  35802. /**
  35803. * Creates a ray that can be used to pick in the scene
  35804. * @param x defines the x coordinate of the origin (on-screen)
  35805. * @param y defines the y coordinate of the origin (on-screen)
  35806. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35807. * @param camera defines the camera to use for the picking
  35808. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35809. * @returns a Ray
  35810. */
  35811. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35812. /**
  35813. * Creates a ray that can be used to pick in the scene
  35814. * @param x defines the x coordinate of the origin (on-screen)
  35815. * @param y defines the y coordinate of the origin (on-screen)
  35816. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35817. * @param result defines the ray where to store the picking ray
  35818. * @param camera defines the camera to use for the picking
  35819. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35820. * @returns the current scene
  35821. */
  35822. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35823. /**
  35824. * Creates a ray that can be used to pick in the scene
  35825. * @param x defines the x coordinate of the origin (on-screen)
  35826. * @param y defines the y coordinate of the origin (on-screen)
  35827. * @param camera defines the camera to use for the picking
  35828. * @returns a Ray
  35829. */
  35830. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35831. /**
  35832. * Creates a ray that can be used to pick in the scene
  35833. * @param x defines the x coordinate of the origin (on-screen)
  35834. * @param y defines the y coordinate of the origin (on-screen)
  35835. * @param result defines the ray where to store the picking ray
  35836. * @param camera defines the camera to use for the picking
  35837. * @returns the current scene
  35838. */
  35839. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35840. /** Launch a ray to try to pick a mesh in the scene
  35841. * @param x position on screen
  35842. * @param y position on screen
  35843. * @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
  35844. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35845. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35846. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35847. * @returns a PickingInfo
  35848. */
  35849. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35850. /** Use the given ray to pick a mesh in the scene
  35851. * @param ray The ray to use to pick meshes
  35852. * @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
  35853. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35854. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35855. * @returns a PickingInfo
  35856. */
  35857. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35858. /**
  35859. * Launch a ray to try to pick a mesh in the scene
  35860. * @param x X position on screen
  35861. * @param y Y position on screen
  35862. * @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
  35863. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35864. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35865. * @returns an array of PickingInfo
  35866. */
  35867. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35868. /**
  35869. * Launch a ray to try to pick a mesh in the scene
  35870. * @param ray Ray to use
  35871. * @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
  35872. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35873. * @returns an array of PickingInfo
  35874. */
  35875. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35876. /**
  35877. * Force the value of meshUnderPointer
  35878. * @param mesh defines the mesh to use
  35879. */
  35880. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35881. /**
  35882. * Gets the mesh under the pointer
  35883. * @returns a Mesh or null if no mesh is under the pointer
  35884. */
  35885. getPointerOverMesh(): Nullable<AbstractMesh>;
  35886. /** @hidden */
  35887. _rebuildGeometries(): void;
  35888. /** @hidden */
  35889. _rebuildTextures(): void;
  35890. private _getByTags;
  35891. /**
  35892. * Get a list of meshes by tags
  35893. * @param tagsQuery defines the tags query to use
  35894. * @param forEach defines a predicate used to filter results
  35895. * @returns an array of Mesh
  35896. */
  35897. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35898. /**
  35899. * Get a list of cameras by tags
  35900. * @param tagsQuery defines the tags query to use
  35901. * @param forEach defines a predicate used to filter results
  35902. * @returns an array of Camera
  35903. */
  35904. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35905. /**
  35906. * Get a list of lights by tags
  35907. * @param tagsQuery defines the tags query to use
  35908. * @param forEach defines a predicate used to filter results
  35909. * @returns an array of Light
  35910. */
  35911. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35912. /**
  35913. * Get a list of materials by tags
  35914. * @param tagsQuery defines the tags query to use
  35915. * @param forEach defines a predicate used to filter results
  35916. * @returns an array of Material
  35917. */
  35918. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35919. /**
  35920. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35921. * This allowed control for front to back rendering or reversly depending of the special needs.
  35922. *
  35923. * @param renderingGroupId The rendering group id corresponding to its index
  35924. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35925. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35926. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35927. */
  35928. 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;
  35929. /**
  35930. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35931. *
  35932. * @param renderingGroupId The rendering group id corresponding to its index
  35933. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35934. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35935. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35936. */
  35937. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35938. /**
  35939. * Gets the current auto clear configuration for one rendering group of the rendering
  35940. * manager.
  35941. * @param index the rendering group index to get the information for
  35942. * @returns The auto clear setup for the requested rendering group
  35943. */
  35944. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35945. private _blockMaterialDirtyMechanism;
  35946. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35947. blockMaterialDirtyMechanism: boolean;
  35948. /**
  35949. * Will flag all materials as dirty to trigger new shader compilation
  35950. * @param flag defines the flag used to specify which material part must be marked as dirty
  35951. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35952. */
  35953. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35954. /** @hidden */
  35955. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  35956. /** @hidden */
  35957. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35958. /** @hidden */
  35959. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  35960. /** @hidden */
  35961. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35962. /** @hidden */
  35963. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35964. /** @hidden */
  35965. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35966. }
  35967. }
  35968. declare module "babylonjs/assetContainer" {
  35969. import { AbstractScene } from "babylonjs/abstractScene";
  35970. import { Scene } from "babylonjs/scene";
  35971. import { Mesh } from "babylonjs/Meshes/mesh";
  35972. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35973. import { Skeleton } from "babylonjs/Bones/skeleton";
  35974. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35975. /**
  35976. * Set of assets to keep when moving a scene into an asset container.
  35977. */
  35978. export class KeepAssets extends AbstractScene {
  35979. }
  35980. /**
  35981. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  35982. */
  35983. export class InstantiatedEntries {
  35984. /**
  35985. * List of new root nodes (eg. nodes with no parent)
  35986. */
  35987. rootNodes: TransformNode[];
  35988. /**
  35989. * List of new skeletons
  35990. */
  35991. skeletons: Skeleton[];
  35992. /**
  35993. * List of new animation groups
  35994. */
  35995. animationGroups: AnimationGroup[];
  35996. }
  35997. /**
  35998. * Container with a set of assets that can be added or removed from a scene.
  35999. */
  36000. export class AssetContainer extends AbstractScene {
  36001. /**
  36002. * The scene the AssetContainer belongs to.
  36003. */
  36004. scene: Scene;
  36005. /**
  36006. * Instantiates an AssetContainer.
  36007. * @param scene The scene the AssetContainer belongs to.
  36008. */
  36009. constructor(scene: Scene);
  36010. /**
  36011. * Instantiate or clone all meshes and add the new ones to the scene.
  36012. * Skeletons and animation groups will all be cloned
  36013. * @param nameFunction defines an optional function used to get new names for clones
  36014. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36015. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36016. */
  36017. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36018. /**
  36019. * Adds all the assets from the container to the scene.
  36020. */
  36021. addAllToScene(): void;
  36022. /**
  36023. * Removes all the assets in the container from the scene
  36024. */
  36025. removeAllFromScene(): void;
  36026. /**
  36027. * Disposes all the assets in the container
  36028. */
  36029. dispose(): void;
  36030. private _moveAssets;
  36031. /**
  36032. * Removes all the assets contained in the scene and adds them to the container.
  36033. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36034. */
  36035. moveAllFromScene(keepAssets?: KeepAssets): void;
  36036. /**
  36037. * 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.
  36038. * @returns the root mesh
  36039. */
  36040. createRootMesh(): Mesh;
  36041. }
  36042. }
  36043. declare module "babylonjs/abstractScene" {
  36044. import { Scene } from "babylonjs/scene";
  36045. import { Nullable } from "babylonjs/types";
  36046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36047. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36048. import { Geometry } from "babylonjs/Meshes/geometry";
  36049. import { Skeleton } from "babylonjs/Bones/skeleton";
  36050. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36051. import { AssetContainer } from "babylonjs/assetContainer";
  36052. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36053. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36054. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36055. import { Material } from "babylonjs/Materials/material";
  36056. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36057. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36058. import { Camera } from "babylonjs/Cameras/camera";
  36059. import { Light } from "babylonjs/Lights/light";
  36060. import { Node } from "babylonjs/node";
  36061. import { Animation } from "babylonjs/Animations/animation";
  36062. /**
  36063. * Defines how the parser contract is defined.
  36064. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36065. */
  36066. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36067. /**
  36068. * Defines how the individual parser contract is defined.
  36069. * These parser can parse an individual asset
  36070. */
  36071. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36072. /**
  36073. * Base class of the scene acting as a container for the different elements composing a scene.
  36074. * This class is dynamically extended by the different components of the scene increasing
  36075. * flexibility and reducing coupling
  36076. */
  36077. export abstract class AbstractScene {
  36078. /**
  36079. * Stores the list of available parsers in the application.
  36080. */
  36081. private static _BabylonFileParsers;
  36082. /**
  36083. * Stores the list of available individual parsers in the application.
  36084. */
  36085. private static _IndividualBabylonFileParsers;
  36086. /**
  36087. * Adds a parser in the list of available ones
  36088. * @param name Defines the name of the parser
  36089. * @param parser Defines the parser to add
  36090. */
  36091. static AddParser(name: string, parser: BabylonFileParser): void;
  36092. /**
  36093. * Gets a general parser from the list of avaialble ones
  36094. * @param name Defines the name of the parser
  36095. * @returns the requested parser or null
  36096. */
  36097. static GetParser(name: string): Nullable<BabylonFileParser>;
  36098. /**
  36099. * Adds n individual parser in the list of available ones
  36100. * @param name Defines the name of the parser
  36101. * @param parser Defines the parser to add
  36102. */
  36103. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36104. /**
  36105. * Gets an individual parser from the list of avaialble ones
  36106. * @param name Defines the name of the parser
  36107. * @returns the requested parser or null
  36108. */
  36109. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36110. /**
  36111. * Parser json data and populate both a scene and its associated container object
  36112. * @param jsonData Defines the data to parse
  36113. * @param scene Defines the scene to parse the data for
  36114. * @param container Defines the container attached to the parsing sequence
  36115. * @param rootUrl Defines the root url of the data
  36116. */
  36117. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36118. /**
  36119. * Gets the list of root nodes (ie. nodes with no parent)
  36120. */
  36121. rootNodes: Node[];
  36122. /** All of the cameras added to this scene
  36123. * @see http://doc.babylonjs.com/babylon101/cameras
  36124. */
  36125. cameras: Camera[];
  36126. /**
  36127. * All of the lights added to this scene
  36128. * @see http://doc.babylonjs.com/babylon101/lights
  36129. */
  36130. lights: Light[];
  36131. /**
  36132. * All of the (abstract) meshes added to this scene
  36133. */
  36134. meshes: AbstractMesh[];
  36135. /**
  36136. * The list of skeletons added to the scene
  36137. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36138. */
  36139. skeletons: Skeleton[];
  36140. /**
  36141. * All of the particle systems added to this scene
  36142. * @see http://doc.babylonjs.com/babylon101/particles
  36143. */
  36144. particleSystems: IParticleSystem[];
  36145. /**
  36146. * Gets a list of Animations associated with the scene
  36147. */
  36148. animations: Animation[];
  36149. /**
  36150. * All of the animation groups added to this scene
  36151. * @see http://doc.babylonjs.com/how_to/group
  36152. */
  36153. animationGroups: AnimationGroup[];
  36154. /**
  36155. * All of the multi-materials added to this scene
  36156. * @see http://doc.babylonjs.com/how_to/multi_materials
  36157. */
  36158. multiMaterials: MultiMaterial[];
  36159. /**
  36160. * All of the materials added to this scene
  36161. * In the context of a Scene, it is not supposed to be modified manually.
  36162. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36163. * Note also that the order of the Material within the array is not significant and might change.
  36164. * @see http://doc.babylonjs.com/babylon101/materials
  36165. */
  36166. materials: Material[];
  36167. /**
  36168. * The list of morph target managers added to the scene
  36169. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36170. */
  36171. morphTargetManagers: MorphTargetManager[];
  36172. /**
  36173. * The list of geometries used in the scene.
  36174. */
  36175. geometries: Geometry[];
  36176. /**
  36177. * All of the tranform nodes added to this scene
  36178. * In the context of a Scene, it is not supposed to be modified manually.
  36179. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36180. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36181. * @see http://doc.babylonjs.com/how_to/transformnode
  36182. */
  36183. transformNodes: TransformNode[];
  36184. /**
  36185. * ActionManagers available on the scene.
  36186. */
  36187. actionManagers: AbstractActionManager[];
  36188. /**
  36189. * Textures to keep.
  36190. */
  36191. textures: BaseTexture[];
  36192. /**
  36193. * Environment texture for the scene
  36194. */
  36195. environmentTexture: Nullable<BaseTexture>;
  36196. }
  36197. }
  36198. declare module "babylonjs/Audio/sound" {
  36199. import { Observable } from "babylonjs/Misc/observable";
  36200. import { Vector3 } from "babylonjs/Maths/math.vector";
  36201. import { Nullable } from "babylonjs/types";
  36202. import { Scene } from "babylonjs/scene";
  36203. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36204. /**
  36205. * Interface used to define options for Sound class
  36206. */
  36207. export interface ISoundOptions {
  36208. /**
  36209. * Does the sound autoplay once loaded.
  36210. */
  36211. autoplay?: boolean;
  36212. /**
  36213. * Does the sound loop after it finishes playing once.
  36214. */
  36215. loop?: boolean;
  36216. /**
  36217. * Sound's volume
  36218. */
  36219. volume?: number;
  36220. /**
  36221. * Is it a spatial sound?
  36222. */
  36223. spatialSound?: boolean;
  36224. /**
  36225. * Maximum distance to hear that sound
  36226. */
  36227. maxDistance?: number;
  36228. /**
  36229. * Uses user defined attenuation function
  36230. */
  36231. useCustomAttenuation?: boolean;
  36232. /**
  36233. * Define the roll off factor of spatial sounds.
  36234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36235. */
  36236. rolloffFactor?: number;
  36237. /**
  36238. * Define the reference distance the sound should be heard perfectly.
  36239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36240. */
  36241. refDistance?: number;
  36242. /**
  36243. * Define the distance attenuation model the sound will follow.
  36244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36245. */
  36246. distanceModel?: string;
  36247. /**
  36248. * Defines the playback speed (1 by default)
  36249. */
  36250. playbackRate?: number;
  36251. /**
  36252. * Defines if the sound is from a streaming source
  36253. */
  36254. streaming?: boolean;
  36255. /**
  36256. * Defines an optional length (in seconds) inside the sound file
  36257. */
  36258. length?: number;
  36259. /**
  36260. * Defines an optional offset (in seconds) inside the sound file
  36261. */
  36262. offset?: number;
  36263. /**
  36264. * If true, URLs will not be required to state the audio file codec to use.
  36265. */
  36266. skipCodecCheck?: boolean;
  36267. }
  36268. /**
  36269. * Defines a sound that can be played in the application.
  36270. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36272. */
  36273. export class Sound {
  36274. /**
  36275. * The name of the sound in the scene.
  36276. */
  36277. name: string;
  36278. /**
  36279. * Does the sound autoplay once loaded.
  36280. */
  36281. autoplay: boolean;
  36282. /**
  36283. * Does the sound loop after it finishes playing once.
  36284. */
  36285. loop: boolean;
  36286. /**
  36287. * Does the sound use a custom attenuation curve to simulate the falloff
  36288. * happening when the source gets further away from the camera.
  36289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36290. */
  36291. useCustomAttenuation: boolean;
  36292. /**
  36293. * The sound track id this sound belongs to.
  36294. */
  36295. soundTrackId: number;
  36296. /**
  36297. * Is this sound currently played.
  36298. */
  36299. isPlaying: boolean;
  36300. /**
  36301. * Is this sound currently paused.
  36302. */
  36303. isPaused: boolean;
  36304. /**
  36305. * Does this sound enables spatial sound.
  36306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36307. */
  36308. spatialSound: boolean;
  36309. /**
  36310. * Define the reference distance the sound should be heard perfectly.
  36311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36312. */
  36313. refDistance: number;
  36314. /**
  36315. * Define the roll off factor of spatial sounds.
  36316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36317. */
  36318. rolloffFactor: number;
  36319. /**
  36320. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36322. */
  36323. maxDistance: number;
  36324. /**
  36325. * Define the distance attenuation model the sound will follow.
  36326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36327. */
  36328. distanceModel: string;
  36329. /**
  36330. * @hidden
  36331. * Back Compat
  36332. **/
  36333. onended: () => any;
  36334. /**
  36335. * Observable event when the current playing sound finishes.
  36336. */
  36337. onEndedObservable: Observable<Sound>;
  36338. private _panningModel;
  36339. private _playbackRate;
  36340. private _streaming;
  36341. private _startTime;
  36342. private _startOffset;
  36343. private _position;
  36344. /** @hidden */
  36345. _positionInEmitterSpace: boolean;
  36346. private _localDirection;
  36347. private _volume;
  36348. private _isReadyToPlay;
  36349. private _isDirectional;
  36350. private _readyToPlayCallback;
  36351. private _audioBuffer;
  36352. private _soundSource;
  36353. private _streamingSource;
  36354. private _soundPanner;
  36355. private _soundGain;
  36356. private _inputAudioNode;
  36357. private _outputAudioNode;
  36358. private _coneInnerAngle;
  36359. private _coneOuterAngle;
  36360. private _coneOuterGain;
  36361. private _scene;
  36362. private _connectedTransformNode;
  36363. private _customAttenuationFunction;
  36364. private _registerFunc;
  36365. private _isOutputConnected;
  36366. private _htmlAudioElement;
  36367. private _urlType;
  36368. private _length?;
  36369. private _offset?;
  36370. /** @hidden */
  36371. static _SceneComponentInitialization: (scene: Scene) => void;
  36372. /**
  36373. * Create a sound and attach it to a scene
  36374. * @param name Name of your sound
  36375. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36376. * @param scene defines the scene the sound belongs to
  36377. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36378. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36379. */
  36380. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36381. /**
  36382. * Release the sound and its associated resources
  36383. */
  36384. dispose(): void;
  36385. /**
  36386. * Gets if the sounds is ready to be played or not.
  36387. * @returns true if ready, otherwise false
  36388. */
  36389. isReady(): boolean;
  36390. private _soundLoaded;
  36391. /**
  36392. * Sets the data of the sound from an audiobuffer
  36393. * @param audioBuffer The audioBuffer containing the data
  36394. */
  36395. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36396. /**
  36397. * Updates the current sounds options such as maxdistance, loop...
  36398. * @param options A JSON object containing values named as the object properties
  36399. */
  36400. updateOptions(options: ISoundOptions): void;
  36401. private _createSpatialParameters;
  36402. private _updateSpatialParameters;
  36403. /**
  36404. * Switch the panning model to HRTF:
  36405. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36407. */
  36408. switchPanningModelToHRTF(): void;
  36409. /**
  36410. * Switch the panning model to Equal Power:
  36411. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36413. */
  36414. switchPanningModelToEqualPower(): void;
  36415. private _switchPanningModel;
  36416. /**
  36417. * Connect this sound to a sound track audio node like gain...
  36418. * @param soundTrackAudioNode the sound track audio node to connect to
  36419. */
  36420. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36421. /**
  36422. * Transform this sound into a directional source
  36423. * @param coneInnerAngle Size of the inner cone in degree
  36424. * @param coneOuterAngle Size of the outer cone in degree
  36425. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36426. */
  36427. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36428. /**
  36429. * Gets or sets the inner angle for the directional cone.
  36430. */
  36431. /**
  36432. * Gets or sets the inner angle for the directional cone.
  36433. */
  36434. directionalConeInnerAngle: number;
  36435. /**
  36436. * Gets or sets the outer angle for the directional cone.
  36437. */
  36438. /**
  36439. * Gets or sets the outer angle for the directional cone.
  36440. */
  36441. directionalConeOuterAngle: number;
  36442. /**
  36443. * Sets the position of the emitter if spatial sound is enabled
  36444. * @param newPosition Defines the new posisiton
  36445. */
  36446. setPosition(newPosition: Vector3): void;
  36447. /**
  36448. * Sets the local direction of the emitter if spatial sound is enabled
  36449. * @param newLocalDirection Defines the new local direction
  36450. */
  36451. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36452. private _updateDirection;
  36453. /** @hidden */
  36454. updateDistanceFromListener(): void;
  36455. /**
  36456. * Sets a new custom attenuation function for the sound.
  36457. * @param callback Defines the function used for the attenuation
  36458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36459. */
  36460. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36461. /**
  36462. * Play the sound
  36463. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36464. * @param offset (optional) Start the sound at a specific time in seconds
  36465. * @param length (optional) Sound duration (in seconds)
  36466. */
  36467. play(time?: number, offset?: number, length?: number): void;
  36468. private _onended;
  36469. /**
  36470. * Stop the sound
  36471. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36472. */
  36473. stop(time?: number): void;
  36474. /**
  36475. * Put the sound in pause
  36476. */
  36477. pause(): void;
  36478. /**
  36479. * Sets a dedicated volume for this sounds
  36480. * @param newVolume Define the new volume of the sound
  36481. * @param time Define time for gradual change to new volume
  36482. */
  36483. setVolume(newVolume: number, time?: number): void;
  36484. /**
  36485. * Set the sound play back rate
  36486. * @param newPlaybackRate Define the playback rate the sound should be played at
  36487. */
  36488. setPlaybackRate(newPlaybackRate: number): void;
  36489. /**
  36490. * Gets the volume of the sound.
  36491. * @returns the volume of the sound
  36492. */
  36493. getVolume(): number;
  36494. /**
  36495. * Attach the sound to a dedicated mesh
  36496. * @param transformNode The transform node to connect the sound with
  36497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36498. */
  36499. attachToMesh(transformNode: TransformNode): void;
  36500. /**
  36501. * Detach the sound from the previously attached mesh
  36502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36503. */
  36504. detachFromMesh(): void;
  36505. private _onRegisterAfterWorldMatrixUpdate;
  36506. /**
  36507. * Clone the current sound in the scene.
  36508. * @returns the new sound clone
  36509. */
  36510. clone(): Nullable<Sound>;
  36511. /**
  36512. * Gets the current underlying audio buffer containing the data
  36513. * @returns the audio buffer
  36514. */
  36515. getAudioBuffer(): Nullable<AudioBuffer>;
  36516. /**
  36517. * Serializes the Sound in a JSON representation
  36518. * @returns the JSON representation of the sound
  36519. */
  36520. serialize(): any;
  36521. /**
  36522. * Parse a JSON representation of a sound to innstantiate in a given scene
  36523. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36524. * @param scene Define the scene the new parsed sound should be created in
  36525. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36526. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36527. * @returns the newly parsed sound
  36528. */
  36529. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36530. }
  36531. }
  36532. declare module "babylonjs/Actions/directAudioActions" {
  36533. import { Action } from "babylonjs/Actions/action";
  36534. import { Condition } from "babylonjs/Actions/condition";
  36535. import { Sound } from "babylonjs/Audio/sound";
  36536. /**
  36537. * This defines an action helpful to play a defined sound on a triggered action.
  36538. */
  36539. export class PlaySoundAction extends Action {
  36540. private _sound;
  36541. /**
  36542. * Instantiate the action
  36543. * @param triggerOptions defines the trigger options
  36544. * @param sound defines the sound to play
  36545. * @param condition defines the trigger related conditions
  36546. */
  36547. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36548. /** @hidden */
  36549. _prepare(): void;
  36550. /**
  36551. * Execute the action and play the sound.
  36552. */
  36553. execute(): void;
  36554. /**
  36555. * Serializes the actions and its related information.
  36556. * @param parent defines the object to serialize in
  36557. * @returns the serialized object
  36558. */
  36559. serialize(parent: any): any;
  36560. }
  36561. /**
  36562. * This defines an action helpful to stop a defined sound on a triggered action.
  36563. */
  36564. export class StopSoundAction extends Action {
  36565. private _sound;
  36566. /**
  36567. * Instantiate the action
  36568. * @param triggerOptions defines the trigger options
  36569. * @param sound defines the sound to stop
  36570. * @param condition defines the trigger related conditions
  36571. */
  36572. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36573. /** @hidden */
  36574. _prepare(): void;
  36575. /**
  36576. * Execute the action and stop the sound.
  36577. */
  36578. execute(): void;
  36579. /**
  36580. * Serializes the actions and its related information.
  36581. * @param parent defines the object to serialize in
  36582. * @returns the serialized object
  36583. */
  36584. serialize(parent: any): any;
  36585. }
  36586. }
  36587. declare module "babylonjs/Actions/interpolateValueAction" {
  36588. import { Action } from "babylonjs/Actions/action";
  36589. import { Condition } from "babylonjs/Actions/condition";
  36590. import { Observable } from "babylonjs/Misc/observable";
  36591. /**
  36592. * This defines an action responsible to change the value of a property
  36593. * by interpolating between its current value and the newly set one once triggered.
  36594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36595. */
  36596. export class InterpolateValueAction extends Action {
  36597. /**
  36598. * Defines the path of the property where the value should be interpolated
  36599. */
  36600. propertyPath: string;
  36601. /**
  36602. * Defines the target value at the end of the interpolation.
  36603. */
  36604. value: any;
  36605. /**
  36606. * Defines the time it will take for the property to interpolate to the value.
  36607. */
  36608. duration: number;
  36609. /**
  36610. * Defines if the other scene animations should be stopped when the action has been triggered
  36611. */
  36612. stopOtherAnimations?: boolean;
  36613. /**
  36614. * Defines a callback raised once the interpolation animation has been done.
  36615. */
  36616. onInterpolationDone?: () => void;
  36617. /**
  36618. * Observable triggered once the interpolation animation has been done.
  36619. */
  36620. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36621. private _target;
  36622. private _effectiveTarget;
  36623. private _property;
  36624. /**
  36625. * Instantiate the action
  36626. * @param triggerOptions defines the trigger options
  36627. * @param target defines the object containing the value to interpolate
  36628. * @param propertyPath defines the path to the property in the target object
  36629. * @param value defines the target value at the end of the interpolation
  36630. * @param duration deines the time it will take for the property to interpolate to the value.
  36631. * @param condition defines the trigger related conditions
  36632. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36633. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36634. */
  36635. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36636. /** @hidden */
  36637. _prepare(): void;
  36638. /**
  36639. * Execute the action starts the value interpolation.
  36640. */
  36641. execute(): void;
  36642. /**
  36643. * Serializes the actions and its related information.
  36644. * @param parent defines the object to serialize in
  36645. * @returns the serialized object
  36646. */
  36647. serialize(parent: any): any;
  36648. }
  36649. }
  36650. declare module "babylonjs/Actions/index" {
  36651. export * from "babylonjs/Actions/abstractActionManager";
  36652. export * from "babylonjs/Actions/action";
  36653. export * from "babylonjs/Actions/actionEvent";
  36654. export * from "babylonjs/Actions/actionManager";
  36655. export * from "babylonjs/Actions/condition";
  36656. export * from "babylonjs/Actions/directActions";
  36657. export * from "babylonjs/Actions/directAudioActions";
  36658. export * from "babylonjs/Actions/interpolateValueAction";
  36659. }
  36660. declare module "babylonjs/Animations/index" {
  36661. export * from "babylonjs/Animations/animatable";
  36662. export * from "babylonjs/Animations/animation";
  36663. export * from "babylonjs/Animations/animationGroup";
  36664. export * from "babylonjs/Animations/animationPropertiesOverride";
  36665. export * from "babylonjs/Animations/easing";
  36666. export * from "babylonjs/Animations/runtimeAnimation";
  36667. export * from "babylonjs/Animations/animationEvent";
  36668. export * from "babylonjs/Animations/animationGroup";
  36669. export * from "babylonjs/Animations/animationKey";
  36670. export * from "babylonjs/Animations/animationRange";
  36671. export * from "babylonjs/Animations/animatable.interface";
  36672. }
  36673. declare module "babylonjs/Audio/soundTrack" {
  36674. import { Sound } from "babylonjs/Audio/sound";
  36675. import { Analyser } from "babylonjs/Audio/analyser";
  36676. import { Scene } from "babylonjs/scene";
  36677. /**
  36678. * Options allowed during the creation of a sound track.
  36679. */
  36680. export interface ISoundTrackOptions {
  36681. /**
  36682. * The volume the sound track should take during creation
  36683. */
  36684. volume?: number;
  36685. /**
  36686. * Define if the sound track is the main sound track of the scene
  36687. */
  36688. mainTrack?: boolean;
  36689. }
  36690. /**
  36691. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36692. * It will be also used in a future release to apply effects on a specific track.
  36693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36694. */
  36695. export class SoundTrack {
  36696. /**
  36697. * The unique identifier of the sound track in the scene.
  36698. */
  36699. id: number;
  36700. /**
  36701. * The list of sounds included in the sound track.
  36702. */
  36703. soundCollection: Array<Sound>;
  36704. private _outputAudioNode;
  36705. private _scene;
  36706. private _isMainTrack;
  36707. private _connectedAnalyser;
  36708. private _options;
  36709. private _isInitialized;
  36710. /**
  36711. * Creates a new sound track.
  36712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36713. * @param scene Define the scene the sound track belongs to
  36714. * @param options
  36715. */
  36716. constructor(scene: Scene, options?: ISoundTrackOptions);
  36717. private _initializeSoundTrackAudioGraph;
  36718. /**
  36719. * Release the sound track and its associated resources
  36720. */
  36721. dispose(): void;
  36722. /**
  36723. * Adds a sound to this sound track
  36724. * @param sound define the cound to add
  36725. * @ignoreNaming
  36726. */
  36727. AddSound(sound: Sound): void;
  36728. /**
  36729. * Removes a sound to this sound track
  36730. * @param sound define the cound to remove
  36731. * @ignoreNaming
  36732. */
  36733. RemoveSound(sound: Sound): void;
  36734. /**
  36735. * Set a global volume for the full sound track.
  36736. * @param newVolume Define the new volume of the sound track
  36737. */
  36738. setVolume(newVolume: number): void;
  36739. /**
  36740. * Switch the panning model to HRTF:
  36741. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36743. */
  36744. switchPanningModelToHRTF(): void;
  36745. /**
  36746. * Switch the panning model to Equal Power:
  36747. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36749. */
  36750. switchPanningModelToEqualPower(): void;
  36751. /**
  36752. * Connect the sound track to an audio analyser allowing some amazing
  36753. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36755. * @param analyser The analyser to connect to the engine
  36756. */
  36757. connectToAnalyser(analyser: Analyser): void;
  36758. }
  36759. }
  36760. declare module "babylonjs/Audio/audioSceneComponent" {
  36761. import { Sound } from "babylonjs/Audio/sound";
  36762. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36763. import { Nullable } from "babylonjs/types";
  36764. import { Vector3 } from "babylonjs/Maths/math.vector";
  36765. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36766. import { Scene } from "babylonjs/scene";
  36767. import { AbstractScene } from "babylonjs/abstractScene";
  36768. import "babylonjs/Audio/audioEngine";
  36769. module "babylonjs/abstractScene" {
  36770. interface AbstractScene {
  36771. /**
  36772. * The list of sounds used in the scene.
  36773. */
  36774. sounds: Nullable<Array<Sound>>;
  36775. }
  36776. }
  36777. module "babylonjs/scene" {
  36778. interface Scene {
  36779. /**
  36780. * @hidden
  36781. * Backing field
  36782. */
  36783. _mainSoundTrack: SoundTrack;
  36784. /**
  36785. * The main sound track played by the scene.
  36786. * It cotains your primary collection of sounds.
  36787. */
  36788. mainSoundTrack: SoundTrack;
  36789. /**
  36790. * The list of sound tracks added to the scene
  36791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36792. */
  36793. soundTracks: Nullable<Array<SoundTrack>>;
  36794. /**
  36795. * Gets a sound using a given name
  36796. * @param name defines the name to search for
  36797. * @return the found sound or null if not found at all.
  36798. */
  36799. getSoundByName(name: string): Nullable<Sound>;
  36800. /**
  36801. * Gets or sets if audio support is enabled
  36802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36803. */
  36804. audioEnabled: boolean;
  36805. /**
  36806. * Gets or sets if audio will be output to headphones
  36807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36808. */
  36809. headphone: boolean;
  36810. /**
  36811. * Gets or sets custom audio listener position provider
  36812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36813. */
  36814. audioListenerPositionProvider: Nullable<() => Vector3>;
  36815. /**
  36816. * Gets or sets a refresh rate when using 3D audio positioning
  36817. */
  36818. audioPositioningRefreshRate: number;
  36819. }
  36820. }
  36821. /**
  36822. * Defines the sound scene component responsible to manage any sounds
  36823. * in a given scene.
  36824. */
  36825. export class AudioSceneComponent implements ISceneSerializableComponent {
  36826. /**
  36827. * The component name helpfull to identify the component in the list of scene components.
  36828. */
  36829. readonly name: string;
  36830. /**
  36831. * The scene the component belongs to.
  36832. */
  36833. scene: Scene;
  36834. private _audioEnabled;
  36835. /**
  36836. * Gets whether audio is enabled or not.
  36837. * Please use related enable/disable method to switch state.
  36838. */
  36839. readonly audioEnabled: boolean;
  36840. private _headphone;
  36841. /**
  36842. * Gets whether audio is outputing to headphone or not.
  36843. * Please use the according Switch methods to change output.
  36844. */
  36845. readonly headphone: boolean;
  36846. /**
  36847. * Gets or sets a refresh rate when using 3D audio positioning
  36848. */
  36849. audioPositioningRefreshRate: number;
  36850. private _audioListenerPositionProvider;
  36851. /**
  36852. * Gets the current audio listener position provider
  36853. */
  36854. /**
  36855. * Sets a custom listener position for all sounds in the scene
  36856. * By default, this is the position of the first active camera
  36857. */
  36858. audioListenerPositionProvider: Nullable<() => Vector3>;
  36859. /**
  36860. * Creates a new instance of the component for the given scene
  36861. * @param scene Defines the scene to register the component in
  36862. */
  36863. constructor(scene: Scene);
  36864. /**
  36865. * Registers the component in a given scene
  36866. */
  36867. register(): void;
  36868. /**
  36869. * Rebuilds the elements related to this component in case of
  36870. * context lost for instance.
  36871. */
  36872. rebuild(): void;
  36873. /**
  36874. * Serializes the component data to the specified json object
  36875. * @param serializationObject The object to serialize to
  36876. */
  36877. serialize(serializationObject: any): void;
  36878. /**
  36879. * Adds all the elements from the container to the scene
  36880. * @param container the container holding the elements
  36881. */
  36882. addFromContainer(container: AbstractScene): void;
  36883. /**
  36884. * Removes all the elements in the container from the scene
  36885. * @param container contains the elements to remove
  36886. * @param dispose if the removed element should be disposed (default: false)
  36887. */
  36888. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36889. /**
  36890. * Disposes the component and the associated ressources.
  36891. */
  36892. dispose(): void;
  36893. /**
  36894. * Disables audio in the associated scene.
  36895. */
  36896. disableAudio(): void;
  36897. /**
  36898. * Enables audio in the associated scene.
  36899. */
  36900. enableAudio(): void;
  36901. /**
  36902. * Switch audio to headphone output.
  36903. */
  36904. switchAudioModeForHeadphones(): void;
  36905. /**
  36906. * Switch audio to normal speakers.
  36907. */
  36908. switchAudioModeForNormalSpeakers(): void;
  36909. private _cachedCameraDirection;
  36910. private _cachedCameraPosition;
  36911. private _lastCheck;
  36912. private _afterRender;
  36913. }
  36914. }
  36915. declare module "babylonjs/Audio/weightedsound" {
  36916. import { Sound } from "babylonjs/Audio/sound";
  36917. /**
  36918. * Wraps one or more Sound objects and selects one with random weight for playback.
  36919. */
  36920. export class WeightedSound {
  36921. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36922. loop: boolean;
  36923. private _coneInnerAngle;
  36924. private _coneOuterAngle;
  36925. private _volume;
  36926. /** A Sound is currently playing. */
  36927. isPlaying: boolean;
  36928. /** A Sound is currently paused. */
  36929. isPaused: boolean;
  36930. private _sounds;
  36931. private _weights;
  36932. private _currentIndex?;
  36933. /**
  36934. * Creates a new WeightedSound from the list of sounds given.
  36935. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36936. * @param sounds Array of Sounds that will be selected from.
  36937. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36938. */
  36939. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36940. /**
  36941. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36942. */
  36943. /**
  36944. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36945. */
  36946. directionalConeInnerAngle: number;
  36947. /**
  36948. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36949. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36950. */
  36951. /**
  36952. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36953. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36954. */
  36955. directionalConeOuterAngle: number;
  36956. /**
  36957. * Playback volume.
  36958. */
  36959. /**
  36960. * Playback volume.
  36961. */
  36962. volume: number;
  36963. private _onended;
  36964. /**
  36965. * Suspend playback
  36966. */
  36967. pause(): void;
  36968. /**
  36969. * Stop playback
  36970. */
  36971. stop(): void;
  36972. /**
  36973. * Start playback.
  36974. * @param startOffset Position the clip head at a specific time in seconds.
  36975. */
  36976. play(startOffset?: number): void;
  36977. }
  36978. }
  36979. declare module "babylonjs/Audio/index" {
  36980. export * from "babylonjs/Audio/analyser";
  36981. export * from "babylonjs/Audio/audioEngine";
  36982. export * from "babylonjs/Audio/audioSceneComponent";
  36983. export * from "babylonjs/Audio/sound";
  36984. export * from "babylonjs/Audio/soundTrack";
  36985. export * from "babylonjs/Audio/weightedsound";
  36986. }
  36987. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36988. import { Behavior } from "babylonjs/Behaviors/behavior";
  36989. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36990. import { BackEase } from "babylonjs/Animations/easing";
  36991. /**
  36992. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36993. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36994. */
  36995. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36996. /**
  36997. * Gets the name of the behavior.
  36998. */
  36999. readonly name: string;
  37000. /**
  37001. * The easing function used by animations
  37002. */
  37003. static EasingFunction: BackEase;
  37004. /**
  37005. * The easing mode used by animations
  37006. */
  37007. static EasingMode: number;
  37008. /**
  37009. * The duration of the animation, in milliseconds
  37010. */
  37011. transitionDuration: number;
  37012. /**
  37013. * Length of the distance animated by the transition when lower radius is reached
  37014. */
  37015. lowerRadiusTransitionRange: number;
  37016. /**
  37017. * Length of the distance animated by the transition when upper radius is reached
  37018. */
  37019. upperRadiusTransitionRange: number;
  37020. private _autoTransitionRange;
  37021. /**
  37022. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37023. */
  37024. /**
  37025. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37026. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37027. */
  37028. autoTransitionRange: boolean;
  37029. private _attachedCamera;
  37030. private _onAfterCheckInputsObserver;
  37031. private _onMeshTargetChangedObserver;
  37032. /**
  37033. * Initializes the behavior.
  37034. */
  37035. init(): void;
  37036. /**
  37037. * Attaches the behavior to its arc rotate camera.
  37038. * @param camera Defines the camera to attach the behavior to
  37039. */
  37040. attach(camera: ArcRotateCamera): void;
  37041. /**
  37042. * Detaches the behavior from its current arc rotate camera.
  37043. */
  37044. detach(): void;
  37045. private _radiusIsAnimating;
  37046. private _radiusBounceTransition;
  37047. private _animatables;
  37048. private _cachedWheelPrecision;
  37049. /**
  37050. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37051. * @param radiusLimit The limit to check against.
  37052. * @return Bool to indicate if at limit.
  37053. */
  37054. private _isRadiusAtLimit;
  37055. /**
  37056. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37057. * @param radiusDelta The delta by which to animate to. Can be negative.
  37058. */
  37059. private _applyBoundRadiusAnimation;
  37060. /**
  37061. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37062. */
  37063. protected _clearAnimationLocks(): void;
  37064. /**
  37065. * Stops and removes all animations that have been applied to the camera
  37066. */
  37067. stopAllAnimations(): void;
  37068. }
  37069. }
  37070. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37071. import { Behavior } from "babylonjs/Behaviors/behavior";
  37072. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37073. import { ExponentialEase } from "babylonjs/Animations/easing";
  37074. import { Nullable } from "babylonjs/types";
  37075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37076. import { Vector3 } from "babylonjs/Maths/math.vector";
  37077. /**
  37078. * 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.
  37079. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37080. */
  37081. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37082. /**
  37083. * Gets the name of the behavior.
  37084. */
  37085. readonly name: string;
  37086. private _mode;
  37087. private _radiusScale;
  37088. private _positionScale;
  37089. private _defaultElevation;
  37090. private _elevationReturnTime;
  37091. private _elevationReturnWaitTime;
  37092. private _zoomStopsAnimation;
  37093. private _framingTime;
  37094. /**
  37095. * The easing function used by animations
  37096. */
  37097. static EasingFunction: ExponentialEase;
  37098. /**
  37099. * The easing mode used by animations
  37100. */
  37101. static EasingMode: number;
  37102. /**
  37103. * Sets the current mode used by the behavior
  37104. */
  37105. /**
  37106. * Gets current mode used by the behavior.
  37107. */
  37108. mode: number;
  37109. /**
  37110. * Sets the scale applied to the radius (1 by default)
  37111. */
  37112. /**
  37113. * Gets the scale applied to the radius
  37114. */
  37115. radiusScale: number;
  37116. /**
  37117. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37118. */
  37119. /**
  37120. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37121. */
  37122. positionScale: number;
  37123. /**
  37124. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37125. * behaviour is triggered, in radians.
  37126. */
  37127. /**
  37128. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37129. * behaviour is triggered, in radians.
  37130. */
  37131. defaultElevation: number;
  37132. /**
  37133. * Sets the time (in milliseconds) taken to return to the default beta position.
  37134. * Negative value indicates camera should not return to default.
  37135. */
  37136. /**
  37137. * Gets the time (in milliseconds) taken to return to the default beta position.
  37138. * Negative value indicates camera should not return to default.
  37139. */
  37140. elevationReturnTime: number;
  37141. /**
  37142. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37143. */
  37144. /**
  37145. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37146. */
  37147. elevationReturnWaitTime: number;
  37148. /**
  37149. * Sets the flag that indicates if user zooming should stop animation.
  37150. */
  37151. /**
  37152. * Gets the flag that indicates if user zooming should stop animation.
  37153. */
  37154. zoomStopsAnimation: boolean;
  37155. /**
  37156. * Sets the transition time when framing the mesh, in milliseconds
  37157. */
  37158. /**
  37159. * Gets the transition time when framing the mesh, in milliseconds
  37160. */
  37161. framingTime: number;
  37162. /**
  37163. * Define if the behavior should automatically change the configured
  37164. * camera limits and sensibilities.
  37165. */
  37166. autoCorrectCameraLimitsAndSensibility: boolean;
  37167. private _onPrePointerObservableObserver;
  37168. private _onAfterCheckInputsObserver;
  37169. private _onMeshTargetChangedObserver;
  37170. private _attachedCamera;
  37171. private _isPointerDown;
  37172. private _lastInteractionTime;
  37173. /**
  37174. * Initializes the behavior.
  37175. */
  37176. init(): void;
  37177. /**
  37178. * Attaches the behavior to its arc rotate camera.
  37179. * @param camera Defines the camera to attach the behavior to
  37180. */
  37181. attach(camera: ArcRotateCamera): void;
  37182. /**
  37183. * Detaches the behavior from its current arc rotate camera.
  37184. */
  37185. detach(): void;
  37186. private _animatables;
  37187. private _betaIsAnimating;
  37188. private _betaTransition;
  37189. private _radiusTransition;
  37190. private _vectorTransition;
  37191. /**
  37192. * Targets the given mesh and updates zoom level accordingly.
  37193. * @param mesh The mesh to target.
  37194. * @param radius Optional. If a cached radius position already exists, overrides default.
  37195. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37196. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37197. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37198. */
  37199. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37200. /**
  37201. * Targets the given mesh with its children and updates zoom level accordingly.
  37202. * @param mesh The mesh to target.
  37203. * @param radius Optional. If a cached radius position already exists, overrides default.
  37204. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37205. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37206. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37207. */
  37208. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37209. /**
  37210. * Targets the given meshes with their children and updates zoom level accordingly.
  37211. * @param meshes The mesh to target.
  37212. * @param radius Optional. If a cached radius position already exists, overrides default.
  37213. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37214. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37215. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37216. */
  37217. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37218. /**
  37219. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37220. * @param minimumWorld Determines the smaller position of the bounding box extend
  37221. * @param maximumWorld Determines the bigger position of the bounding box extend
  37222. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37223. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37224. */
  37225. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37226. /**
  37227. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37228. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37229. * frustum width.
  37230. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37231. * to fully enclose the mesh in the viewing frustum.
  37232. */
  37233. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37234. /**
  37235. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37236. * is automatically returned to its default position (expected to be above ground plane).
  37237. */
  37238. private _maintainCameraAboveGround;
  37239. /**
  37240. * Returns the frustum slope based on the canvas ratio and camera FOV
  37241. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37242. */
  37243. private _getFrustumSlope;
  37244. /**
  37245. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37246. */
  37247. private _clearAnimationLocks;
  37248. /**
  37249. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37250. */
  37251. private _applyUserInteraction;
  37252. /**
  37253. * Stops and removes all animations that have been applied to the camera
  37254. */
  37255. stopAllAnimations(): void;
  37256. /**
  37257. * Gets a value indicating if the user is moving the camera
  37258. */
  37259. readonly isUserIsMoving: boolean;
  37260. /**
  37261. * The camera can move all the way towards the mesh.
  37262. */
  37263. static IgnoreBoundsSizeMode: number;
  37264. /**
  37265. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37266. */
  37267. static FitFrustumSidesMode: number;
  37268. }
  37269. }
  37270. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37271. import { Nullable } from "babylonjs/types";
  37272. import { Camera } from "babylonjs/Cameras/camera";
  37273. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37274. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37275. /**
  37276. * Base class for Camera Pointer Inputs.
  37277. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37278. * for example usage.
  37279. */
  37280. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37281. /**
  37282. * Defines the camera the input is attached to.
  37283. */
  37284. abstract camera: Camera;
  37285. /**
  37286. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37287. */
  37288. protected _altKey: boolean;
  37289. protected _ctrlKey: boolean;
  37290. protected _metaKey: boolean;
  37291. protected _shiftKey: boolean;
  37292. /**
  37293. * Which mouse buttons were pressed at time of last mouse event.
  37294. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37295. */
  37296. protected _buttonsPressed: number;
  37297. /**
  37298. * Defines the buttons associated with the input to handle camera move.
  37299. */
  37300. buttons: number[];
  37301. /**
  37302. * Attach the input controls to a specific dom element to get the input from.
  37303. * @param element Defines the element the controls should be listened from
  37304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37305. */
  37306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37307. /**
  37308. * Detach the current controls from the specified dom element.
  37309. * @param element Defines the element to stop listening the inputs from
  37310. */
  37311. detachControl(element: Nullable<HTMLElement>): void;
  37312. /**
  37313. * Gets the class name of the current input.
  37314. * @returns the class name
  37315. */
  37316. getClassName(): string;
  37317. /**
  37318. * Get the friendly name associated with the input class.
  37319. * @returns the input friendly name
  37320. */
  37321. getSimpleName(): string;
  37322. /**
  37323. * Called on pointer POINTERDOUBLETAP event.
  37324. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37325. */
  37326. protected onDoubleTap(type: string): void;
  37327. /**
  37328. * Called on pointer POINTERMOVE event if only a single touch is active.
  37329. * Override this method to provide functionality.
  37330. */
  37331. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37332. /**
  37333. * Called on pointer POINTERMOVE event if multiple touches are active.
  37334. * Override this method to provide functionality.
  37335. */
  37336. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37337. /**
  37338. * Called on JS contextmenu event.
  37339. * Override this method to provide functionality.
  37340. */
  37341. protected onContextMenu(evt: PointerEvent): void;
  37342. /**
  37343. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37344. * press.
  37345. * Override this method to provide functionality.
  37346. */
  37347. protected onButtonDown(evt: PointerEvent): void;
  37348. /**
  37349. * Called each time a new POINTERUP event occurs. Ie, for each button
  37350. * release.
  37351. * Override this method to provide functionality.
  37352. */
  37353. protected onButtonUp(evt: PointerEvent): void;
  37354. /**
  37355. * Called when window becomes inactive.
  37356. * Override this method to provide functionality.
  37357. */
  37358. protected onLostFocus(): void;
  37359. private _pointerInput;
  37360. private _observer;
  37361. private _onLostFocus;
  37362. private pointA;
  37363. private pointB;
  37364. }
  37365. }
  37366. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37367. import { Nullable } from "babylonjs/types";
  37368. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37369. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37370. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37371. /**
  37372. * Manage the pointers inputs to control an arc rotate camera.
  37373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37374. */
  37375. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37376. /**
  37377. * Defines the camera the input is attached to.
  37378. */
  37379. camera: ArcRotateCamera;
  37380. /**
  37381. * Gets the class name of the current input.
  37382. * @returns the class name
  37383. */
  37384. getClassName(): string;
  37385. /**
  37386. * Defines the buttons associated with the input to handle camera move.
  37387. */
  37388. buttons: number[];
  37389. /**
  37390. * Defines the pointer angular sensibility along the X axis or how fast is
  37391. * the camera rotating.
  37392. */
  37393. angularSensibilityX: number;
  37394. /**
  37395. * Defines the pointer angular sensibility along the Y axis or how fast is
  37396. * the camera rotating.
  37397. */
  37398. angularSensibilityY: number;
  37399. /**
  37400. * Defines the pointer pinch precision or how fast is the camera zooming.
  37401. */
  37402. pinchPrecision: number;
  37403. /**
  37404. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37405. * from 0.
  37406. * It defines the percentage of current camera.radius to use as delta when
  37407. * pinch zoom is used.
  37408. */
  37409. pinchDeltaPercentage: number;
  37410. /**
  37411. * Defines the pointer panning sensibility or how fast is the camera moving.
  37412. */
  37413. panningSensibility: number;
  37414. /**
  37415. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37416. */
  37417. multiTouchPanning: boolean;
  37418. /**
  37419. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37420. * zoom (pinch) through multitouch.
  37421. */
  37422. multiTouchPanAndZoom: boolean;
  37423. /**
  37424. * Revers pinch action direction.
  37425. */
  37426. pinchInwards: boolean;
  37427. private _isPanClick;
  37428. private _twoFingerActivityCount;
  37429. private _isPinching;
  37430. /**
  37431. * Called on pointer POINTERMOVE event if only a single touch is active.
  37432. */
  37433. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37434. /**
  37435. * Called on pointer POINTERDOUBLETAP event.
  37436. */
  37437. protected onDoubleTap(type: string): void;
  37438. /**
  37439. * Called on pointer POINTERMOVE event if multiple touches are active.
  37440. */
  37441. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37442. /**
  37443. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37444. * press.
  37445. */
  37446. protected onButtonDown(evt: PointerEvent): void;
  37447. /**
  37448. * Called each time a new POINTERUP event occurs. Ie, for each button
  37449. * release.
  37450. */
  37451. protected onButtonUp(evt: PointerEvent): void;
  37452. /**
  37453. * Called when window becomes inactive.
  37454. */
  37455. protected onLostFocus(): void;
  37456. }
  37457. }
  37458. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37459. import { Nullable } from "babylonjs/types";
  37460. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37461. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37462. /**
  37463. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37465. */
  37466. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37467. /**
  37468. * Defines the camera the input is attached to.
  37469. */
  37470. camera: ArcRotateCamera;
  37471. /**
  37472. * Defines the list of key codes associated with the up action (increase alpha)
  37473. */
  37474. keysUp: number[];
  37475. /**
  37476. * Defines the list of key codes associated with the down action (decrease alpha)
  37477. */
  37478. keysDown: number[];
  37479. /**
  37480. * Defines the list of key codes associated with the left action (increase beta)
  37481. */
  37482. keysLeft: number[];
  37483. /**
  37484. * Defines the list of key codes associated with the right action (decrease beta)
  37485. */
  37486. keysRight: number[];
  37487. /**
  37488. * Defines the list of key codes associated with the reset action.
  37489. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37490. */
  37491. keysReset: number[];
  37492. /**
  37493. * Defines the panning sensibility of the inputs.
  37494. * (How fast is the camera paning)
  37495. */
  37496. panningSensibility: number;
  37497. /**
  37498. * Defines the zooming sensibility of the inputs.
  37499. * (How fast is the camera zooming)
  37500. */
  37501. zoomingSensibility: number;
  37502. /**
  37503. * Defines wether maintaining the alt key down switch the movement mode from
  37504. * orientation to zoom.
  37505. */
  37506. useAltToZoom: boolean;
  37507. /**
  37508. * Rotation speed of the camera
  37509. */
  37510. angularSpeed: number;
  37511. private _keys;
  37512. private _ctrlPressed;
  37513. private _altPressed;
  37514. private _onCanvasBlurObserver;
  37515. private _onKeyboardObserver;
  37516. private _engine;
  37517. private _scene;
  37518. /**
  37519. * Attach the input controls to a specific dom element to get the input from.
  37520. * @param element Defines the element the controls should be listened from
  37521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37522. */
  37523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37524. /**
  37525. * Detach the current controls from the specified dom element.
  37526. * @param element Defines the element to stop listening the inputs from
  37527. */
  37528. detachControl(element: Nullable<HTMLElement>): void;
  37529. /**
  37530. * Update the current camera state depending on the inputs that have been used this frame.
  37531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37532. */
  37533. checkInputs(): void;
  37534. /**
  37535. * Gets the class name of the current intput.
  37536. * @returns the class name
  37537. */
  37538. getClassName(): string;
  37539. /**
  37540. * Get the friendly name associated with the input class.
  37541. * @returns the input friendly name
  37542. */
  37543. getSimpleName(): string;
  37544. }
  37545. }
  37546. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37547. import { Nullable } from "babylonjs/types";
  37548. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37549. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37550. /**
  37551. * Manage the mouse wheel inputs to control an arc rotate camera.
  37552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37553. */
  37554. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37555. /**
  37556. * Defines the camera the input is attached to.
  37557. */
  37558. camera: ArcRotateCamera;
  37559. /**
  37560. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37561. */
  37562. wheelPrecision: number;
  37563. /**
  37564. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37565. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37566. */
  37567. wheelDeltaPercentage: number;
  37568. private _wheel;
  37569. private _observer;
  37570. private computeDeltaFromMouseWheelLegacyEvent;
  37571. /**
  37572. * Attach the input controls to a specific dom element to get the input from.
  37573. * @param element Defines the element the controls should be listened from
  37574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37575. */
  37576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37577. /**
  37578. * Detach the current controls from the specified dom element.
  37579. * @param element Defines the element to stop listening the inputs from
  37580. */
  37581. detachControl(element: Nullable<HTMLElement>): void;
  37582. /**
  37583. * Gets the class name of the current intput.
  37584. * @returns the class name
  37585. */
  37586. getClassName(): string;
  37587. /**
  37588. * Get the friendly name associated with the input class.
  37589. * @returns the input friendly name
  37590. */
  37591. getSimpleName(): string;
  37592. }
  37593. }
  37594. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37595. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37596. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37597. /**
  37598. * Default Inputs manager for the ArcRotateCamera.
  37599. * It groups all the default supported inputs for ease of use.
  37600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37601. */
  37602. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37603. /**
  37604. * Instantiates a new ArcRotateCameraInputsManager.
  37605. * @param camera Defines the camera the inputs belong to
  37606. */
  37607. constructor(camera: ArcRotateCamera);
  37608. /**
  37609. * Add mouse wheel input support to the input manager.
  37610. * @returns the current input manager
  37611. */
  37612. addMouseWheel(): ArcRotateCameraInputsManager;
  37613. /**
  37614. * Add pointers input support to the input manager.
  37615. * @returns the current input manager
  37616. */
  37617. addPointers(): ArcRotateCameraInputsManager;
  37618. /**
  37619. * Add keyboard input support to the input manager.
  37620. * @returns the current input manager
  37621. */
  37622. addKeyboard(): ArcRotateCameraInputsManager;
  37623. }
  37624. }
  37625. declare module "babylonjs/Cameras/arcRotateCamera" {
  37626. import { Observable } from "babylonjs/Misc/observable";
  37627. import { Nullable } from "babylonjs/types";
  37628. import { Scene } from "babylonjs/scene";
  37629. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37631. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37632. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37633. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37634. import { Camera } from "babylonjs/Cameras/camera";
  37635. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37636. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37637. import { Collider } from "babylonjs/Collisions/collider";
  37638. /**
  37639. * This represents an orbital type of camera.
  37640. *
  37641. * 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.
  37642. * 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.
  37643. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37644. */
  37645. export class ArcRotateCamera extends TargetCamera {
  37646. /**
  37647. * Defines the rotation angle of the camera along the longitudinal axis.
  37648. */
  37649. alpha: number;
  37650. /**
  37651. * Defines the rotation angle of the camera along the latitudinal axis.
  37652. */
  37653. beta: number;
  37654. /**
  37655. * Defines the radius of the camera from it s target point.
  37656. */
  37657. radius: number;
  37658. protected _target: Vector3;
  37659. protected _targetHost: Nullable<AbstractMesh>;
  37660. /**
  37661. * Defines the target point of the camera.
  37662. * The camera looks towards it form the radius distance.
  37663. */
  37664. target: Vector3;
  37665. /**
  37666. * Define the current local position of the camera in the scene
  37667. */
  37668. position: Vector3;
  37669. protected _upVector: Vector3;
  37670. protected _upToYMatrix: Matrix;
  37671. protected _YToUpMatrix: Matrix;
  37672. /**
  37673. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37674. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37675. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37676. */
  37677. upVector: Vector3;
  37678. /**
  37679. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37680. */
  37681. setMatUp(): void;
  37682. /**
  37683. * Current inertia value on the longitudinal axis.
  37684. * The bigger this number the longer it will take for the camera to stop.
  37685. */
  37686. inertialAlphaOffset: number;
  37687. /**
  37688. * Current inertia value on the latitudinal axis.
  37689. * The bigger this number the longer it will take for the camera to stop.
  37690. */
  37691. inertialBetaOffset: number;
  37692. /**
  37693. * Current inertia value on the radius axis.
  37694. * The bigger this number the longer it will take for the camera to stop.
  37695. */
  37696. inertialRadiusOffset: number;
  37697. /**
  37698. * Minimum allowed angle on the longitudinal axis.
  37699. * This can help limiting how the Camera is able to move in the scene.
  37700. */
  37701. lowerAlphaLimit: Nullable<number>;
  37702. /**
  37703. * Maximum allowed angle on the longitudinal axis.
  37704. * This can help limiting how the Camera is able to move in the scene.
  37705. */
  37706. upperAlphaLimit: Nullable<number>;
  37707. /**
  37708. * Minimum allowed angle on the latitudinal axis.
  37709. * This can help limiting how the Camera is able to move in the scene.
  37710. */
  37711. lowerBetaLimit: number;
  37712. /**
  37713. * Maximum allowed angle on the latitudinal axis.
  37714. * This can help limiting how the Camera is able to move in the scene.
  37715. */
  37716. upperBetaLimit: number;
  37717. /**
  37718. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37719. * This can help limiting how the Camera is able to move in the scene.
  37720. */
  37721. lowerRadiusLimit: Nullable<number>;
  37722. /**
  37723. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37724. * This can help limiting how the Camera is able to move in the scene.
  37725. */
  37726. upperRadiusLimit: Nullable<number>;
  37727. /**
  37728. * Defines the current inertia value used during panning of the camera along the X axis.
  37729. */
  37730. inertialPanningX: number;
  37731. /**
  37732. * Defines the current inertia value used during panning of the camera along the Y axis.
  37733. */
  37734. inertialPanningY: number;
  37735. /**
  37736. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37737. * Basically if your fingers moves away from more than this distance you will be considered
  37738. * in pinch mode.
  37739. */
  37740. pinchToPanMaxDistance: number;
  37741. /**
  37742. * Defines the maximum distance the camera can pan.
  37743. * This could help keeping the cammera always in your scene.
  37744. */
  37745. panningDistanceLimit: Nullable<number>;
  37746. /**
  37747. * Defines the target of the camera before paning.
  37748. */
  37749. panningOriginTarget: Vector3;
  37750. /**
  37751. * Defines the value of the inertia used during panning.
  37752. * 0 would mean stop inertia and one would mean no decelleration at all.
  37753. */
  37754. panningInertia: number;
  37755. /**
  37756. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37757. */
  37758. angularSensibilityX: number;
  37759. /**
  37760. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37761. */
  37762. angularSensibilityY: number;
  37763. /**
  37764. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37765. */
  37766. pinchPrecision: number;
  37767. /**
  37768. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37769. * It will be used instead of pinchDeltaPrecision if different from 0.
  37770. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37771. */
  37772. pinchDeltaPercentage: number;
  37773. /**
  37774. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37775. */
  37776. panningSensibility: number;
  37777. /**
  37778. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37779. */
  37780. keysUp: number[];
  37781. /**
  37782. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37783. */
  37784. keysDown: number[];
  37785. /**
  37786. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37787. */
  37788. keysLeft: number[];
  37789. /**
  37790. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37791. */
  37792. keysRight: number[];
  37793. /**
  37794. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37795. */
  37796. wheelPrecision: number;
  37797. /**
  37798. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37799. * It will be used instead of pinchDeltaPrecision if different from 0.
  37800. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37801. */
  37802. wheelDeltaPercentage: number;
  37803. /**
  37804. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37805. */
  37806. zoomOnFactor: number;
  37807. /**
  37808. * Defines a screen offset for the camera position.
  37809. */
  37810. targetScreenOffset: Vector2;
  37811. /**
  37812. * Allows the camera to be completely reversed.
  37813. * If false the camera can not arrive upside down.
  37814. */
  37815. allowUpsideDown: boolean;
  37816. /**
  37817. * Define if double tap/click is used to restore the previously saved state of the camera.
  37818. */
  37819. useInputToRestoreState: boolean;
  37820. /** @hidden */
  37821. _viewMatrix: Matrix;
  37822. /** @hidden */
  37823. _useCtrlForPanning: boolean;
  37824. /** @hidden */
  37825. _panningMouseButton: number;
  37826. /**
  37827. * Defines the input associated to the camera.
  37828. */
  37829. inputs: ArcRotateCameraInputsManager;
  37830. /** @hidden */
  37831. _reset: () => void;
  37832. /**
  37833. * Defines the allowed panning axis.
  37834. */
  37835. panningAxis: Vector3;
  37836. protected _localDirection: Vector3;
  37837. protected _transformedDirection: Vector3;
  37838. private _bouncingBehavior;
  37839. /**
  37840. * Gets the bouncing behavior of the camera if it has been enabled.
  37841. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37842. */
  37843. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37844. /**
  37845. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37846. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37847. */
  37848. useBouncingBehavior: boolean;
  37849. private _framingBehavior;
  37850. /**
  37851. * Gets the framing behavior of the camera if it has been enabled.
  37852. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37853. */
  37854. readonly framingBehavior: Nullable<FramingBehavior>;
  37855. /**
  37856. * Defines if the framing behavior of the camera is enabled on the camera.
  37857. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37858. */
  37859. useFramingBehavior: boolean;
  37860. private _autoRotationBehavior;
  37861. /**
  37862. * Gets the auto rotation behavior of the camera if it has been enabled.
  37863. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37864. */
  37865. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37866. /**
  37867. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37868. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37869. */
  37870. useAutoRotationBehavior: boolean;
  37871. /**
  37872. * Observable triggered when the mesh target has been changed on the camera.
  37873. */
  37874. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37875. /**
  37876. * Event raised when the camera is colliding with a mesh.
  37877. */
  37878. onCollide: (collidedMesh: AbstractMesh) => void;
  37879. /**
  37880. * Defines whether the camera should check collision with the objects oh the scene.
  37881. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37882. */
  37883. checkCollisions: boolean;
  37884. /**
  37885. * Defines the collision radius of the camera.
  37886. * This simulates a sphere around the camera.
  37887. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37888. */
  37889. collisionRadius: Vector3;
  37890. protected _collider: Collider;
  37891. protected _previousPosition: Vector3;
  37892. protected _collisionVelocity: Vector3;
  37893. protected _newPosition: Vector3;
  37894. protected _previousAlpha: number;
  37895. protected _previousBeta: number;
  37896. protected _previousRadius: number;
  37897. protected _collisionTriggered: boolean;
  37898. protected _targetBoundingCenter: Nullable<Vector3>;
  37899. private _computationVector;
  37900. /**
  37901. * Instantiates a new ArcRotateCamera in a given scene
  37902. * @param name Defines the name of the camera
  37903. * @param alpha Defines the camera rotation along the logitudinal axis
  37904. * @param beta Defines the camera rotation along the latitudinal axis
  37905. * @param radius Defines the camera distance from its target
  37906. * @param target Defines the camera target
  37907. * @param scene Defines the scene the camera belongs to
  37908. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37909. */
  37910. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37911. /** @hidden */
  37912. _initCache(): void;
  37913. /** @hidden */
  37914. _updateCache(ignoreParentClass?: boolean): void;
  37915. protected _getTargetPosition(): Vector3;
  37916. private _storedAlpha;
  37917. private _storedBeta;
  37918. private _storedRadius;
  37919. private _storedTarget;
  37920. private _storedTargetScreenOffset;
  37921. /**
  37922. * Stores the current state of the camera (alpha, beta, radius and target)
  37923. * @returns the camera itself
  37924. */
  37925. storeState(): Camera;
  37926. /**
  37927. * @hidden
  37928. * Restored camera state. You must call storeState() first
  37929. */
  37930. _restoreStateValues(): boolean;
  37931. /** @hidden */
  37932. _isSynchronizedViewMatrix(): boolean;
  37933. /**
  37934. * Attached controls to the current camera.
  37935. * @param element Defines the element the controls should be listened from
  37936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37937. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37938. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37939. */
  37940. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37941. /**
  37942. * Detach the current controls from the camera.
  37943. * The camera will stop reacting to inputs.
  37944. * @param element Defines the element to stop listening the inputs from
  37945. */
  37946. detachControl(element: HTMLElement): void;
  37947. /** @hidden */
  37948. _checkInputs(): void;
  37949. protected _checkLimits(): void;
  37950. /**
  37951. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37952. */
  37953. rebuildAnglesAndRadius(): void;
  37954. /**
  37955. * Use a position to define the current camera related information like alpha, beta and radius
  37956. * @param position Defines the position to set the camera at
  37957. */
  37958. setPosition(position: Vector3): void;
  37959. /**
  37960. * Defines the target the camera should look at.
  37961. * This will automatically adapt alpha beta and radius to fit within the new target.
  37962. * @param target Defines the new target as a Vector or a mesh
  37963. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37964. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37965. */
  37966. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37967. /** @hidden */
  37968. _getViewMatrix(): Matrix;
  37969. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37970. /**
  37971. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37972. * @param meshes Defines the mesh to zoom on
  37973. * @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)
  37974. */
  37975. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37976. /**
  37977. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37978. * The target will be changed but the radius
  37979. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37980. * @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)
  37981. */
  37982. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37983. min: Vector3;
  37984. max: Vector3;
  37985. distance: number;
  37986. }, doNotUpdateMaxZ?: boolean): void;
  37987. /**
  37988. * @override
  37989. * Override Camera.createRigCamera
  37990. */
  37991. createRigCamera(name: string, cameraIndex: number): Camera;
  37992. /**
  37993. * @hidden
  37994. * @override
  37995. * Override Camera._updateRigCameras
  37996. */
  37997. _updateRigCameras(): void;
  37998. /**
  37999. * Destroy the camera and release the current resources hold by it.
  38000. */
  38001. dispose(): void;
  38002. /**
  38003. * Gets the current object class name.
  38004. * @return the class name
  38005. */
  38006. getClassName(): string;
  38007. }
  38008. }
  38009. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38010. import { Behavior } from "babylonjs/Behaviors/behavior";
  38011. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38012. /**
  38013. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38014. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38015. */
  38016. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38017. /**
  38018. * Gets the name of the behavior.
  38019. */
  38020. readonly name: string;
  38021. private _zoomStopsAnimation;
  38022. private _idleRotationSpeed;
  38023. private _idleRotationWaitTime;
  38024. private _idleRotationSpinupTime;
  38025. /**
  38026. * Sets the flag that indicates if user zooming should stop animation.
  38027. */
  38028. /**
  38029. * Gets the flag that indicates if user zooming should stop animation.
  38030. */
  38031. zoomStopsAnimation: boolean;
  38032. /**
  38033. * Sets the default speed at which the camera rotates around the model.
  38034. */
  38035. /**
  38036. * Gets the default speed at which the camera rotates around the model.
  38037. */
  38038. idleRotationSpeed: number;
  38039. /**
  38040. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38041. */
  38042. /**
  38043. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38044. */
  38045. idleRotationWaitTime: number;
  38046. /**
  38047. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38048. */
  38049. /**
  38050. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38051. */
  38052. idleRotationSpinupTime: number;
  38053. /**
  38054. * Gets a value indicating if the camera is currently rotating because of this behavior
  38055. */
  38056. readonly rotationInProgress: boolean;
  38057. private _onPrePointerObservableObserver;
  38058. private _onAfterCheckInputsObserver;
  38059. private _attachedCamera;
  38060. private _isPointerDown;
  38061. private _lastFrameTime;
  38062. private _lastInteractionTime;
  38063. private _cameraRotationSpeed;
  38064. /**
  38065. * Initializes the behavior.
  38066. */
  38067. init(): void;
  38068. /**
  38069. * Attaches the behavior to its arc rotate camera.
  38070. * @param camera Defines the camera to attach the behavior to
  38071. */
  38072. attach(camera: ArcRotateCamera): void;
  38073. /**
  38074. * Detaches the behavior from its current arc rotate camera.
  38075. */
  38076. detach(): void;
  38077. /**
  38078. * Returns true if user is scrolling.
  38079. * @return true if user is scrolling.
  38080. */
  38081. private _userIsZooming;
  38082. private _lastFrameRadius;
  38083. private _shouldAnimationStopForInteraction;
  38084. /**
  38085. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38086. */
  38087. private _applyUserInteraction;
  38088. private _userIsMoving;
  38089. }
  38090. }
  38091. declare module "babylonjs/Behaviors/Cameras/index" {
  38092. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38093. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38094. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38095. }
  38096. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38097. import { Mesh } from "babylonjs/Meshes/mesh";
  38098. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38099. import { Behavior } from "babylonjs/Behaviors/behavior";
  38100. /**
  38101. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38102. */
  38103. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38104. private ui;
  38105. /**
  38106. * The name of the behavior
  38107. */
  38108. name: string;
  38109. /**
  38110. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38111. */
  38112. distanceAwayFromFace: number;
  38113. /**
  38114. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38115. */
  38116. distanceAwayFromBottomOfFace: number;
  38117. private _faceVectors;
  38118. private _target;
  38119. private _scene;
  38120. private _onRenderObserver;
  38121. private _tmpMatrix;
  38122. private _tmpVector;
  38123. /**
  38124. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38125. * @param ui The transform node that should be attched to the mesh
  38126. */
  38127. constructor(ui: TransformNode);
  38128. /**
  38129. * Initializes the behavior
  38130. */
  38131. init(): void;
  38132. private _closestFace;
  38133. private _zeroVector;
  38134. private _lookAtTmpMatrix;
  38135. private _lookAtToRef;
  38136. /**
  38137. * Attaches the AttachToBoxBehavior to the passed in mesh
  38138. * @param target The mesh that the specified node will be attached to
  38139. */
  38140. attach(target: Mesh): void;
  38141. /**
  38142. * Detaches the behavior from the mesh
  38143. */
  38144. detach(): void;
  38145. }
  38146. }
  38147. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38148. import { Behavior } from "babylonjs/Behaviors/behavior";
  38149. import { Mesh } from "babylonjs/Meshes/mesh";
  38150. /**
  38151. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38152. */
  38153. export class FadeInOutBehavior implements Behavior<Mesh> {
  38154. /**
  38155. * Time in milliseconds to delay before fading in (Default: 0)
  38156. */
  38157. delay: number;
  38158. /**
  38159. * Time in milliseconds for the mesh to fade in (Default: 300)
  38160. */
  38161. fadeInTime: number;
  38162. private _millisecondsPerFrame;
  38163. private _hovered;
  38164. private _hoverValue;
  38165. private _ownerNode;
  38166. /**
  38167. * Instatiates the FadeInOutBehavior
  38168. */
  38169. constructor();
  38170. /**
  38171. * The name of the behavior
  38172. */
  38173. readonly name: string;
  38174. /**
  38175. * Initializes the behavior
  38176. */
  38177. init(): void;
  38178. /**
  38179. * Attaches the fade behavior on the passed in mesh
  38180. * @param ownerNode The mesh that will be faded in/out once attached
  38181. */
  38182. attach(ownerNode: Mesh): void;
  38183. /**
  38184. * Detaches the behavior from the mesh
  38185. */
  38186. detach(): void;
  38187. /**
  38188. * Triggers the mesh to begin fading in or out
  38189. * @param value if the object should fade in or out (true to fade in)
  38190. */
  38191. fadeIn(value: boolean): void;
  38192. private _update;
  38193. private _setAllVisibility;
  38194. }
  38195. }
  38196. declare module "babylonjs/Misc/pivotTools" {
  38197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38198. /**
  38199. * Class containing a set of static utilities functions for managing Pivots
  38200. * @hidden
  38201. */
  38202. export class PivotTools {
  38203. private static _PivotCached;
  38204. private static _OldPivotPoint;
  38205. private static _PivotTranslation;
  38206. private static _PivotTmpVector;
  38207. /** @hidden */
  38208. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38209. /** @hidden */
  38210. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38211. }
  38212. }
  38213. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38214. import { Scene } from "babylonjs/scene";
  38215. import { Vector4 } from "babylonjs/Maths/math.vector";
  38216. import { Mesh } from "babylonjs/Meshes/mesh";
  38217. import { Nullable } from "babylonjs/types";
  38218. import { Plane } from "babylonjs/Maths/math.plane";
  38219. /**
  38220. * Class containing static functions to help procedurally build meshes
  38221. */
  38222. export class PlaneBuilder {
  38223. /**
  38224. * Creates a plane mesh
  38225. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38226. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38227. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38231. * @param name defines the name of the mesh
  38232. * @param options defines the options used to create the mesh
  38233. * @param scene defines the hosting scene
  38234. * @returns the plane mesh
  38235. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38236. */
  38237. static CreatePlane(name: string, options: {
  38238. size?: number;
  38239. width?: number;
  38240. height?: number;
  38241. sideOrientation?: number;
  38242. frontUVs?: Vector4;
  38243. backUVs?: Vector4;
  38244. updatable?: boolean;
  38245. sourcePlane?: Plane;
  38246. }, scene?: Nullable<Scene>): Mesh;
  38247. }
  38248. }
  38249. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38250. import { Behavior } from "babylonjs/Behaviors/behavior";
  38251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38252. import { Observable } from "babylonjs/Misc/observable";
  38253. import { Vector3 } from "babylonjs/Maths/math.vector";
  38254. import { Ray } from "babylonjs/Culling/ray";
  38255. import "babylonjs/Meshes/Builders/planeBuilder";
  38256. /**
  38257. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38258. */
  38259. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38260. private static _AnyMouseID;
  38261. /**
  38262. * Abstract mesh the behavior is set on
  38263. */
  38264. attachedNode: AbstractMesh;
  38265. private _dragPlane;
  38266. private _scene;
  38267. private _pointerObserver;
  38268. private _beforeRenderObserver;
  38269. private static _planeScene;
  38270. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38271. /**
  38272. * 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)
  38273. */
  38274. maxDragAngle: number;
  38275. /**
  38276. * @hidden
  38277. */
  38278. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38279. /**
  38280. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38281. */
  38282. currentDraggingPointerID: number;
  38283. /**
  38284. * The last position where the pointer hit the drag plane in world space
  38285. */
  38286. lastDragPosition: Vector3;
  38287. /**
  38288. * If the behavior is currently in a dragging state
  38289. */
  38290. dragging: boolean;
  38291. /**
  38292. * 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)
  38293. */
  38294. dragDeltaRatio: number;
  38295. /**
  38296. * If the drag plane orientation should be updated during the dragging (Default: true)
  38297. */
  38298. updateDragPlane: boolean;
  38299. private _debugMode;
  38300. private _moving;
  38301. /**
  38302. * Fires each time the attached mesh is dragged with the pointer
  38303. * * delta between last drag position and current drag position in world space
  38304. * * dragDistance along the drag axis
  38305. * * dragPlaneNormal normal of the current drag plane used during the drag
  38306. * * dragPlanePoint in world space where the drag intersects the drag plane
  38307. */
  38308. onDragObservable: Observable<{
  38309. delta: Vector3;
  38310. dragPlanePoint: Vector3;
  38311. dragPlaneNormal: Vector3;
  38312. dragDistance: number;
  38313. pointerId: number;
  38314. }>;
  38315. /**
  38316. * Fires each time a drag begins (eg. mouse down on mesh)
  38317. */
  38318. onDragStartObservable: Observable<{
  38319. dragPlanePoint: Vector3;
  38320. pointerId: number;
  38321. }>;
  38322. /**
  38323. * Fires each time a drag ends (eg. mouse release after drag)
  38324. */
  38325. onDragEndObservable: Observable<{
  38326. dragPlanePoint: Vector3;
  38327. pointerId: number;
  38328. }>;
  38329. /**
  38330. * If the attached mesh should be moved when dragged
  38331. */
  38332. moveAttached: boolean;
  38333. /**
  38334. * If the drag behavior will react to drag events (Default: true)
  38335. */
  38336. enabled: boolean;
  38337. /**
  38338. * If pointer events should start and release the drag (Default: true)
  38339. */
  38340. startAndReleaseDragOnPointerEvents: boolean;
  38341. /**
  38342. * If camera controls should be detached during the drag
  38343. */
  38344. detachCameraControls: boolean;
  38345. /**
  38346. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38347. */
  38348. useObjectOrienationForDragging: boolean;
  38349. private _options;
  38350. /**
  38351. * Creates a pointer drag behavior that can be attached to a mesh
  38352. * @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)
  38353. */
  38354. constructor(options?: {
  38355. dragAxis?: Vector3;
  38356. dragPlaneNormal?: Vector3;
  38357. });
  38358. /**
  38359. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38360. */
  38361. validateDrag: (targetPosition: Vector3) => boolean;
  38362. /**
  38363. * The name of the behavior
  38364. */
  38365. readonly name: string;
  38366. /**
  38367. * Initializes the behavior
  38368. */
  38369. init(): void;
  38370. private _tmpVector;
  38371. private _alternatePickedPoint;
  38372. private _worldDragAxis;
  38373. private _targetPosition;
  38374. private _attachedElement;
  38375. /**
  38376. * Attaches the drag behavior the passed in mesh
  38377. * @param ownerNode The mesh that will be dragged around once attached
  38378. * @param predicate Predicate to use for pick filtering
  38379. */
  38380. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38381. /**
  38382. * Force relase the drag action by code.
  38383. */
  38384. releaseDrag(): void;
  38385. private _startDragRay;
  38386. private _lastPointerRay;
  38387. /**
  38388. * Simulates the start of a pointer drag event on the behavior
  38389. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38390. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38391. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38392. */
  38393. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38394. private _startDrag;
  38395. private _dragDelta;
  38396. private _moveDrag;
  38397. private _pickWithRayOnDragPlane;
  38398. private _pointA;
  38399. private _pointB;
  38400. private _pointC;
  38401. private _lineA;
  38402. private _lineB;
  38403. private _localAxis;
  38404. private _lookAt;
  38405. private _updateDragPlanePosition;
  38406. /**
  38407. * Detaches the behavior from the mesh
  38408. */
  38409. detach(): void;
  38410. }
  38411. }
  38412. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38413. import { Mesh } from "babylonjs/Meshes/mesh";
  38414. import { Behavior } from "babylonjs/Behaviors/behavior";
  38415. /**
  38416. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38417. */
  38418. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38419. private _dragBehaviorA;
  38420. private _dragBehaviorB;
  38421. private _startDistance;
  38422. private _initialScale;
  38423. private _targetScale;
  38424. private _ownerNode;
  38425. private _sceneRenderObserver;
  38426. /**
  38427. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38428. */
  38429. constructor();
  38430. /**
  38431. * The name of the behavior
  38432. */
  38433. readonly name: string;
  38434. /**
  38435. * Initializes the behavior
  38436. */
  38437. init(): void;
  38438. private _getCurrentDistance;
  38439. /**
  38440. * Attaches the scale behavior the passed in mesh
  38441. * @param ownerNode The mesh that will be scaled around once attached
  38442. */
  38443. attach(ownerNode: Mesh): void;
  38444. /**
  38445. * Detaches the behavior from the mesh
  38446. */
  38447. detach(): void;
  38448. }
  38449. }
  38450. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38451. import { Behavior } from "babylonjs/Behaviors/behavior";
  38452. import { Mesh } from "babylonjs/Meshes/mesh";
  38453. import { Observable } from "babylonjs/Misc/observable";
  38454. /**
  38455. * 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
  38456. */
  38457. export class SixDofDragBehavior implements Behavior<Mesh> {
  38458. private static _virtualScene;
  38459. private _ownerNode;
  38460. private _sceneRenderObserver;
  38461. private _scene;
  38462. private _targetPosition;
  38463. private _virtualOriginMesh;
  38464. private _virtualDragMesh;
  38465. private _pointerObserver;
  38466. private _moving;
  38467. private _startingOrientation;
  38468. /**
  38469. * 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)
  38470. */
  38471. private zDragFactor;
  38472. /**
  38473. * If the object should rotate to face the drag origin
  38474. */
  38475. rotateDraggedObject: boolean;
  38476. /**
  38477. * If the behavior is currently in a dragging state
  38478. */
  38479. dragging: boolean;
  38480. /**
  38481. * 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)
  38482. */
  38483. dragDeltaRatio: number;
  38484. /**
  38485. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38486. */
  38487. currentDraggingPointerID: number;
  38488. /**
  38489. * If camera controls should be detached during the drag
  38490. */
  38491. detachCameraControls: boolean;
  38492. /**
  38493. * Fires each time a drag starts
  38494. */
  38495. onDragStartObservable: Observable<{}>;
  38496. /**
  38497. * Fires each time a drag ends (eg. mouse release after drag)
  38498. */
  38499. onDragEndObservable: Observable<{}>;
  38500. /**
  38501. * 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
  38502. */
  38503. constructor();
  38504. /**
  38505. * The name of the behavior
  38506. */
  38507. readonly name: string;
  38508. /**
  38509. * Initializes the behavior
  38510. */
  38511. init(): void;
  38512. /**
  38513. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38514. */
  38515. private readonly _pointerCamera;
  38516. /**
  38517. * Attaches the scale behavior the passed in mesh
  38518. * @param ownerNode The mesh that will be scaled around once attached
  38519. */
  38520. attach(ownerNode: Mesh): void;
  38521. /**
  38522. * Detaches the behavior from the mesh
  38523. */
  38524. detach(): void;
  38525. }
  38526. }
  38527. declare module "babylonjs/Behaviors/Meshes/index" {
  38528. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38529. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38530. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38531. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38532. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38533. }
  38534. declare module "babylonjs/Behaviors/index" {
  38535. export * from "babylonjs/Behaviors/behavior";
  38536. export * from "babylonjs/Behaviors/Cameras/index";
  38537. export * from "babylonjs/Behaviors/Meshes/index";
  38538. }
  38539. declare module "babylonjs/Bones/boneIKController" {
  38540. import { Bone } from "babylonjs/Bones/bone";
  38541. import { Vector3 } from "babylonjs/Maths/math.vector";
  38542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38543. import { Nullable } from "babylonjs/types";
  38544. /**
  38545. * Class used to apply inverse kinematics to bones
  38546. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38547. */
  38548. export class BoneIKController {
  38549. private static _tmpVecs;
  38550. private static _tmpQuat;
  38551. private static _tmpMats;
  38552. /**
  38553. * Gets or sets the target mesh
  38554. */
  38555. targetMesh: AbstractMesh;
  38556. /** Gets or sets the mesh used as pole */
  38557. poleTargetMesh: AbstractMesh;
  38558. /**
  38559. * Gets or sets the bone used as pole
  38560. */
  38561. poleTargetBone: Nullable<Bone>;
  38562. /**
  38563. * Gets or sets the target position
  38564. */
  38565. targetPosition: Vector3;
  38566. /**
  38567. * Gets or sets the pole target position
  38568. */
  38569. poleTargetPosition: Vector3;
  38570. /**
  38571. * Gets or sets the pole target local offset
  38572. */
  38573. poleTargetLocalOffset: Vector3;
  38574. /**
  38575. * Gets or sets the pole angle
  38576. */
  38577. poleAngle: number;
  38578. /**
  38579. * Gets or sets the mesh associated with the controller
  38580. */
  38581. mesh: AbstractMesh;
  38582. /**
  38583. * 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)
  38584. */
  38585. slerpAmount: number;
  38586. private _bone1Quat;
  38587. private _bone1Mat;
  38588. private _bone2Ang;
  38589. private _bone1;
  38590. private _bone2;
  38591. private _bone1Length;
  38592. private _bone2Length;
  38593. private _maxAngle;
  38594. private _maxReach;
  38595. private _rightHandedSystem;
  38596. private _bendAxis;
  38597. private _slerping;
  38598. private _adjustRoll;
  38599. /**
  38600. * Gets or sets maximum allowed angle
  38601. */
  38602. maxAngle: number;
  38603. /**
  38604. * Creates a new BoneIKController
  38605. * @param mesh defines the mesh to control
  38606. * @param bone defines the bone to control
  38607. * @param options defines options to set up the controller
  38608. */
  38609. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38610. targetMesh?: AbstractMesh;
  38611. poleTargetMesh?: AbstractMesh;
  38612. poleTargetBone?: Bone;
  38613. poleTargetLocalOffset?: Vector3;
  38614. poleAngle?: number;
  38615. bendAxis?: Vector3;
  38616. maxAngle?: number;
  38617. slerpAmount?: number;
  38618. });
  38619. private _setMaxAngle;
  38620. /**
  38621. * Force the controller to update the bones
  38622. */
  38623. update(): void;
  38624. }
  38625. }
  38626. declare module "babylonjs/Bones/boneLookController" {
  38627. import { Vector3 } from "babylonjs/Maths/math.vector";
  38628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38629. import { Bone } from "babylonjs/Bones/bone";
  38630. import { Space } from "babylonjs/Maths/math.axis";
  38631. /**
  38632. * Class used to make a bone look toward a point in space
  38633. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38634. */
  38635. export class BoneLookController {
  38636. private static _tmpVecs;
  38637. private static _tmpQuat;
  38638. private static _tmpMats;
  38639. /**
  38640. * The target Vector3 that the bone will look at
  38641. */
  38642. target: Vector3;
  38643. /**
  38644. * The mesh that the bone is attached to
  38645. */
  38646. mesh: AbstractMesh;
  38647. /**
  38648. * The bone that will be looking to the target
  38649. */
  38650. bone: Bone;
  38651. /**
  38652. * The up axis of the coordinate system that is used when the bone is rotated
  38653. */
  38654. upAxis: Vector3;
  38655. /**
  38656. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38657. */
  38658. upAxisSpace: Space;
  38659. /**
  38660. * Used to make an adjustment to the yaw of the bone
  38661. */
  38662. adjustYaw: number;
  38663. /**
  38664. * Used to make an adjustment to the pitch of the bone
  38665. */
  38666. adjustPitch: number;
  38667. /**
  38668. * Used to make an adjustment to the roll of the bone
  38669. */
  38670. adjustRoll: number;
  38671. /**
  38672. * 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)
  38673. */
  38674. slerpAmount: number;
  38675. private _minYaw;
  38676. private _maxYaw;
  38677. private _minPitch;
  38678. private _maxPitch;
  38679. private _minYawSin;
  38680. private _minYawCos;
  38681. private _maxYawSin;
  38682. private _maxYawCos;
  38683. private _midYawConstraint;
  38684. private _minPitchTan;
  38685. private _maxPitchTan;
  38686. private _boneQuat;
  38687. private _slerping;
  38688. private _transformYawPitch;
  38689. private _transformYawPitchInv;
  38690. private _firstFrameSkipped;
  38691. private _yawRange;
  38692. private _fowardAxis;
  38693. /**
  38694. * Gets or sets the minimum yaw angle that the bone can look to
  38695. */
  38696. minYaw: number;
  38697. /**
  38698. * Gets or sets the maximum yaw angle that the bone can look to
  38699. */
  38700. maxYaw: number;
  38701. /**
  38702. * Gets or sets the minimum pitch angle that the bone can look to
  38703. */
  38704. minPitch: number;
  38705. /**
  38706. * Gets or sets the maximum pitch angle that the bone can look to
  38707. */
  38708. maxPitch: number;
  38709. /**
  38710. * Create a BoneLookController
  38711. * @param mesh the mesh that the bone belongs to
  38712. * @param bone the bone that will be looking to the target
  38713. * @param target the target Vector3 to look at
  38714. * @param options optional settings:
  38715. * * maxYaw: the maximum angle the bone will yaw to
  38716. * * minYaw: the minimum angle the bone will yaw to
  38717. * * maxPitch: the maximum angle the bone will pitch to
  38718. * * minPitch: the minimum angle the bone will yaw to
  38719. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38720. * * upAxis: the up axis of the coordinate system
  38721. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38722. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38723. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38724. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38725. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38726. * * adjustRoll: used to make an adjustment to the roll of the bone
  38727. **/
  38728. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38729. maxYaw?: number;
  38730. minYaw?: number;
  38731. maxPitch?: number;
  38732. minPitch?: number;
  38733. slerpAmount?: number;
  38734. upAxis?: Vector3;
  38735. upAxisSpace?: Space;
  38736. yawAxis?: Vector3;
  38737. pitchAxis?: Vector3;
  38738. adjustYaw?: number;
  38739. adjustPitch?: number;
  38740. adjustRoll?: number;
  38741. });
  38742. /**
  38743. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38744. */
  38745. update(): void;
  38746. private _getAngleDiff;
  38747. private _getAngleBetween;
  38748. private _isAngleBetween;
  38749. }
  38750. }
  38751. declare module "babylonjs/Bones/index" {
  38752. export * from "babylonjs/Bones/bone";
  38753. export * from "babylonjs/Bones/boneIKController";
  38754. export * from "babylonjs/Bones/boneLookController";
  38755. export * from "babylonjs/Bones/skeleton";
  38756. }
  38757. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38758. import { Nullable } from "babylonjs/types";
  38759. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38760. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38761. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38762. /**
  38763. * Manage the gamepad inputs to control an arc rotate camera.
  38764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38765. */
  38766. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38767. /**
  38768. * Defines the camera the input is attached to.
  38769. */
  38770. camera: ArcRotateCamera;
  38771. /**
  38772. * Defines the gamepad the input is gathering event from.
  38773. */
  38774. gamepad: Nullable<Gamepad>;
  38775. /**
  38776. * Defines the gamepad rotation sensiblity.
  38777. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38778. */
  38779. gamepadRotationSensibility: number;
  38780. /**
  38781. * Defines the gamepad move sensiblity.
  38782. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38783. */
  38784. gamepadMoveSensibility: number;
  38785. private _yAxisScale;
  38786. /**
  38787. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38788. */
  38789. invertYAxis: boolean;
  38790. private _onGamepadConnectedObserver;
  38791. private _onGamepadDisconnectedObserver;
  38792. /**
  38793. * Attach the input controls to a specific dom element to get the input from.
  38794. * @param element Defines the element the controls should be listened from
  38795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38796. */
  38797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38798. /**
  38799. * Detach the current controls from the specified dom element.
  38800. * @param element Defines the element to stop listening the inputs from
  38801. */
  38802. detachControl(element: Nullable<HTMLElement>): void;
  38803. /**
  38804. * Update the current camera state depending on the inputs that have been used this frame.
  38805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38806. */
  38807. checkInputs(): void;
  38808. /**
  38809. * Gets the class name of the current intput.
  38810. * @returns the class name
  38811. */
  38812. getClassName(): string;
  38813. /**
  38814. * Get the friendly name associated with the input class.
  38815. * @returns the input friendly name
  38816. */
  38817. getSimpleName(): string;
  38818. }
  38819. }
  38820. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38821. import { Nullable } from "babylonjs/types";
  38822. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38823. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38824. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38825. interface ArcRotateCameraInputsManager {
  38826. /**
  38827. * Add orientation input support to the input manager.
  38828. * @returns the current input manager
  38829. */
  38830. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38831. }
  38832. }
  38833. /**
  38834. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38836. */
  38837. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38838. /**
  38839. * Defines the camera the input is attached to.
  38840. */
  38841. camera: ArcRotateCamera;
  38842. /**
  38843. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38844. */
  38845. alphaCorrection: number;
  38846. /**
  38847. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38848. */
  38849. gammaCorrection: number;
  38850. private _alpha;
  38851. private _gamma;
  38852. private _dirty;
  38853. private _deviceOrientationHandler;
  38854. /**
  38855. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38856. */
  38857. constructor();
  38858. /**
  38859. * Attach the input controls to a specific dom element to get the input from.
  38860. * @param element Defines the element the controls should be listened from
  38861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38862. */
  38863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38864. /** @hidden */
  38865. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38866. /**
  38867. * Update the current camera state depending on the inputs that have been used this frame.
  38868. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38869. */
  38870. checkInputs(): void;
  38871. /**
  38872. * Detach the current controls from the specified dom element.
  38873. * @param element Defines the element to stop listening the inputs from
  38874. */
  38875. detachControl(element: Nullable<HTMLElement>): void;
  38876. /**
  38877. * Gets the class name of the current intput.
  38878. * @returns the class name
  38879. */
  38880. getClassName(): string;
  38881. /**
  38882. * Get the friendly name associated with the input class.
  38883. * @returns the input friendly name
  38884. */
  38885. getSimpleName(): string;
  38886. }
  38887. }
  38888. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38889. import { Nullable } from "babylonjs/types";
  38890. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38891. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38892. /**
  38893. * Listen to mouse events to control the camera.
  38894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38895. */
  38896. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38897. /**
  38898. * Defines the camera the input is attached to.
  38899. */
  38900. camera: FlyCamera;
  38901. /**
  38902. * Defines if touch is enabled. (Default is true.)
  38903. */
  38904. touchEnabled: boolean;
  38905. /**
  38906. * Defines the buttons associated with the input to handle camera rotation.
  38907. */
  38908. buttons: number[];
  38909. /**
  38910. * Assign buttons for Yaw control.
  38911. */
  38912. buttonsYaw: number[];
  38913. /**
  38914. * Assign buttons for Pitch control.
  38915. */
  38916. buttonsPitch: number[];
  38917. /**
  38918. * Assign buttons for Roll control.
  38919. */
  38920. buttonsRoll: number[];
  38921. /**
  38922. * Detect if any button is being pressed while mouse is moved.
  38923. * -1 = Mouse locked.
  38924. * 0 = Left button.
  38925. * 1 = Middle Button.
  38926. * 2 = Right Button.
  38927. */
  38928. activeButton: number;
  38929. /**
  38930. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38931. * Higher values reduce its sensitivity.
  38932. */
  38933. angularSensibility: number;
  38934. private _mousemoveCallback;
  38935. private _observer;
  38936. private _rollObserver;
  38937. private previousPosition;
  38938. private noPreventDefault;
  38939. private element;
  38940. /**
  38941. * Listen to mouse events to control the camera.
  38942. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38944. */
  38945. constructor(touchEnabled?: boolean);
  38946. /**
  38947. * Attach the mouse control to the HTML DOM element.
  38948. * @param element Defines the element that listens to the input events.
  38949. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38950. */
  38951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38952. /**
  38953. * Detach the current controls from the specified dom element.
  38954. * @param element Defines the element to stop listening the inputs from
  38955. */
  38956. detachControl(element: Nullable<HTMLElement>): void;
  38957. /**
  38958. * Gets the class name of the current input.
  38959. * @returns the class name.
  38960. */
  38961. getClassName(): string;
  38962. /**
  38963. * Get the friendly name associated with the input class.
  38964. * @returns the input's friendly name.
  38965. */
  38966. getSimpleName(): string;
  38967. private _pointerInput;
  38968. private _onMouseMove;
  38969. /**
  38970. * Rotate camera by mouse offset.
  38971. */
  38972. private rotateCamera;
  38973. }
  38974. }
  38975. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38976. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38977. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38978. /**
  38979. * Default Inputs manager for the FlyCamera.
  38980. * It groups all the default supported inputs for ease of use.
  38981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38982. */
  38983. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38984. /**
  38985. * Instantiates a new FlyCameraInputsManager.
  38986. * @param camera Defines the camera the inputs belong to.
  38987. */
  38988. constructor(camera: FlyCamera);
  38989. /**
  38990. * Add keyboard input support to the input manager.
  38991. * @returns the new FlyCameraKeyboardMoveInput().
  38992. */
  38993. addKeyboard(): FlyCameraInputsManager;
  38994. /**
  38995. * Add mouse input support to the input manager.
  38996. * @param touchEnabled Enable touch screen support.
  38997. * @returns the new FlyCameraMouseInput().
  38998. */
  38999. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39000. }
  39001. }
  39002. declare module "babylonjs/Cameras/flyCamera" {
  39003. import { Scene } from "babylonjs/scene";
  39004. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39006. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39007. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39008. /**
  39009. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39010. * such as in a 3D Space Shooter or a Flight Simulator.
  39011. */
  39012. export class FlyCamera extends TargetCamera {
  39013. /**
  39014. * Define the collision ellipsoid of the camera.
  39015. * This is helpful for simulating a camera body, like a player's body.
  39016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39017. */
  39018. ellipsoid: Vector3;
  39019. /**
  39020. * Define an offset for the position of the ellipsoid around the camera.
  39021. * This can be helpful if the camera is attached away from the player's body center,
  39022. * such as at its head.
  39023. */
  39024. ellipsoidOffset: Vector3;
  39025. /**
  39026. * Enable or disable collisions of the camera with the rest of the scene objects.
  39027. */
  39028. checkCollisions: boolean;
  39029. /**
  39030. * Enable or disable gravity on the camera.
  39031. */
  39032. applyGravity: boolean;
  39033. /**
  39034. * Define the current direction the camera is moving to.
  39035. */
  39036. cameraDirection: Vector3;
  39037. /**
  39038. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39039. * This overrides and empties cameraRotation.
  39040. */
  39041. rotationQuaternion: Quaternion;
  39042. /**
  39043. * Track Roll to maintain the wanted Rolling when looking around.
  39044. */
  39045. _trackRoll: number;
  39046. /**
  39047. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39048. */
  39049. rollCorrect: number;
  39050. /**
  39051. * Mimic a banked turn, Rolling the camera when Yawing.
  39052. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39053. */
  39054. bankedTurn: boolean;
  39055. /**
  39056. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39057. */
  39058. bankedTurnLimit: number;
  39059. /**
  39060. * Value of 0 disables the banked Roll.
  39061. * Value of 1 is equal to the Yaw angle in radians.
  39062. */
  39063. bankedTurnMultiplier: number;
  39064. /**
  39065. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39066. */
  39067. inputs: FlyCameraInputsManager;
  39068. /**
  39069. * Gets the input sensibility for mouse input.
  39070. * Higher values reduce sensitivity.
  39071. */
  39072. /**
  39073. * Sets the input sensibility for a mouse input.
  39074. * Higher values reduce sensitivity.
  39075. */
  39076. angularSensibility: number;
  39077. /**
  39078. * Get the keys for camera movement forward.
  39079. */
  39080. /**
  39081. * Set the keys for camera movement forward.
  39082. */
  39083. keysForward: number[];
  39084. /**
  39085. * Get the keys for camera movement backward.
  39086. */
  39087. keysBackward: number[];
  39088. /**
  39089. * Get the keys for camera movement up.
  39090. */
  39091. /**
  39092. * Set the keys for camera movement up.
  39093. */
  39094. keysUp: number[];
  39095. /**
  39096. * Get the keys for camera movement down.
  39097. */
  39098. /**
  39099. * Set the keys for camera movement down.
  39100. */
  39101. keysDown: number[];
  39102. /**
  39103. * Get the keys for camera movement left.
  39104. */
  39105. /**
  39106. * Set the keys for camera movement left.
  39107. */
  39108. keysLeft: number[];
  39109. /**
  39110. * Set the keys for camera movement right.
  39111. */
  39112. /**
  39113. * Set the keys for camera movement right.
  39114. */
  39115. keysRight: number[];
  39116. /**
  39117. * Event raised when the camera collides with a mesh in the scene.
  39118. */
  39119. onCollide: (collidedMesh: AbstractMesh) => void;
  39120. private _collider;
  39121. private _needMoveForGravity;
  39122. private _oldPosition;
  39123. private _diffPosition;
  39124. private _newPosition;
  39125. /** @hidden */
  39126. _localDirection: Vector3;
  39127. /** @hidden */
  39128. _transformedDirection: Vector3;
  39129. /**
  39130. * Instantiates a FlyCamera.
  39131. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39132. * such as in a 3D Space Shooter or a Flight Simulator.
  39133. * @param name Define the name of the camera in the scene.
  39134. * @param position Define the starting position of the camera in the scene.
  39135. * @param scene Define the scene the camera belongs to.
  39136. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39137. */
  39138. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39139. /**
  39140. * Attach a control to the HTML DOM element.
  39141. * @param element Defines the element that listens to the input events.
  39142. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39143. */
  39144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39145. /**
  39146. * Detach a control from the HTML DOM element.
  39147. * The camera will stop reacting to that input.
  39148. * @param element Defines the element that listens to the input events.
  39149. */
  39150. detachControl(element: HTMLElement): void;
  39151. private _collisionMask;
  39152. /**
  39153. * Get the mask that the camera ignores in collision events.
  39154. */
  39155. /**
  39156. * Set the mask that the camera ignores in collision events.
  39157. */
  39158. collisionMask: number;
  39159. /** @hidden */
  39160. _collideWithWorld(displacement: Vector3): void;
  39161. /** @hidden */
  39162. private _onCollisionPositionChange;
  39163. /** @hidden */
  39164. _checkInputs(): void;
  39165. /** @hidden */
  39166. _decideIfNeedsToMove(): boolean;
  39167. /** @hidden */
  39168. _updatePosition(): void;
  39169. /**
  39170. * Restore the Roll to its target value at the rate specified.
  39171. * @param rate - Higher means slower restoring.
  39172. * @hidden
  39173. */
  39174. restoreRoll(rate: number): void;
  39175. /**
  39176. * Destroy the camera and release the current resources held by it.
  39177. */
  39178. dispose(): void;
  39179. /**
  39180. * Get the current object class name.
  39181. * @returns the class name.
  39182. */
  39183. getClassName(): string;
  39184. }
  39185. }
  39186. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39187. import { Nullable } from "babylonjs/types";
  39188. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39189. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39190. /**
  39191. * Listen to keyboard events to control the camera.
  39192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39193. */
  39194. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39195. /**
  39196. * Defines the camera the input is attached to.
  39197. */
  39198. camera: FlyCamera;
  39199. /**
  39200. * The list of keyboard keys used to control the forward move of the camera.
  39201. */
  39202. keysForward: number[];
  39203. /**
  39204. * The list of keyboard keys used to control the backward move of the camera.
  39205. */
  39206. keysBackward: number[];
  39207. /**
  39208. * The list of keyboard keys used to control the forward move of the camera.
  39209. */
  39210. keysUp: number[];
  39211. /**
  39212. * The list of keyboard keys used to control the backward move of the camera.
  39213. */
  39214. keysDown: number[];
  39215. /**
  39216. * The list of keyboard keys used to control the right strafe move of the camera.
  39217. */
  39218. keysRight: number[];
  39219. /**
  39220. * The list of keyboard keys used to control the left strafe move of the camera.
  39221. */
  39222. keysLeft: number[];
  39223. private _keys;
  39224. private _onCanvasBlurObserver;
  39225. private _onKeyboardObserver;
  39226. private _engine;
  39227. private _scene;
  39228. /**
  39229. * Attach the input controls to a specific dom element to get the input from.
  39230. * @param element Defines the element the controls should be listened from
  39231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39232. */
  39233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39234. /**
  39235. * Detach the current controls from the specified dom element.
  39236. * @param element Defines the element to stop listening the inputs from
  39237. */
  39238. detachControl(element: Nullable<HTMLElement>): void;
  39239. /**
  39240. * Gets the class name of the current intput.
  39241. * @returns the class name
  39242. */
  39243. getClassName(): string;
  39244. /** @hidden */
  39245. _onLostFocus(e: FocusEvent): void;
  39246. /**
  39247. * Get the friendly name associated with the input class.
  39248. * @returns the input friendly name
  39249. */
  39250. getSimpleName(): string;
  39251. /**
  39252. * Update the current camera state depending on the inputs that have been used this frame.
  39253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39254. */
  39255. checkInputs(): void;
  39256. }
  39257. }
  39258. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39259. import { Nullable } from "babylonjs/types";
  39260. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39261. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39262. /**
  39263. * Manage the mouse wheel inputs to control a follow camera.
  39264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39265. */
  39266. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39267. /**
  39268. * Defines the camera the input is attached to.
  39269. */
  39270. camera: FollowCamera;
  39271. /**
  39272. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39273. */
  39274. axisControlRadius: boolean;
  39275. /**
  39276. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39277. */
  39278. axisControlHeight: boolean;
  39279. /**
  39280. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39281. */
  39282. axisControlRotation: boolean;
  39283. /**
  39284. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39285. * relation to mouseWheel events.
  39286. */
  39287. wheelPrecision: number;
  39288. /**
  39289. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39290. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39291. */
  39292. wheelDeltaPercentage: number;
  39293. private _wheel;
  39294. private _observer;
  39295. /**
  39296. * Attach the input controls to a specific dom element to get the input from.
  39297. * @param element Defines the element the controls should be listened from
  39298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39299. */
  39300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39301. /**
  39302. * Detach the current controls from the specified dom element.
  39303. * @param element Defines the element to stop listening the inputs from
  39304. */
  39305. detachControl(element: Nullable<HTMLElement>): void;
  39306. /**
  39307. * Gets the class name of the current intput.
  39308. * @returns the class name
  39309. */
  39310. getClassName(): string;
  39311. /**
  39312. * Get the friendly name associated with the input class.
  39313. * @returns the input friendly name
  39314. */
  39315. getSimpleName(): string;
  39316. }
  39317. }
  39318. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39319. import { Nullable } from "babylonjs/types";
  39320. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39321. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39322. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39323. /**
  39324. * Manage the pointers inputs to control an follow camera.
  39325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39326. */
  39327. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39328. /**
  39329. * Defines the camera the input is attached to.
  39330. */
  39331. camera: FollowCamera;
  39332. /**
  39333. * Gets the class name of the current input.
  39334. * @returns the class name
  39335. */
  39336. getClassName(): string;
  39337. /**
  39338. * Defines the pointer angular sensibility along the X axis or how fast is
  39339. * the camera rotating.
  39340. * A negative number will reverse the axis direction.
  39341. */
  39342. angularSensibilityX: number;
  39343. /**
  39344. * Defines the pointer angular sensibility along the Y axis or how fast is
  39345. * the camera rotating.
  39346. * A negative number will reverse the axis direction.
  39347. */
  39348. angularSensibilityY: number;
  39349. /**
  39350. * Defines the pointer pinch precision or how fast is the camera zooming.
  39351. * A negative number will reverse the axis direction.
  39352. */
  39353. pinchPrecision: number;
  39354. /**
  39355. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39356. * from 0.
  39357. * It defines the percentage of current camera.radius to use as delta when
  39358. * pinch zoom is used.
  39359. */
  39360. pinchDeltaPercentage: number;
  39361. /**
  39362. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39363. */
  39364. axisXControlRadius: boolean;
  39365. /**
  39366. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39367. */
  39368. axisXControlHeight: boolean;
  39369. /**
  39370. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39371. */
  39372. axisXControlRotation: boolean;
  39373. /**
  39374. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39375. */
  39376. axisYControlRadius: boolean;
  39377. /**
  39378. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39379. */
  39380. axisYControlHeight: boolean;
  39381. /**
  39382. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39383. */
  39384. axisYControlRotation: boolean;
  39385. /**
  39386. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39387. */
  39388. axisPinchControlRadius: boolean;
  39389. /**
  39390. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39391. */
  39392. axisPinchControlHeight: boolean;
  39393. /**
  39394. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39395. */
  39396. axisPinchControlRotation: boolean;
  39397. /**
  39398. * Log error messages if basic misconfiguration has occurred.
  39399. */
  39400. warningEnable: boolean;
  39401. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39402. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39403. private _warningCounter;
  39404. private _warning;
  39405. }
  39406. }
  39407. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39408. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39409. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39410. /**
  39411. * Default Inputs manager for the FollowCamera.
  39412. * It groups all the default supported inputs for ease of use.
  39413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39414. */
  39415. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39416. /**
  39417. * Instantiates a new FollowCameraInputsManager.
  39418. * @param camera Defines the camera the inputs belong to
  39419. */
  39420. constructor(camera: FollowCamera);
  39421. /**
  39422. * Add keyboard input support to the input manager.
  39423. * @returns the current input manager
  39424. */
  39425. addKeyboard(): FollowCameraInputsManager;
  39426. /**
  39427. * Add mouse wheel input support to the input manager.
  39428. * @returns the current input manager
  39429. */
  39430. addMouseWheel(): FollowCameraInputsManager;
  39431. /**
  39432. * Add pointers input support to the input manager.
  39433. * @returns the current input manager
  39434. */
  39435. addPointers(): FollowCameraInputsManager;
  39436. /**
  39437. * Add orientation input support to the input manager.
  39438. * @returns the current input manager
  39439. */
  39440. addVRDeviceOrientation(): FollowCameraInputsManager;
  39441. }
  39442. }
  39443. declare module "babylonjs/Cameras/followCamera" {
  39444. import { Nullable } from "babylonjs/types";
  39445. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39446. import { Scene } from "babylonjs/scene";
  39447. import { Vector3 } from "babylonjs/Maths/math.vector";
  39448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39449. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39450. /**
  39451. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39452. * an arc rotate version arcFollowCamera are available.
  39453. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39454. */
  39455. export class FollowCamera extends TargetCamera {
  39456. /**
  39457. * Distance the follow camera should follow an object at
  39458. */
  39459. radius: number;
  39460. /**
  39461. * Minimum allowed distance of the camera to the axis of rotation
  39462. * (The camera can not get closer).
  39463. * This can help limiting how the Camera is able to move in the scene.
  39464. */
  39465. lowerRadiusLimit: Nullable<number>;
  39466. /**
  39467. * Maximum allowed distance of the camera to the axis of rotation
  39468. * (The camera can not get further).
  39469. * This can help limiting how the Camera is able to move in the scene.
  39470. */
  39471. upperRadiusLimit: Nullable<number>;
  39472. /**
  39473. * Define a rotation offset between the camera and the object it follows
  39474. */
  39475. rotationOffset: number;
  39476. /**
  39477. * Minimum allowed angle to camera position relative to target object.
  39478. * This can help limiting how the Camera is able to move in the scene.
  39479. */
  39480. lowerRotationOffsetLimit: Nullable<number>;
  39481. /**
  39482. * Maximum allowed angle to camera position relative to target object.
  39483. * This can help limiting how the Camera is able to move in the scene.
  39484. */
  39485. upperRotationOffsetLimit: Nullable<number>;
  39486. /**
  39487. * Define a height offset between the camera and the object it follows.
  39488. * It can help following an object from the top (like a car chaing a plane)
  39489. */
  39490. heightOffset: number;
  39491. /**
  39492. * Minimum allowed height of camera position relative to target object.
  39493. * This can help limiting how the Camera is able to move in the scene.
  39494. */
  39495. lowerHeightOffsetLimit: Nullable<number>;
  39496. /**
  39497. * Maximum allowed height of camera position relative to target object.
  39498. * This can help limiting how the Camera is able to move in the scene.
  39499. */
  39500. upperHeightOffsetLimit: Nullable<number>;
  39501. /**
  39502. * Define how fast the camera can accelerate to follow it s target.
  39503. */
  39504. cameraAcceleration: number;
  39505. /**
  39506. * Define the speed limit of the camera following an object.
  39507. */
  39508. maxCameraSpeed: number;
  39509. /**
  39510. * Define the target of the camera.
  39511. */
  39512. lockedTarget: Nullable<AbstractMesh>;
  39513. /**
  39514. * Defines the input associated with the camera.
  39515. */
  39516. inputs: FollowCameraInputsManager;
  39517. /**
  39518. * Instantiates the follow camera.
  39519. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39520. * @param name Define the name of the camera in the scene
  39521. * @param position Define the position of the camera
  39522. * @param scene Define the scene the camera belong to
  39523. * @param lockedTarget Define the target of the camera
  39524. */
  39525. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39526. private _follow;
  39527. /**
  39528. * Attached controls to the current camera.
  39529. * @param element Defines the element the controls should be listened from
  39530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39531. */
  39532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39533. /**
  39534. * Detach the current controls from the camera.
  39535. * The camera will stop reacting to inputs.
  39536. * @param element Defines the element to stop listening the inputs from
  39537. */
  39538. detachControl(element: HTMLElement): void;
  39539. /** @hidden */
  39540. _checkInputs(): void;
  39541. private _checkLimits;
  39542. /**
  39543. * Gets the camera class name.
  39544. * @returns the class name
  39545. */
  39546. getClassName(): string;
  39547. }
  39548. /**
  39549. * Arc Rotate version of the follow camera.
  39550. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39551. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39552. */
  39553. export class ArcFollowCamera extends TargetCamera {
  39554. /** The longitudinal angle of the camera */
  39555. alpha: number;
  39556. /** The latitudinal angle of the camera */
  39557. beta: number;
  39558. /** The radius of the camera from its target */
  39559. radius: number;
  39560. /** Define the camera target (the messh it should follow) */
  39561. target: Nullable<AbstractMesh>;
  39562. private _cartesianCoordinates;
  39563. /**
  39564. * Instantiates a new ArcFollowCamera
  39565. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39566. * @param name Define the name of the camera
  39567. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39568. * @param beta Define the rotation angle of the camera around the elevation axis
  39569. * @param radius Define the radius of the camera from its target point
  39570. * @param target Define the target of the camera
  39571. * @param scene Define the scene the camera belongs to
  39572. */
  39573. constructor(name: string,
  39574. /** The longitudinal angle of the camera */
  39575. alpha: number,
  39576. /** The latitudinal angle of the camera */
  39577. beta: number,
  39578. /** The radius of the camera from its target */
  39579. radius: number,
  39580. /** Define the camera target (the messh it should follow) */
  39581. target: Nullable<AbstractMesh>, scene: Scene);
  39582. private _follow;
  39583. /** @hidden */
  39584. _checkInputs(): void;
  39585. /**
  39586. * Returns the class name of the object.
  39587. * It is mostly used internally for serialization purposes.
  39588. */
  39589. getClassName(): string;
  39590. }
  39591. }
  39592. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39593. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39594. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39595. import { Nullable } from "babylonjs/types";
  39596. /**
  39597. * Manage the keyboard inputs to control the movement of a follow camera.
  39598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39599. */
  39600. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39601. /**
  39602. * Defines the camera the input is attached to.
  39603. */
  39604. camera: FollowCamera;
  39605. /**
  39606. * Defines the list of key codes associated with the up action (increase heightOffset)
  39607. */
  39608. keysHeightOffsetIncr: number[];
  39609. /**
  39610. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39611. */
  39612. keysHeightOffsetDecr: number[];
  39613. /**
  39614. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39615. */
  39616. keysHeightOffsetModifierAlt: boolean;
  39617. /**
  39618. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39619. */
  39620. keysHeightOffsetModifierCtrl: boolean;
  39621. /**
  39622. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39623. */
  39624. keysHeightOffsetModifierShift: boolean;
  39625. /**
  39626. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39627. */
  39628. keysRotationOffsetIncr: number[];
  39629. /**
  39630. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39631. */
  39632. keysRotationOffsetDecr: number[];
  39633. /**
  39634. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39635. */
  39636. keysRotationOffsetModifierAlt: boolean;
  39637. /**
  39638. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39639. */
  39640. keysRotationOffsetModifierCtrl: boolean;
  39641. /**
  39642. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39643. */
  39644. keysRotationOffsetModifierShift: boolean;
  39645. /**
  39646. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39647. */
  39648. keysRadiusIncr: number[];
  39649. /**
  39650. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39651. */
  39652. keysRadiusDecr: number[];
  39653. /**
  39654. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39655. */
  39656. keysRadiusModifierAlt: boolean;
  39657. /**
  39658. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39659. */
  39660. keysRadiusModifierCtrl: boolean;
  39661. /**
  39662. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39663. */
  39664. keysRadiusModifierShift: boolean;
  39665. /**
  39666. * Defines the rate of change of heightOffset.
  39667. */
  39668. heightSensibility: number;
  39669. /**
  39670. * Defines the rate of change of rotationOffset.
  39671. */
  39672. rotationSensibility: number;
  39673. /**
  39674. * Defines the rate of change of radius.
  39675. */
  39676. radiusSensibility: number;
  39677. private _keys;
  39678. private _ctrlPressed;
  39679. private _altPressed;
  39680. private _shiftPressed;
  39681. private _onCanvasBlurObserver;
  39682. private _onKeyboardObserver;
  39683. private _engine;
  39684. private _scene;
  39685. /**
  39686. * Attach the input controls to a specific dom element to get the input from.
  39687. * @param element Defines the element the controls should be listened from
  39688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39689. */
  39690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39691. /**
  39692. * Detach the current controls from the specified dom element.
  39693. * @param element Defines the element to stop listening the inputs from
  39694. */
  39695. detachControl(element: Nullable<HTMLElement>): void;
  39696. /**
  39697. * Update the current camera state depending on the inputs that have been used this frame.
  39698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39699. */
  39700. checkInputs(): void;
  39701. /**
  39702. * Gets the class name of the current input.
  39703. * @returns the class name
  39704. */
  39705. getClassName(): string;
  39706. /**
  39707. * Get the friendly name associated with the input class.
  39708. * @returns the input friendly name
  39709. */
  39710. getSimpleName(): string;
  39711. /**
  39712. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39713. * allow modification of the heightOffset value.
  39714. */
  39715. private _modifierHeightOffset;
  39716. /**
  39717. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39718. * allow modification of the rotationOffset value.
  39719. */
  39720. private _modifierRotationOffset;
  39721. /**
  39722. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39723. * allow modification of the radius value.
  39724. */
  39725. private _modifierRadius;
  39726. }
  39727. }
  39728. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39729. import { Nullable } from "babylonjs/types";
  39730. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39731. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39732. import { Observable } from "babylonjs/Misc/observable";
  39733. module "babylonjs/Cameras/freeCameraInputsManager" {
  39734. interface FreeCameraInputsManager {
  39735. /**
  39736. * @hidden
  39737. */
  39738. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39739. /**
  39740. * Add orientation input support to the input manager.
  39741. * @returns the current input manager
  39742. */
  39743. addDeviceOrientation(): FreeCameraInputsManager;
  39744. }
  39745. }
  39746. /**
  39747. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39748. * Screen rotation is taken into account.
  39749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39750. */
  39751. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39752. private _camera;
  39753. private _screenOrientationAngle;
  39754. private _constantTranform;
  39755. private _screenQuaternion;
  39756. private _alpha;
  39757. private _beta;
  39758. private _gamma;
  39759. /**
  39760. * Can be used to detect if a device orientation sensor is availible on a device
  39761. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39762. * @returns a promise that will resolve on orientation change
  39763. */
  39764. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39765. /**
  39766. * @hidden
  39767. */
  39768. _onDeviceOrientationChangedObservable: Observable<void>;
  39769. /**
  39770. * Instantiates a new input
  39771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39772. */
  39773. constructor();
  39774. /**
  39775. * Define the camera controlled by the input.
  39776. */
  39777. camera: FreeCamera;
  39778. /**
  39779. * Attach the input controls to a specific dom element to get the input from.
  39780. * @param element Defines the element the controls should be listened from
  39781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39782. */
  39783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39784. private _orientationChanged;
  39785. private _deviceOrientation;
  39786. /**
  39787. * Detach the current controls from the specified dom element.
  39788. * @param element Defines the element to stop listening the inputs from
  39789. */
  39790. detachControl(element: Nullable<HTMLElement>): void;
  39791. /**
  39792. * Update the current camera state depending on the inputs that have been used this frame.
  39793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39794. */
  39795. checkInputs(): void;
  39796. /**
  39797. * Gets the class name of the current intput.
  39798. * @returns the class name
  39799. */
  39800. getClassName(): string;
  39801. /**
  39802. * Get the friendly name associated with the input class.
  39803. * @returns the input friendly name
  39804. */
  39805. getSimpleName(): string;
  39806. }
  39807. }
  39808. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39809. import { Nullable } from "babylonjs/types";
  39810. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39811. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39812. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39813. /**
  39814. * Manage the gamepad inputs to control a free camera.
  39815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39816. */
  39817. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39818. /**
  39819. * Define the camera the input is attached to.
  39820. */
  39821. camera: FreeCamera;
  39822. /**
  39823. * Define the Gamepad controlling the input
  39824. */
  39825. gamepad: Nullable<Gamepad>;
  39826. /**
  39827. * Defines the gamepad rotation sensiblity.
  39828. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39829. */
  39830. gamepadAngularSensibility: number;
  39831. /**
  39832. * Defines the gamepad move sensiblity.
  39833. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39834. */
  39835. gamepadMoveSensibility: number;
  39836. private _yAxisScale;
  39837. /**
  39838. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39839. */
  39840. invertYAxis: boolean;
  39841. private _onGamepadConnectedObserver;
  39842. private _onGamepadDisconnectedObserver;
  39843. private _cameraTransform;
  39844. private _deltaTransform;
  39845. private _vector3;
  39846. private _vector2;
  39847. /**
  39848. * Attach the input controls to a specific dom element to get the input from.
  39849. * @param element Defines the element the controls should be listened from
  39850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39851. */
  39852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39853. /**
  39854. * Detach the current controls from the specified dom element.
  39855. * @param element Defines the element to stop listening the inputs from
  39856. */
  39857. detachControl(element: Nullable<HTMLElement>): void;
  39858. /**
  39859. * Update the current camera state depending on the inputs that have been used this frame.
  39860. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39861. */
  39862. checkInputs(): void;
  39863. /**
  39864. * Gets the class name of the current intput.
  39865. * @returns the class name
  39866. */
  39867. getClassName(): string;
  39868. /**
  39869. * Get the friendly name associated with the input class.
  39870. * @returns the input friendly name
  39871. */
  39872. getSimpleName(): string;
  39873. }
  39874. }
  39875. declare module "babylonjs/Misc/virtualJoystick" {
  39876. import { Nullable } from "babylonjs/types";
  39877. import { Vector3 } from "babylonjs/Maths/math.vector";
  39878. /**
  39879. * Defines the potential axis of a Joystick
  39880. */
  39881. export enum JoystickAxis {
  39882. /** X axis */
  39883. X = 0,
  39884. /** Y axis */
  39885. Y = 1,
  39886. /** Z axis */
  39887. Z = 2
  39888. }
  39889. /**
  39890. * Class used to define virtual joystick (used in touch mode)
  39891. */
  39892. export class VirtualJoystick {
  39893. /**
  39894. * Gets or sets a boolean indicating that left and right values must be inverted
  39895. */
  39896. reverseLeftRight: boolean;
  39897. /**
  39898. * Gets or sets a boolean indicating that up and down values must be inverted
  39899. */
  39900. reverseUpDown: boolean;
  39901. /**
  39902. * Gets the offset value for the position (ie. the change of the position value)
  39903. */
  39904. deltaPosition: Vector3;
  39905. /**
  39906. * Gets a boolean indicating if the virtual joystick was pressed
  39907. */
  39908. pressed: boolean;
  39909. /**
  39910. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39911. */
  39912. static Canvas: Nullable<HTMLCanvasElement>;
  39913. private static _globalJoystickIndex;
  39914. private static vjCanvasContext;
  39915. private static vjCanvasWidth;
  39916. private static vjCanvasHeight;
  39917. private static halfWidth;
  39918. private _action;
  39919. private _axisTargetedByLeftAndRight;
  39920. private _axisTargetedByUpAndDown;
  39921. private _joystickSensibility;
  39922. private _inversedSensibility;
  39923. private _joystickPointerID;
  39924. private _joystickColor;
  39925. private _joystickPointerPos;
  39926. private _joystickPreviousPointerPos;
  39927. private _joystickPointerStartPos;
  39928. private _deltaJoystickVector;
  39929. private _leftJoystick;
  39930. private _touches;
  39931. private _onPointerDownHandlerRef;
  39932. private _onPointerMoveHandlerRef;
  39933. private _onPointerUpHandlerRef;
  39934. private _onResize;
  39935. /**
  39936. * Creates a new virtual joystick
  39937. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39938. */
  39939. constructor(leftJoystick?: boolean);
  39940. /**
  39941. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39942. * @param newJoystickSensibility defines the new sensibility
  39943. */
  39944. setJoystickSensibility(newJoystickSensibility: number): void;
  39945. private _onPointerDown;
  39946. private _onPointerMove;
  39947. private _onPointerUp;
  39948. /**
  39949. * Change the color of the virtual joystick
  39950. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39951. */
  39952. setJoystickColor(newColor: string): void;
  39953. /**
  39954. * Defines a callback to call when the joystick is touched
  39955. * @param action defines the callback
  39956. */
  39957. setActionOnTouch(action: () => any): void;
  39958. /**
  39959. * Defines which axis you'd like to control for left & right
  39960. * @param axis defines the axis to use
  39961. */
  39962. setAxisForLeftRight(axis: JoystickAxis): void;
  39963. /**
  39964. * Defines which axis you'd like to control for up & down
  39965. * @param axis defines the axis to use
  39966. */
  39967. setAxisForUpDown(axis: JoystickAxis): void;
  39968. private _drawVirtualJoystick;
  39969. /**
  39970. * Release internal HTML canvas
  39971. */
  39972. releaseCanvas(): void;
  39973. }
  39974. }
  39975. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39976. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39977. import { Nullable } from "babylonjs/types";
  39978. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39979. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39980. module "babylonjs/Cameras/freeCameraInputsManager" {
  39981. interface FreeCameraInputsManager {
  39982. /**
  39983. * Add virtual joystick input support to the input manager.
  39984. * @returns the current input manager
  39985. */
  39986. addVirtualJoystick(): FreeCameraInputsManager;
  39987. }
  39988. }
  39989. /**
  39990. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39992. */
  39993. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39994. /**
  39995. * Defines the camera the input is attached to.
  39996. */
  39997. camera: FreeCamera;
  39998. private _leftjoystick;
  39999. private _rightjoystick;
  40000. /**
  40001. * Gets the left stick of the virtual joystick.
  40002. * @returns The virtual Joystick
  40003. */
  40004. getLeftJoystick(): VirtualJoystick;
  40005. /**
  40006. * Gets the right stick of the virtual joystick.
  40007. * @returns The virtual Joystick
  40008. */
  40009. getRightJoystick(): VirtualJoystick;
  40010. /**
  40011. * Update the current camera state depending on the inputs that have been used this frame.
  40012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40013. */
  40014. checkInputs(): void;
  40015. /**
  40016. * Attach the input controls to a specific dom element to get the input from.
  40017. * @param element Defines the element the controls should be listened from
  40018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40019. */
  40020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40021. /**
  40022. * Detach the current controls from the specified dom element.
  40023. * @param element Defines the element to stop listening the inputs from
  40024. */
  40025. detachControl(element: Nullable<HTMLElement>): void;
  40026. /**
  40027. * Gets the class name of the current intput.
  40028. * @returns the class name
  40029. */
  40030. getClassName(): string;
  40031. /**
  40032. * Get the friendly name associated with the input class.
  40033. * @returns the input friendly name
  40034. */
  40035. getSimpleName(): string;
  40036. }
  40037. }
  40038. declare module "babylonjs/Cameras/Inputs/index" {
  40039. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40040. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40041. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40042. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40043. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40044. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40045. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40046. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40047. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40048. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40049. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40050. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40051. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40052. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40053. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40054. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40055. }
  40056. declare module "babylonjs/Cameras/touchCamera" {
  40057. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40058. import { Scene } from "babylonjs/scene";
  40059. import { Vector3 } from "babylonjs/Maths/math.vector";
  40060. /**
  40061. * This represents a FPS type of camera controlled by touch.
  40062. * This is like a universal camera minus the Gamepad controls.
  40063. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40064. */
  40065. export class TouchCamera extends FreeCamera {
  40066. /**
  40067. * Defines the touch sensibility for rotation.
  40068. * The higher the faster.
  40069. */
  40070. touchAngularSensibility: number;
  40071. /**
  40072. * Defines the touch sensibility for move.
  40073. * The higher the faster.
  40074. */
  40075. touchMoveSensibility: number;
  40076. /**
  40077. * Instantiates a new touch camera.
  40078. * This represents a FPS type of camera controlled by touch.
  40079. * This is like a universal camera minus the Gamepad controls.
  40080. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40081. * @param name Define the name of the camera in the scene
  40082. * @param position Define the start position of the camera in the scene
  40083. * @param scene Define the scene the camera belongs to
  40084. */
  40085. constructor(name: string, position: Vector3, scene: Scene);
  40086. /**
  40087. * Gets the current object class name.
  40088. * @return the class name
  40089. */
  40090. getClassName(): string;
  40091. /** @hidden */
  40092. _setupInputs(): void;
  40093. }
  40094. }
  40095. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40096. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40097. import { Scene } from "babylonjs/scene";
  40098. import { Vector3 } from "babylonjs/Maths/math.vector";
  40099. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40100. import { Axis } from "babylonjs/Maths/math.axis";
  40101. /**
  40102. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40103. * being tilted forward or back and left or right.
  40104. */
  40105. export class DeviceOrientationCamera extends FreeCamera {
  40106. private _initialQuaternion;
  40107. private _quaternionCache;
  40108. private _tmpDragQuaternion;
  40109. private _disablePointerInputWhenUsingDeviceOrientation;
  40110. /**
  40111. * Creates a new device orientation camera
  40112. * @param name The name of the camera
  40113. * @param position The start position camera
  40114. * @param scene The scene the camera belongs to
  40115. */
  40116. constructor(name: string, position: Vector3, scene: Scene);
  40117. /**
  40118. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40119. */
  40120. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40121. private _dragFactor;
  40122. /**
  40123. * Enabled turning on the y axis when the orientation sensor is active
  40124. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40125. */
  40126. enableHorizontalDragging(dragFactor?: number): void;
  40127. /**
  40128. * Gets the current instance class name ("DeviceOrientationCamera").
  40129. * This helps avoiding instanceof at run time.
  40130. * @returns the class name
  40131. */
  40132. getClassName(): string;
  40133. /**
  40134. * @hidden
  40135. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40136. */
  40137. _checkInputs(): void;
  40138. /**
  40139. * Reset the camera to its default orientation on the specified axis only.
  40140. * @param axis The axis to reset
  40141. */
  40142. resetToCurrentRotation(axis?: Axis): void;
  40143. }
  40144. }
  40145. declare module "babylonjs/Gamepads/xboxGamepad" {
  40146. import { Observable } from "babylonjs/Misc/observable";
  40147. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40148. /**
  40149. * Defines supported buttons for XBox360 compatible gamepads
  40150. */
  40151. export enum Xbox360Button {
  40152. /** A */
  40153. A = 0,
  40154. /** B */
  40155. B = 1,
  40156. /** X */
  40157. X = 2,
  40158. /** Y */
  40159. Y = 3,
  40160. /** Start */
  40161. Start = 4,
  40162. /** Back */
  40163. Back = 5,
  40164. /** Left button */
  40165. LB = 6,
  40166. /** Right button */
  40167. RB = 7,
  40168. /** Left stick */
  40169. LeftStick = 8,
  40170. /** Right stick */
  40171. RightStick = 9
  40172. }
  40173. /** Defines values for XBox360 DPad */
  40174. export enum Xbox360Dpad {
  40175. /** Up */
  40176. Up = 0,
  40177. /** Down */
  40178. Down = 1,
  40179. /** Left */
  40180. Left = 2,
  40181. /** Right */
  40182. Right = 3
  40183. }
  40184. /**
  40185. * Defines a XBox360 gamepad
  40186. */
  40187. export class Xbox360Pad extends Gamepad {
  40188. private _leftTrigger;
  40189. private _rightTrigger;
  40190. private _onlefttriggerchanged;
  40191. private _onrighttriggerchanged;
  40192. private _onbuttondown;
  40193. private _onbuttonup;
  40194. private _ondpaddown;
  40195. private _ondpadup;
  40196. /** Observable raised when a button is pressed */
  40197. onButtonDownObservable: Observable<Xbox360Button>;
  40198. /** Observable raised when a button is released */
  40199. onButtonUpObservable: Observable<Xbox360Button>;
  40200. /** Observable raised when a pad is pressed */
  40201. onPadDownObservable: Observable<Xbox360Dpad>;
  40202. /** Observable raised when a pad is released */
  40203. onPadUpObservable: Observable<Xbox360Dpad>;
  40204. private _buttonA;
  40205. private _buttonB;
  40206. private _buttonX;
  40207. private _buttonY;
  40208. private _buttonBack;
  40209. private _buttonStart;
  40210. private _buttonLB;
  40211. private _buttonRB;
  40212. private _buttonLeftStick;
  40213. private _buttonRightStick;
  40214. private _dPadUp;
  40215. private _dPadDown;
  40216. private _dPadLeft;
  40217. private _dPadRight;
  40218. private _isXboxOnePad;
  40219. /**
  40220. * Creates a new XBox360 gamepad object
  40221. * @param id defines the id of this gamepad
  40222. * @param index defines its index
  40223. * @param gamepad defines the internal HTML gamepad object
  40224. * @param xboxOne defines if it is a XBox One gamepad
  40225. */
  40226. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40227. /**
  40228. * Defines the callback to call when left trigger is pressed
  40229. * @param callback defines the callback to use
  40230. */
  40231. onlefttriggerchanged(callback: (value: number) => void): void;
  40232. /**
  40233. * Defines the callback to call when right trigger is pressed
  40234. * @param callback defines the callback to use
  40235. */
  40236. onrighttriggerchanged(callback: (value: number) => void): void;
  40237. /**
  40238. * Gets the left trigger value
  40239. */
  40240. /**
  40241. * Sets the left trigger value
  40242. */
  40243. leftTrigger: number;
  40244. /**
  40245. * Gets the right trigger value
  40246. */
  40247. /**
  40248. * Sets the right trigger value
  40249. */
  40250. rightTrigger: number;
  40251. /**
  40252. * Defines the callback to call when a button is pressed
  40253. * @param callback defines the callback to use
  40254. */
  40255. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40256. /**
  40257. * Defines the callback to call when a button is released
  40258. * @param callback defines the callback to use
  40259. */
  40260. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40261. /**
  40262. * Defines the callback to call when a pad is pressed
  40263. * @param callback defines the callback to use
  40264. */
  40265. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40266. /**
  40267. * Defines the callback to call when a pad is released
  40268. * @param callback defines the callback to use
  40269. */
  40270. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40271. private _setButtonValue;
  40272. private _setDPadValue;
  40273. /**
  40274. * Gets the value of the `A` button
  40275. */
  40276. /**
  40277. * Sets the value of the `A` button
  40278. */
  40279. buttonA: number;
  40280. /**
  40281. * Gets the value of the `B` button
  40282. */
  40283. /**
  40284. * Sets the value of the `B` button
  40285. */
  40286. buttonB: number;
  40287. /**
  40288. * Gets the value of the `X` button
  40289. */
  40290. /**
  40291. * Sets the value of the `X` button
  40292. */
  40293. buttonX: number;
  40294. /**
  40295. * Gets the value of the `Y` button
  40296. */
  40297. /**
  40298. * Sets the value of the `Y` button
  40299. */
  40300. buttonY: number;
  40301. /**
  40302. * Gets the value of the `Start` button
  40303. */
  40304. /**
  40305. * Sets the value of the `Start` button
  40306. */
  40307. buttonStart: number;
  40308. /**
  40309. * Gets the value of the `Back` button
  40310. */
  40311. /**
  40312. * Sets the value of the `Back` button
  40313. */
  40314. buttonBack: number;
  40315. /**
  40316. * Gets the value of the `Left` button
  40317. */
  40318. /**
  40319. * Sets the value of the `Left` button
  40320. */
  40321. buttonLB: number;
  40322. /**
  40323. * Gets the value of the `Right` button
  40324. */
  40325. /**
  40326. * Sets the value of the `Right` button
  40327. */
  40328. buttonRB: number;
  40329. /**
  40330. * Gets the value of the Left joystick
  40331. */
  40332. /**
  40333. * Sets the value of the Left joystick
  40334. */
  40335. buttonLeftStick: number;
  40336. /**
  40337. * Gets the value of the Right joystick
  40338. */
  40339. /**
  40340. * Sets the value of the Right joystick
  40341. */
  40342. buttonRightStick: number;
  40343. /**
  40344. * Gets the value of D-pad up
  40345. */
  40346. /**
  40347. * Sets the value of D-pad up
  40348. */
  40349. dPadUp: number;
  40350. /**
  40351. * Gets the value of D-pad down
  40352. */
  40353. /**
  40354. * Sets the value of D-pad down
  40355. */
  40356. dPadDown: number;
  40357. /**
  40358. * Gets the value of D-pad left
  40359. */
  40360. /**
  40361. * Sets the value of D-pad left
  40362. */
  40363. dPadLeft: number;
  40364. /**
  40365. * Gets the value of D-pad right
  40366. */
  40367. /**
  40368. * Sets the value of D-pad right
  40369. */
  40370. dPadRight: number;
  40371. /**
  40372. * Force the gamepad to synchronize with device values
  40373. */
  40374. update(): void;
  40375. /**
  40376. * Disposes the gamepad
  40377. */
  40378. dispose(): void;
  40379. }
  40380. }
  40381. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40382. import { Observable } from "babylonjs/Misc/observable";
  40383. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40384. /**
  40385. * Defines supported buttons for DualShock compatible gamepads
  40386. */
  40387. export enum DualShockButton {
  40388. /** Cross */
  40389. Cross = 0,
  40390. /** Circle */
  40391. Circle = 1,
  40392. /** Square */
  40393. Square = 2,
  40394. /** Triangle */
  40395. Triangle = 3,
  40396. /** Options */
  40397. Options = 4,
  40398. /** Share */
  40399. Share = 5,
  40400. /** L1 */
  40401. L1 = 6,
  40402. /** R1 */
  40403. R1 = 7,
  40404. /** Left stick */
  40405. LeftStick = 8,
  40406. /** Right stick */
  40407. RightStick = 9
  40408. }
  40409. /** Defines values for DualShock DPad */
  40410. export enum DualShockDpad {
  40411. /** Up */
  40412. Up = 0,
  40413. /** Down */
  40414. Down = 1,
  40415. /** Left */
  40416. Left = 2,
  40417. /** Right */
  40418. Right = 3
  40419. }
  40420. /**
  40421. * Defines a DualShock gamepad
  40422. */
  40423. export class DualShockPad extends Gamepad {
  40424. private _leftTrigger;
  40425. private _rightTrigger;
  40426. private _onlefttriggerchanged;
  40427. private _onrighttriggerchanged;
  40428. private _onbuttondown;
  40429. private _onbuttonup;
  40430. private _ondpaddown;
  40431. private _ondpadup;
  40432. /** Observable raised when a button is pressed */
  40433. onButtonDownObservable: Observable<DualShockButton>;
  40434. /** Observable raised when a button is released */
  40435. onButtonUpObservable: Observable<DualShockButton>;
  40436. /** Observable raised when a pad is pressed */
  40437. onPadDownObservable: Observable<DualShockDpad>;
  40438. /** Observable raised when a pad is released */
  40439. onPadUpObservable: Observable<DualShockDpad>;
  40440. private _buttonCross;
  40441. private _buttonCircle;
  40442. private _buttonSquare;
  40443. private _buttonTriangle;
  40444. private _buttonShare;
  40445. private _buttonOptions;
  40446. private _buttonL1;
  40447. private _buttonR1;
  40448. private _buttonLeftStick;
  40449. private _buttonRightStick;
  40450. private _dPadUp;
  40451. private _dPadDown;
  40452. private _dPadLeft;
  40453. private _dPadRight;
  40454. /**
  40455. * Creates a new DualShock gamepad object
  40456. * @param id defines the id of this gamepad
  40457. * @param index defines its index
  40458. * @param gamepad defines the internal HTML gamepad object
  40459. */
  40460. constructor(id: string, index: number, gamepad: any);
  40461. /**
  40462. * Defines the callback to call when left trigger is pressed
  40463. * @param callback defines the callback to use
  40464. */
  40465. onlefttriggerchanged(callback: (value: number) => void): void;
  40466. /**
  40467. * Defines the callback to call when right trigger is pressed
  40468. * @param callback defines the callback to use
  40469. */
  40470. onrighttriggerchanged(callback: (value: number) => void): void;
  40471. /**
  40472. * Gets the left trigger value
  40473. */
  40474. /**
  40475. * Sets the left trigger value
  40476. */
  40477. leftTrigger: number;
  40478. /**
  40479. * Gets the right trigger value
  40480. */
  40481. /**
  40482. * Sets the right trigger value
  40483. */
  40484. rightTrigger: number;
  40485. /**
  40486. * Defines the callback to call when a button is pressed
  40487. * @param callback defines the callback to use
  40488. */
  40489. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40490. /**
  40491. * Defines the callback to call when a button is released
  40492. * @param callback defines the callback to use
  40493. */
  40494. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40495. /**
  40496. * Defines the callback to call when a pad is pressed
  40497. * @param callback defines the callback to use
  40498. */
  40499. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40500. /**
  40501. * Defines the callback to call when a pad is released
  40502. * @param callback defines the callback to use
  40503. */
  40504. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40505. private _setButtonValue;
  40506. private _setDPadValue;
  40507. /**
  40508. * Gets the value of the `Cross` button
  40509. */
  40510. /**
  40511. * Sets the value of the `Cross` button
  40512. */
  40513. buttonCross: number;
  40514. /**
  40515. * Gets the value of the `Circle` button
  40516. */
  40517. /**
  40518. * Sets the value of the `Circle` button
  40519. */
  40520. buttonCircle: number;
  40521. /**
  40522. * Gets the value of the `Square` button
  40523. */
  40524. /**
  40525. * Sets the value of the `Square` button
  40526. */
  40527. buttonSquare: number;
  40528. /**
  40529. * Gets the value of the `Triangle` button
  40530. */
  40531. /**
  40532. * Sets the value of the `Triangle` button
  40533. */
  40534. buttonTriangle: number;
  40535. /**
  40536. * Gets the value of the `Options` button
  40537. */
  40538. /**
  40539. * Sets the value of the `Options` button
  40540. */
  40541. buttonOptions: number;
  40542. /**
  40543. * Gets the value of the `Share` button
  40544. */
  40545. /**
  40546. * Sets the value of the `Share` button
  40547. */
  40548. buttonShare: number;
  40549. /**
  40550. * Gets the value of the `L1` button
  40551. */
  40552. /**
  40553. * Sets the value of the `L1` button
  40554. */
  40555. buttonL1: number;
  40556. /**
  40557. * Gets the value of the `R1` button
  40558. */
  40559. /**
  40560. * Sets the value of the `R1` button
  40561. */
  40562. buttonR1: number;
  40563. /**
  40564. * Gets the value of the Left joystick
  40565. */
  40566. /**
  40567. * Sets the value of the Left joystick
  40568. */
  40569. buttonLeftStick: number;
  40570. /**
  40571. * Gets the value of the Right joystick
  40572. */
  40573. /**
  40574. * Sets the value of the Right joystick
  40575. */
  40576. buttonRightStick: number;
  40577. /**
  40578. * Gets the value of D-pad up
  40579. */
  40580. /**
  40581. * Sets the value of D-pad up
  40582. */
  40583. dPadUp: number;
  40584. /**
  40585. * Gets the value of D-pad down
  40586. */
  40587. /**
  40588. * Sets the value of D-pad down
  40589. */
  40590. dPadDown: number;
  40591. /**
  40592. * Gets the value of D-pad left
  40593. */
  40594. /**
  40595. * Sets the value of D-pad left
  40596. */
  40597. dPadLeft: number;
  40598. /**
  40599. * Gets the value of D-pad right
  40600. */
  40601. /**
  40602. * Sets the value of D-pad right
  40603. */
  40604. dPadRight: number;
  40605. /**
  40606. * Force the gamepad to synchronize with device values
  40607. */
  40608. update(): void;
  40609. /**
  40610. * Disposes the gamepad
  40611. */
  40612. dispose(): void;
  40613. }
  40614. }
  40615. declare module "babylonjs/Gamepads/gamepadManager" {
  40616. import { Observable } from "babylonjs/Misc/observable";
  40617. import { Nullable } from "babylonjs/types";
  40618. import { Scene } from "babylonjs/scene";
  40619. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40620. /**
  40621. * Manager for handling gamepads
  40622. */
  40623. export class GamepadManager {
  40624. private _scene?;
  40625. private _babylonGamepads;
  40626. private _oneGamepadConnected;
  40627. /** @hidden */
  40628. _isMonitoring: boolean;
  40629. private _gamepadEventSupported;
  40630. private _gamepadSupport;
  40631. /**
  40632. * observable to be triggered when the gamepad controller has been connected
  40633. */
  40634. onGamepadConnectedObservable: Observable<Gamepad>;
  40635. /**
  40636. * observable to be triggered when the gamepad controller has been disconnected
  40637. */
  40638. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40639. private _onGamepadConnectedEvent;
  40640. private _onGamepadDisconnectedEvent;
  40641. /**
  40642. * Initializes the gamepad manager
  40643. * @param _scene BabylonJS scene
  40644. */
  40645. constructor(_scene?: Scene | undefined);
  40646. /**
  40647. * The gamepads in the game pad manager
  40648. */
  40649. readonly gamepads: Gamepad[];
  40650. /**
  40651. * Get the gamepad controllers based on type
  40652. * @param type The type of gamepad controller
  40653. * @returns Nullable gamepad
  40654. */
  40655. getGamepadByType(type?: number): Nullable<Gamepad>;
  40656. /**
  40657. * Disposes the gamepad manager
  40658. */
  40659. dispose(): void;
  40660. private _addNewGamepad;
  40661. private _startMonitoringGamepads;
  40662. private _stopMonitoringGamepads;
  40663. /** @hidden */
  40664. _checkGamepadsStatus(): void;
  40665. private _updateGamepadObjects;
  40666. }
  40667. }
  40668. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40669. import { Nullable } from "babylonjs/types";
  40670. import { Scene } from "babylonjs/scene";
  40671. import { ISceneComponent } from "babylonjs/sceneComponent";
  40672. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40673. module "babylonjs/scene" {
  40674. interface Scene {
  40675. /** @hidden */
  40676. _gamepadManager: Nullable<GamepadManager>;
  40677. /**
  40678. * Gets the gamepad manager associated with the scene
  40679. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40680. */
  40681. gamepadManager: GamepadManager;
  40682. }
  40683. }
  40684. module "babylonjs/Cameras/freeCameraInputsManager" {
  40685. /**
  40686. * Interface representing a free camera inputs manager
  40687. */
  40688. interface FreeCameraInputsManager {
  40689. /**
  40690. * Adds gamepad input support to the FreeCameraInputsManager.
  40691. * @returns the FreeCameraInputsManager
  40692. */
  40693. addGamepad(): FreeCameraInputsManager;
  40694. }
  40695. }
  40696. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40697. /**
  40698. * Interface representing an arc rotate camera inputs manager
  40699. */
  40700. interface ArcRotateCameraInputsManager {
  40701. /**
  40702. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40703. * @returns the camera inputs manager
  40704. */
  40705. addGamepad(): ArcRotateCameraInputsManager;
  40706. }
  40707. }
  40708. /**
  40709. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40710. */
  40711. export class GamepadSystemSceneComponent implements ISceneComponent {
  40712. /**
  40713. * The component name helpfull to identify the component in the list of scene components.
  40714. */
  40715. readonly name: string;
  40716. /**
  40717. * The scene the component belongs to.
  40718. */
  40719. scene: Scene;
  40720. /**
  40721. * Creates a new instance of the component for the given scene
  40722. * @param scene Defines the scene to register the component in
  40723. */
  40724. constructor(scene: Scene);
  40725. /**
  40726. * Registers the component in a given scene
  40727. */
  40728. register(): void;
  40729. /**
  40730. * Rebuilds the elements related to this component in case of
  40731. * context lost for instance.
  40732. */
  40733. rebuild(): void;
  40734. /**
  40735. * Disposes the component and the associated ressources
  40736. */
  40737. dispose(): void;
  40738. private _beforeCameraUpdate;
  40739. }
  40740. }
  40741. declare module "babylonjs/Cameras/universalCamera" {
  40742. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40743. import { Scene } from "babylonjs/scene";
  40744. import { Vector3 } from "babylonjs/Maths/math.vector";
  40745. import "babylonjs/Gamepads/gamepadSceneComponent";
  40746. /**
  40747. * 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,
  40748. * which still works and will still be found in many Playgrounds.
  40749. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40750. */
  40751. export class UniversalCamera extends TouchCamera {
  40752. /**
  40753. * Defines the gamepad rotation sensiblity.
  40754. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40755. */
  40756. gamepadAngularSensibility: number;
  40757. /**
  40758. * Defines the gamepad move sensiblity.
  40759. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40760. */
  40761. gamepadMoveSensibility: number;
  40762. /**
  40763. * 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,
  40764. * which still works and will still be found in many Playgrounds.
  40765. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40766. * @param name Define the name of the camera in the scene
  40767. * @param position Define the start position of the camera in the scene
  40768. * @param scene Define the scene the camera belongs to
  40769. */
  40770. constructor(name: string, position: Vector3, scene: Scene);
  40771. /**
  40772. * Gets the current object class name.
  40773. * @return the class name
  40774. */
  40775. getClassName(): string;
  40776. }
  40777. }
  40778. declare module "babylonjs/Cameras/gamepadCamera" {
  40779. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40780. import { Scene } from "babylonjs/scene";
  40781. import { Vector3 } from "babylonjs/Maths/math.vector";
  40782. /**
  40783. * This represents a FPS type of camera. This is only here for back compat purpose.
  40784. * Please use the UniversalCamera instead as both are identical.
  40785. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40786. */
  40787. export class GamepadCamera extends UniversalCamera {
  40788. /**
  40789. * Instantiates a new Gamepad Camera
  40790. * This represents a FPS type of camera. This is only here for back compat purpose.
  40791. * Please use the UniversalCamera instead as both are identical.
  40792. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40793. * @param name Define the name of the camera in the scene
  40794. * @param position Define the start position of the camera in the scene
  40795. * @param scene Define the scene the camera belongs to
  40796. */
  40797. constructor(name: string, position: Vector3, scene: Scene);
  40798. /**
  40799. * Gets the current object class name.
  40800. * @return the class name
  40801. */
  40802. getClassName(): string;
  40803. }
  40804. }
  40805. declare module "babylonjs/Shaders/pass.fragment" {
  40806. /** @hidden */
  40807. export var passPixelShader: {
  40808. name: string;
  40809. shader: string;
  40810. };
  40811. }
  40812. declare module "babylonjs/Shaders/passCube.fragment" {
  40813. /** @hidden */
  40814. export var passCubePixelShader: {
  40815. name: string;
  40816. shader: string;
  40817. };
  40818. }
  40819. declare module "babylonjs/PostProcesses/passPostProcess" {
  40820. import { Nullable } from "babylonjs/types";
  40821. import { Camera } from "babylonjs/Cameras/camera";
  40822. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40823. import { Engine } from "babylonjs/Engines/engine";
  40824. import "babylonjs/Shaders/pass.fragment";
  40825. import "babylonjs/Shaders/passCube.fragment";
  40826. /**
  40827. * PassPostProcess which produces an output the same as it's input
  40828. */
  40829. export class PassPostProcess extends PostProcess {
  40830. /**
  40831. * Creates the PassPostProcess
  40832. * @param name The name of the effect.
  40833. * @param options The required width/height ratio to downsize to before computing the render pass.
  40834. * @param camera The camera to apply the render pass to.
  40835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40836. * @param engine The engine which the post process will be applied. (default: current engine)
  40837. * @param reusable If the post process can be reused on the same frame. (default: false)
  40838. * @param textureType The type of texture to be used when performing the post processing.
  40839. * @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)
  40840. */
  40841. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40842. }
  40843. /**
  40844. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40845. */
  40846. export class PassCubePostProcess extends PostProcess {
  40847. private _face;
  40848. /**
  40849. * Gets or sets the cube face to display.
  40850. * * 0 is +X
  40851. * * 1 is -X
  40852. * * 2 is +Y
  40853. * * 3 is -Y
  40854. * * 4 is +Z
  40855. * * 5 is -Z
  40856. */
  40857. face: number;
  40858. /**
  40859. * Creates the PassCubePostProcess
  40860. * @param name The name of the effect.
  40861. * @param options The required width/height ratio to downsize to before computing the render pass.
  40862. * @param camera The camera to apply the render pass to.
  40863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40864. * @param engine The engine which the post process will be applied. (default: current engine)
  40865. * @param reusable If the post process can be reused on the same frame. (default: false)
  40866. * @param textureType The type of texture to be used when performing the post processing.
  40867. * @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)
  40868. */
  40869. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40870. }
  40871. }
  40872. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40873. /** @hidden */
  40874. export var anaglyphPixelShader: {
  40875. name: string;
  40876. shader: string;
  40877. };
  40878. }
  40879. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40880. import { Engine } from "babylonjs/Engines/engine";
  40881. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40882. import { Camera } from "babylonjs/Cameras/camera";
  40883. import "babylonjs/Shaders/anaglyph.fragment";
  40884. /**
  40885. * Postprocess used to generate anaglyphic rendering
  40886. */
  40887. export class AnaglyphPostProcess extends PostProcess {
  40888. private _passedProcess;
  40889. /**
  40890. * Creates a new AnaglyphPostProcess
  40891. * @param name defines postprocess name
  40892. * @param options defines creation options or target ratio scale
  40893. * @param rigCameras defines cameras using this postprocess
  40894. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40895. * @param engine defines hosting engine
  40896. * @param reusable defines if the postprocess will be reused multiple times per frame
  40897. */
  40898. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40899. }
  40900. }
  40901. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40902. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40903. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40904. import { Scene } from "babylonjs/scene";
  40905. import { Vector3 } from "babylonjs/Maths/math.vector";
  40906. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40907. /**
  40908. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40909. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40910. */
  40911. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40912. /**
  40913. * Creates a new AnaglyphArcRotateCamera
  40914. * @param name defines camera name
  40915. * @param alpha defines alpha angle (in radians)
  40916. * @param beta defines beta angle (in radians)
  40917. * @param radius defines radius
  40918. * @param target defines camera target
  40919. * @param interaxialDistance defines distance between each color axis
  40920. * @param scene defines the hosting scene
  40921. */
  40922. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40923. /**
  40924. * Gets camera class name
  40925. * @returns AnaglyphArcRotateCamera
  40926. */
  40927. getClassName(): string;
  40928. }
  40929. }
  40930. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40931. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40932. import { Scene } from "babylonjs/scene";
  40933. import { Vector3 } from "babylonjs/Maths/math.vector";
  40934. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40935. /**
  40936. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40937. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40938. */
  40939. export class AnaglyphFreeCamera extends FreeCamera {
  40940. /**
  40941. * Creates a new AnaglyphFreeCamera
  40942. * @param name defines camera name
  40943. * @param position defines initial position
  40944. * @param interaxialDistance defines distance between each color axis
  40945. * @param scene defines the hosting scene
  40946. */
  40947. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40948. /**
  40949. * Gets camera class name
  40950. * @returns AnaglyphFreeCamera
  40951. */
  40952. getClassName(): string;
  40953. }
  40954. }
  40955. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40956. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40957. import { Scene } from "babylonjs/scene";
  40958. import { Vector3 } from "babylonjs/Maths/math.vector";
  40959. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40960. /**
  40961. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40962. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40963. */
  40964. export class AnaglyphGamepadCamera extends GamepadCamera {
  40965. /**
  40966. * Creates a new AnaglyphGamepadCamera
  40967. * @param name defines camera name
  40968. * @param position defines initial position
  40969. * @param interaxialDistance defines distance between each color axis
  40970. * @param scene defines the hosting scene
  40971. */
  40972. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40973. /**
  40974. * Gets camera class name
  40975. * @returns AnaglyphGamepadCamera
  40976. */
  40977. getClassName(): string;
  40978. }
  40979. }
  40980. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40981. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40982. import { Scene } from "babylonjs/scene";
  40983. import { Vector3 } from "babylonjs/Maths/math.vector";
  40984. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40985. /**
  40986. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40987. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40988. */
  40989. export class AnaglyphUniversalCamera extends UniversalCamera {
  40990. /**
  40991. * Creates a new AnaglyphUniversalCamera
  40992. * @param name defines camera name
  40993. * @param position defines initial position
  40994. * @param interaxialDistance defines distance between each color axis
  40995. * @param scene defines the hosting scene
  40996. */
  40997. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40998. /**
  40999. * Gets camera class name
  41000. * @returns AnaglyphUniversalCamera
  41001. */
  41002. getClassName(): string;
  41003. }
  41004. }
  41005. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41006. /** @hidden */
  41007. export var stereoscopicInterlacePixelShader: {
  41008. name: string;
  41009. shader: string;
  41010. };
  41011. }
  41012. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41013. import { Camera } from "babylonjs/Cameras/camera";
  41014. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41015. import { Engine } from "babylonjs/Engines/engine";
  41016. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41017. /**
  41018. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41019. */
  41020. export class StereoscopicInterlacePostProcess extends PostProcess {
  41021. private _stepSize;
  41022. private _passedProcess;
  41023. /**
  41024. * Initializes a StereoscopicInterlacePostProcess
  41025. * @param name The name of the effect.
  41026. * @param rigCameras The rig cameras to be appled to the post process
  41027. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41029. * @param engine The engine which the post process will be applied. (default: current engine)
  41030. * @param reusable If the post process can be reused on the same frame. (default: false)
  41031. */
  41032. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41033. }
  41034. }
  41035. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41036. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41037. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41038. import { Scene } from "babylonjs/scene";
  41039. import { Vector3 } from "babylonjs/Maths/math.vector";
  41040. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41041. /**
  41042. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41043. * @see http://doc.babylonjs.com/features/cameras
  41044. */
  41045. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41046. /**
  41047. * Creates a new StereoscopicArcRotateCamera
  41048. * @param name defines camera name
  41049. * @param alpha defines alpha angle (in radians)
  41050. * @param beta defines beta angle (in radians)
  41051. * @param radius defines radius
  41052. * @param target defines camera target
  41053. * @param interaxialDistance defines distance between each color axis
  41054. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41055. * @param scene defines the hosting scene
  41056. */
  41057. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41058. /**
  41059. * Gets camera class name
  41060. * @returns StereoscopicArcRotateCamera
  41061. */
  41062. getClassName(): string;
  41063. }
  41064. }
  41065. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41066. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41067. import { Scene } from "babylonjs/scene";
  41068. import { Vector3 } from "babylonjs/Maths/math.vector";
  41069. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41070. /**
  41071. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41072. * @see http://doc.babylonjs.com/features/cameras
  41073. */
  41074. export class StereoscopicFreeCamera extends FreeCamera {
  41075. /**
  41076. * Creates a new StereoscopicFreeCamera
  41077. * @param name defines camera name
  41078. * @param position defines initial position
  41079. * @param interaxialDistance defines distance between each color axis
  41080. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41081. * @param scene defines the hosting scene
  41082. */
  41083. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41084. /**
  41085. * Gets camera class name
  41086. * @returns StereoscopicFreeCamera
  41087. */
  41088. getClassName(): string;
  41089. }
  41090. }
  41091. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41092. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41093. import { Scene } from "babylonjs/scene";
  41094. import { Vector3 } from "babylonjs/Maths/math.vector";
  41095. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41096. /**
  41097. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41098. * @see http://doc.babylonjs.com/features/cameras
  41099. */
  41100. export class StereoscopicGamepadCamera extends GamepadCamera {
  41101. /**
  41102. * Creates a new StereoscopicGamepadCamera
  41103. * @param name defines camera name
  41104. * @param position defines initial position
  41105. * @param interaxialDistance defines distance between each color axis
  41106. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41107. * @param scene defines the hosting scene
  41108. */
  41109. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41110. /**
  41111. * Gets camera class name
  41112. * @returns StereoscopicGamepadCamera
  41113. */
  41114. getClassName(): string;
  41115. }
  41116. }
  41117. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41118. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41119. import { Scene } from "babylonjs/scene";
  41120. import { Vector3 } from "babylonjs/Maths/math.vector";
  41121. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41122. /**
  41123. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41124. * @see http://doc.babylonjs.com/features/cameras
  41125. */
  41126. export class StereoscopicUniversalCamera extends UniversalCamera {
  41127. /**
  41128. * Creates a new StereoscopicUniversalCamera
  41129. * @param name defines camera name
  41130. * @param position defines initial position
  41131. * @param interaxialDistance defines distance between each color axis
  41132. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41133. * @param scene defines the hosting scene
  41134. */
  41135. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41136. /**
  41137. * Gets camera class name
  41138. * @returns StereoscopicUniversalCamera
  41139. */
  41140. getClassName(): string;
  41141. }
  41142. }
  41143. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41144. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41145. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41146. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41147. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41148. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41149. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41150. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41151. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41152. }
  41153. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41154. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41155. import { Scene } from "babylonjs/scene";
  41156. import { Vector3 } from "babylonjs/Maths/math.vector";
  41157. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41158. /**
  41159. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41160. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41161. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41162. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41163. */
  41164. export class VirtualJoysticksCamera extends FreeCamera {
  41165. /**
  41166. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41167. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41168. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41169. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41170. * @param name Define the name of the camera in the scene
  41171. * @param position Define the start position of the camera in the scene
  41172. * @param scene Define the scene the camera belongs to
  41173. */
  41174. constructor(name: string, position: Vector3, scene: Scene);
  41175. /**
  41176. * Gets the current object class name.
  41177. * @return the class name
  41178. */
  41179. getClassName(): string;
  41180. }
  41181. }
  41182. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41183. import { Matrix } from "babylonjs/Maths/math.vector";
  41184. /**
  41185. * This represents all the required metrics to create a VR camera.
  41186. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41187. */
  41188. export class VRCameraMetrics {
  41189. /**
  41190. * Define the horizontal resolution off the screen.
  41191. */
  41192. hResolution: number;
  41193. /**
  41194. * Define the vertical resolution off the screen.
  41195. */
  41196. vResolution: number;
  41197. /**
  41198. * Define the horizontal screen size.
  41199. */
  41200. hScreenSize: number;
  41201. /**
  41202. * Define the vertical screen size.
  41203. */
  41204. vScreenSize: number;
  41205. /**
  41206. * Define the vertical screen center position.
  41207. */
  41208. vScreenCenter: number;
  41209. /**
  41210. * Define the distance of the eyes to the screen.
  41211. */
  41212. eyeToScreenDistance: number;
  41213. /**
  41214. * Define the distance between both lenses
  41215. */
  41216. lensSeparationDistance: number;
  41217. /**
  41218. * Define the distance between both viewer's eyes.
  41219. */
  41220. interpupillaryDistance: number;
  41221. /**
  41222. * Define the distortion factor of the VR postprocess.
  41223. * Please, touch with care.
  41224. */
  41225. distortionK: number[];
  41226. /**
  41227. * Define the chromatic aberration correction factors for the VR post process.
  41228. */
  41229. chromaAbCorrection: number[];
  41230. /**
  41231. * Define the scale factor of the post process.
  41232. * The smaller the better but the slower.
  41233. */
  41234. postProcessScaleFactor: number;
  41235. /**
  41236. * Define an offset for the lens center.
  41237. */
  41238. lensCenterOffset: number;
  41239. /**
  41240. * Define if the current vr camera should compensate the distortion of the lense or not.
  41241. */
  41242. compensateDistortion: boolean;
  41243. /**
  41244. * Defines if multiview should be enabled when rendering (Default: false)
  41245. */
  41246. multiviewEnabled: boolean;
  41247. /**
  41248. * Gets the rendering aspect ratio based on the provided resolutions.
  41249. */
  41250. readonly aspectRatio: number;
  41251. /**
  41252. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41253. */
  41254. readonly aspectRatioFov: number;
  41255. /**
  41256. * @hidden
  41257. */
  41258. readonly leftHMatrix: Matrix;
  41259. /**
  41260. * @hidden
  41261. */
  41262. readonly rightHMatrix: Matrix;
  41263. /**
  41264. * @hidden
  41265. */
  41266. readonly leftPreViewMatrix: Matrix;
  41267. /**
  41268. * @hidden
  41269. */
  41270. readonly rightPreViewMatrix: Matrix;
  41271. /**
  41272. * Get the default VRMetrics based on the most generic setup.
  41273. * @returns the default vr metrics
  41274. */
  41275. static GetDefault(): VRCameraMetrics;
  41276. }
  41277. }
  41278. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41279. /** @hidden */
  41280. export var vrDistortionCorrectionPixelShader: {
  41281. name: string;
  41282. shader: string;
  41283. };
  41284. }
  41285. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41286. import { Camera } from "babylonjs/Cameras/camera";
  41287. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41288. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41289. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41290. /**
  41291. * VRDistortionCorrectionPostProcess used for mobile VR
  41292. */
  41293. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41294. private _isRightEye;
  41295. private _distortionFactors;
  41296. private _postProcessScaleFactor;
  41297. private _lensCenterOffset;
  41298. private _scaleIn;
  41299. private _scaleFactor;
  41300. private _lensCenter;
  41301. /**
  41302. * Initializes the VRDistortionCorrectionPostProcess
  41303. * @param name The name of the effect.
  41304. * @param camera The camera to apply the render pass to.
  41305. * @param isRightEye If this is for the right eye distortion
  41306. * @param vrMetrics All the required metrics for the VR camera
  41307. */
  41308. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41309. }
  41310. }
  41311. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41312. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41313. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41314. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41315. import { Scene } from "babylonjs/scene";
  41316. import { Vector3 } from "babylonjs/Maths/math.vector";
  41317. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41318. import "babylonjs/Cameras/RigModes/vrRigMode";
  41319. /**
  41320. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41321. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41322. */
  41323. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41324. /**
  41325. * Creates a new VRDeviceOrientationArcRotateCamera
  41326. * @param name defines camera name
  41327. * @param alpha defines the camera rotation along the logitudinal axis
  41328. * @param beta defines the camera rotation along the latitudinal axis
  41329. * @param radius defines the camera distance from its target
  41330. * @param target defines the camera target
  41331. * @param scene defines the scene the camera belongs to
  41332. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41333. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41334. */
  41335. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41336. /**
  41337. * Gets camera class name
  41338. * @returns VRDeviceOrientationArcRotateCamera
  41339. */
  41340. getClassName(): string;
  41341. }
  41342. }
  41343. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41344. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41345. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41346. import { Scene } from "babylonjs/scene";
  41347. import { Vector3 } from "babylonjs/Maths/math.vector";
  41348. import "babylonjs/Cameras/RigModes/vrRigMode";
  41349. /**
  41350. * Camera used to simulate VR rendering (based on FreeCamera)
  41351. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41352. */
  41353. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41354. /**
  41355. * Creates a new VRDeviceOrientationFreeCamera
  41356. * @param name defines camera name
  41357. * @param position defines the start position of the camera
  41358. * @param scene defines the scene the camera belongs to
  41359. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41360. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41361. */
  41362. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41363. /**
  41364. * Gets camera class name
  41365. * @returns VRDeviceOrientationFreeCamera
  41366. */
  41367. getClassName(): string;
  41368. }
  41369. }
  41370. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41371. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41372. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41373. import { Scene } from "babylonjs/scene";
  41374. import { Vector3 } from "babylonjs/Maths/math.vector";
  41375. import "babylonjs/Gamepads/gamepadSceneComponent";
  41376. /**
  41377. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41378. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41379. */
  41380. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41381. /**
  41382. * Creates a new VRDeviceOrientationGamepadCamera
  41383. * @param name defines camera name
  41384. * @param position defines the start position of the camera
  41385. * @param scene defines the scene the camera belongs to
  41386. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41387. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41388. */
  41389. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41390. /**
  41391. * Gets camera class name
  41392. * @returns VRDeviceOrientationGamepadCamera
  41393. */
  41394. getClassName(): string;
  41395. }
  41396. }
  41397. declare module "babylonjs/Materials/pushMaterial" {
  41398. import { Nullable } from "babylonjs/types";
  41399. import { Scene } from "babylonjs/scene";
  41400. import { Matrix } from "babylonjs/Maths/math.vector";
  41401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41402. import { Mesh } from "babylonjs/Meshes/mesh";
  41403. import { Material } from "babylonjs/Materials/material";
  41404. import { Effect } from "babylonjs/Materials/effect";
  41405. /**
  41406. * Base class of materials working in push mode in babylon JS
  41407. * @hidden
  41408. */
  41409. export class PushMaterial extends Material {
  41410. protected _activeEffect: Effect;
  41411. protected _normalMatrix: Matrix;
  41412. /**
  41413. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41414. * This means that the material can keep using a previous shader while a new one is being compiled.
  41415. * This is mostly used when shader parallel compilation is supported (true by default)
  41416. */
  41417. allowShaderHotSwapping: boolean;
  41418. constructor(name: string, scene: Scene);
  41419. getEffect(): Effect;
  41420. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41421. /**
  41422. * Binds the given world matrix to the active effect
  41423. *
  41424. * @param world the matrix to bind
  41425. */
  41426. bindOnlyWorldMatrix(world: Matrix): void;
  41427. /**
  41428. * Binds the given normal matrix to the active effect
  41429. *
  41430. * @param normalMatrix the matrix to bind
  41431. */
  41432. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41433. bind(world: Matrix, mesh?: Mesh): void;
  41434. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41435. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41436. }
  41437. }
  41438. declare module "babylonjs/Materials/materialFlags" {
  41439. /**
  41440. * This groups all the flags used to control the materials channel.
  41441. */
  41442. export class MaterialFlags {
  41443. private static _DiffuseTextureEnabled;
  41444. /**
  41445. * Are diffuse textures enabled in the application.
  41446. */
  41447. static DiffuseTextureEnabled: boolean;
  41448. private static _AmbientTextureEnabled;
  41449. /**
  41450. * Are ambient textures enabled in the application.
  41451. */
  41452. static AmbientTextureEnabled: boolean;
  41453. private static _OpacityTextureEnabled;
  41454. /**
  41455. * Are opacity textures enabled in the application.
  41456. */
  41457. static OpacityTextureEnabled: boolean;
  41458. private static _ReflectionTextureEnabled;
  41459. /**
  41460. * Are reflection textures enabled in the application.
  41461. */
  41462. static ReflectionTextureEnabled: boolean;
  41463. private static _EmissiveTextureEnabled;
  41464. /**
  41465. * Are emissive textures enabled in the application.
  41466. */
  41467. static EmissiveTextureEnabled: boolean;
  41468. private static _SpecularTextureEnabled;
  41469. /**
  41470. * Are specular textures enabled in the application.
  41471. */
  41472. static SpecularTextureEnabled: boolean;
  41473. private static _BumpTextureEnabled;
  41474. /**
  41475. * Are bump textures enabled in the application.
  41476. */
  41477. static BumpTextureEnabled: boolean;
  41478. private static _LightmapTextureEnabled;
  41479. /**
  41480. * Are lightmap textures enabled in the application.
  41481. */
  41482. static LightmapTextureEnabled: boolean;
  41483. private static _RefractionTextureEnabled;
  41484. /**
  41485. * Are refraction textures enabled in the application.
  41486. */
  41487. static RefractionTextureEnabled: boolean;
  41488. private static _ColorGradingTextureEnabled;
  41489. /**
  41490. * Are color grading textures enabled in the application.
  41491. */
  41492. static ColorGradingTextureEnabled: boolean;
  41493. private static _FresnelEnabled;
  41494. /**
  41495. * Are fresnels enabled in the application.
  41496. */
  41497. static FresnelEnabled: boolean;
  41498. private static _ClearCoatTextureEnabled;
  41499. /**
  41500. * Are clear coat textures enabled in the application.
  41501. */
  41502. static ClearCoatTextureEnabled: boolean;
  41503. private static _ClearCoatBumpTextureEnabled;
  41504. /**
  41505. * Are clear coat bump textures enabled in the application.
  41506. */
  41507. static ClearCoatBumpTextureEnabled: boolean;
  41508. private static _ClearCoatTintTextureEnabled;
  41509. /**
  41510. * Are clear coat tint textures enabled in the application.
  41511. */
  41512. static ClearCoatTintTextureEnabled: boolean;
  41513. private static _SheenTextureEnabled;
  41514. /**
  41515. * Are sheen textures enabled in the application.
  41516. */
  41517. static SheenTextureEnabled: boolean;
  41518. private static _AnisotropicTextureEnabled;
  41519. /**
  41520. * Are anisotropic textures enabled in the application.
  41521. */
  41522. static AnisotropicTextureEnabled: boolean;
  41523. private static _ThicknessTextureEnabled;
  41524. /**
  41525. * Are thickness textures enabled in the application.
  41526. */
  41527. static ThicknessTextureEnabled: boolean;
  41528. }
  41529. }
  41530. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41531. /** @hidden */
  41532. export var defaultFragmentDeclaration: {
  41533. name: string;
  41534. shader: string;
  41535. };
  41536. }
  41537. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41538. /** @hidden */
  41539. export var defaultUboDeclaration: {
  41540. name: string;
  41541. shader: string;
  41542. };
  41543. }
  41544. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41545. /** @hidden */
  41546. export var lightFragmentDeclaration: {
  41547. name: string;
  41548. shader: string;
  41549. };
  41550. }
  41551. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41552. /** @hidden */
  41553. export var lightUboDeclaration: {
  41554. name: string;
  41555. shader: string;
  41556. };
  41557. }
  41558. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41559. /** @hidden */
  41560. export var lightsFragmentFunctions: {
  41561. name: string;
  41562. shader: string;
  41563. };
  41564. }
  41565. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41566. /** @hidden */
  41567. export var shadowsFragmentFunctions: {
  41568. name: string;
  41569. shader: string;
  41570. };
  41571. }
  41572. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41573. /** @hidden */
  41574. export var fresnelFunction: {
  41575. name: string;
  41576. shader: string;
  41577. };
  41578. }
  41579. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41580. /** @hidden */
  41581. export var reflectionFunction: {
  41582. name: string;
  41583. shader: string;
  41584. };
  41585. }
  41586. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41587. /** @hidden */
  41588. export var bumpFragmentFunctions: {
  41589. name: string;
  41590. shader: string;
  41591. };
  41592. }
  41593. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41594. /** @hidden */
  41595. export var logDepthDeclaration: {
  41596. name: string;
  41597. shader: string;
  41598. };
  41599. }
  41600. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41601. /** @hidden */
  41602. export var bumpFragment: {
  41603. name: string;
  41604. shader: string;
  41605. };
  41606. }
  41607. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41608. /** @hidden */
  41609. export var depthPrePass: {
  41610. name: string;
  41611. shader: string;
  41612. };
  41613. }
  41614. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41615. /** @hidden */
  41616. export var lightFragment: {
  41617. name: string;
  41618. shader: string;
  41619. };
  41620. }
  41621. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41622. /** @hidden */
  41623. export var logDepthFragment: {
  41624. name: string;
  41625. shader: string;
  41626. };
  41627. }
  41628. declare module "babylonjs/Shaders/default.fragment" {
  41629. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41630. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41631. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41632. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41633. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41634. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41635. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41636. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41637. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41638. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41639. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41640. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41641. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41642. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41643. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41644. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41645. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41646. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41647. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41648. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41649. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41650. /** @hidden */
  41651. export var defaultPixelShader: {
  41652. name: string;
  41653. shader: string;
  41654. };
  41655. }
  41656. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41657. /** @hidden */
  41658. export var defaultVertexDeclaration: {
  41659. name: string;
  41660. shader: string;
  41661. };
  41662. }
  41663. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41664. /** @hidden */
  41665. export var bumpVertexDeclaration: {
  41666. name: string;
  41667. shader: string;
  41668. };
  41669. }
  41670. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41671. /** @hidden */
  41672. export var bumpVertex: {
  41673. name: string;
  41674. shader: string;
  41675. };
  41676. }
  41677. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41678. /** @hidden */
  41679. export var fogVertex: {
  41680. name: string;
  41681. shader: string;
  41682. };
  41683. }
  41684. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41685. /** @hidden */
  41686. export var shadowsVertex: {
  41687. name: string;
  41688. shader: string;
  41689. };
  41690. }
  41691. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41692. /** @hidden */
  41693. export var pointCloudVertex: {
  41694. name: string;
  41695. shader: string;
  41696. };
  41697. }
  41698. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41699. /** @hidden */
  41700. export var logDepthVertex: {
  41701. name: string;
  41702. shader: string;
  41703. };
  41704. }
  41705. declare module "babylonjs/Shaders/default.vertex" {
  41706. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41707. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41708. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41709. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41710. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41711. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41712. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41713. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41714. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41715. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41716. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41717. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41718. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41719. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41720. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41721. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41722. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41723. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41724. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41725. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41726. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41727. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41728. /** @hidden */
  41729. export var defaultVertexShader: {
  41730. name: string;
  41731. shader: string;
  41732. };
  41733. }
  41734. declare module "babylonjs/Materials/standardMaterial" {
  41735. import { SmartArray } from "babylonjs/Misc/smartArray";
  41736. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41737. import { Nullable } from "babylonjs/types";
  41738. import { Scene } from "babylonjs/scene";
  41739. import { Matrix } from "babylonjs/Maths/math.vector";
  41740. import { Color3 } from "babylonjs/Maths/math.color";
  41741. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41743. import { Mesh } from "babylonjs/Meshes/mesh";
  41744. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41745. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41746. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41747. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41748. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41750. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41751. import "babylonjs/Shaders/default.fragment";
  41752. import "babylonjs/Shaders/default.vertex";
  41753. /** @hidden */
  41754. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41755. MAINUV1: boolean;
  41756. MAINUV2: boolean;
  41757. DIFFUSE: boolean;
  41758. DIFFUSEDIRECTUV: number;
  41759. AMBIENT: boolean;
  41760. AMBIENTDIRECTUV: number;
  41761. OPACITY: boolean;
  41762. OPACITYDIRECTUV: number;
  41763. OPACITYRGB: boolean;
  41764. REFLECTION: boolean;
  41765. EMISSIVE: boolean;
  41766. EMISSIVEDIRECTUV: number;
  41767. SPECULAR: boolean;
  41768. SPECULARDIRECTUV: number;
  41769. BUMP: boolean;
  41770. BUMPDIRECTUV: number;
  41771. PARALLAX: boolean;
  41772. PARALLAXOCCLUSION: boolean;
  41773. SPECULAROVERALPHA: boolean;
  41774. CLIPPLANE: boolean;
  41775. CLIPPLANE2: boolean;
  41776. CLIPPLANE3: boolean;
  41777. CLIPPLANE4: boolean;
  41778. ALPHATEST: boolean;
  41779. DEPTHPREPASS: boolean;
  41780. ALPHAFROMDIFFUSE: boolean;
  41781. POINTSIZE: boolean;
  41782. FOG: boolean;
  41783. SPECULARTERM: boolean;
  41784. DIFFUSEFRESNEL: boolean;
  41785. OPACITYFRESNEL: boolean;
  41786. REFLECTIONFRESNEL: boolean;
  41787. REFRACTIONFRESNEL: boolean;
  41788. EMISSIVEFRESNEL: boolean;
  41789. FRESNEL: boolean;
  41790. NORMAL: boolean;
  41791. UV1: boolean;
  41792. UV2: boolean;
  41793. VERTEXCOLOR: boolean;
  41794. VERTEXALPHA: boolean;
  41795. NUM_BONE_INFLUENCERS: number;
  41796. BonesPerMesh: number;
  41797. BONETEXTURE: boolean;
  41798. INSTANCES: boolean;
  41799. GLOSSINESS: boolean;
  41800. ROUGHNESS: boolean;
  41801. EMISSIVEASILLUMINATION: boolean;
  41802. LINKEMISSIVEWITHDIFFUSE: boolean;
  41803. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41804. LIGHTMAP: boolean;
  41805. LIGHTMAPDIRECTUV: number;
  41806. OBJECTSPACE_NORMALMAP: boolean;
  41807. USELIGHTMAPASSHADOWMAP: boolean;
  41808. REFLECTIONMAP_3D: boolean;
  41809. REFLECTIONMAP_SPHERICAL: boolean;
  41810. REFLECTIONMAP_PLANAR: boolean;
  41811. REFLECTIONMAP_CUBIC: boolean;
  41812. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41813. REFLECTIONMAP_PROJECTION: boolean;
  41814. REFLECTIONMAP_SKYBOX: boolean;
  41815. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41816. REFLECTIONMAP_EXPLICIT: boolean;
  41817. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41818. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41819. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41820. INVERTCUBICMAP: boolean;
  41821. LOGARITHMICDEPTH: boolean;
  41822. REFRACTION: boolean;
  41823. REFRACTIONMAP_3D: boolean;
  41824. REFLECTIONOVERALPHA: boolean;
  41825. TWOSIDEDLIGHTING: boolean;
  41826. SHADOWFLOAT: boolean;
  41827. MORPHTARGETS: boolean;
  41828. MORPHTARGETS_NORMAL: boolean;
  41829. MORPHTARGETS_TANGENT: boolean;
  41830. MORPHTARGETS_UV: boolean;
  41831. NUM_MORPH_INFLUENCERS: number;
  41832. NONUNIFORMSCALING: boolean;
  41833. PREMULTIPLYALPHA: boolean;
  41834. IMAGEPROCESSING: boolean;
  41835. VIGNETTE: boolean;
  41836. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41837. VIGNETTEBLENDMODEOPAQUE: boolean;
  41838. TONEMAPPING: boolean;
  41839. TONEMAPPING_ACES: boolean;
  41840. CONTRAST: boolean;
  41841. COLORCURVES: boolean;
  41842. COLORGRADING: boolean;
  41843. COLORGRADING3D: boolean;
  41844. SAMPLER3DGREENDEPTH: boolean;
  41845. SAMPLER3DBGRMAP: boolean;
  41846. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41847. MULTIVIEW: boolean;
  41848. /**
  41849. * If the reflection texture on this material is in linear color space
  41850. * @hidden
  41851. */
  41852. IS_REFLECTION_LINEAR: boolean;
  41853. /**
  41854. * If the refraction texture on this material is in linear color space
  41855. * @hidden
  41856. */
  41857. IS_REFRACTION_LINEAR: boolean;
  41858. EXPOSURE: boolean;
  41859. constructor();
  41860. setReflectionMode(modeToEnable: string): void;
  41861. }
  41862. /**
  41863. * This is the default material used in Babylon. It is the best trade off between quality
  41864. * and performances.
  41865. * @see http://doc.babylonjs.com/babylon101/materials
  41866. */
  41867. export class StandardMaterial extends PushMaterial {
  41868. private _diffuseTexture;
  41869. /**
  41870. * The basic texture of the material as viewed under a light.
  41871. */
  41872. diffuseTexture: Nullable<BaseTexture>;
  41873. private _ambientTexture;
  41874. /**
  41875. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41876. */
  41877. ambientTexture: Nullable<BaseTexture>;
  41878. private _opacityTexture;
  41879. /**
  41880. * Define the transparency of the material from a texture.
  41881. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41882. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41883. */
  41884. opacityTexture: Nullable<BaseTexture>;
  41885. private _reflectionTexture;
  41886. /**
  41887. * Define the texture used to display the reflection.
  41888. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41889. */
  41890. reflectionTexture: Nullable<BaseTexture>;
  41891. private _emissiveTexture;
  41892. /**
  41893. * Define texture of the material as if self lit.
  41894. * This will be mixed in the final result even in the absence of light.
  41895. */
  41896. emissiveTexture: Nullable<BaseTexture>;
  41897. private _specularTexture;
  41898. /**
  41899. * Define how the color and intensity of the highlight given by the light in the material.
  41900. */
  41901. specularTexture: Nullable<BaseTexture>;
  41902. private _bumpTexture;
  41903. /**
  41904. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41905. * 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.
  41906. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41907. */
  41908. bumpTexture: Nullable<BaseTexture>;
  41909. private _lightmapTexture;
  41910. /**
  41911. * Complex lighting can be computationally expensive to compute at runtime.
  41912. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41913. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41914. */
  41915. lightmapTexture: Nullable<BaseTexture>;
  41916. private _refractionTexture;
  41917. /**
  41918. * Define the texture used to display the refraction.
  41919. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41920. */
  41921. refractionTexture: Nullable<BaseTexture>;
  41922. /**
  41923. * The color of the material lit by the environmental background lighting.
  41924. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41925. */
  41926. ambientColor: Color3;
  41927. /**
  41928. * The basic color of the material as viewed under a light.
  41929. */
  41930. diffuseColor: Color3;
  41931. /**
  41932. * Define how the color and intensity of the highlight given by the light in the material.
  41933. */
  41934. specularColor: Color3;
  41935. /**
  41936. * Define the color of the material as if self lit.
  41937. * This will be mixed in the final result even in the absence of light.
  41938. */
  41939. emissiveColor: Color3;
  41940. /**
  41941. * Defines how sharp are the highlights in the material.
  41942. * The bigger the value the sharper giving a more glossy feeling to the result.
  41943. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41944. */
  41945. specularPower: number;
  41946. private _useAlphaFromDiffuseTexture;
  41947. /**
  41948. * Does the transparency come from the diffuse texture alpha channel.
  41949. */
  41950. useAlphaFromDiffuseTexture: boolean;
  41951. private _useEmissiveAsIllumination;
  41952. /**
  41953. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41954. */
  41955. useEmissiveAsIllumination: boolean;
  41956. private _linkEmissiveWithDiffuse;
  41957. /**
  41958. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41959. * the emissive level when the final color is close to one.
  41960. */
  41961. linkEmissiveWithDiffuse: boolean;
  41962. private _useSpecularOverAlpha;
  41963. /**
  41964. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41965. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41966. */
  41967. useSpecularOverAlpha: boolean;
  41968. private _useReflectionOverAlpha;
  41969. /**
  41970. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41971. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41972. */
  41973. useReflectionOverAlpha: boolean;
  41974. private _disableLighting;
  41975. /**
  41976. * Does lights from the scene impacts this material.
  41977. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41978. */
  41979. disableLighting: boolean;
  41980. private _useObjectSpaceNormalMap;
  41981. /**
  41982. * Allows using an object space normal map (instead of tangent space).
  41983. */
  41984. useObjectSpaceNormalMap: boolean;
  41985. private _useParallax;
  41986. /**
  41987. * Is parallax enabled or not.
  41988. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41989. */
  41990. useParallax: boolean;
  41991. private _useParallaxOcclusion;
  41992. /**
  41993. * Is parallax occlusion enabled or not.
  41994. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41995. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41996. */
  41997. useParallaxOcclusion: boolean;
  41998. /**
  41999. * 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.
  42000. */
  42001. parallaxScaleBias: number;
  42002. private _roughness;
  42003. /**
  42004. * Helps to define how blurry the reflections should appears in the material.
  42005. */
  42006. roughness: number;
  42007. /**
  42008. * In case of refraction, define the value of the index of refraction.
  42009. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42010. */
  42011. indexOfRefraction: number;
  42012. /**
  42013. * Invert the refraction texture alongside the y axis.
  42014. * It can be useful with procedural textures or probe for instance.
  42015. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42016. */
  42017. invertRefractionY: boolean;
  42018. /**
  42019. * Defines the alpha limits in alpha test mode.
  42020. */
  42021. alphaCutOff: number;
  42022. private _useLightmapAsShadowmap;
  42023. /**
  42024. * In case of light mapping, define whether the map contains light or shadow informations.
  42025. */
  42026. useLightmapAsShadowmap: boolean;
  42027. private _diffuseFresnelParameters;
  42028. /**
  42029. * Define the diffuse fresnel parameters of the material.
  42030. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42031. */
  42032. diffuseFresnelParameters: FresnelParameters;
  42033. private _opacityFresnelParameters;
  42034. /**
  42035. * Define the opacity fresnel parameters of the material.
  42036. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42037. */
  42038. opacityFresnelParameters: FresnelParameters;
  42039. private _reflectionFresnelParameters;
  42040. /**
  42041. * Define the reflection fresnel parameters of the material.
  42042. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42043. */
  42044. reflectionFresnelParameters: FresnelParameters;
  42045. private _refractionFresnelParameters;
  42046. /**
  42047. * Define the refraction fresnel parameters of the material.
  42048. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42049. */
  42050. refractionFresnelParameters: FresnelParameters;
  42051. private _emissiveFresnelParameters;
  42052. /**
  42053. * Define the emissive fresnel parameters of the material.
  42054. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42055. */
  42056. emissiveFresnelParameters: FresnelParameters;
  42057. private _useReflectionFresnelFromSpecular;
  42058. /**
  42059. * If true automatically deducts the fresnels values from the material specularity.
  42060. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42061. */
  42062. useReflectionFresnelFromSpecular: boolean;
  42063. private _useGlossinessFromSpecularMapAlpha;
  42064. /**
  42065. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42066. */
  42067. useGlossinessFromSpecularMapAlpha: boolean;
  42068. private _maxSimultaneousLights;
  42069. /**
  42070. * Defines the maximum number of lights that can be used in the material
  42071. */
  42072. maxSimultaneousLights: number;
  42073. private _invertNormalMapX;
  42074. /**
  42075. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42076. */
  42077. invertNormalMapX: boolean;
  42078. private _invertNormalMapY;
  42079. /**
  42080. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42081. */
  42082. invertNormalMapY: boolean;
  42083. private _twoSidedLighting;
  42084. /**
  42085. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42086. */
  42087. twoSidedLighting: boolean;
  42088. /**
  42089. * Default configuration related to image processing available in the standard Material.
  42090. */
  42091. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42092. /**
  42093. * Gets the image processing configuration used either in this material.
  42094. */
  42095. /**
  42096. * Sets the Default image processing configuration used either in the this material.
  42097. *
  42098. * If sets to null, the scene one is in use.
  42099. */
  42100. imageProcessingConfiguration: ImageProcessingConfiguration;
  42101. /**
  42102. * Keep track of the image processing observer to allow dispose and replace.
  42103. */
  42104. private _imageProcessingObserver;
  42105. /**
  42106. * Attaches a new image processing configuration to the Standard Material.
  42107. * @param configuration
  42108. */
  42109. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42110. /**
  42111. * Gets wether the color curves effect is enabled.
  42112. */
  42113. /**
  42114. * Sets wether the color curves effect is enabled.
  42115. */
  42116. cameraColorCurvesEnabled: boolean;
  42117. /**
  42118. * Gets wether the color grading effect is enabled.
  42119. */
  42120. /**
  42121. * Gets wether the color grading effect is enabled.
  42122. */
  42123. cameraColorGradingEnabled: boolean;
  42124. /**
  42125. * Gets wether tonemapping is enabled or not.
  42126. */
  42127. /**
  42128. * Sets wether tonemapping is enabled or not
  42129. */
  42130. cameraToneMappingEnabled: boolean;
  42131. /**
  42132. * The camera exposure used on this material.
  42133. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42134. * This corresponds to a photographic exposure.
  42135. */
  42136. /**
  42137. * The camera exposure used on this material.
  42138. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42139. * This corresponds to a photographic exposure.
  42140. */
  42141. cameraExposure: number;
  42142. /**
  42143. * Gets The camera contrast used on this material.
  42144. */
  42145. /**
  42146. * Sets The camera contrast used on this material.
  42147. */
  42148. cameraContrast: number;
  42149. /**
  42150. * Gets the Color Grading 2D Lookup Texture.
  42151. */
  42152. /**
  42153. * Sets the Color Grading 2D Lookup Texture.
  42154. */
  42155. cameraColorGradingTexture: Nullable<BaseTexture>;
  42156. /**
  42157. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42158. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42159. * 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;
  42160. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42161. */
  42162. /**
  42163. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42164. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42165. * 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;
  42166. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42167. */
  42168. cameraColorCurves: Nullable<ColorCurves>;
  42169. /**
  42170. * Custom callback helping to override the default shader used in the material.
  42171. */
  42172. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42173. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42174. protected _worldViewProjectionMatrix: Matrix;
  42175. protected _globalAmbientColor: Color3;
  42176. protected _useLogarithmicDepth: boolean;
  42177. protected _rebuildInParallel: boolean;
  42178. /**
  42179. * Instantiates a new standard material.
  42180. * This is the default material used in Babylon. It is the best trade off between quality
  42181. * and performances.
  42182. * @see http://doc.babylonjs.com/babylon101/materials
  42183. * @param name Define the name of the material in the scene
  42184. * @param scene Define the scene the material belong to
  42185. */
  42186. constructor(name: string, scene: Scene);
  42187. /**
  42188. * Gets a boolean indicating that current material needs to register RTT
  42189. */
  42190. readonly hasRenderTargetTextures: boolean;
  42191. /**
  42192. * Gets the current class name of the material e.g. "StandardMaterial"
  42193. * Mainly use in serialization.
  42194. * @returns the class name
  42195. */
  42196. getClassName(): string;
  42197. /**
  42198. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42199. * You can try switching to logarithmic depth.
  42200. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42201. */
  42202. useLogarithmicDepth: boolean;
  42203. /**
  42204. * Specifies if the material will require alpha blending
  42205. * @returns a boolean specifying if alpha blending is needed
  42206. */
  42207. needAlphaBlending(): boolean;
  42208. /**
  42209. * Specifies if this material should be rendered in alpha test mode
  42210. * @returns a boolean specifying if an alpha test is needed.
  42211. */
  42212. needAlphaTesting(): boolean;
  42213. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42214. /**
  42215. * Get the texture used for alpha test purpose.
  42216. * @returns the diffuse texture in case of the standard material.
  42217. */
  42218. getAlphaTestTexture(): Nullable<BaseTexture>;
  42219. /**
  42220. * Get if the submesh is ready to be used and all its information available.
  42221. * Child classes can use it to update shaders
  42222. * @param mesh defines the mesh to check
  42223. * @param subMesh defines which submesh to check
  42224. * @param useInstances specifies that instances should be used
  42225. * @returns a boolean indicating that the submesh is ready or not
  42226. */
  42227. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42228. /**
  42229. * Builds the material UBO layouts.
  42230. * Used internally during the effect preparation.
  42231. */
  42232. buildUniformLayout(): void;
  42233. /**
  42234. * Unbinds the material from the mesh
  42235. */
  42236. unbind(): void;
  42237. /**
  42238. * Binds the submesh to this material by preparing the effect and shader to draw
  42239. * @param world defines the world transformation matrix
  42240. * @param mesh defines the mesh containing the submesh
  42241. * @param subMesh defines the submesh to bind the material to
  42242. */
  42243. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42244. /**
  42245. * Get the list of animatables in the material.
  42246. * @returns the list of animatables object used in the material
  42247. */
  42248. getAnimatables(): IAnimatable[];
  42249. /**
  42250. * Gets the active textures from the material
  42251. * @returns an array of textures
  42252. */
  42253. getActiveTextures(): BaseTexture[];
  42254. /**
  42255. * Specifies if the material uses a texture
  42256. * @param texture defines the texture to check against the material
  42257. * @returns a boolean specifying if the material uses the texture
  42258. */
  42259. hasTexture(texture: BaseTexture): boolean;
  42260. /**
  42261. * Disposes the material
  42262. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42263. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42264. */
  42265. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42266. /**
  42267. * Makes a duplicate of the material, and gives it a new name
  42268. * @param name defines the new name for the duplicated material
  42269. * @returns the cloned material
  42270. */
  42271. clone(name: string): StandardMaterial;
  42272. /**
  42273. * Serializes this material in a JSON representation
  42274. * @returns the serialized material object
  42275. */
  42276. serialize(): any;
  42277. /**
  42278. * Creates a standard material from parsed material data
  42279. * @param source defines the JSON representation of the material
  42280. * @param scene defines the hosting scene
  42281. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42282. * @returns a new standard material
  42283. */
  42284. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42285. /**
  42286. * Are diffuse textures enabled in the application.
  42287. */
  42288. static DiffuseTextureEnabled: boolean;
  42289. /**
  42290. * Are ambient textures enabled in the application.
  42291. */
  42292. static AmbientTextureEnabled: boolean;
  42293. /**
  42294. * Are opacity textures enabled in the application.
  42295. */
  42296. static OpacityTextureEnabled: boolean;
  42297. /**
  42298. * Are reflection textures enabled in the application.
  42299. */
  42300. static ReflectionTextureEnabled: boolean;
  42301. /**
  42302. * Are emissive textures enabled in the application.
  42303. */
  42304. static EmissiveTextureEnabled: boolean;
  42305. /**
  42306. * Are specular textures enabled in the application.
  42307. */
  42308. static SpecularTextureEnabled: boolean;
  42309. /**
  42310. * Are bump textures enabled in the application.
  42311. */
  42312. static BumpTextureEnabled: boolean;
  42313. /**
  42314. * Are lightmap textures enabled in the application.
  42315. */
  42316. static LightmapTextureEnabled: boolean;
  42317. /**
  42318. * Are refraction textures enabled in the application.
  42319. */
  42320. static RefractionTextureEnabled: boolean;
  42321. /**
  42322. * Are color grading textures enabled in the application.
  42323. */
  42324. static ColorGradingTextureEnabled: boolean;
  42325. /**
  42326. * Are fresnels enabled in the application.
  42327. */
  42328. static FresnelEnabled: boolean;
  42329. }
  42330. }
  42331. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42332. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42334. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42335. /** @hidden */
  42336. export var imageProcessingPixelShader: {
  42337. name: string;
  42338. shader: string;
  42339. };
  42340. }
  42341. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42342. import { Nullable } from "babylonjs/types";
  42343. import { Color4 } from "babylonjs/Maths/math.color";
  42344. import { Camera } from "babylonjs/Cameras/camera";
  42345. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42346. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42347. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42349. import { Engine } from "babylonjs/Engines/engine";
  42350. import "babylonjs/Shaders/imageProcessing.fragment";
  42351. import "babylonjs/Shaders/postprocess.vertex";
  42352. /**
  42353. * ImageProcessingPostProcess
  42354. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42355. */
  42356. export class ImageProcessingPostProcess extends PostProcess {
  42357. /**
  42358. * Default configuration related to image processing available in the PBR Material.
  42359. */
  42360. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42361. /**
  42362. * Gets the image processing configuration used either in this material.
  42363. */
  42364. /**
  42365. * Sets the Default image processing configuration used either in the this material.
  42366. *
  42367. * If sets to null, the scene one is in use.
  42368. */
  42369. imageProcessingConfiguration: ImageProcessingConfiguration;
  42370. /**
  42371. * Keep track of the image processing observer to allow dispose and replace.
  42372. */
  42373. private _imageProcessingObserver;
  42374. /**
  42375. * Attaches a new image processing configuration to the PBR Material.
  42376. * @param configuration
  42377. */
  42378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42379. /**
  42380. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42381. */
  42382. /**
  42383. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42384. */
  42385. colorCurves: Nullable<ColorCurves>;
  42386. /**
  42387. * Gets wether the color curves effect is enabled.
  42388. */
  42389. /**
  42390. * Sets wether the color curves effect is enabled.
  42391. */
  42392. colorCurvesEnabled: boolean;
  42393. /**
  42394. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42395. */
  42396. /**
  42397. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42398. */
  42399. colorGradingTexture: Nullable<BaseTexture>;
  42400. /**
  42401. * Gets wether the color grading effect is enabled.
  42402. */
  42403. /**
  42404. * Gets wether the color grading effect is enabled.
  42405. */
  42406. colorGradingEnabled: boolean;
  42407. /**
  42408. * Gets exposure used in the effect.
  42409. */
  42410. /**
  42411. * Sets exposure used in the effect.
  42412. */
  42413. exposure: number;
  42414. /**
  42415. * Gets wether tonemapping is enabled or not.
  42416. */
  42417. /**
  42418. * Sets wether tonemapping is enabled or not
  42419. */
  42420. toneMappingEnabled: boolean;
  42421. /**
  42422. * Gets the type of tone mapping effect.
  42423. */
  42424. /**
  42425. * Sets the type of tone mapping effect.
  42426. */
  42427. toneMappingType: number;
  42428. /**
  42429. * Gets contrast used in the effect.
  42430. */
  42431. /**
  42432. * Sets contrast used in the effect.
  42433. */
  42434. contrast: number;
  42435. /**
  42436. * Gets Vignette stretch size.
  42437. */
  42438. /**
  42439. * Sets Vignette stretch size.
  42440. */
  42441. vignetteStretch: number;
  42442. /**
  42443. * Gets Vignette centre X Offset.
  42444. */
  42445. /**
  42446. * Sets Vignette centre X Offset.
  42447. */
  42448. vignetteCentreX: number;
  42449. /**
  42450. * Gets Vignette centre Y Offset.
  42451. */
  42452. /**
  42453. * Sets Vignette centre Y Offset.
  42454. */
  42455. vignetteCentreY: number;
  42456. /**
  42457. * Gets Vignette weight or intensity of the vignette effect.
  42458. */
  42459. /**
  42460. * Sets Vignette weight or intensity of the vignette effect.
  42461. */
  42462. vignetteWeight: number;
  42463. /**
  42464. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42465. * if vignetteEnabled is set to true.
  42466. */
  42467. /**
  42468. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42469. * if vignetteEnabled is set to true.
  42470. */
  42471. vignetteColor: Color4;
  42472. /**
  42473. * Gets Camera field of view used by the Vignette effect.
  42474. */
  42475. /**
  42476. * Sets Camera field of view used by the Vignette effect.
  42477. */
  42478. vignetteCameraFov: number;
  42479. /**
  42480. * Gets the vignette blend mode allowing different kind of effect.
  42481. */
  42482. /**
  42483. * Sets the vignette blend mode allowing different kind of effect.
  42484. */
  42485. vignetteBlendMode: number;
  42486. /**
  42487. * Gets wether the vignette effect is enabled.
  42488. */
  42489. /**
  42490. * Sets wether the vignette effect is enabled.
  42491. */
  42492. vignetteEnabled: boolean;
  42493. private _fromLinearSpace;
  42494. /**
  42495. * Gets wether the input of the processing is in Gamma or Linear Space.
  42496. */
  42497. /**
  42498. * Sets wether the input of the processing is in Gamma or Linear Space.
  42499. */
  42500. fromLinearSpace: boolean;
  42501. /**
  42502. * Defines cache preventing GC.
  42503. */
  42504. private _defines;
  42505. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42506. /**
  42507. * "ImageProcessingPostProcess"
  42508. * @returns "ImageProcessingPostProcess"
  42509. */
  42510. getClassName(): string;
  42511. protected _updateParameters(): void;
  42512. dispose(camera?: Camera): void;
  42513. }
  42514. }
  42515. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42516. import { Scene } from "babylonjs/scene";
  42517. import { Color3 } from "babylonjs/Maths/math.color";
  42518. import { Mesh } from "babylonjs/Meshes/mesh";
  42519. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42520. import { Nullable } from "babylonjs/types";
  42521. /**
  42522. * Class containing static functions to help procedurally build meshes
  42523. */
  42524. export class GroundBuilder {
  42525. /**
  42526. * Creates a ground mesh
  42527. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42528. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42530. * @param name defines the name of the mesh
  42531. * @param options defines the options used to create the mesh
  42532. * @param scene defines the hosting scene
  42533. * @returns the ground mesh
  42534. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42535. */
  42536. static CreateGround(name: string, options: {
  42537. width?: number;
  42538. height?: number;
  42539. subdivisions?: number;
  42540. subdivisionsX?: number;
  42541. subdivisionsY?: number;
  42542. updatable?: boolean;
  42543. }, scene: any): Mesh;
  42544. /**
  42545. * Creates a tiled ground mesh
  42546. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42547. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42548. * * 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
  42549. * * 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
  42550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42551. * @param name defines the name of the mesh
  42552. * @param options defines the options used to create the mesh
  42553. * @param scene defines the hosting scene
  42554. * @returns the tiled ground mesh
  42555. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42556. */
  42557. static CreateTiledGround(name: string, options: {
  42558. xmin: number;
  42559. zmin: number;
  42560. xmax: number;
  42561. zmax: number;
  42562. subdivisions?: {
  42563. w: number;
  42564. h: number;
  42565. };
  42566. precision?: {
  42567. w: number;
  42568. h: number;
  42569. };
  42570. updatable?: boolean;
  42571. }, scene?: Nullable<Scene>): Mesh;
  42572. /**
  42573. * Creates a ground mesh from a height map
  42574. * * The parameter `url` sets the URL of the height map image resource.
  42575. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42576. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42577. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42578. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42579. * * 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.
  42580. * * 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).
  42581. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42583. * @param name defines the name of the mesh
  42584. * @param url defines the url to the height map
  42585. * @param options defines the options used to create the mesh
  42586. * @param scene defines the hosting scene
  42587. * @returns the ground mesh
  42588. * @see https://doc.babylonjs.com/babylon101/height_map
  42589. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42590. */
  42591. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42592. width?: number;
  42593. height?: number;
  42594. subdivisions?: number;
  42595. minHeight?: number;
  42596. maxHeight?: number;
  42597. colorFilter?: Color3;
  42598. alphaFilter?: number;
  42599. updatable?: boolean;
  42600. onReady?: (mesh: GroundMesh) => void;
  42601. }, scene?: Nullable<Scene>): GroundMesh;
  42602. }
  42603. }
  42604. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42605. import { Vector4 } from "babylonjs/Maths/math.vector";
  42606. import { Mesh } from "babylonjs/Meshes/mesh";
  42607. /**
  42608. * Class containing static functions to help procedurally build meshes
  42609. */
  42610. export class TorusBuilder {
  42611. /**
  42612. * Creates a torus mesh
  42613. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42614. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42615. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42619. * @param name defines the name of the mesh
  42620. * @param options defines the options used to create the mesh
  42621. * @param scene defines the hosting scene
  42622. * @returns the torus mesh
  42623. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42624. */
  42625. static CreateTorus(name: string, options: {
  42626. diameter?: number;
  42627. thickness?: number;
  42628. tessellation?: number;
  42629. updatable?: boolean;
  42630. sideOrientation?: number;
  42631. frontUVs?: Vector4;
  42632. backUVs?: Vector4;
  42633. }, scene: any): Mesh;
  42634. }
  42635. }
  42636. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42637. import { Vector4 } from "babylonjs/Maths/math.vector";
  42638. import { Color4 } from "babylonjs/Maths/math.color";
  42639. import { Mesh } from "babylonjs/Meshes/mesh";
  42640. /**
  42641. * Class containing static functions to help procedurally build meshes
  42642. */
  42643. export class CylinderBuilder {
  42644. /**
  42645. * Creates a cylinder or a cone mesh
  42646. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42647. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42648. * * 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.
  42649. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42650. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42651. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42652. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42653. * * 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).
  42654. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42655. * * 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).
  42656. * * 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
  42657. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42658. * * 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
  42659. * * 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.
  42660. * * If `enclose` is false, a ring surface is one element.
  42661. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42662. * * 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
  42663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42666. * @param name defines the name of the mesh
  42667. * @param options defines the options used to create the mesh
  42668. * @param scene defines the hosting scene
  42669. * @returns the cylinder mesh
  42670. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42671. */
  42672. static CreateCylinder(name: string, options: {
  42673. height?: number;
  42674. diameterTop?: number;
  42675. diameterBottom?: number;
  42676. diameter?: number;
  42677. tessellation?: number;
  42678. subdivisions?: number;
  42679. arc?: number;
  42680. faceColors?: Color4[];
  42681. faceUV?: Vector4[];
  42682. updatable?: boolean;
  42683. hasRings?: boolean;
  42684. enclose?: boolean;
  42685. cap?: number;
  42686. sideOrientation?: number;
  42687. frontUVs?: Vector4;
  42688. backUVs?: Vector4;
  42689. }, scene: any): Mesh;
  42690. }
  42691. }
  42692. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42693. import { Observable } from "babylonjs/Misc/observable";
  42694. import { Nullable } from "babylonjs/types";
  42695. import { Camera } from "babylonjs/Cameras/camera";
  42696. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42697. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42698. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42699. import { Scene } from "babylonjs/scene";
  42700. import { Vector3 } from "babylonjs/Maths/math.vector";
  42701. import { Color3 } from "babylonjs/Maths/math.color";
  42702. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42704. import { Mesh } from "babylonjs/Meshes/mesh";
  42705. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42706. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42707. import "babylonjs/Meshes/Builders/groundBuilder";
  42708. import "babylonjs/Meshes/Builders/torusBuilder";
  42709. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42710. import "babylonjs/Gamepads/gamepadSceneComponent";
  42711. import "babylonjs/Animations/animatable";
  42712. /**
  42713. * Options to modify the vr teleportation behavior.
  42714. */
  42715. export interface VRTeleportationOptions {
  42716. /**
  42717. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42718. */
  42719. floorMeshName?: string;
  42720. /**
  42721. * A list of meshes to be used as the teleportation floor. (default: empty)
  42722. */
  42723. floorMeshes?: Mesh[];
  42724. }
  42725. /**
  42726. * Options to modify the vr experience helper's behavior.
  42727. */
  42728. export interface VRExperienceHelperOptions extends WebVROptions {
  42729. /**
  42730. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42731. */
  42732. createDeviceOrientationCamera?: boolean;
  42733. /**
  42734. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42735. */
  42736. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42737. /**
  42738. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42739. */
  42740. laserToggle?: boolean;
  42741. /**
  42742. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42743. */
  42744. floorMeshes?: Mesh[];
  42745. /**
  42746. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42747. */
  42748. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42749. }
  42750. /**
  42751. * Event containing information after VR has been entered
  42752. */
  42753. export class OnAfterEnteringVRObservableEvent {
  42754. /**
  42755. * If entering vr was successful
  42756. */
  42757. success: boolean;
  42758. }
  42759. /**
  42760. * Helps to quickly add VR support to an existing scene.
  42761. * See http://doc.babylonjs.com/how_to/webvr_helper
  42762. */
  42763. export class VRExperienceHelper {
  42764. /** Options to modify the vr experience helper's behavior. */
  42765. webVROptions: VRExperienceHelperOptions;
  42766. private _scene;
  42767. private _position;
  42768. private _btnVR;
  42769. private _btnVRDisplayed;
  42770. private _webVRsupported;
  42771. private _webVRready;
  42772. private _webVRrequesting;
  42773. private _webVRpresenting;
  42774. private _hasEnteredVR;
  42775. private _fullscreenVRpresenting;
  42776. private _inputElement;
  42777. private _webVRCamera;
  42778. private _vrDeviceOrientationCamera;
  42779. private _deviceOrientationCamera;
  42780. private _existingCamera;
  42781. private _onKeyDown;
  42782. private _onVrDisplayPresentChange;
  42783. private _onVRDisplayChanged;
  42784. private _onVRRequestPresentStart;
  42785. private _onVRRequestPresentComplete;
  42786. /**
  42787. * 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)
  42788. */
  42789. enableGazeEvenWhenNoPointerLock: boolean;
  42790. /**
  42791. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42792. */
  42793. exitVROnDoubleTap: boolean;
  42794. /**
  42795. * Observable raised right before entering VR.
  42796. */
  42797. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42798. /**
  42799. * Observable raised when entering VR has completed.
  42800. */
  42801. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42802. /**
  42803. * Observable raised when exiting VR.
  42804. */
  42805. onExitingVRObservable: Observable<VRExperienceHelper>;
  42806. /**
  42807. * Observable raised when controller mesh is loaded.
  42808. */
  42809. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42810. /** Return this.onEnteringVRObservable
  42811. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42812. */
  42813. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42814. /** Return this.onExitingVRObservable
  42815. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42816. */
  42817. readonly onExitingVR: Observable<VRExperienceHelper>;
  42818. /** Return this.onControllerMeshLoadedObservable
  42819. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42820. */
  42821. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42822. private _rayLength;
  42823. private _useCustomVRButton;
  42824. private _teleportationRequested;
  42825. private _teleportActive;
  42826. private _floorMeshName;
  42827. private _floorMeshesCollection;
  42828. private _rotationAllowed;
  42829. private _teleportBackwardsVector;
  42830. private _teleportationTarget;
  42831. private _isDefaultTeleportationTarget;
  42832. private _postProcessMove;
  42833. private _teleportationFillColor;
  42834. private _teleportationBorderColor;
  42835. private _rotationAngle;
  42836. private _haloCenter;
  42837. private _cameraGazer;
  42838. private _padSensibilityUp;
  42839. private _padSensibilityDown;
  42840. private _leftController;
  42841. private _rightController;
  42842. /**
  42843. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42844. */
  42845. onNewMeshSelected: Observable<AbstractMesh>;
  42846. /**
  42847. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42848. * This observable will provide the mesh and the controller used to select the mesh
  42849. */
  42850. onMeshSelectedWithController: Observable<{
  42851. mesh: AbstractMesh;
  42852. controller: WebVRController;
  42853. }>;
  42854. /**
  42855. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42856. */
  42857. onNewMeshPicked: Observable<PickingInfo>;
  42858. private _circleEase;
  42859. /**
  42860. * Observable raised before camera teleportation
  42861. */
  42862. onBeforeCameraTeleport: Observable<Vector3>;
  42863. /**
  42864. * Observable raised after camera teleportation
  42865. */
  42866. onAfterCameraTeleport: Observable<Vector3>;
  42867. /**
  42868. * Observable raised when current selected mesh gets unselected
  42869. */
  42870. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42871. private _raySelectionPredicate;
  42872. /**
  42873. * To be optionaly changed by user to define custom ray selection
  42874. */
  42875. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42876. /**
  42877. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42878. */
  42879. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42880. /**
  42881. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42882. */
  42883. teleportationEnabled: boolean;
  42884. private _defaultHeight;
  42885. private _teleportationInitialized;
  42886. private _interactionsEnabled;
  42887. private _interactionsRequested;
  42888. private _displayGaze;
  42889. private _displayLaserPointer;
  42890. /**
  42891. * The mesh used to display where the user is going to teleport.
  42892. */
  42893. /**
  42894. * Sets the mesh to be used to display where the user is going to teleport.
  42895. */
  42896. teleportationTarget: Mesh;
  42897. /**
  42898. * 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
  42899. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42900. * See http://doc.babylonjs.com/resources/baking_transformations
  42901. */
  42902. gazeTrackerMesh: Mesh;
  42903. /**
  42904. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42905. */
  42906. updateGazeTrackerScale: boolean;
  42907. /**
  42908. * If the gaze trackers color should be updated when selecting meshes
  42909. */
  42910. updateGazeTrackerColor: boolean;
  42911. /**
  42912. * If the controller laser color should be updated when selecting meshes
  42913. */
  42914. updateControllerLaserColor: boolean;
  42915. /**
  42916. * The gaze tracking mesh corresponding to the left controller
  42917. */
  42918. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42919. /**
  42920. * The gaze tracking mesh corresponding to the right controller
  42921. */
  42922. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42923. /**
  42924. * If the ray of the gaze should be displayed.
  42925. */
  42926. /**
  42927. * Sets if the ray of the gaze should be displayed.
  42928. */
  42929. displayGaze: boolean;
  42930. /**
  42931. * If the ray of the LaserPointer should be displayed.
  42932. */
  42933. /**
  42934. * Sets if the ray of the LaserPointer should be displayed.
  42935. */
  42936. displayLaserPointer: boolean;
  42937. /**
  42938. * The deviceOrientationCamera used as the camera when not in VR.
  42939. */
  42940. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42941. /**
  42942. * Based on the current WebVR support, returns the current VR camera used.
  42943. */
  42944. readonly currentVRCamera: Nullable<Camera>;
  42945. /**
  42946. * The webVRCamera which is used when in VR.
  42947. */
  42948. readonly webVRCamera: WebVRFreeCamera;
  42949. /**
  42950. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42951. */
  42952. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42953. /**
  42954. * The html button that is used to trigger entering into VR.
  42955. */
  42956. readonly vrButton: Nullable<HTMLButtonElement>;
  42957. private readonly _teleportationRequestInitiated;
  42958. /**
  42959. * Defines wether or not Pointer lock should be requested when switching to
  42960. * full screen.
  42961. */
  42962. requestPointerLockOnFullScreen: boolean;
  42963. /**
  42964. * Instantiates a VRExperienceHelper.
  42965. * Helps to quickly add VR support to an existing scene.
  42966. * @param scene The scene the VRExperienceHelper belongs to.
  42967. * @param webVROptions Options to modify the vr experience helper's behavior.
  42968. */
  42969. constructor(scene: Scene,
  42970. /** Options to modify the vr experience helper's behavior. */
  42971. webVROptions?: VRExperienceHelperOptions);
  42972. private _onDefaultMeshLoaded;
  42973. private _onResize;
  42974. private _onFullscreenChange;
  42975. /**
  42976. * Gets a value indicating if we are currently in VR mode.
  42977. */
  42978. readonly isInVRMode: boolean;
  42979. private onVrDisplayPresentChange;
  42980. private onVRDisplayChanged;
  42981. private moveButtonToBottomRight;
  42982. private displayVRButton;
  42983. private updateButtonVisibility;
  42984. private _cachedAngularSensibility;
  42985. /**
  42986. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42987. * Otherwise, will use the fullscreen API.
  42988. */
  42989. enterVR(): void;
  42990. /**
  42991. * Attempt to exit VR, or fullscreen.
  42992. */
  42993. exitVR(): void;
  42994. /**
  42995. * The position of the vr experience helper.
  42996. */
  42997. /**
  42998. * Sets the position of the vr experience helper.
  42999. */
  43000. position: Vector3;
  43001. /**
  43002. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43003. */
  43004. enableInteractions(): void;
  43005. private readonly _noControllerIsActive;
  43006. private beforeRender;
  43007. private _isTeleportationFloor;
  43008. /**
  43009. * Adds a floor mesh to be used for teleportation.
  43010. * @param floorMesh the mesh to be used for teleportation.
  43011. */
  43012. addFloorMesh(floorMesh: Mesh): void;
  43013. /**
  43014. * Removes a floor mesh from being used for teleportation.
  43015. * @param floorMesh the mesh to be removed.
  43016. */
  43017. removeFloorMesh(floorMesh: Mesh): void;
  43018. /**
  43019. * Enables interactions and teleportation using the VR controllers and gaze.
  43020. * @param vrTeleportationOptions options to modify teleportation behavior.
  43021. */
  43022. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43023. private _onNewGamepadConnected;
  43024. private _tryEnableInteractionOnController;
  43025. private _onNewGamepadDisconnected;
  43026. private _enableInteractionOnController;
  43027. private _checkTeleportWithRay;
  43028. private _checkRotate;
  43029. private _checkTeleportBackwards;
  43030. private _enableTeleportationOnController;
  43031. private _createTeleportationCircles;
  43032. private _displayTeleportationTarget;
  43033. private _hideTeleportationTarget;
  43034. private _rotateCamera;
  43035. private _moveTeleportationSelectorTo;
  43036. private _workingVector;
  43037. private _workingQuaternion;
  43038. private _workingMatrix;
  43039. /**
  43040. * Teleports the users feet to the desired location
  43041. * @param location The location where the user's feet should be placed
  43042. */
  43043. teleportCamera(location: Vector3): void;
  43044. private _convertNormalToDirectionOfRay;
  43045. private _castRayAndSelectObject;
  43046. private _notifySelectedMeshUnselected;
  43047. /**
  43048. * Sets the color of the laser ray from the vr controllers.
  43049. * @param color new color for the ray.
  43050. */
  43051. changeLaserColor(color: Color3): void;
  43052. /**
  43053. * Sets the color of the ray from the vr headsets gaze.
  43054. * @param color new color for the ray.
  43055. */
  43056. changeGazeColor(color: Color3): void;
  43057. /**
  43058. * Exits VR and disposes of the vr experience helper
  43059. */
  43060. dispose(): void;
  43061. /**
  43062. * Gets the name of the VRExperienceHelper class
  43063. * @returns "VRExperienceHelper"
  43064. */
  43065. getClassName(): string;
  43066. }
  43067. }
  43068. declare module "babylonjs/Cameras/VR/index" {
  43069. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43070. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43071. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43072. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43073. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43074. export * from "babylonjs/Cameras/VR/webVRCamera";
  43075. }
  43076. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43077. import { Nullable } from "babylonjs/types";
  43078. import { IDisposable } from "babylonjs/scene";
  43079. /**
  43080. * States of the webXR experience
  43081. */
  43082. export enum WebXRState {
  43083. /**
  43084. * Transitioning to being in XR mode
  43085. */
  43086. ENTERING_XR = 0,
  43087. /**
  43088. * Transitioning to non XR mode
  43089. */
  43090. EXITING_XR = 1,
  43091. /**
  43092. * In XR mode and presenting
  43093. */
  43094. IN_XR = 2,
  43095. /**
  43096. * Not entered XR mode
  43097. */
  43098. NOT_IN_XR = 3
  43099. }
  43100. /**
  43101. * Abstraction of the XR render target
  43102. */
  43103. export interface WebXRRenderTarget extends IDisposable {
  43104. /**
  43105. * xrpresent context of the canvas which can be used to display/mirror xr content
  43106. */
  43107. canvasContext: WebGLRenderingContext;
  43108. /**
  43109. * xr layer for the canvas
  43110. */
  43111. xrLayer: Nullable<XRWebGLLayer>;
  43112. /**
  43113. * Initializes the xr layer for the session
  43114. * @param xrSession xr session
  43115. * @returns a promise that will resolve once the XR Layer has been created
  43116. */
  43117. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43118. }
  43119. }
  43120. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43121. import { Nullable } from "babylonjs/types";
  43122. import { Observable } from "babylonjs/Misc/observable";
  43123. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43124. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43125. /**
  43126. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43127. */
  43128. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43129. private _engine;
  43130. private _canvas;
  43131. /**
  43132. * xrpresent context of the canvas which can be used to display/mirror xr content
  43133. */
  43134. canvasContext: WebGLRenderingContext;
  43135. /**
  43136. * xr layer for the canvas
  43137. */
  43138. xrLayer: Nullable<XRWebGLLayer>;
  43139. /**
  43140. * Initializes the xr layer for the session
  43141. * @param xrSession xr session
  43142. * @returns a promise that will resolve once the XR Layer has been created
  43143. */
  43144. initializeXRLayerAsync(xrSession: any): any;
  43145. /**
  43146. * Initializes the canvas to be added/removed upon entering/exiting xr
  43147. * @param engine the Babylon engine
  43148. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43149. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43150. */
  43151. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  43152. /**
  43153. * Disposes of the object
  43154. */
  43155. dispose(): void;
  43156. private _setManagedOutputCanvas;
  43157. private _addCanvas;
  43158. private _removeCanvas;
  43159. }
  43160. }
  43161. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43162. import { Observable } from "babylonjs/Misc/observable";
  43163. import { Nullable } from "babylonjs/types";
  43164. import { IDisposable, Scene } from "babylonjs/scene";
  43165. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43166. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43167. /**
  43168. * Manages an XRSession to work with Babylon's engine
  43169. * @see https://doc.babylonjs.com/how_to/webxr
  43170. */
  43171. export class WebXRSessionManager implements IDisposable {
  43172. private scene;
  43173. /**
  43174. * Fires every time a new xrFrame arrives which can be used to update the camera
  43175. */
  43176. onXRFrameObservable: Observable<any>;
  43177. /**
  43178. * Fires when the xr session is ended either by the device or manually done
  43179. */
  43180. onXRSessionEnded: Observable<any>;
  43181. /**
  43182. * Underlying xr session
  43183. */
  43184. session: XRSession;
  43185. /**
  43186. * Type of reference space used when creating the session
  43187. */
  43188. referenceSpace: XRReferenceSpace;
  43189. /**
  43190. * Current XR frame
  43191. */
  43192. currentFrame: Nullable<XRFrame>;
  43193. private _xrNavigator;
  43194. private baseLayer;
  43195. private _rttProvider;
  43196. private _sessionEnded;
  43197. /**
  43198. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43199. * @param scene The scene which the session should be created for
  43200. */
  43201. constructor(scene: Scene);
  43202. /**
  43203. * Initializes the manager
  43204. * After initialization enterXR can be called to start an XR session
  43205. * @returns Promise which resolves after it is initialized
  43206. */
  43207. initializeAsync(): Promise<void>;
  43208. /**
  43209. * Initializes an xr session
  43210. * @param xrSessionMode mode to initialize
  43211. * @param optionalFeatures defines optional values to pass to the session builder
  43212. * @returns a promise which will resolve once the session has been initialized
  43213. */
  43214. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43215. /**
  43216. * Sets the reference space on the xr session
  43217. * @param referenceSpace space to set
  43218. * @returns a promise that will resolve once the reference space has been set
  43219. */
  43220. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43221. /**
  43222. * Updates the render state of the session
  43223. * @param state state to set
  43224. * @returns a promise that resolves once the render state has been updated
  43225. */
  43226. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43227. /**
  43228. * Starts rendering to the xr layer
  43229. * @returns a promise that will resolve once rendering has started
  43230. */
  43231. startRenderingToXRAsync(): Promise<void>;
  43232. /**
  43233. * Gets the correct render target texture to be rendered this frame for this eye
  43234. * @param eye the eye for which to get the render target
  43235. * @returns the render target for the specified eye
  43236. */
  43237. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43238. /**
  43239. * Stops the xrSession and restores the renderloop
  43240. * @returns Promise which resolves after it exits XR
  43241. */
  43242. exitXRAsync(): Promise<void>;
  43243. /**
  43244. * Checks if a session would be supported for the creation options specified
  43245. * @param sessionMode session mode to check if supported eg. immersive-vr
  43246. * @returns true if supported
  43247. */
  43248. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43249. /**
  43250. * Creates a WebXRRenderTarget object for the XR session
  43251. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43252. * @returns a WebXR render target to which the session can render
  43253. */
  43254. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  43255. /**
  43256. * @hidden
  43257. * Converts the render layer of xrSession to a render target
  43258. * @param session session to create render target for
  43259. * @param scene scene the new render target should be created for
  43260. */
  43261. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43262. /**
  43263. * Disposes of the session manager
  43264. */
  43265. dispose(): void;
  43266. }
  43267. }
  43268. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43269. import { Scene } from "babylonjs/scene";
  43270. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43271. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43272. /**
  43273. * WebXR Camera which holds the views for the xrSession
  43274. * @see https://doc.babylonjs.com/how_to/webxr
  43275. */
  43276. export class WebXRCamera extends FreeCamera {
  43277. private static _TmpMatrix;
  43278. /**
  43279. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43280. * @param name the name of the camera
  43281. * @param scene the scene to add the camera to
  43282. */
  43283. constructor(name: string, scene: Scene);
  43284. private _updateNumberOfRigCameras;
  43285. /** @hidden */
  43286. _updateForDualEyeDebugging(): void;
  43287. /**
  43288. * Updates the cameras position from the current pose information of the XR session
  43289. * @param xrSessionManager the session containing pose information
  43290. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43291. */
  43292. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43293. }
  43294. }
  43295. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43296. import { Observable } from "babylonjs/Misc/observable";
  43297. import { IDisposable, Scene } from "babylonjs/scene";
  43298. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43300. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43301. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43302. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43303. /**
  43304. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43305. * @see https://doc.babylonjs.com/how_to/webxr
  43306. */
  43307. export class WebXRExperienceHelper implements IDisposable {
  43308. private scene;
  43309. /**
  43310. * 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
  43311. */
  43312. container: AbstractMesh;
  43313. /**
  43314. * Camera used to render xr content
  43315. */
  43316. camera: WebXRCamera;
  43317. /**
  43318. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43319. */
  43320. state: WebXRState;
  43321. private _setState;
  43322. private static _TmpVector;
  43323. /**
  43324. * Fires when the state of the experience helper has changed
  43325. */
  43326. onStateChangedObservable: Observable<WebXRState>;
  43327. /** Session manager used to keep track of xr session */
  43328. sessionManager: WebXRSessionManager;
  43329. private _nonVRCamera;
  43330. private _originalSceneAutoClear;
  43331. private _supported;
  43332. /**
  43333. * Creates the experience helper
  43334. * @param scene the scene to attach the experience helper to
  43335. * @returns a promise for the experience helper
  43336. */
  43337. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43338. /**
  43339. * Creates a WebXRExperienceHelper
  43340. * @param scene The scene the helper should be created in
  43341. */
  43342. private constructor();
  43343. /**
  43344. * Exits XR mode and returns the scene to its original state
  43345. * @returns promise that resolves after xr mode has exited
  43346. */
  43347. exitXRAsync(): Promise<void>;
  43348. /**
  43349. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43350. * @param sessionMode options for the XR session
  43351. * @param referenceSpaceType frame of reference of the XR session
  43352. * @param renderTarget the output canvas that will be used to enter XR mode
  43353. * @returns promise that resolves after xr mode has entered
  43354. */
  43355. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43356. /**
  43357. * Updates the global position of the camera by moving the camera's container
  43358. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43359. * @param position The desired global position of the camera
  43360. */
  43361. setPositionOfCameraUsingContainer(position: Vector3): void;
  43362. /**
  43363. * Rotates the xr camera by rotating the camera's container around the camera's position
  43364. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43365. * @param rotation the desired quaternion rotation to apply to the camera
  43366. */
  43367. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43368. /**
  43369. * Disposes of the experience helper
  43370. */
  43371. dispose(): void;
  43372. }
  43373. }
  43374. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43375. import { Nullable } from "babylonjs/types";
  43376. import { Observable } from "babylonjs/Misc/observable";
  43377. import { IDisposable, Scene } from "babylonjs/scene";
  43378. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43379. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43380. /**
  43381. * Button which can be used to enter a different mode of XR
  43382. */
  43383. export class WebXREnterExitUIButton {
  43384. /** button element */
  43385. element: HTMLElement;
  43386. /** XR initialization options for the button */
  43387. sessionMode: XRSessionMode;
  43388. /** Reference space type */
  43389. referenceSpaceType: XRReferenceSpaceType;
  43390. /**
  43391. * Creates a WebXREnterExitUIButton
  43392. * @param element button element
  43393. * @param sessionMode XR initialization session mode
  43394. * @param referenceSpaceType the type of reference space to be used
  43395. */
  43396. constructor(
  43397. /** button element */
  43398. element: HTMLElement,
  43399. /** XR initialization options for the button */
  43400. sessionMode: XRSessionMode,
  43401. /** Reference space type */
  43402. referenceSpaceType: XRReferenceSpaceType);
  43403. /**
  43404. * Overwritable function which can be used to update the button's visuals when the state changes
  43405. * @param activeButton the current active button in the UI
  43406. */
  43407. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43408. }
  43409. /**
  43410. * Options to create the webXR UI
  43411. */
  43412. export class WebXREnterExitUIOptions {
  43413. /**
  43414. * Context to enter xr with
  43415. */
  43416. renderTarget?: Nullable<WebXRRenderTarget>;
  43417. /**
  43418. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43419. */
  43420. customButtons?: Array<WebXREnterExitUIButton>;
  43421. }
  43422. /**
  43423. * UI to allow the user to enter/exit XR mode
  43424. */
  43425. export class WebXREnterExitUI implements IDisposable {
  43426. private scene;
  43427. private _overlay;
  43428. private _buttons;
  43429. private _activeButton;
  43430. /**
  43431. * Fired every time the active button is changed.
  43432. *
  43433. * When xr is entered via a button that launches xr that button will be the callback parameter
  43434. *
  43435. * When exiting xr the callback parameter will be null)
  43436. */
  43437. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43438. /**
  43439. * Creates UI to allow the user to enter/exit XR mode
  43440. * @param scene the scene to add the ui to
  43441. * @param helper the xr experience helper to enter/exit xr with
  43442. * @param options options to configure the UI
  43443. * @returns the created ui
  43444. */
  43445. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43446. private constructor();
  43447. private _updateButtons;
  43448. /**
  43449. * Disposes of the object
  43450. */
  43451. dispose(): void;
  43452. }
  43453. }
  43454. declare module "babylonjs/Cameras/XR/webXRController" {
  43455. import { Nullable } from "babylonjs/types";
  43456. import { Observable } from "babylonjs/Misc/observable";
  43457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43458. import { Ray } from "babylonjs/Culling/ray";
  43459. import { Scene } from "babylonjs/scene";
  43460. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43461. /**
  43462. * Represents an XR input
  43463. */
  43464. export class WebXRController {
  43465. private scene;
  43466. /** The underlying input source for the controller */
  43467. inputSource: XRInputSource;
  43468. private parentContainer;
  43469. /**
  43470. * 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
  43471. */
  43472. grip?: AbstractMesh;
  43473. /**
  43474. * Pointer which can be used to select objects or attach a visible laser to
  43475. */
  43476. pointer: AbstractMesh;
  43477. private _gamepadMode;
  43478. /**
  43479. * If available, this is the gamepad object related to this controller.
  43480. * Using this object it is possible to get click events and trackpad changes of the
  43481. * webxr controller that is currently being used.
  43482. */
  43483. gamepadController?: WebVRController;
  43484. /**
  43485. * Event that fires when the controller is removed/disposed
  43486. */
  43487. onDisposeObservable: Observable<{}>;
  43488. private _tmpMatrix;
  43489. private _tmpQuaternion;
  43490. private _tmpVector;
  43491. /**
  43492. * Creates the controller
  43493. * @see https://doc.babylonjs.com/how_to/webxr
  43494. * @param scene the scene which the controller should be associated to
  43495. * @param inputSource the underlying input source for the controller
  43496. * @param parentContainer parent that the controller meshes should be children of
  43497. */
  43498. constructor(scene: Scene,
  43499. /** The underlying input source for the controller */
  43500. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43501. /**
  43502. * Updates the controller pose based on the given XRFrame
  43503. * @param xrFrame xr frame to update the pose with
  43504. * @param referenceSpace reference space to use
  43505. */
  43506. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43507. /**
  43508. * Gets a world space ray coming from the controller
  43509. * @param result the resulting ray
  43510. */
  43511. getWorldPointerRayToRef(result: Ray): void;
  43512. /**
  43513. * Get the scene associated with this controller
  43514. * @returns the scene object
  43515. */
  43516. getScene(): Scene;
  43517. /**
  43518. * Disposes of the object
  43519. */
  43520. dispose(): void;
  43521. }
  43522. }
  43523. declare module "babylonjs/Cameras/XR/webXRInput" {
  43524. import { Observable } from "babylonjs/Misc/observable";
  43525. import { IDisposable } from "babylonjs/scene";
  43526. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43527. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43528. /**
  43529. * XR input used to track XR inputs such as controllers/rays
  43530. */
  43531. export class WebXRInput implements IDisposable {
  43532. /**
  43533. * Base experience the input listens to
  43534. */
  43535. baseExperience: WebXRExperienceHelper;
  43536. /**
  43537. * XR controllers being tracked
  43538. */
  43539. controllers: Array<WebXRController>;
  43540. private _frameObserver;
  43541. private _stateObserver;
  43542. /**
  43543. * Event when a controller has been connected/added
  43544. */
  43545. onControllerAddedObservable: Observable<WebXRController>;
  43546. /**
  43547. * Event when a controller has been removed/disconnected
  43548. */
  43549. onControllerRemovedObservable: Observable<WebXRController>;
  43550. /**
  43551. * Initializes the WebXRInput
  43552. * @param baseExperience experience helper which the input should be created for
  43553. */
  43554. constructor(
  43555. /**
  43556. * Base experience the input listens to
  43557. */
  43558. baseExperience: WebXRExperienceHelper);
  43559. private _onInputSourcesChange;
  43560. private _addAndRemoveControllers;
  43561. /**
  43562. * Disposes of the object
  43563. */
  43564. dispose(): void;
  43565. }
  43566. }
  43567. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43569. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43570. /**
  43571. * Enables teleportation
  43572. */
  43573. export class WebXRControllerTeleportation {
  43574. private _teleportationFillColor;
  43575. private _teleportationBorderColor;
  43576. private _tmpRay;
  43577. private _tmpVector;
  43578. /**
  43579. * Creates a WebXRControllerTeleportation
  43580. * @param input input manager to add teleportation to
  43581. * @param floorMeshes floormeshes which can be teleported to
  43582. */
  43583. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43584. }
  43585. }
  43586. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43587. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43588. /**
  43589. * Handles pointer input automatically for the pointer of XR controllers
  43590. */
  43591. export class WebXRControllerPointerSelection {
  43592. private static _idCounter;
  43593. private _tmpRay;
  43594. /**
  43595. * Creates a WebXRControllerPointerSelection
  43596. * @param input input manager to setup pointer selection
  43597. */
  43598. constructor(input: WebXRInput);
  43599. private _convertNormalToDirectionOfRay;
  43600. private _updatePointerDistance;
  43601. }
  43602. }
  43603. declare module "babylonjs/Loading/sceneLoader" {
  43604. import { Observable } from "babylonjs/Misc/observable";
  43605. import { Nullable } from "babylonjs/types";
  43606. import { Scene } from "babylonjs/scene";
  43607. import { Engine } from "babylonjs/Engines/engine";
  43608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43609. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43610. import { AssetContainer } from "babylonjs/assetContainer";
  43611. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43612. import { Skeleton } from "babylonjs/Bones/skeleton";
  43613. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43614. import { WebRequest } from "babylonjs/Misc/webRequest";
  43615. /**
  43616. * Class used to represent data loading progression
  43617. */
  43618. export class SceneLoaderProgressEvent {
  43619. /** defines if data length to load can be evaluated */
  43620. readonly lengthComputable: boolean;
  43621. /** defines the loaded data length */
  43622. readonly loaded: number;
  43623. /** defines the data length to load */
  43624. readonly total: number;
  43625. /**
  43626. * Create a new progress event
  43627. * @param lengthComputable defines if data length to load can be evaluated
  43628. * @param loaded defines the loaded data length
  43629. * @param total defines the data length to load
  43630. */
  43631. constructor(
  43632. /** defines if data length to load can be evaluated */
  43633. lengthComputable: boolean,
  43634. /** defines the loaded data length */
  43635. loaded: number,
  43636. /** defines the data length to load */
  43637. total: number);
  43638. /**
  43639. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43640. * @param event defines the source event
  43641. * @returns a new SceneLoaderProgressEvent
  43642. */
  43643. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43644. }
  43645. /**
  43646. * Interface used by SceneLoader plugins to define supported file extensions
  43647. */
  43648. export interface ISceneLoaderPluginExtensions {
  43649. /**
  43650. * Defines the list of supported extensions
  43651. */
  43652. [extension: string]: {
  43653. isBinary: boolean;
  43654. };
  43655. }
  43656. /**
  43657. * Interface used by SceneLoader plugin factory
  43658. */
  43659. export interface ISceneLoaderPluginFactory {
  43660. /**
  43661. * Defines the name of the factory
  43662. */
  43663. name: string;
  43664. /**
  43665. * Function called to create a new plugin
  43666. * @return the new plugin
  43667. */
  43668. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43669. /**
  43670. * The callback that returns true if the data can be directly loaded.
  43671. * @param data string containing the file data
  43672. * @returns if the data can be loaded directly
  43673. */
  43674. canDirectLoad?(data: string): boolean;
  43675. }
  43676. /**
  43677. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43678. */
  43679. export interface ISceneLoaderPluginBase {
  43680. /**
  43681. * The friendly name of this plugin.
  43682. */
  43683. name: string;
  43684. /**
  43685. * The file extensions supported by this plugin.
  43686. */
  43687. extensions: string | ISceneLoaderPluginExtensions;
  43688. /**
  43689. * The callback called when loading from a url.
  43690. * @param scene scene loading this url
  43691. * @param url url to load
  43692. * @param onSuccess callback called when the file successfully loads
  43693. * @param onProgress callback called while file is loading (if the server supports this mode)
  43694. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43695. * @param onError callback called when the file fails to load
  43696. * @returns a file request object
  43697. */
  43698. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43699. /**
  43700. * The callback called when loading from a file object.
  43701. * @param scene scene loading this file
  43702. * @param file defines the file to load
  43703. * @param onSuccess defines the callback to call when data is loaded
  43704. * @param onProgress defines the callback to call during loading process
  43705. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43706. * @param onError defines the callback to call when an error occurs
  43707. * @returns a file request object
  43708. */
  43709. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43710. /**
  43711. * The callback that returns true if the data can be directly loaded.
  43712. * @param data string containing the file data
  43713. * @returns if the data can be loaded directly
  43714. */
  43715. canDirectLoad?(data: string): boolean;
  43716. /**
  43717. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43718. * @param scene scene loading this data
  43719. * @param data string containing the data
  43720. * @returns data to pass to the plugin
  43721. */
  43722. directLoad?(scene: Scene, data: string): any;
  43723. /**
  43724. * The callback that allows custom handling of the root url based on the response url.
  43725. * @param rootUrl the original root url
  43726. * @param responseURL the response url if available
  43727. * @returns the new root url
  43728. */
  43729. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43730. }
  43731. /**
  43732. * Interface used to define a SceneLoader plugin
  43733. */
  43734. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43735. /**
  43736. * Import meshes into a scene.
  43737. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43738. * @param scene The scene to import into
  43739. * @param data The data to import
  43740. * @param rootUrl The root url for scene and resources
  43741. * @param meshes The meshes array to import into
  43742. * @param particleSystems The particle systems array to import into
  43743. * @param skeletons The skeletons array to import into
  43744. * @param onError The callback when import fails
  43745. * @returns True if successful or false otherwise
  43746. */
  43747. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43748. /**
  43749. * Load into a scene.
  43750. * @param scene The scene to load into
  43751. * @param data The data to import
  43752. * @param rootUrl The root url for scene and resources
  43753. * @param onError The callback when import fails
  43754. * @returns True if successful or false otherwise
  43755. */
  43756. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43757. /**
  43758. * Load into an asset container.
  43759. * @param scene The scene to load into
  43760. * @param data The data to import
  43761. * @param rootUrl The root url for scene and resources
  43762. * @param onError The callback when import fails
  43763. * @returns The loaded asset container
  43764. */
  43765. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43766. }
  43767. /**
  43768. * Interface used to define an async SceneLoader plugin
  43769. */
  43770. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43771. /**
  43772. * Import meshes into a scene.
  43773. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43774. * @param scene The scene to import into
  43775. * @param data The data to import
  43776. * @param rootUrl The root url for scene and resources
  43777. * @param onProgress The callback when the load progresses
  43778. * @param fileName Defines the name of the file to load
  43779. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43780. */
  43781. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43782. meshes: AbstractMesh[];
  43783. particleSystems: IParticleSystem[];
  43784. skeletons: Skeleton[];
  43785. animationGroups: AnimationGroup[];
  43786. }>;
  43787. /**
  43788. * Load into a scene.
  43789. * @param scene The scene to load into
  43790. * @param data The data to import
  43791. * @param rootUrl The root url for scene and resources
  43792. * @param onProgress The callback when the load progresses
  43793. * @param fileName Defines the name of the file to load
  43794. * @returns Nothing
  43795. */
  43796. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43797. /**
  43798. * Load into an asset container.
  43799. * @param scene The scene to load into
  43800. * @param data The data to import
  43801. * @param rootUrl The root url for scene and resources
  43802. * @param onProgress The callback when the load progresses
  43803. * @param fileName Defines the name of the file to load
  43804. * @returns The loaded asset container
  43805. */
  43806. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43807. }
  43808. /**
  43809. * Class used to load scene from various file formats using registered plugins
  43810. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43811. */
  43812. export class SceneLoader {
  43813. /**
  43814. * No logging while loading
  43815. */
  43816. static readonly NO_LOGGING: number;
  43817. /**
  43818. * Minimal logging while loading
  43819. */
  43820. static readonly MINIMAL_LOGGING: number;
  43821. /**
  43822. * Summary logging while loading
  43823. */
  43824. static readonly SUMMARY_LOGGING: number;
  43825. /**
  43826. * Detailled logging while loading
  43827. */
  43828. static readonly DETAILED_LOGGING: number;
  43829. /**
  43830. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43831. */
  43832. static ForceFullSceneLoadingForIncremental: boolean;
  43833. /**
  43834. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43835. */
  43836. static ShowLoadingScreen: boolean;
  43837. /**
  43838. * Defines the current logging level (while loading the scene)
  43839. * @ignorenaming
  43840. */
  43841. static loggingLevel: number;
  43842. /**
  43843. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43844. */
  43845. static CleanBoneMatrixWeights: boolean;
  43846. /**
  43847. * Event raised when a plugin is used to load a scene
  43848. */
  43849. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43850. private static _registeredPlugins;
  43851. private static _getDefaultPlugin;
  43852. private static _getPluginForExtension;
  43853. private static _getPluginForDirectLoad;
  43854. private static _getPluginForFilename;
  43855. private static _getDirectLoad;
  43856. private static _loadData;
  43857. private static _getFileInfo;
  43858. /**
  43859. * Gets a plugin that can load the given extension
  43860. * @param extension defines the extension to load
  43861. * @returns a plugin or null if none works
  43862. */
  43863. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43864. /**
  43865. * Gets a boolean indicating that the given extension can be loaded
  43866. * @param extension defines the extension to load
  43867. * @returns true if the extension is supported
  43868. */
  43869. static IsPluginForExtensionAvailable(extension: string): boolean;
  43870. /**
  43871. * Adds a new plugin to the list of registered plugins
  43872. * @param plugin defines the plugin to add
  43873. */
  43874. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43875. /**
  43876. * Import meshes into a scene
  43877. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43878. * @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)
  43879. * @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)
  43880. * @param scene the instance of BABYLON.Scene to append to
  43881. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43882. * @param onProgress a callback with a progress event for each file being loaded
  43883. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43884. * @param pluginExtension the extension used to determine the plugin
  43885. * @returns The loaded plugin
  43886. */
  43887. 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>;
  43888. /**
  43889. * Import meshes into a scene
  43890. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43891. * @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)
  43892. * @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)
  43893. * @param scene the instance of BABYLON.Scene to append to
  43894. * @param onProgress a callback with a progress event for each file being loaded
  43895. * @param pluginExtension the extension used to determine the plugin
  43896. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43897. */
  43898. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43899. meshes: AbstractMesh[];
  43900. particleSystems: IParticleSystem[];
  43901. skeletons: Skeleton[];
  43902. animationGroups: AnimationGroup[];
  43903. }>;
  43904. /**
  43905. * Load a scene
  43906. * @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)
  43907. * @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)
  43908. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43909. * @param onSuccess a callback with the scene when import succeeds
  43910. * @param onProgress a callback with a progress event for each file being loaded
  43911. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43912. * @param pluginExtension the extension used to determine the plugin
  43913. * @returns The loaded plugin
  43914. */
  43915. 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>;
  43916. /**
  43917. * Load a scene
  43918. * @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)
  43919. * @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)
  43920. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43921. * @param onProgress a callback with a progress event for each file being loaded
  43922. * @param pluginExtension the extension used to determine the plugin
  43923. * @returns The loaded scene
  43924. */
  43925. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43926. /**
  43927. * Append a scene
  43928. * @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)
  43929. * @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)
  43930. * @param scene is the instance of BABYLON.Scene to append to
  43931. * @param onSuccess a callback with the scene when import succeeds
  43932. * @param onProgress a callback with a progress event for each file being loaded
  43933. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43934. * @param pluginExtension the extension used to determine the plugin
  43935. * @returns The loaded plugin
  43936. */
  43937. 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>;
  43938. /**
  43939. * Append a scene
  43940. * @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)
  43941. * @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)
  43942. * @param scene is the instance of BABYLON.Scene to append to
  43943. * @param onProgress a callback with a progress event for each file being loaded
  43944. * @param pluginExtension the extension used to determine the plugin
  43945. * @returns The given scene
  43946. */
  43947. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43948. /**
  43949. * Load a scene into an asset container
  43950. * @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)
  43951. * @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)
  43952. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43953. * @param onSuccess a callback with the scene when import succeeds
  43954. * @param onProgress a callback with a progress event for each file being loaded
  43955. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43956. * @param pluginExtension the extension used to determine the plugin
  43957. * @returns The loaded plugin
  43958. */
  43959. 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>;
  43960. /**
  43961. * Load a scene into an asset container
  43962. * @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)
  43963. * @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)
  43964. * @param scene is the instance of Scene to append to
  43965. * @param onProgress a callback with a progress event for each file being loaded
  43966. * @param pluginExtension the extension used to determine the plugin
  43967. * @returns The loaded asset container
  43968. */
  43969. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43970. }
  43971. }
  43972. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43973. import { Scene } from "babylonjs/scene";
  43974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43975. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43976. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43977. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43978. /**
  43979. * Generic Controller
  43980. */
  43981. export class GenericController extends WebVRController {
  43982. /**
  43983. * Base Url for the controller model.
  43984. */
  43985. static readonly MODEL_BASE_URL: string;
  43986. /**
  43987. * File name for the controller model.
  43988. */
  43989. static readonly MODEL_FILENAME: string;
  43990. /**
  43991. * Creates a new GenericController from a gamepad
  43992. * @param vrGamepad the gamepad that the controller should be created from
  43993. */
  43994. constructor(vrGamepad: any);
  43995. /**
  43996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43997. * @param scene scene in which to add meshes
  43998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43999. */
  44000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44001. /**
  44002. * Called once for each button that changed state since the last frame
  44003. * @param buttonIdx Which button index changed
  44004. * @param state New state of the button
  44005. * @param changes Which properties on the state changed since last frame
  44006. */
  44007. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44008. }
  44009. }
  44010. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44011. import { Observable } from "babylonjs/Misc/observable";
  44012. import { Scene } from "babylonjs/scene";
  44013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44014. import { Ray } from "babylonjs/Culling/ray";
  44015. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44016. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44017. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44018. /**
  44019. * Defines the WindowsMotionController object that the state of the windows motion controller
  44020. */
  44021. export class WindowsMotionController extends WebVRController {
  44022. /**
  44023. * The base url used to load the left and right controller models
  44024. */
  44025. static MODEL_BASE_URL: string;
  44026. /**
  44027. * The name of the left controller model file
  44028. */
  44029. static MODEL_LEFT_FILENAME: string;
  44030. /**
  44031. * The name of the right controller model file
  44032. */
  44033. static MODEL_RIGHT_FILENAME: string;
  44034. /**
  44035. * The controller name prefix for this controller type
  44036. */
  44037. static readonly GAMEPAD_ID_PREFIX: string;
  44038. /**
  44039. * The controller id pattern for this controller type
  44040. */
  44041. private static readonly GAMEPAD_ID_PATTERN;
  44042. private _loadedMeshInfo;
  44043. private readonly _mapping;
  44044. /**
  44045. * Fired when the trackpad on this controller is clicked
  44046. */
  44047. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44048. /**
  44049. * Fired when the trackpad on this controller is modified
  44050. */
  44051. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44052. /**
  44053. * The current x and y values of this controller's trackpad
  44054. */
  44055. trackpad: StickValues;
  44056. /**
  44057. * Creates a new WindowsMotionController from a gamepad
  44058. * @param vrGamepad the gamepad that the controller should be created from
  44059. */
  44060. constructor(vrGamepad: any);
  44061. /**
  44062. * Fired when the trigger on this controller is modified
  44063. */
  44064. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44065. /**
  44066. * Fired when the menu button on this controller is modified
  44067. */
  44068. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44069. /**
  44070. * Fired when the grip button on this controller is modified
  44071. */
  44072. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44073. /**
  44074. * Fired when the thumbstick button on this controller is modified
  44075. */
  44076. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44077. /**
  44078. * Fired when the touchpad button on this controller is modified
  44079. */
  44080. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44081. /**
  44082. * Fired when the touchpad values on this controller are modified
  44083. */
  44084. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44085. private _updateTrackpad;
  44086. /**
  44087. * Called once per frame by the engine.
  44088. */
  44089. update(): void;
  44090. /**
  44091. * Called once for each button that changed state since the last frame
  44092. * @param buttonIdx Which button index changed
  44093. * @param state New state of the button
  44094. * @param changes Which properties on the state changed since last frame
  44095. */
  44096. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44097. /**
  44098. * Moves the buttons on the controller mesh based on their current state
  44099. * @param buttonName the name of the button to move
  44100. * @param buttonValue the value of the button which determines the buttons new position
  44101. */
  44102. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44103. /**
  44104. * Moves the axis on the controller mesh based on its current state
  44105. * @param axis the index of the axis
  44106. * @param axisValue the value of the axis which determines the meshes new position
  44107. * @hidden
  44108. */
  44109. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44110. /**
  44111. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44112. * @param scene scene in which to add meshes
  44113. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44114. */
  44115. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44116. /**
  44117. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44118. * can be transformed by button presses and axes values, based on this._mapping.
  44119. *
  44120. * @param scene scene in which the meshes exist
  44121. * @param meshes list of meshes that make up the controller model to process
  44122. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44123. */
  44124. private processModel;
  44125. private createMeshInfo;
  44126. /**
  44127. * Gets the ray of the controller in the direction the controller is pointing
  44128. * @param length the length the resulting ray should be
  44129. * @returns a ray in the direction the controller is pointing
  44130. */
  44131. getForwardRay(length?: number): Ray;
  44132. /**
  44133. * Disposes of the controller
  44134. */
  44135. dispose(): void;
  44136. }
  44137. }
  44138. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44139. import { Observable } from "babylonjs/Misc/observable";
  44140. import { Scene } from "babylonjs/scene";
  44141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44142. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44143. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44144. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44145. /**
  44146. * Oculus Touch Controller
  44147. */
  44148. export class OculusTouchController extends WebVRController {
  44149. /**
  44150. * Base Url for the controller model.
  44151. */
  44152. static MODEL_BASE_URL: string;
  44153. /**
  44154. * File name for the left controller model.
  44155. */
  44156. static MODEL_LEFT_FILENAME: string;
  44157. /**
  44158. * File name for the right controller model.
  44159. */
  44160. static MODEL_RIGHT_FILENAME: string;
  44161. /**
  44162. * Base Url for the Quest controller model.
  44163. */
  44164. static QUEST_MODEL_BASE_URL: string;
  44165. /**
  44166. * @hidden
  44167. * If the controllers are running on a device that needs the updated Quest controller models
  44168. */
  44169. static _IsQuest: boolean;
  44170. /**
  44171. * Fired when the secondary trigger on this controller is modified
  44172. */
  44173. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44174. /**
  44175. * Fired when the thumb rest on this controller is modified
  44176. */
  44177. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44178. /**
  44179. * Creates a new OculusTouchController from a gamepad
  44180. * @param vrGamepad the gamepad that the controller should be created from
  44181. */
  44182. constructor(vrGamepad: any);
  44183. /**
  44184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44185. * @param scene scene in which to add meshes
  44186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44187. */
  44188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44189. /**
  44190. * Fired when the A button on this controller is modified
  44191. */
  44192. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44193. /**
  44194. * Fired when the B button on this controller is modified
  44195. */
  44196. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44197. /**
  44198. * Fired when the X button on this controller is modified
  44199. */
  44200. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44201. /**
  44202. * Fired when the Y button on this controller is modified
  44203. */
  44204. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44205. /**
  44206. * Called once for each button that changed state since the last frame
  44207. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44208. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44209. * 2) secondary trigger (same)
  44210. * 3) A (right) X (left), touch, pressed = value
  44211. * 4) B / Y
  44212. * 5) thumb rest
  44213. * @param buttonIdx Which button index changed
  44214. * @param state New state of the button
  44215. * @param changes Which properties on the state changed since last frame
  44216. */
  44217. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44218. }
  44219. }
  44220. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44221. import { Scene } from "babylonjs/scene";
  44222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44223. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44224. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44225. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44226. import { Observable } from "babylonjs/Misc/observable";
  44227. /**
  44228. * Vive Controller
  44229. */
  44230. export class ViveController extends WebVRController {
  44231. /**
  44232. * Base Url for the controller model.
  44233. */
  44234. static MODEL_BASE_URL: string;
  44235. /**
  44236. * File name for the controller model.
  44237. */
  44238. static MODEL_FILENAME: string;
  44239. /**
  44240. * Creates a new ViveController from a gamepad
  44241. * @param vrGamepad the gamepad that the controller should be created from
  44242. */
  44243. constructor(vrGamepad: any);
  44244. /**
  44245. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44246. * @param scene scene in which to add meshes
  44247. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44248. */
  44249. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44250. /**
  44251. * Fired when the left button on this controller is modified
  44252. */
  44253. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44254. /**
  44255. * Fired when the right button on this controller is modified
  44256. */
  44257. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44258. /**
  44259. * Fired when the menu button on this controller is modified
  44260. */
  44261. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44262. /**
  44263. * Called once for each button that changed state since the last frame
  44264. * Vive mapping:
  44265. * 0: touchpad
  44266. * 1: trigger
  44267. * 2: left AND right buttons
  44268. * 3: menu button
  44269. * @param buttonIdx Which button index changed
  44270. * @param state New state of the button
  44271. * @param changes Which properties on the state changed since last frame
  44272. */
  44273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44274. }
  44275. }
  44276. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44277. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44278. /**
  44279. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44280. */
  44281. export class WebXRControllerModelLoader {
  44282. /**
  44283. * Creates the WebXRControllerModelLoader
  44284. * @param input xr input that creates the controllers
  44285. */
  44286. constructor(input: WebXRInput);
  44287. }
  44288. }
  44289. declare module "babylonjs/Cameras/XR/index" {
  44290. export * from "babylonjs/Cameras/XR/webXRCamera";
  44291. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44292. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44293. export * from "babylonjs/Cameras/XR/webXRInput";
  44294. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44295. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44296. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44297. export * from "babylonjs/Cameras/XR/webXRController";
  44298. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44299. export * from "babylonjs/Cameras/XR/webXRTypes";
  44300. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44301. }
  44302. declare module "babylonjs/Cameras/RigModes/index" {
  44303. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44304. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44305. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44306. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44307. }
  44308. declare module "babylonjs/Cameras/index" {
  44309. export * from "babylonjs/Cameras/Inputs/index";
  44310. export * from "babylonjs/Cameras/cameraInputsManager";
  44311. export * from "babylonjs/Cameras/camera";
  44312. export * from "babylonjs/Cameras/targetCamera";
  44313. export * from "babylonjs/Cameras/freeCamera";
  44314. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44315. export * from "babylonjs/Cameras/touchCamera";
  44316. export * from "babylonjs/Cameras/arcRotateCamera";
  44317. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44318. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44319. export * from "babylonjs/Cameras/flyCamera";
  44320. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44321. export * from "babylonjs/Cameras/followCamera";
  44322. export * from "babylonjs/Cameras/followCameraInputsManager";
  44323. export * from "babylonjs/Cameras/gamepadCamera";
  44324. export * from "babylonjs/Cameras/Stereoscopic/index";
  44325. export * from "babylonjs/Cameras/universalCamera";
  44326. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44327. export * from "babylonjs/Cameras/VR/index";
  44328. export * from "babylonjs/Cameras/XR/index";
  44329. export * from "babylonjs/Cameras/RigModes/index";
  44330. }
  44331. declare module "babylonjs/Collisions/index" {
  44332. export * from "babylonjs/Collisions/collider";
  44333. export * from "babylonjs/Collisions/collisionCoordinator";
  44334. export * from "babylonjs/Collisions/pickingInfo";
  44335. export * from "babylonjs/Collisions/intersectionInfo";
  44336. export * from "babylonjs/Collisions/meshCollisionData";
  44337. }
  44338. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44339. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44340. import { Vector3 } from "babylonjs/Maths/math.vector";
  44341. import { Ray } from "babylonjs/Culling/ray";
  44342. import { Plane } from "babylonjs/Maths/math.plane";
  44343. /**
  44344. * Contains an array of blocks representing the octree
  44345. */
  44346. export interface IOctreeContainer<T> {
  44347. /**
  44348. * Blocks within the octree
  44349. */
  44350. blocks: Array<OctreeBlock<T>>;
  44351. }
  44352. /**
  44353. * Class used to store a cell in an octree
  44354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44355. */
  44356. export class OctreeBlock<T> {
  44357. /**
  44358. * Gets the content of the current block
  44359. */
  44360. entries: T[];
  44361. /**
  44362. * Gets the list of block children
  44363. */
  44364. blocks: Array<OctreeBlock<T>>;
  44365. private _depth;
  44366. private _maxDepth;
  44367. private _capacity;
  44368. private _minPoint;
  44369. private _maxPoint;
  44370. private _boundingVectors;
  44371. private _creationFunc;
  44372. /**
  44373. * Creates a new block
  44374. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44375. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44376. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44377. * @param depth defines the current depth of this block in the octree
  44378. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44379. * @param creationFunc defines a callback to call when an element is added to the block
  44380. */
  44381. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44382. /**
  44383. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44384. */
  44385. readonly capacity: number;
  44386. /**
  44387. * Gets the minimum vector (in world space) of the block's bounding box
  44388. */
  44389. readonly minPoint: Vector3;
  44390. /**
  44391. * Gets the maximum vector (in world space) of the block's bounding box
  44392. */
  44393. readonly maxPoint: Vector3;
  44394. /**
  44395. * Add a new element to this block
  44396. * @param entry defines the element to add
  44397. */
  44398. addEntry(entry: T): void;
  44399. /**
  44400. * Remove an element from this block
  44401. * @param entry defines the element to remove
  44402. */
  44403. removeEntry(entry: T): void;
  44404. /**
  44405. * Add an array of elements to this block
  44406. * @param entries defines the array of elements to add
  44407. */
  44408. addEntries(entries: T[]): void;
  44409. /**
  44410. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44411. * @param frustumPlanes defines the frustum planes to test
  44412. * @param selection defines the array to store current content if selection is positive
  44413. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44414. */
  44415. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44416. /**
  44417. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44418. * @param sphereCenter defines the bounding sphere center
  44419. * @param sphereRadius defines the bounding sphere radius
  44420. * @param selection defines the array to store current content if selection is positive
  44421. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44422. */
  44423. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44424. /**
  44425. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44426. * @param ray defines the ray to test with
  44427. * @param selection defines the array to store current content if selection is positive
  44428. */
  44429. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44430. /**
  44431. * Subdivide the content into child blocks (this block will then be empty)
  44432. */
  44433. createInnerBlocks(): void;
  44434. /**
  44435. * @hidden
  44436. */
  44437. 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;
  44438. }
  44439. }
  44440. declare module "babylonjs/Culling/Octrees/octree" {
  44441. import { SmartArray } from "babylonjs/Misc/smartArray";
  44442. import { Vector3 } from "babylonjs/Maths/math.vector";
  44443. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44445. import { Ray } from "babylonjs/Culling/ray";
  44446. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44447. import { Plane } from "babylonjs/Maths/math.plane";
  44448. /**
  44449. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44450. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44451. */
  44452. export class Octree<T> {
  44453. /** 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.) */
  44454. maxDepth: number;
  44455. /**
  44456. * Blocks within the octree containing objects
  44457. */
  44458. blocks: Array<OctreeBlock<T>>;
  44459. /**
  44460. * Content stored in the octree
  44461. */
  44462. dynamicContent: T[];
  44463. private _maxBlockCapacity;
  44464. private _selectionContent;
  44465. private _creationFunc;
  44466. /**
  44467. * Creates a octree
  44468. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44469. * @param creationFunc function to be used to instatiate the octree
  44470. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44471. * @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.)
  44472. */
  44473. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44474. /** 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.) */
  44475. maxDepth?: number);
  44476. /**
  44477. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44478. * @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);
  44479. * @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);
  44480. * @param entries meshes to be added to the octree blocks
  44481. */
  44482. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44483. /**
  44484. * Adds a mesh to the octree
  44485. * @param entry Mesh to add to the octree
  44486. */
  44487. addMesh(entry: T): void;
  44488. /**
  44489. * Remove an element from the octree
  44490. * @param entry defines the element to remove
  44491. */
  44492. removeMesh(entry: T): void;
  44493. /**
  44494. * Selects an array of meshes within the frustum
  44495. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44496. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44497. * @returns array of meshes within the frustum
  44498. */
  44499. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44500. /**
  44501. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44502. * @param sphereCenter defines the bounding sphere center
  44503. * @param sphereRadius defines the bounding sphere radius
  44504. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44505. * @returns an array of objects that intersect the sphere
  44506. */
  44507. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44508. /**
  44509. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44510. * @param ray defines the ray to test with
  44511. * @returns array of intersected objects
  44512. */
  44513. intersectsRay(ray: Ray): SmartArray<T>;
  44514. /**
  44515. * Adds a mesh into the octree block if it intersects the block
  44516. */
  44517. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44518. /**
  44519. * Adds a submesh into the octree block if it intersects the block
  44520. */
  44521. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44522. }
  44523. }
  44524. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44525. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44526. import { Scene } from "babylonjs/scene";
  44527. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44529. import { Ray } from "babylonjs/Culling/ray";
  44530. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44531. import { Collider } from "babylonjs/Collisions/collider";
  44532. module "babylonjs/scene" {
  44533. interface Scene {
  44534. /**
  44535. * @hidden
  44536. * Backing Filed
  44537. */
  44538. _selectionOctree: Octree<AbstractMesh>;
  44539. /**
  44540. * Gets the octree used to boost mesh selection (picking)
  44541. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44542. */
  44543. selectionOctree: Octree<AbstractMesh>;
  44544. /**
  44545. * Creates or updates the octree used to boost selection (picking)
  44546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44547. * @param maxCapacity defines the maximum capacity per leaf
  44548. * @param maxDepth defines the maximum depth of the octree
  44549. * @returns an octree of AbstractMesh
  44550. */
  44551. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44552. }
  44553. }
  44554. module "babylonjs/Meshes/abstractMesh" {
  44555. interface AbstractMesh {
  44556. /**
  44557. * @hidden
  44558. * Backing Field
  44559. */
  44560. _submeshesOctree: Octree<SubMesh>;
  44561. /**
  44562. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44563. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44564. * @param maxCapacity defines the maximum size of each block (64 by default)
  44565. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44566. * @returns the new octree
  44567. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44569. */
  44570. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44571. }
  44572. }
  44573. /**
  44574. * Defines the octree scene component responsible to manage any octrees
  44575. * in a given scene.
  44576. */
  44577. export class OctreeSceneComponent {
  44578. /**
  44579. * The component name help to identify the component in the list of scene components.
  44580. */
  44581. readonly name: string;
  44582. /**
  44583. * The scene the component belongs to.
  44584. */
  44585. scene: Scene;
  44586. /**
  44587. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44588. */
  44589. readonly checksIsEnabled: boolean;
  44590. /**
  44591. * Creates a new instance of the component for the given scene
  44592. * @param scene Defines the scene to register the component in
  44593. */
  44594. constructor(scene: Scene);
  44595. /**
  44596. * Registers the component in a given scene
  44597. */
  44598. register(): void;
  44599. /**
  44600. * Return the list of active meshes
  44601. * @returns the list of active meshes
  44602. */
  44603. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44604. /**
  44605. * Return the list of active sub meshes
  44606. * @param mesh The mesh to get the candidates sub meshes from
  44607. * @returns the list of active sub meshes
  44608. */
  44609. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44610. private _tempRay;
  44611. /**
  44612. * Return the list of sub meshes intersecting with a given local ray
  44613. * @param mesh defines the mesh to find the submesh for
  44614. * @param localRay defines the ray in local space
  44615. * @returns the list of intersecting sub meshes
  44616. */
  44617. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44618. /**
  44619. * Return the list of sub meshes colliding with a collider
  44620. * @param mesh defines the mesh to find the submesh for
  44621. * @param collider defines the collider to evaluate the collision against
  44622. * @returns the list of colliding sub meshes
  44623. */
  44624. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44625. /**
  44626. * Rebuilds the elements related to this component in case of
  44627. * context lost for instance.
  44628. */
  44629. rebuild(): void;
  44630. /**
  44631. * Disposes the component and the associated ressources.
  44632. */
  44633. dispose(): void;
  44634. }
  44635. }
  44636. declare module "babylonjs/Culling/Octrees/index" {
  44637. export * from "babylonjs/Culling/Octrees/octree";
  44638. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44639. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44640. }
  44641. declare module "babylonjs/Culling/index" {
  44642. export * from "babylonjs/Culling/boundingBox";
  44643. export * from "babylonjs/Culling/boundingInfo";
  44644. export * from "babylonjs/Culling/boundingSphere";
  44645. export * from "babylonjs/Culling/Octrees/index";
  44646. export * from "babylonjs/Culling/ray";
  44647. }
  44648. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44649. import { IDisposable, Scene } from "babylonjs/scene";
  44650. import { Nullable } from "babylonjs/types";
  44651. import { Observable } from "babylonjs/Misc/observable";
  44652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44653. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44654. import { Camera } from "babylonjs/Cameras/camera";
  44655. /**
  44656. * Renders a layer on top of an existing scene
  44657. */
  44658. export class UtilityLayerRenderer implements IDisposable {
  44659. /** the original scene that will be rendered on top of */
  44660. originalScene: Scene;
  44661. private _pointerCaptures;
  44662. private _lastPointerEvents;
  44663. private static _DefaultUtilityLayer;
  44664. private static _DefaultKeepDepthUtilityLayer;
  44665. private _sharedGizmoLight;
  44666. private _renderCamera;
  44667. /**
  44668. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44669. * @returns the camera that is used when rendering the utility layer
  44670. */
  44671. getRenderCamera(): Nullable<Camera>;
  44672. /**
  44673. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44674. * @param cam the camera that should be used when rendering the utility layer
  44675. */
  44676. setRenderCamera(cam: Nullable<Camera>): void;
  44677. /**
  44678. * @hidden
  44679. * Light which used by gizmos to get light shading
  44680. */
  44681. _getSharedGizmoLight(): HemisphericLight;
  44682. /**
  44683. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44684. */
  44685. pickUtilitySceneFirst: boolean;
  44686. /**
  44687. * 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)
  44688. */
  44689. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44690. /**
  44691. * 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)
  44692. */
  44693. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44694. /**
  44695. * The scene that is rendered on top of the original scene
  44696. */
  44697. utilityLayerScene: Scene;
  44698. /**
  44699. * If the utility layer should automatically be rendered on top of existing scene
  44700. */
  44701. shouldRender: boolean;
  44702. /**
  44703. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44704. */
  44705. onlyCheckPointerDownEvents: boolean;
  44706. /**
  44707. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44708. */
  44709. processAllEvents: boolean;
  44710. /**
  44711. * Observable raised when the pointer move from the utility layer scene to the main scene
  44712. */
  44713. onPointerOutObservable: Observable<number>;
  44714. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44715. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44716. private _afterRenderObserver;
  44717. private _sceneDisposeObserver;
  44718. private _originalPointerObserver;
  44719. /**
  44720. * Instantiates a UtilityLayerRenderer
  44721. * @param originalScene the original scene that will be rendered on top of
  44722. * @param handleEvents boolean indicating if the utility layer should handle events
  44723. */
  44724. constructor(
  44725. /** the original scene that will be rendered on top of */
  44726. originalScene: Scene, handleEvents?: boolean);
  44727. private _notifyObservers;
  44728. /**
  44729. * Renders the utility layers scene on top of the original scene
  44730. */
  44731. render(): void;
  44732. /**
  44733. * Disposes of the renderer
  44734. */
  44735. dispose(): void;
  44736. private _updateCamera;
  44737. }
  44738. }
  44739. declare module "babylonjs/Gizmos/gizmo" {
  44740. import { Nullable } from "babylonjs/types";
  44741. import { IDisposable } from "babylonjs/scene";
  44742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44743. import { Mesh } from "babylonjs/Meshes/mesh";
  44744. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44745. /**
  44746. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44747. */
  44748. export class Gizmo implements IDisposable {
  44749. /** The utility layer the gizmo will be added to */
  44750. gizmoLayer: UtilityLayerRenderer;
  44751. /**
  44752. * The root mesh of the gizmo
  44753. */
  44754. _rootMesh: Mesh;
  44755. private _attachedMesh;
  44756. /**
  44757. * Ratio for the scale of the gizmo (Default: 1)
  44758. */
  44759. scaleRatio: number;
  44760. /**
  44761. * If a custom mesh has been set (Default: false)
  44762. */
  44763. protected _customMeshSet: boolean;
  44764. /**
  44765. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44766. * * When set, interactions will be enabled
  44767. */
  44768. attachedMesh: Nullable<AbstractMesh>;
  44769. /**
  44770. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44771. * @param mesh The mesh to replace the default mesh of the gizmo
  44772. */
  44773. setCustomMesh(mesh: Mesh): void;
  44774. /**
  44775. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44776. */
  44777. updateGizmoRotationToMatchAttachedMesh: boolean;
  44778. /**
  44779. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44780. */
  44781. updateGizmoPositionToMatchAttachedMesh: boolean;
  44782. /**
  44783. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44784. */
  44785. updateScale: boolean;
  44786. protected _interactionsEnabled: boolean;
  44787. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44788. private _beforeRenderObserver;
  44789. private _tempVector;
  44790. /**
  44791. * Creates a gizmo
  44792. * @param gizmoLayer The utility layer the gizmo will be added to
  44793. */
  44794. constructor(
  44795. /** The utility layer the gizmo will be added to */
  44796. gizmoLayer?: UtilityLayerRenderer);
  44797. /**
  44798. * Updates the gizmo to match the attached mesh's position/rotation
  44799. */
  44800. protected _update(): void;
  44801. /**
  44802. * Disposes of the gizmo
  44803. */
  44804. dispose(): void;
  44805. }
  44806. }
  44807. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44808. import { Observable } from "babylonjs/Misc/observable";
  44809. import { Nullable } from "babylonjs/types";
  44810. import { Vector3 } from "babylonjs/Maths/math.vector";
  44811. import { Color3 } from "babylonjs/Maths/math.color";
  44812. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44814. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44815. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44816. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44817. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44818. import { Scene } from "babylonjs/scene";
  44819. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44820. /**
  44821. * Single plane drag gizmo
  44822. */
  44823. export class PlaneDragGizmo extends Gizmo {
  44824. /**
  44825. * Drag behavior responsible for the gizmos dragging interactions
  44826. */
  44827. dragBehavior: PointerDragBehavior;
  44828. private _pointerObserver;
  44829. /**
  44830. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44831. */
  44832. snapDistance: number;
  44833. /**
  44834. * Event that fires each time the gizmo snaps to a new location.
  44835. * * snapDistance is the the change in distance
  44836. */
  44837. onSnapObservable: Observable<{
  44838. snapDistance: number;
  44839. }>;
  44840. private _plane;
  44841. private _coloredMaterial;
  44842. private _hoverMaterial;
  44843. private _isEnabled;
  44844. private _parent;
  44845. /** @hidden */
  44846. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44847. /** @hidden */
  44848. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44849. /**
  44850. * Creates a PlaneDragGizmo
  44851. * @param gizmoLayer The utility layer the gizmo will be added to
  44852. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44853. * @param color The color of the gizmo
  44854. */
  44855. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44856. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44857. /**
  44858. * If the gizmo is enabled
  44859. */
  44860. isEnabled: boolean;
  44861. /**
  44862. * Disposes of the gizmo
  44863. */
  44864. dispose(): void;
  44865. }
  44866. }
  44867. declare module "babylonjs/Gizmos/positionGizmo" {
  44868. import { Observable } from "babylonjs/Misc/observable";
  44869. import { Nullable } from "babylonjs/types";
  44870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44871. import { Mesh } from "babylonjs/Meshes/mesh";
  44872. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44873. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44874. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44875. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44876. /**
  44877. * Gizmo that enables dragging a mesh along 3 axis
  44878. */
  44879. export class PositionGizmo extends Gizmo {
  44880. /**
  44881. * Internal gizmo used for interactions on the x axis
  44882. */
  44883. xGizmo: AxisDragGizmo;
  44884. /**
  44885. * Internal gizmo used for interactions on the y axis
  44886. */
  44887. yGizmo: AxisDragGizmo;
  44888. /**
  44889. * Internal gizmo used for interactions on the z axis
  44890. */
  44891. zGizmo: AxisDragGizmo;
  44892. /**
  44893. * Internal gizmo used for interactions on the yz plane
  44894. */
  44895. xPlaneGizmo: PlaneDragGizmo;
  44896. /**
  44897. * Internal gizmo used for interactions on the xz plane
  44898. */
  44899. yPlaneGizmo: PlaneDragGizmo;
  44900. /**
  44901. * Internal gizmo used for interactions on the xy plane
  44902. */
  44903. zPlaneGizmo: PlaneDragGizmo;
  44904. /**
  44905. * private variables
  44906. */
  44907. private _meshAttached;
  44908. private _updateGizmoRotationToMatchAttachedMesh;
  44909. private _snapDistance;
  44910. private _scaleRatio;
  44911. /** Fires an event when any of it's sub gizmos are dragged */
  44912. onDragStartObservable: Observable<unknown>;
  44913. /** Fires an event when any of it's sub gizmos are released from dragging */
  44914. onDragEndObservable: Observable<unknown>;
  44915. /**
  44916. * If set to true, planar drag is enabled
  44917. */
  44918. private _planarGizmoEnabled;
  44919. attachedMesh: Nullable<AbstractMesh>;
  44920. /**
  44921. * Creates a PositionGizmo
  44922. * @param gizmoLayer The utility layer the gizmo will be added to
  44923. */
  44924. constructor(gizmoLayer?: UtilityLayerRenderer);
  44925. /**
  44926. * If the planar drag gizmo is enabled
  44927. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44928. */
  44929. planarGizmoEnabled: boolean;
  44930. updateGizmoRotationToMatchAttachedMesh: boolean;
  44931. /**
  44932. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44933. */
  44934. snapDistance: number;
  44935. /**
  44936. * Ratio for the scale of the gizmo (Default: 1)
  44937. */
  44938. scaleRatio: number;
  44939. /**
  44940. * Disposes of the gizmo
  44941. */
  44942. dispose(): void;
  44943. /**
  44944. * CustomMeshes are not supported by this gizmo
  44945. * @param mesh The mesh to replace the default mesh of the gizmo
  44946. */
  44947. setCustomMesh(mesh: Mesh): void;
  44948. }
  44949. }
  44950. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44951. import { Observable } from "babylonjs/Misc/observable";
  44952. import { Nullable } from "babylonjs/types";
  44953. import { Vector3 } from "babylonjs/Maths/math.vector";
  44954. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44956. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44957. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44958. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44959. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44960. import { Scene } from "babylonjs/scene";
  44961. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44962. import { Color3 } from "babylonjs/Maths/math.color";
  44963. /**
  44964. * Single axis drag gizmo
  44965. */
  44966. export class AxisDragGizmo extends Gizmo {
  44967. /**
  44968. * Drag behavior responsible for the gizmos dragging interactions
  44969. */
  44970. dragBehavior: PointerDragBehavior;
  44971. private _pointerObserver;
  44972. /**
  44973. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44974. */
  44975. snapDistance: number;
  44976. /**
  44977. * Event that fires each time the gizmo snaps to a new location.
  44978. * * snapDistance is the the change in distance
  44979. */
  44980. onSnapObservable: Observable<{
  44981. snapDistance: number;
  44982. }>;
  44983. private _isEnabled;
  44984. private _parent;
  44985. private _arrow;
  44986. private _coloredMaterial;
  44987. private _hoverMaterial;
  44988. /** @hidden */
  44989. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44990. /** @hidden */
  44991. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44992. /**
  44993. * Creates an AxisDragGizmo
  44994. * @param gizmoLayer The utility layer the gizmo will be added to
  44995. * @param dragAxis The axis which the gizmo will be able to drag on
  44996. * @param color The color of the gizmo
  44997. */
  44998. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44999. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45000. /**
  45001. * If the gizmo is enabled
  45002. */
  45003. isEnabled: boolean;
  45004. /**
  45005. * Disposes of the gizmo
  45006. */
  45007. dispose(): void;
  45008. }
  45009. }
  45010. declare module "babylonjs/Debug/axesViewer" {
  45011. import { Vector3 } from "babylonjs/Maths/math.vector";
  45012. import { Nullable } from "babylonjs/types";
  45013. import { Scene } from "babylonjs/scene";
  45014. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45015. /**
  45016. * The Axes viewer will show 3 axes in a specific point in space
  45017. */
  45018. export class AxesViewer {
  45019. private _xAxis;
  45020. private _yAxis;
  45021. private _zAxis;
  45022. private _scaleLinesFactor;
  45023. private _instanced;
  45024. /**
  45025. * Gets the hosting scene
  45026. */
  45027. scene: Scene;
  45028. /**
  45029. * Gets or sets a number used to scale line length
  45030. */
  45031. scaleLines: number;
  45032. /** Gets the node hierarchy used to render x-axis */
  45033. readonly xAxis: TransformNode;
  45034. /** Gets the node hierarchy used to render y-axis */
  45035. readonly yAxis: TransformNode;
  45036. /** Gets the node hierarchy used to render z-axis */
  45037. readonly zAxis: TransformNode;
  45038. /**
  45039. * Creates a new AxesViewer
  45040. * @param scene defines the hosting scene
  45041. * @param scaleLines defines a number used to scale line length (1 by default)
  45042. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45043. * @param xAxis defines the node hierarchy used to render the x-axis
  45044. * @param yAxis defines the node hierarchy used to render the y-axis
  45045. * @param zAxis defines the node hierarchy used to render the z-axis
  45046. */
  45047. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45048. /**
  45049. * Force the viewer to update
  45050. * @param position defines the position of the viewer
  45051. * @param xaxis defines the x axis of the viewer
  45052. * @param yaxis defines the y axis of the viewer
  45053. * @param zaxis defines the z axis of the viewer
  45054. */
  45055. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45056. /**
  45057. * Creates an instance of this axes viewer.
  45058. * @returns a new axes viewer with instanced meshes
  45059. */
  45060. createInstance(): AxesViewer;
  45061. /** Releases resources */
  45062. dispose(): void;
  45063. private static _SetRenderingGroupId;
  45064. }
  45065. }
  45066. declare module "babylonjs/Debug/boneAxesViewer" {
  45067. import { Nullable } from "babylonjs/types";
  45068. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45069. import { Vector3 } from "babylonjs/Maths/math.vector";
  45070. import { Mesh } from "babylonjs/Meshes/mesh";
  45071. import { Bone } from "babylonjs/Bones/bone";
  45072. import { Scene } from "babylonjs/scene";
  45073. /**
  45074. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45075. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45076. */
  45077. export class BoneAxesViewer extends AxesViewer {
  45078. /**
  45079. * Gets or sets the target mesh where to display the axes viewer
  45080. */
  45081. mesh: Nullable<Mesh>;
  45082. /**
  45083. * Gets or sets the target bone where to display the axes viewer
  45084. */
  45085. bone: Nullable<Bone>;
  45086. /** Gets current position */
  45087. pos: Vector3;
  45088. /** Gets direction of X axis */
  45089. xaxis: Vector3;
  45090. /** Gets direction of Y axis */
  45091. yaxis: Vector3;
  45092. /** Gets direction of Z axis */
  45093. zaxis: Vector3;
  45094. /**
  45095. * Creates a new BoneAxesViewer
  45096. * @param scene defines the hosting scene
  45097. * @param bone defines the target bone
  45098. * @param mesh defines the target mesh
  45099. * @param scaleLines defines a scaling factor for line length (1 by default)
  45100. */
  45101. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45102. /**
  45103. * Force the viewer to update
  45104. */
  45105. update(): void;
  45106. /** Releases resources */
  45107. dispose(): void;
  45108. }
  45109. }
  45110. declare module "babylonjs/Debug/debugLayer" {
  45111. import { Scene } from "babylonjs/scene";
  45112. /**
  45113. * Interface used to define scene explorer extensibility option
  45114. */
  45115. export interface IExplorerExtensibilityOption {
  45116. /**
  45117. * Define the option label
  45118. */
  45119. label: string;
  45120. /**
  45121. * Defines the action to execute on click
  45122. */
  45123. action: (entity: any) => void;
  45124. }
  45125. /**
  45126. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45127. */
  45128. export interface IExplorerExtensibilityGroup {
  45129. /**
  45130. * Defines a predicate to test if a given type mut be extended
  45131. */
  45132. predicate: (entity: any) => boolean;
  45133. /**
  45134. * Gets the list of options added to a type
  45135. */
  45136. entries: IExplorerExtensibilityOption[];
  45137. }
  45138. /**
  45139. * Interface used to define the options to use to create the Inspector
  45140. */
  45141. export interface IInspectorOptions {
  45142. /**
  45143. * Display in overlay mode (default: false)
  45144. */
  45145. overlay?: boolean;
  45146. /**
  45147. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45148. */
  45149. globalRoot?: HTMLElement;
  45150. /**
  45151. * Display the Scene explorer
  45152. */
  45153. showExplorer?: boolean;
  45154. /**
  45155. * Display the property inspector
  45156. */
  45157. showInspector?: boolean;
  45158. /**
  45159. * Display in embed mode (both panes on the right)
  45160. */
  45161. embedMode?: boolean;
  45162. /**
  45163. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45164. */
  45165. handleResize?: boolean;
  45166. /**
  45167. * Allow the panes to popup (default: true)
  45168. */
  45169. enablePopup?: boolean;
  45170. /**
  45171. * Allow the panes to be closed by users (default: true)
  45172. */
  45173. enableClose?: boolean;
  45174. /**
  45175. * Optional list of extensibility entries
  45176. */
  45177. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45178. /**
  45179. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45180. */
  45181. inspectorURL?: string;
  45182. }
  45183. module "babylonjs/scene" {
  45184. interface Scene {
  45185. /**
  45186. * @hidden
  45187. * Backing field
  45188. */
  45189. _debugLayer: DebugLayer;
  45190. /**
  45191. * Gets the debug layer (aka Inspector) associated with the scene
  45192. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45193. */
  45194. debugLayer: DebugLayer;
  45195. }
  45196. }
  45197. /**
  45198. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45199. * what is happening in your scene
  45200. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45201. */
  45202. export class DebugLayer {
  45203. /**
  45204. * Define the url to get the inspector script from.
  45205. * By default it uses the babylonjs CDN.
  45206. * @ignoreNaming
  45207. */
  45208. static InspectorURL: string;
  45209. private _scene;
  45210. private BJSINSPECTOR;
  45211. private _onPropertyChangedObservable?;
  45212. /**
  45213. * Observable triggered when a property is changed through the inspector.
  45214. */
  45215. readonly onPropertyChangedObservable: any;
  45216. /**
  45217. * Instantiates a new debug layer.
  45218. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45219. * what is happening in your scene
  45220. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45221. * @param scene Defines the scene to inspect
  45222. */
  45223. constructor(scene: Scene);
  45224. /** Creates the inspector window. */
  45225. private _createInspector;
  45226. /**
  45227. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45228. * @param entity defines the entity to select
  45229. * @param lineContainerTitle defines the specific block to highlight
  45230. */
  45231. select(entity: any, lineContainerTitle?: string): void;
  45232. /** Get the inspector from bundle or global */
  45233. private _getGlobalInspector;
  45234. /**
  45235. * Get if the inspector is visible or not.
  45236. * @returns true if visible otherwise, false
  45237. */
  45238. isVisible(): boolean;
  45239. /**
  45240. * Hide the inspector and close its window.
  45241. */
  45242. hide(): void;
  45243. /**
  45244. * Launch the debugLayer.
  45245. * @param config Define the configuration of the inspector
  45246. * @return a promise fulfilled when the debug layer is visible
  45247. */
  45248. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45249. }
  45250. }
  45251. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45252. import { Nullable } from "babylonjs/types";
  45253. import { Scene } from "babylonjs/scene";
  45254. import { Vector4 } from "babylonjs/Maths/math.vector";
  45255. import { Color4 } from "babylonjs/Maths/math.color";
  45256. import { Mesh } from "babylonjs/Meshes/mesh";
  45257. /**
  45258. * Class containing static functions to help procedurally build meshes
  45259. */
  45260. export class BoxBuilder {
  45261. /**
  45262. * Creates a box mesh
  45263. * * The parameter `size` sets the size (float) of each box side (default 1)
  45264. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45265. * * 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)
  45266. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45270. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45271. * @param name defines the name of the mesh
  45272. * @param options defines the options used to create the mesh
  45273. * @param scene defines the hosting scene
  45274. * @returns the box mesh
  45275. */
  45276. static CreateBox(name: string, options: {
  45277. size?: number;
  45278. width?: number;
  45279. height?: number;
  45280. depth?: number;
  45281. faceUV?: Vector4[];
  45282. faceColors?: Color4[];
  45283. sideOrientation?: number;
  45284. frontUVs?: Vector4;
  45285. backUVs?: Vector4;
  45286. wrap?: boolean;
  45287. topBaseAt?: number;
  45288. bottomBaseAt?: number;
  45289. updatable?: boolean;
  45290. }, scene?: Nullable<Scene>): Mesh;
  45291. }
  45292. }
  45293. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45294. import { Vector4 } from "babylonjs/Maths/math.vector";
  45295. import { Mesh } from "babylonjs/Meshes/mesh";
  45296. import { Scene } from "babylonjs/scene";
  45297. import { Nullable } from "babylonjs/types";
  45298. /**
  45299. * Class containing static functions to help procedurally build meshes
  45300. */
  45301. export class SphereBuilder {
  45302. /**
  45303. * Creates a sphere mesh
  45304. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45305. * * 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`)
  45306. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45307. * * 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
  45308. * * 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)
  45309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45312. * @param name defines the name of the mesh
  45313. * @param options defines the options used to create the mesh
  45314. * @param scene defines the hosting scene
  45315. * @returns the sphere mesh
  45316. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45317. */
  45318. static CreateSphere(name: string, options: {
  45319. segments?: number;
  45320. diameter?: number;
  45321. diameterX?: number;
  45322. diameterY?: number;
  45323. diameterZ?: number;
  45324. arc?: number;
  45325. slice?: number;
  45326. sideOrientation?: number;
  45327. frontUVs?: Vector4;
  45328. backUVs?: Vector4;
  45329. updatable?: boolean;
  45330. }, scene?: Nullable<Scene>): Mesh;
  45331. }
  45332. }
  45333. declare module "babylonjs/Debug/physicsViewer" {
  45334. import { Nullable } from "babylonjs/types";
  45335. import { Scene } from "babylonjs/scene";
  45336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45337. import { Mesh } from "babylonjs/Meshes/mesh";
  45338. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45339. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45340. /**
  45341. * Used to show the physics impostor around the specific mesh
  45342. */
  45343. export class PhysicsViewer {
  45344. /** @hidden */
  45345. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45346. /** @hidden */
  45347. protected _meshes: Array<Nullable<AbstractMesh>>;
  45348. /** @hidden */
  45349. protected _scene: Nullable<Scene>;
  45350. /** @hidden */
  45351. protected _numMeshes: number;
  45352. /** @hidden */
  45353. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45354. private _renderFunction;
  45355. private _utilityLayer;
  45356. private _debugBoxMesh;
  45357. private _debugSphereMesh;
  45358. private _debugCylinderMesh;
  45359. private _debugMaterial;
  45360. private _debugMeshMeshes;
  45361. /**
  45362. * Creates a new PhysicsViewer
  45363. * @param scene defines the hosting scene
  45364. */
  45365. constructor(scene: Scene);
  45366. /** @hidden */
  45367. protected _updateDebugMeshes(): void;
  45368. /**
  45369. * Renders a specified physic impostor
  45370. * @param impostor defines the impostor to render
  45371. * @param targetMesh defines the mesh represented by the impostor
  45372. * @returns the new debug mesh used to render the impostor
  45373. */
  45374. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45375. /**
  45376. * Hides a specified physic impostor
  45377. * @param impostor defines the impostor to hide
  45378. */
  45379. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45380. private _getDebugMaterial;
  45381. private _getDebugBoxMesh;
  45382. private _getDebugSphereMesh;
  45383. private _getDebugCylinderMesh;
  45384. private _getDebugMeshMesh;
  45385. private _getDebugMesh;
  45386. /** Releases all resources */
  45387. dispose(): void;
  45388. }
  45389. }
  45390. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45391. import { Vector3 } from "babylonjs/Maths/math.vector";
  45392. import { Color4 } from "babylonjs/Maths/math.color";
  45393. import { Nullable } from "babylonjs/types";
  45394. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45395. import { Scene } from "babylonjs/scene";
  45396. /**
  45397. * Class containing static functions to help procedurally build meshes
  45398. */
  45399. export class LinesBuilder {
  45400. /**
  45401. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45402. * * 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
  45403. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45404. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45405. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45406. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45407. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45408. * * 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
  45409. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45412. * @param name defines the name of the new line system
  45413. * @param options defines the options used to create the line system
  45414. * @param scene defines the hosting scene
  45415. * @returns a new line system mesh
  45416. */
  45417. static CreateLineSystem(name: string, options: {
  45418. lines: Vector3[][];
  45419. updatable?: boolean;
  45420. instance?: Nullable<LinesMesh>;
  45421. colors?: Nullable<Color4[][]>;
  45422. useVertexAlpha?: boolean;
  45423. }, scene: Nullable<Scene>): LinesMesh;
  45424. /**
  45425. * Creates a line mesh
  45426. * 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
  45427. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45428. * * The parameter `points` is an array successive Vector3
  45429. * * 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
  45430. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45431. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45432. * * When updating an instance, remember that only point positions can change, not the number of points
  45433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45435. * @param name defines the name of the new line system
  45436. * @param options defines the options used to create the line system
  45437. * @param scene defines the hosting scene
  45438. * @returns a new line mesh
  45439. */
  45440. static CreateLines(name: string, options: {
  45441. points: Vector3[];
  45442. updatable?: boolean;
  45443. instance?: Nullable<LinesMesh>;
  45444. colors?: Color4[];
  45445. useVertexAlpha?: boolean;
  45446. }, scene?: Nullable<Scene>): LinesMesh;
  45447. /**
  45448. * Creates a dashed line mesh
  45449. * * 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
  45450. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45451. * * The parameter `points` is an array successive Vector3
  45452. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45453. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45454. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45455. * * 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
  45456. * * When updating an instance, remember that only point positions can change, not the number of points
  45457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45458. * @param name defines the name of the mesh
  45459. * @param options defines the options used to create the mesh
  45460. * @param scene defines the hosting scene
  45461. * @returns the dashed line mesh
  45462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45463. */
  45464. static CreateDashedLines(name: string, options: {
  45465. points: Vector3[];
  45466. dashSize?: number;
  45467. gapSize?: number;
  45468. dashNb?: number;
  45469. updatable?: boolean;
  45470. instance?: LinesMesh;
  45471. }, scene?: Nullable<Scene>): LinesMesh;
  45472. }
  45473. }
  45474. declare module "babylonjs/Debug/rayHelper" {
  45475. import { Nullable } from "babylonjs/types";
  45476. import { Ray } from "babylonjs/Culling/ray";
  45477. import { Vector3 } from "babylonjs/Maths/math.vector";
  45478. import { Color3 } from "babylonjs/Maths/math.color";
  45479. import { Scene } from "babylonjs/scene";
  45480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45481. import "babylonjs/Meshes/Builders/linesBuilder";
  45482. /**
  45483. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45484. * in order to better appreciate the issue one might have.
  45485. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45486. */
  45487. export class RayHelper {
  45488. /**
  45489. * Defines the ray we are currently tryin to visualize.
  45490. */
  45491. ray: Nullable<Ray>;
  45492. private _renderPoints;
  45493. private _renderLine;
  45494. private _renderFunction;
  45495. private _scene;
  45496. private _updateToMeshFunction;
  45497. private _attachedToMesh;
  45498. private _meshSpaceDirection;
  45499. private _meshSpaceOrigin;
  45500. /**
  45501. * Helper function to create a colored helper in a scene in one line.
  45502. * @param ray Defines the ray we are currently tryin to visualize
  45503. * @param scene Defines the scene the ray is used in
  45504. * @param color Defines the color we want to see the ray in
  45505. * @returns The newly created ray helper.
  45506. */
  45507. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45508. /**
  45509. * Instantiate a new ray helper.
  45510. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45511. * in order to better appreciate the issue one might have.
  45512. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45513. * @param ray Defines the ray we are currently tryin to visualize
  45514. */
  45515. constructor(ray: Ray);
  45516. /**
  45517. * Shows the ray we are willing to debug.
  45518. * @param scene Defines the scene the ray needs to be rendered in
  45519. * @param color Defines the color the ray needs to be rendered in
  45520. */
  45521. show(scene: Scene, color?: Color3): void;
  45522. /**
  45523. * Hides the ray we are debugging.
  45524. */
  45525. hide(): void;
  45526. private _render;
  45527. /**
  45528. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45529. * @param mesh Defines the mesh we want the helper attached to
  45530. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45531. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45532. * @param length Defines the length of the ray
  45533. */
  45534. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45535. /**
  45536. * Detach the ray helper from the mesh it has previously been attached to.
  45537. */
  45538. detachFromMesh(): void;
  45539. private _updateToMesh;
  45540. /**
  45541. * Dispose the helper and release its associated resources.
  45542. */
  45543. dispose(): void;
  45544. }
  45545. }
  45546. declare module "babylonjs/Debug/skeletonViewer" {
  45547. import { Color3 } from "babylonjs/Maths/math.color";
  45548. import { Scene } from "babylonjs/scene";
  45549. import { Nullable } from "babylonjs/types";
  45550. import { Skeleton } from "babylonjs/Bones/skeleton";
  45551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45552. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45553. /**
  45554. * Class used to render a debug view of a given skeleton
  45555. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45556. */
  45557. export class SkeletonViewer {
  45558. /** defines the skeleton to render */
  45559. skeleton: Skeleton;
  45560. /** defines the mesh attached to the skeleton */
  45561. mesh: AbstractMesh;
  45562. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45563. autoUpdateBonesMatrices: boolean;
  45564. /** defines the rendering group id to use with the viewer */
  45565. renderingGroupId: number;
  45566. /** Gets or sets the color used to render the skeleton */
  45567. color: Color3;
  45568. private _scene;
  45569. private _debugLines;
  45570. private _debugMesh;
  45571. private _isEnabled;
  45572. private _renderFunction;
  45573. private _utilityLayer;
  45574. /**
  45575. * Returns the mesh used to render the bones
  45576. */
  45577. readonly debugMesh: Nullable<LinesMesh>;
  45578. /**
  45579. * Creates a new SkeletonViewer
  45580. * @param skeleton defines the skeleton to render
  45581. * @param mesh defines the mesh attached to the skeleton
  45582. * @param scene defines the hosting scene
  45583. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45584. * @param renderingGroupId defines the rendering group id to use with the viewer
  45585. */
  45586. constructor(
  45587. /** defines the skeleton to render */
  45588. skeleton: Skeleton,
  45589. /** defines the mesh attached to the skeleton */
  45590. mesh: AbstractMesh, scene: Scene,
  45591. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45592. autoUpdateBonesMatrices?: boolean,
  45593. /** defines the rendering group id to use with the viewer */
  45594. renderingGroupId?: number);
  45595. /** Gets or sets a boolean indicating if the viewer is enabled */
  45596. isEnabled: boolean;
  45597. private _getBonePosition;
  45598. private _getLinesForBonesWithLength;
  45599. private _getLinesForBonesNoLength;
  45600. /** Update the viewer to sync with current skeleton state */
  45601. update(): void;
  45602. /** Release associated resources */
  45603. dispose(): void;
  45604. }
  45605. }
  45606. declare module "babylonjs/Debug/index" {
  45607. export * from "babylonjs/Debug/axesViewer";
  45608. export * from "babylonjs/Debug/boneAxesViewer";
  45609. export * from "babylonjs/Debug/debugLayer";
  45610. export * from "babylonjs/Debug/physicsViewer";
  45611. export * from "babylonjs/Debug/rayHelper";
  45612. export * from "babylonjs/Debug/skeletonViewer";
  45613. }
  45614. declare module "babylonjs/Engines/nullEngine" {
  45615. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45616. import { Scene } from "babylonjs/scene";
  45617. import { Engine } from "babylonjs/Engines/engine";
  45618. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45619. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45620. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45621. import { Effect } from "babylonjs/Materials/effect";
  45622. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45623. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45624. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45625. /**
  45626. * Options to create the null engine
  45627. */
  45628. export class NullEngineOptions {
  45629. /**
  45630. * Render width (Default: 512)
  45631. */
  45632. renderWidth: number;
  45633. /**
  45634. * Render height (Default: 256)
  45635. */
  45636. renderHeight: number;
  45637. /**
  45638. * Texture size (Default: 512)
  45639. */
  45640. textureSize: number;
  45641. /**
  45642. * If delta time between frames should be constant
  45643. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45644. */
  45645. deterministicLockstep: boolean;
  45646. /**
  45647. * Maximum about of steps between frames (Default: 4)
  45648. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45649. */
  45650. lockstepMaxSteps: number;
  45651. }
  45652. /**
  45653. * The null engine class provides support for headless version of babylon.js.
  45654. * This can be used in server side scenario or for testing purposes
  45655. */
  45656. export class NullEngine extends Engine {
  45657. private _options;
  45658. /**
  45659. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45660. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45661. * @returns true if engine is in deterministic lock step mode
  45662. */
  45663. isDeterministicLockStep(): boolean;
  45664. /**
  45665. * Gets the max steps when engine is running in deterministic lock step
  45666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45667. * @returns the max steps
  45668. */
  45669. getLockstepMaxSteps(): number;
  45670. /**
  45671. * Gets the current hardware scaling level.
  45672. * By default the hardware scaling level is computed from the window device ratio.
  45673. * 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.
  45674. * @returns a number indicating the current hardware scaling level
  45675. */
  45676. getHardwareScalingLevel(): number;
  45677. constructor(options?: NullEngineOptions);
  45678. /**
  45679. * Creates a vertex buffer
  45680. * @param vertices the data for the vertex buffer
  45681. * @returns the new WebGL static buffer
  45682. */
  45683. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45684. /**
  45685. * Creates a new index buffer
  45686. * @param indices defines the content of the index buffer
  45687. * @param updatable defines if the index buffer must be updatable
  45688. * @returns a new webGL buffer
  45689. */
  45690. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45691. /**
  45692. * Clear the current render buffer or the current render target (if any is set up)
  45693. * @param color defines the color to use
  45694. * @param backBuffer defines if the back buffer must be cleared
  45695. * @param depth defines if the depth buffer must be cleared
  45696. * @param stencil defines if the stencil buffer must be cleared
  45697. */
  45698. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45699. /**
  45700. * Gets the current render width
  45701. * @param useScreen defines if screen size must be used (or the current render target if any)
  45702. * @returns a number defining the current render width
  45703. */
  45704. getRenderWidth(useScreen?: boolean): number;
  45705. /**
  45706. * Gets the current render height
  45707. * @param useScreen defines if screen size must be used (or the current render target if any)
  45708. * @returns a number defining the current render height
  45709. */
  45710. getRenderHeight(useScreen?: boolean): number;
  45711. /**
  45712. * Set the WebGL's viewport
  45713. * @param viewport defines the viewport element to be used
  45714. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45715. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45716. */
  45717. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45718. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45719. /**
  45720. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45721. * @param pipelineContext defines the pipeline context to use
  45722. * @param uniformsNames defines the list of uniform names
  45723. * @returns an array of webGL uniform locations
  45724. */
  45725. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45726. /**
  45727. * Gets the lsit of active attributes for a given webGL program
  45728. * @param pipelineContext defines the pipeline context to use
  45729. * @param attributesNames defines the list of attribute names to get
  45730. * @returns an array of indices indicating the offset of each attribute
  45731. */
  45732. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45733. /**
  45734. * Binds an effect to the webGL context
  45735. * @param effect defines the effect to bind
  45736. */
  45737. bindSamplers(effect: Effect): void;
  45738. /**
  45739. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45740. * @param effect defines the effect to activate
  45741. */
  45742. enableEffect(effect: Effect): void;
  45743. /**
  45744. * Set various states to the webGL context
  45745. * @param culling defines backface culling state
  45746. * @param zOffset defines the value to apply to zOffset (0 by default)
  45747. * @param force defines if states must be applied even if cache is up to date
  45748. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45749. */
  45750. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45751. /**
  45752. * Set the value of an uniform to an array of int32
  45753. * @param uniform defines the webGL uniform location where to store the value
  45754. * @param array defines the array of int32 to store
  45755. */
  45756. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45757. /**
  45758. * Set the value of an uniform to an array of int32 (stored as vec2)
  45759. * @param uniform defines the webGL uniform location where to store the value
  45760. * @param array defines the array of int32 to store
  45761. */
  45762. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45763. /**
  45764. * Set the value of an uniform to an array of int32 (stored as vec3)
  45765. * @param uniform defines the webGL uniform location where to store the value
  45766. * @param array defines the array of int32 to store
  45767. */
  45768. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45769. /**
  45770. * Set the value of an uniform to an array of int32 (stored as vec4)
  45771. * @param uniform defines the webGL uniform location where to store the value
  45772. * @param array defines the array of int32 to store
  45773. */
  45774. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45775. /**
  45776. * Set the value of an uniform to an array of float32
  45777. * @param uniform defines the webGL uniform location where to store the value
  45778. * @param array defines the array of float32 to store
  45779. */
  45780. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45781. /**
  45782. * Set the value of an uniform to an array of float32 (stored as vec2)
  45783. * @param uniform defines the webGL uniform location where to store the value
  45784. * @param array defines the array of float32 to store
  45785. */
  45786. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45787. /**
  45788. * Set the value of an uniform to an array of float32 (stored as vec3)
  45789. * @param uniform defines the webGL uniform location where to store the value
  45790. * @param array defines the array of float32 to store
  45791. */
  45792. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45793. /**
  45794. * Set the value of an uniform to an array of float32 (stored as vec4)
  45795. * @param uniform defines the webGL uniform location where to store the value
  45796. * @param array defines the array of float32 to store
  45797. */
  45798. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45799. /**
  45800. * Set the value of an uniform to an array of number
  45801. * @param uniform defines the webGL uniform location where to store the value
  45802. * @param array defines the array of number to store
  45803. */
  45804. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45805. /**
  45806. * Set the value of an uniform to an array of number (stored as vec2)
  45807. * @param uniform defines the webGL uniform location where to store the value
  45808. * @param array defines the array of number to store
  45809. */
  45810. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45811. /**
  45812. * Set the value of an uniform to an array of number (stored as vec3)
  45813. * @param uniform defines the webGL uniform location where to store the value
  45814. * @param array defines the array of number to store
  45815. */
  45816. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45817. /**
  45818. * Set the value of an uniform to an array of number (stored as vec4)
  45819. * @param uniform defines the webGL uniform location where to store the value
  45820. * @param array defines the array of number to store
  45821. */
  45822. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45823. /**
  45824. * Set the value of an uniform to an array of float32 (stored as matrices)
  45825. * @param uniform defines the webGL uniform location where to store the value
  45826. * @param matrices defines the array of float32 to store
  45827. */
  45828. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45829. /**
  45830. * Set the value of an uniform to a matrix (3x3)
  45831. * @param uniform defines the webGL uniform location where to store the value
  45832. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45833. */
  45834. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45835. /**
  45836. * Set the value of an uniform to a matrix (2x2)
  45837. * @param uniform defines the webGL uniform location where to store the value
  45838. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45839. */
  45840. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45841. /**
  45842. * Set the value of an uniform to a number (float)
  45843. * @param uniform defines the webGL uniform location where to store the value
  45844. * @param value defines the float number to store
  45845. */
  45846. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45847. /**
  45848. * Set the value of an uniform to a vec2
  45849. * @param uniform defines the webGL uniform location where to store the value
  45850. * @param x defines the 1st component of the value
  45851. * @param y defines the 2nd component of the value
  45852. */
  45853. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45854. /**
  45855. * Set the value of an uniform to a vec3
  45856. * @param uniform defines the webGL uniform location where to store the value
  45857. * @param x defines the 1st component of the value
  45858. * @param y defines the 2nd component of the value
  45859. * @param z defines the 3rd component of the value
  45860. */
  45861. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45862. /**
  45863. * Set the value of an uniform to a boolean
  45864. * @param uniform defines the webGL uniform location where to store the value
  45865. * @param bool defines the boolean to store
  45866. */
  45867. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45868. /**
  45869. * Set the value of an uniform to a vec4
  45870. * @param uniform defines the webGL uniform location where to store the value
  45871. * @param x defines the 1st component of the value
  45872. * @param y defines the 2nd component of the value
  45873. * @param z defines the 3rd component of the value
  45874. * @param w defines the 4th component of the value
  45875. */
  45876. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45877. /**
  45878. * Sets the current alpha mode
  45879. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45880. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45881. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45882. */
  45883. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45884. /**
  45885. * Bind webGl buffers directly to the webGL context
  45886. * @param vertexBuffers defines the vertex buffer to bind
  45887. * @param indexBuffer defines the index buffer to bind
  45888. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45889. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45890. * @param effect defines the effect associated with the vertex buffer
  45891. */
  45892. bindBuffers(vertexBuffers: {
  45893. [key: string]: VertexBuffer;
  45894. }, indexBuffer: DataBuffer, effect: Effect): void;
  45895. /**
  45896. * Force the entire cache to be cleared
  45897. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45898. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45899. */
  45900. wipeCaches(bruteForce?: boolean): void;
  45901. /**
  45902. * Send a draw order
  45903. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45904. * @param indexStart defines the starting index
  45905. * @param indexCount defines the number of index to draw
  45906. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45907. */
  45908. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45909. /**
  45910. * Draw a list of indexed primitives
  45911. * @param fillMode defines the primitive to use
  45912. * @param indexStart defines the starting index
  45913. * @param indexCount defines the number of index to draw
  45914. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45915. */
  45916. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45917. /**
  45918. * Draw a list of unindexed primitives
  45919. * @param fillMode defines the primitive to use
  45920. * @param verticesStart defines the index of first vertex to draw
  45921. * @param verticesCount defines the count of vertices to draw
  45922. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45923. */
  45924. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45925. /** @hidden */
  45926. _createTexture(): WebGLTexture;
  45927. /** @hidden */
  45928. _releaseTexture(texture: InternalTexture): void;
  45929. /**
  45930. * Usually called from Texture.ts.
  45931. * Passed information to create a WebGLTexture
  45932. * @param urlArg defines a value which contains one of the following:
  45933. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45934. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45935. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45936. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45937. * @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)
  45938. * @param scene needed for loading to the correct scene
  45939. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45940. * @param onLoad optional callback to be called upon successful completion
  45941. * @param onError optional callback to be called upon failure
  45942. * @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
  45943. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45944. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45945. * @param forcedExtension defines the extension to use to pick the right loader
  45946. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45947. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45948. */
  45949. 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;
  45950. /**
  45951. * Creates a new render target texture
  45952. * @param size defines the size of the texture
  45953. * @param options defines the options used to create the texture
  45954. * @returns a new render target texture stored in an InternalTexture
  45955. */
  45956. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45957. /**
  45958. * Update the sampling mode of a given texture
  45959. * @param samplingMode defines the required sampling mode
  45960. * @param texture defines the texture to update
  45961. */
  45962. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45963. /**
  45964. * Binds the frame buffer to the specified texture.
  45965. * @param texture The texture to render to or null for the default canvas
  45966. * @param faceIndex The face of the texture to render to in case of cube texture
  45967. * @param requiredWidth The width of the target to render to
  45968. * @param requiredHeight The height of the target to render to
  45969. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45970. * @param depthStencilTexture The depth stencil texture to use to render
  45971. * @param lodLevel defines le lod level to bind to the frame buffer
  45972. */
  45973. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45974. /**
  45975. * Unbind the current render target texture from the webGL context
  45976. * @param texture defines the render target texture to unbind
  45977. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45978. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45979. */
  45980. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45981. /**
  45982. * Creates a dynamic vertex buffer
  45983. * @param vertices the data for the dynamic vertex buffer
  45984. * @returns the new WebGL dynamic buffer
  45985. */
  45986. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45987. /**
  45988. * Update the content of a dynamic texture
  45989. * @param texture defines the texture to update
  45990. * @param canvas defines the canvas containing the source
  45991. * @param invertY defines if data must be stored with Y axis inverted
  45992. * @param premulAlpha defines if alpha is stored as premultiplied
  45993. * @param format defines the format of the data
  45994. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45995. */
  45996. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45997. /**
  45998. * Gets a boolean indicating if all created effects are ready
  45999. * @returns true if all effects are ready
  46000. */
  46001. areAllEffectsReady(): boolean;
  46002. /**
  46003. * @hidden
  46004. * Get the current error code of the webGL context
  46005. * @returns the error code
  46006. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46007. */
  46008. getError(): number;
  46009. /** @hidden */
  46010. _getUnpackAlignement(): number;
  46011. /** @hidden */
  46012. _unpackFlipY(value: boolean): void;
  46013. /**
  46014. * Update a dynamic index buffer
  46015. * @param indexBuffer defines the target index buffer
  46016. * @param indices defines the data to update
  46017. * @param offset defines the offset in the target index buffer where update should start
  46018. */
  46019. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46020. /**
  46021. * Updates a dynamic vertex buffer.
  46022. * @param vertexBuffer the vertex buffer to update
  46023. * @param vertices the data used to update the vertex buffer
  46024. * @param byteOffset the byte offset of the data (optional)
  46025. * @param byteLength the byte length of the data (optional)
  46026. */
  46027. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46028. /** @hidden */
  46029. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46030. /** @hidden */
  46031. _bindTexture(channel: number, texture: InternalTexture): void;
  46032. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46033. /**
  46034. * 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
  46035. */
  46036. releaseEffects(): void;
  46037. displayLoadingUI(): void;
  46038. hideLoadingUI(): void;
  46039. /** @hidden */
  46040. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46041. /** @hidden */
  46042. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46043. /** @hidden */
  46044. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46045. /** @hidden */
  46046. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46047. }
  46048. }
  46049. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46050. import { Nullable, int } from "babylonjs/types";
  46051. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46052. /** @hidden */
  46053. export class _OcclusionDataStorage {
  46054. /** @hidden */
  46055. occlusionInternalRetryCounter: number;
  46056. /** @hidden */
  46057. isOcclusionQueryInProgress: boolean;
  46058. /** @hidden */
  46059. isOccluded: boolean;
  46060. /** @hidden */
  46061. occlusionRetryCount: number;
  46062. /** @hidden */
  46063. occlusionType: number;
  46064. /** @hidden */
  46065. occlusionQueryAlgorithmType: number;
  46066. }
  46067. module "babylonjs/Engines/engine" {
  46068. interface Engine {
  46069. /**
  46070. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46071. * @return the new query
  46072. */
  46073. createQuery(): WebGLQuery;
  46074. /**
  46075. * Delete and release a webGL query
  46076. * @param query defines the query to delete
  46077. * @return the current engine
  46078. */
  46079. deleteQuery(query: WebGLQuery): Engine;
  46080. /**
  46081. * Check if a given query has resolved and got its value
  46082. * @param query defines the query to check
  46083. * @returns true if the query got its value
  46084. */
  46085. isQueryResultAvailable(query: WebGLQuery): boolean;
  46086. /**
  46087. * Gets the value of a given query
  46088. * @param query defines the query to check
  46089. * @returns the value of the query
  46090. */
  46091. getQueryResult(query: WebGLQuery): number;
  46092. /**
  46093. * Initiates an occlusion query
  46094. * @param algorithmType defines the algorithm to use
  46095. * @param query defines the query to use
  46096. * @returns the current engine
  46097. * @see http://doc.babylonjs.com/features/occlusionquery
  46098. */
  46099. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46100. /**
  46101. * Ends an occlusion query
  46102. * @see http://doc.babylonjs.com/features/occlusionquery
  46103. * @param algorithmType defines the algorithm to use
  46104. * @returns the current engine
  46105. */
  46106. endOcclusionQuery(algorithmType: number): Engine;
  46107. /**
  46108. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46109. * Please note that only one query can be issued at a time
  46110. * @returns a time token used to track the time span
  46111. */
  46112. startTimeQuery(): Nullable<_TimeToken>;
  46113. /**
  46114. * Ends a time query
  46115. * @param token defines the token used to measure the time span
  46116. * @returns the time spent (in ns)
  46117. */
  46118. endTimeQuery(token: _TimeToken): int;
  46119. /** @hidden */
  46120. _currentNonTimestampToken: Nullable<_TimeToken>;
  46121. /** @hidden */
  46122. _createTimeQuery(): WebGLQuery;
  46123. /** @hidden */
  46124. _deleteTimeQuery(query: WebGLQuery): void;
  46125. /** @hidden */
  46126. _getGlAlgorithmType(algorithmType: number): number;
  46127. /** @hidden */
  46128. _getTimeQueryResult(query: WebGLQuery): any;
  46129. /** @hidden */
  46130. _getTimeQueryAvailability(query: WebGLQuery): any;
  46131. }
  46132. }
  46133. module "babylonjs/Meshes/abstractMesh" {
  46134. interface AbstractMesh {
  46135. /**
  46136. * Backing filed
  46137. * @hidden
  46138. */
  46139. __occlusionDataStorage: _OcclusionDataStorage;
  46140. /**
  46141. * Access property
  46142. * @hidden
  46143. */
  46144. _occlusionDataStorage: _OcclusionDataStorage;
  46145. /**
  46146. * 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.
  46147. * The default value is -1 which means don't break the query and wait till the result
  46148. * @see http://doc.babylonjs.com/features/occlusionquery
  46149. */
  46150. occlusionRetryCount: number;
  46151. /**
  46152. * 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:
  46153. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46154. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46155. * * 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.
  46156. * @see http://doc.babylonjs.com/features/occlusionquery
  46157. */
  46158. occlusionType: number;
  46159. /**
  46160. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46161. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46162. * * 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.
  46163. * @see http://doc.babylonjs.com/features/occlusionquery
  46164. */
  46165. occlusionQueryAlgorithmType: number;
  46166. /**
  46167. * 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
  46168. * @see http://doc.babylonjs.com/features/occlusionquery
  46169. */
  46170. isOccluded: boolean;
  46171. /**
  46172. * Flag to check the progress status of the query
  46173. * @see http://doc.babylonjs.com/features/occlusionquery
  46174. */
  46175. isOcclusionQueryInProgress: boolean;
  46176. }
  46177. }
  46178. }
  46179. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46180. import { Nullable } from "babylonjs/types";
  46181. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46182. /** @hidden */
  46183. export var _forceTransformFeedbackToBundle: boolean;
  46184. module "babylonjs/Engines/engine" {
  46185. interface Engine {
  46186. /**
  46187. * Creates a webGL transform feedback object
  46188. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46189. * @returns the webGL transform feedback object
  46190. */
  46191. createTransformFeedback(): WebGLTransformFeedback;
  46192. /**
  46193. * Delete a webGL transform feedback object
  46194. * @param value defines the webGL transform feedback object to delete
  46195. */
  46196. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46197. /**
  46198. * Bind a webGL transform feedback object to the webgl context
  46199. * @param value defines the webGL transform feedback object to bind
  46200. */
  46201. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46202. /**
  46203. * Begins a transform feedback operation
  46204. * @param usePoints defines if points or triangles must be used
  46205. */
  46206. beginTransformFeedback(usePoints: boolean): void;
  46207. /**
  46208. * Ends a transform feedback operation
  46209. */
  46210. endTransformFeedback(): void;
  46211. /**
  46212. * Specify the varyings to use with transform feedback
  46213. * @param program defines the associated webGL program
  46214. * @param value defines the list of strings representing the varying names
  46215. */
  46216. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46217. /**
  46218. * Bind a webGL buffer for a transform feedback operation
  46219. * @param value defines the webGL buffer to bind
  46220. */
  46221. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46222. }
  46223. }
  46224. }
  46225. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46226. import { Scene } from "babylonjs/scene";
  46227. import { Engine } from "babylonjs/Engines/engine";
  46228. import { Texture } from "babylonjs/Materials/Textures/texture";
  46229. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46230. import "babylonjs/Engines/Extensions/engine.multiRender";
  46231. /**
  46232. * Creation options of the multi render target texture.
  46233. */
  46234. export interface IMultiRenderTargetOptions {
  46235. /**
  46236. * Define if the texture needs to create mip maps after render.
  46237. */
  46238. generateMipMaps?: boolean;
  46239. /**
  46240. * Define the types of all the draw buffers we want to create
  46241. */
  46242. types?: number[];
  46243. /**
  46244. * Define the sampling modes of all the draw buffers we want to create
  46245. */
  46246. samplingModes?: number[];
  46247. /**
  46248. * Define if a depth buffer is required
  46249. */
  46250. generateDepthBuffer?: boolean;
  46251. /**
  46252. * Define if a stencil buffer is required
  46253. */
  46254. generateStencilBuffer?: boolean;
  46255. /**
  46256. * Define if a depth texture is required instead of a depth buffer
  46257. */
  46258. generateDepthTexture?: boolean;
  46259. /**
  46260. * Define the number of desired draw buffers
  46261. */
  46262. textureCount?: number;
  46263. /**
  46264. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46265. */
  46266. doNotChangeAspectRatio?: boolean;
  46267. /**
  46268. * Define the default type of the buffers we are creating
  46269. */
  46270. defaultType?: number;
  46271. }
  46272. /**
  46273. * A multi render target, like a render target provides the ability to render to a texture.
  46274. * Unlike the render target, it can render to several draw buffers in one draw.
  46275. * This is specially interesting in deferred rendering or for any effects requiring more than
  46276. * just one color from a single pass.
  46277. */
  46278. export class MultiRenderTarget extends RenderTargetTexture {
  46279. private _internalTextures;
  46280. private _textures;
  46281. private _multiRenderTargetOptions;
  46282. /**
  46283. * Get if draw buffers are currently supported by the used hardware and browser.
  46284. */
  46285. readonly isSupported: boolean;
  46286. /**
  46287. * Get the list of textures generated by the multi render target.
  46288. */
  46289. readonly textures: Texture[];
  46290. /**
  46291. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46292. */
  46293. readonly depthTexture: Texture;
  46294. /**
  46295. * Set the wrapping mode on U of all the textures we are rendering to.
  46296. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46297. */
  46298. wrapU: number;
  46299. /**
  46300. * Set the wrapping mode on V of all the textures we are rendering to.
  46301. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46302. */
  46303. wrapV: number;
  46304. /**
  46305. * Instantiate a new multi render target texture.
  46306. * A multi render target, like a render target provides the ability to render to a texture.
  46307. * Unlike the render target, it can render to several draw buffers in one draw.
  46308. * This is specially interesting in deferred rendering or for any effects requiring more than
  46309. * just one color from a single pass.
  46310. * @param name Define the name of the texture
  46311. * @param size Define the size of the buffers to render to
  46312. * @param count Define the number of target we are rendering into
  46313. * @param scene Define the scene the texture belongs to
  46314. * @param options Define the options used to create the multi render target
  46315. */
  46316. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46317. /** @hidden */
  46318. _rebuild(): void;
  46319. private _createInternalTextures;
  46320. private _createTextures;
  46321. /**
  46322. * Define the number of samples used if MSAA is enabled.
  46323. */
  46324. samples: number;
  46325. /**
  46326. * Resize all the textures in the multi render target.
  46327. * Be carrefull as it will recreate all the data in the new texture.
  46328. * @param size Define the new size
  46329. */
  46330. resize(size: any): void;
  46331. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46332. /**
  46333. * Dispose the render targets and their associated resources
  46334. */
  46335. dispose(): void;
  46336. /**
  46337. * Release all the underlying texture used as draw buffers.
  46338. */
  46339. releaseInternalTextures(): void;
  46340. }
  46341. }
  46342. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46343. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46344. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46345. import { Nullable } from "babylonjs/types";
  46346. module "babylonjs/Engines/thinEngine" {
  46347. interface ThinEngine {
  46348. /**
  46349. * Unbind a list of render target textures from the webGL context
  46350. * This is used only when drawBuffer extension or webGL2 are active
  46351. * @param textures defines the render target textures to unbind
  46352. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46353. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46354. */
  46355. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46356. /**
  46357. * Create a multi render target texture
  46358. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46359. * @param size defines the size of the texture
  46360. * @param options defines the creation options
  46361. * @returns the cube texture as an InternalTexture
  46362. */
  46363. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46364. /**
  46365. * Update the sample count for a given multiple render target texture
  46366. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46367. * @param textures defines the textures to update
  46368. * @param samples defines the sample count to set
  46369. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46370. */
  46371. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46372. }
  46373. }
  46374. }
  46375. declare module "babylonjs/Engines/Extensions/engine.views" {
  46376. import { Camera } from "babylonjs/Cameras/camera";
  46377. import { Nullable } from "babylonjs/types";
  46378. /**
  46379. * Class used to define an additional view for the engine
  46380. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46381. */
  46382. export class EngineView {
  46383. /** Defines the canvas where to render the view */
  46384. target: HTMLCanvasElement;
  46385. /** Defines an optional camera used to render the view (will use active camera else) */
  46386. camera?: Camera;
  46387. }
  46388. module "babylonjs/Engines/engine" {
  46389. interface Engine {
  46390. /**
  46391. * Gets or sets the HTML element to use for attaching events
  46392. */
  46393. inputElement: Nullable<HTMLElement>;
  46394. /**
  46395. * Gets the current engine view
  46396. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46397. */
  46398. activeView: Nullable<EngineView>;
  46399. /** Gets or sets the list of views */
  46400. views: EngineView[];
  46401. /**
  46402. * Register a new child canvas
  46403. * @param canvas defines the canvas to register
  46404. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46405. * @returns the associated view
  46406. */
  46407. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46408. /**
  46409. * Remove a registered child canvas
  46410. * @param canvas defines the canvas to remove
  46411. * @returns the current engine
  46412. */
  46413. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46414. }
  46415. }
  46416. }
  46417. declare module "babylonjs/Engines/Extensions/index" {
  46418. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46419. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46420. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46421. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46422. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46423. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46424. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46425. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46426. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46427. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46428. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46429. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46430. export * from "babylonjs/Engines/Extensions/engine.views";
  46431. }
  46432. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46433. import { Nullable } from "babylonjs/types";
  46434. /**
  46435. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46436. */
  46437. export interface CubeMapInfo {
  46438. /**
  46439. * The pixel array for the front face.
  46440. * This is stored in format, left to right, up to down format.
  46441. */
  46442. front: Nullable<ArrayBufferView>;
  46443. /**
  46444. * The pixel array for the back face.
  46445. * This is stored in format, left to right, up to down format.
  46446. */
  46447. back: Nullable<ArrayBufferView>;
  46448. /**
  46449. * The pixel array for the left face.
  46450. * This is stored in format, left to right, up to down format.
  46451. */
  46452. left: Nullable<ArrayBufferView>;
  46453. /**
  46454. * The pixel array for the right face.
  46455. * This is stored in format, left to right, up to down format.
  46456. */
  46457. right: Nullable<ArrayBufferView>;
  46458. /**
  46459. * The pixel array for the up face.
  46460. * This is stored in format, left to right, up to down format.
  46461. */
  46462. up: Nullable<ArrayBufferView>;
  46463. /**
  46464. * The pixel array for the down face.
  46465. * This is stored in format, left to right, up to down format.
  46466. */
  46467. down: Nullable<ArrayBufferView>;
  46468. /**
  46469. * The size of the cubemap stored.
  46470. *
  46471. * Each faces will be size * size pixels.
  46472. */
  46473. size: number;
  46474. /**
  46475. * The format of the texture.
  46476. *
  46477. * RGBA, RGB.
  46478. */
  46479. format: number;
  46480. /**
  46481. * The type of the texture data.
  46482. *
  46483. * UNSIGNED_INT, FLOAT.
  46484. */
  46485. type: number;
  46486. /**
  46487. * Specifies whether the texture is in gamma space.
  46488. */
  46489. gammaSpace: boolean;
  46490. }
  46491. /**
  46492. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46493. */
  46494. export class PanoramaToCubeMapTools {
  46495. private static FACE_FRONT;
  46496. private static FACE_BACK;
  46497. private static FACE_RIGHT;
  46498. private static FACE_LEFT;
  46499. private static FACE_DOWN;
  46500. private static FACE_UP;
  46501. /**
  46502. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46503. *
  46504. * @param float32Array The source data.
  46505. * @param inputWidth The width of the input panorama.
  46506. * @param inputHeight The height of the input panorama.
  46507. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46508. * @return The cubemap data
  46509. */
  46510. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46511. private static CreateCubemapTexture;
  46512. private static CalcProjectionSpherical;
  46513. }
  46514. }
  46515. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46516. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46517. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46518. import { Nullable } from "babylonjs/types";
  46519. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46520. /**
  46521. * Helper class dealing with the extraction of spherical polynomial dataArray
  46522. * from a cube map.
  46523. */
  46524. export class CubeMapToSphericalPolynomialTools {
  46525. private static FileFaces;
  46526. /**
  46527. * Converts a texture to the according Spherical Polynomial data.
  46528. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46529. *
  46530. * @param texture The texture to extract the information from.
  46531. * @return The Spherical Polynomial data.
  46532. */
  46533. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46534. /**
  46535. * Converts a cubemap to the according Spherical Polynomial data.
  46536. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46537. *
  46538. * @param cubeInfo The Cube map to extract the information from.
  46539. * @return The Spherical Polynomial data.
  46540. */
  46541. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46542. }
  46543. }
  46544. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46545. import { Nullable } from "babylonjs/types";
  46546. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46547. module "babylonjs/Materials/Textures/baseTexture" {
  46548. interface BaseTexture {
  46549. /**
  46550. * Get the polynomial representation of the texture data.
  46551. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46552. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46553. */
  46554. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46555. }
  46556. }
  46557. }
  46558. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46560. /** @hidden */
  46561. export var rgbdEncodePixelShader: {
  46562. name: string;
  46563. shader: string;
  46564. };
  46565. }
  46566. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46568. /** @hidden */
  46569. export var rgbdDecodePixelShader: {
  46570. name: string;
  46571. shader: string;
  46572. };
  46573. }
  46574. declare module "babylonjs/Misc/environmentTextureTools" {
  46575. import { Nullable } from "babylonjs/types";
  46576. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46578. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46579. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46580. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46581. import "babylonjs/Shaders/rgbdEncode.fragment";
  46582. import "babylonjs/Shaders/rgbdDecode.fragment";
  46583. /**
  46584. * Raw texture data and descriptor sufficient for WebGL texture upload
  46585. */
  46586. export interface EnvironmentTextureInfo {
  46587. /**
  46588. * Version of the environment map
  46589. */
  46590. version: number;
  46591. /**
  46592. * Width of image
  46593. */
  46594. width: number;
  46595. /**
  46596. * Irradiance information stored in the file.
  46597. */
  46598. irradiance: any;
  46599. /**
  46600. * Specular information stored in the file.
  46601. */
  46602. specular: any;
  46603. }
  46604. /**
  46605. * Defines One Image in the file. It requires only the position in the file
  46606. * as well as the length.
  46607. */
  46608. interface BufferImageData {
  46609. /**
  46610. * Length of the image data.
  46611. */
  46612. length: number;
  46613. /**
  46614. * Position of the data from the null terminator delimiting the end of the JSON.
  46615. */
  46616. position: number;
  46617. }
  46618. /**
  46619. * Defines the specular data enclosed in the file.
  46620. * This corresponds to the version 1 of the data.
  46621. */
  46622. export interface EnvironmentTextureSpecularInfoV1 {
  46623. /**
  46624. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46625. */
  46626. specularDataPosition?: number;
  46627. /**
  46628. * This contains all the images data needed to reconstruct the cubemap.
  46629. */
  46630. mipmaps: Array<BufferImageData>;
  46631. /**
  46632. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46633. */
  46634. lodGenerationScale: number;
  46635. }
  46636. /**
  46637. * Sets of helpers addressing the serialization and deserialization of environment texture
  46638. * stored in a BabylonJS env file.
  46639. * Those files are usually stored as .env files.
  46640. */
  46641. export class EnvironmentTextureTools {
  46642. /**
  46643. * Magic number identifying the env file.
  46644. */
  46645. private static _MagicBytes;
  46646. /**
  46647. * Gets the environment info from an env file.
  46648. * @param data The array buffer containing the .env bytes.
  46649. * @returns the environment file info (the json header) if successfully parsed.
  46650. */
  46651. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46652. /**
  46653. * Creates an environment texture from a loaded cube texture.
  46654. * @param texture defines the cube texture to convert in env file
  46655. * @return a promise containing the environment data if succesfull.
  46656. */
  46657. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46658. /**
  46659. * Creates a JSON representation of the spherical data.
  46660. * @param texture defines the texture containing the polynomials
  46661. * @return the JSON representation of the spherical info
  46662. */
  46663. private static _CreateEnvTextureIrradiance;
  46664. /**
  46665. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46666. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46667. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46668. * @return the views described by info providing access to the underlying buffer
  46669. */
  46670. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46671. /**
  46672. * Uploads the texture info contained in the env file to the GPU.
  46673. * @param texture defines the internal texture to upload to
  46674. * @param arrayBuffer defines the buffer cotaining the data to load
  46675. * @param info defines the texture info retrieved through the GetEnvInfo method
  46676. * @returns a promise
  46677. */
  46678. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46679. private static _OnImageReadyAsync;
  46680. /**
  46681. * Uploads the levels of image data to the GPU.
  46682. * @param texture defines the internal texture to upload to
  46683. * @param imageData defines the array buffer views of image data [mipmap][face]
  46684. * @returns a promise
  46685. */
  46686. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46687. /**
  46688. * Uploads spherical polynomials information to the texture.
  46689. * @param texture defines the texture we are trying to upload the information to
  46690. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46691. */
  46692. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46693. /** @hidden */
  46694. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46695. }
  46696. }
  46697. declare module "babylonjs/Maths/math.vertexFormat" {
  46698. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46699. /**
  46700. * Contains position and normal vectors for a vertex
  46701. */
  46702. export class PositionNormalVertex {
  46703. /** the position of the vertex (defaut: 0,0,0) */
  46704. position: Vector3;
  46705. /** the normal of the vertex (defaut: 0,1,0) */
  46706. normal: Vector3;
  46707. /**
  46708. * Creates a PositionNormalVertex
  46709. * @param position the position of the vertex (defaut: 0,0,0)
  46710. * @param normal the normal of the vertex (defaut: 0,1,0)
  46711. */
  46712. constructor(
  46713. /** the position of the vertex (defaut: 0,0,0) */
  46714. position?: Vector3,
  46715. /** the normal of the vertex (defaut: 0,1,0) */
  46716. normal?: Vector3);
  46717. /**
  46718. * Clones the PositionNormalVertex
  46719. * @returns the cloned PositionNormalVertex
  46720. */
  46721. clone(): PositionNormalVertex;
  46722. }
  46723. /**
  46724. * Contains position, normal and uv vectors for a vertex
  46725. */
  46726. export class PositionNormalTextureVertex {
  46727. /** the position of the vertex (defaut: 0,0,0) */
  46728. position: Vector3;
  46729. /** the normal of the vertex (defaut: 0,1,0) */
  46730. normal: Vector3;
  46731. /** the uv of the vertex (default: 0,0) */
  46732. uv: Vector2;
  46733. /**
  46734. * Creates a PositionNormalTextureVertex
  46735. * @param position the position of the vertex (defaut: 0,0,0)
  46736. * @param normal the normal of the vertex (defaut: 0,1,0)
  46737. * @param uv the uv of the vertex (default: 0,0)
  46738. */
  46739. constructor(
  46740. /** the position of the vertex (defaut: 0,0,0) */
  46741. position?: Vector3,
  46742. /** the normal of the vertex (defaut: 0,1,0) */
  46743. normal?: Vector3,
  46744. /** the uv of the vertex (default: 0,0) */
  46745. uv?: Vector2);
  46746. /**
  46747. * Clones the PositionNormalTextureVertex
  46748. * @returns the cloned PositionNormalTextureVertex
  46749. */
  46750. clone(): PositionNormalTextureVertex;
  46751. }
  46752. }
  46753. declare module "babylonjs/Maths/math" {
  46754. export * from "babylonjs/Maths/math.axis";
  46755. export * from "babylonjs/Maths/math.color";
  46756. export * from "babylonjs/Maths/math.constants";
  46757. export * from "babylonjs/Maths/math.frustum";
  46758. export * from "babylonjs/Maths/math.path";
  46759. export * from "babylonjs/Maths/math.plane";
  46760. export * from "babylonjs/Maths/math.size";
  46761. export * from "babylonjs/Maths/math.vector";
  46762. export * from "babylonjs/Maths/math.vertexFormat";
  46763. export * from "babylonjs/Maths/math.viewport";
  46764. }
  46765. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46766. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46767. /** @hidden */
  46768. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46769. private _genericAttributeLocation;
  46770. private _varyingLocationCount;
  46771. private _varyingLocationMap;
  46772. private _replacements;
  46773. private _textureCount;
  46774. private _uniforms;
  46775. lineProcessor(line: string): string;
  46776. attributeProcessor(attribute: string): string;
  46777. varyingProcessor(varying: string, isFragment: boolean): string;
  46778. uniformProcessor(uniform: string): string;
  46779. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46780. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46781. }
  46782. }
  46783. declare module "babylonjs/Engines/nativeEngine" {
  46784. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46785. import { Engine } from "babylonjs/Engines/engine";
  46786. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46787. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46789. import { Effect } from "babylonjs/Materials/effect";
  46790. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46791. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46792. import { Scene } from "babylonjs/scene";
  46793. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46794. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46795. /**
  46796. * Container for accessors for natively-stored mesh data buffers.
  46797. */
  46798. class NativeDataBuffer extends DataBuffer {
  46799. /**
  46800. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46801. */
  46802. nativeIndexBuffer?: any;
  46803. /**
  46804. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46805. */
  46806. nativeVertexBuffer?: any;
  46807. }
  46808. /** @hidden */
  46809. class NativeTexture extends InternalTexture {
  46810. getInternalTexture(): InternalTexture;
  46811. getViewCount(): number;
  46812. }
  46813. /** @hidden */
  46814. export class NativeEngine extends Engine {
  46815. private readonly _native;
  46816. getHardwareScalingLevel(): number;
  46817. constructor();
  46818. /**
  46819. * Can be used to override the current requestAnimationFrame requester.
  46820. * @hidden
  46821. */
  46822. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46823. /**
  46824. * Override default engine behavior.
  46825. * @param color
  46826. * @param backBuffer
  46827. * @param depth
  46828. * @param stencil
  46829. */
  46830. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46831. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46832. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46833. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46834. recordVertexArrayObject(vertexBuffers: {
  46835. [key: string]: VertexBuffer;
  46836. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46837. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46838. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46839. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46840. /**
  46841. * Draw a list of indexed primitives
  46842. * @param fillMode defines the primitive to use
  46843. * @param indexStart defines the starting index
  46844. * @param indexCount defines the number of index to draw
  46845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46846. */
  46847. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46848. /**
  46849. * Draw a list of unindexed primitives
  46850. * @param fillMode defines the primitive to use
  46851. * @param verticesStart defines the index of first vertex to draw
  46852. * @param verticesCount defines the count of vertices to draw
  46853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46854. */
  46855. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46856. createPipelineContext(): IPipelineContext;
  46857. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46858. /** @hidden */
  46859. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46860. /** @hidden */
  46861. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46862. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46863. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46864. protected _setProgram(program: WebGLProgram): void;
  46865. _releaseEffect(effect: Effect): void;
  46866. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46867. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46868. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46869. bindSamplers(effect: Effect): void;
  46870. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46871. getRenderWidth(useScreen?: boolean): number;
  46872. getRenderHeight(useScreen?: boolean): number;
  46873. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46874. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46875. /**
  46876. * Set the z offset to apply to current rendering
  46877. * @param value defines the offset to apply
  46878. */
  46879. setZOffset(value: number): void;
  46880. /**
  46881. * Gets the current value of the zOffset
  46882. * @returns the current zOffset state
  46883. */
  46884. getZOffset(): number;
  46885. /**
  46886. * Enable or disable depth buffering
  46887. * @param enable defines the state to set
  46888. */
  46889. setDepthBuffer(enable: boolean): void;
  46890. /**
  46891. * Gets a boolean indicating if depth writing is enabled
  46892. * @returns the current depth writing state
  46893. */
  46894. getDepthWrite(): boolean;
  46895. /**
  46896. * Enable or disable depth writing
  46897. * @param enable defines the state to set
  46898. */
  46899. setDepthWrite(enable: boolean): void;
  46900. /**
  46901. * Enable or disable color writing
  46902. * @param enable defines the state to set
  46903. */
  46904. setColorWrite(enable: boolean): void;
  46905. /**
  46906. * Gets a boolean indicating if color writing is enabled
  46907. * @returns the current color writing state
  46908. */
  46909. getColorWrite(): boolean;
  46910. /**
  46911. * Sets alpha constants used by some alpha blending modes
  46912. * @param r defines the red component
  46913. * @param g defines the green component
  46914. * @param b defines the blue component
  46915. * @param a defines the alpha component
  46916. */
  46917. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46918. /**
  46919. * Sets the current alpha mode
  46920. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46921. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46922. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46923. */
  46924. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46925. /**
  46926. * Gets the current alpha mode
  46927. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46928. * @returns the current alpha mode
  46929. */
  46930. getAlphaMode(): number;
  46931. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46932. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46933. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46934. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46935. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46936. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46937. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46938. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46939. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46940. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46941. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46942. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46943. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46944. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46945. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46946. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46947. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46948. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46949. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46950. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46951. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46952. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46953. wipeCaches(bruteForce?: boolean): void;
  46954. _createTexture(): WebGLTexture;
  46955. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46956. /**
  46957. * Usually called from BABYLON.Texture.ts.
  46958. * Passed information to create a WebGLTexture
  46959. * @param urlArg defines a value which contains one of the following:
  46960. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46961. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46962. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46963. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46964. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46965. * @param scene needed for loading to the correct scene
  46966. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46967. * @param onLoad optional callback to be called upon successful completion
  46968. * @param onError optional callback to be called upon failure
  46969. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46970. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46971. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46972. * @param forcedExtension defines the extension to use to pick the right loader
  46973. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46974. */
  46975. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  46976. /**
  46977. * Creates a cube texture
  46978. * @param rootUrl defines the url where the files to load is located
  46979. * @param scene defines the current scene
  46980. * @param files defines the list of files to load (1 per face)
  46981. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46982. * @param onLoad defines an optional callback raised when the texture is loaded
  46983. * @param onError defines an optional callback raised if there is an issue to load the texture
  46984. * @param format defines the format of the data
  46985. * @param forcedExtension defines the extension to use to pick the right loader
  46986. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46987. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46988. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46989. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46990. * @returns the cube texture as an InternalTexture
  46991. */
  46992. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  46993. private _getSamplingFilter;
  46994. private static _GetNativeTextureFormat;
  46995. createRenderTargetTexture(size: number | {
  46996. width: number;
  46997. height: number;
  46998. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  46999. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47000. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47001. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47002. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47003. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47004. /**
  47005. * Updates a dynamic vertex buffer.
  47006. * @param vertexBuffer the vertex buffer to update
  47007. * @param data the data used to update the vertex buffer
  47008. * @param byteOffset the byte offset of the data (optional)
  47009. * @param byteLength the byte length of the data (optional)
  47010. */
  47011. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47012. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47013. private _updateAnisotropicLevel;
  47014. private _getAddressMode;
  47015. /** @hidden */
  47016. _bindTexture(channel: number, texture: InternalTexture): void;
  47017. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47018. releaseEffects(): void;
  47019. /** @hidden */
  47020. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47021. /** @hidden */
  47022. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47023. /** @hidden */
  47024. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47025. /** @hidden */
  47026. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47027. }
  47028. }
  47029. declare module "babylonjs/Engines/index" {
  47030. export * from "babylonjs/Engines/constants";
  47031. export * from "babylonjs/Engines/engineCapabilities";
  47032. export * from "babylonjs/Engines/instancingAttributeInfo";
  47033. export * from "babylonjs/Engines/thinEngine";
  47034. export * from "babylonjs/Engines/engine";
  47035. export * from "babylonjs/Engines/engineStore";
  47036. export * from "babylonjs/Engines/nullEngine";
  47037. export * from "babylonjs/Engines/Extensions/index";
  47038. export * from "babylonjs/Engines/IPipelineContext";
  47039. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47040. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47041. export * from "babylonjs/Engines/nativeEngine";
  47042. }
  47043. declare module "babylonjs/Events/clipboardEvents" {
  47044. /**
  47045. * Gather the list of clipboard event types as constants.
  47046. */
  47047. export class ClipboardEventTypes {
  47048. /**
  47049. * The clipboard event is fired when a copy command is active (pressed).
  47050. */
  47051. static readonly COPY: number;
  47052. /**
  47053. * The clipboard event is fired when a cut command is active (pressed).
  47054. */
  47055. static readonly CUT: number;
  47056. /**
  47057. * The clipboard event is fired when a paste command is active (pressed).
  47058. */
  47059. static readonly PASTE: number;
  47060. }
  47061. /**
  47062. * This class is used to store clipboard related info for the onClipboardObservable event.
  47063. */
  47064. export class ClipboardInfo {
  47065. /**
  47066. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47067. */
  47068. type: number;
  47069. /**
  47070. * Defines the related dom event
  47071. */
  47072. event: ClipboardEvent;
  47073. /**
  47074. *Creates an instance of ClipboardInfo.
  47075. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47076. * @param event Defines the related dom event
  47077. */
  47078. constructor(
  47079. /**
  47080. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47081. */
  47082. type: number,
  47083. /**
  47084. * Defines the related dom event
  47085. */
  47086. event: ClipboardEvent);
  47087. /**
  47088. * Get the clipboard event's type from the keycode.
  47089. * @param keyCode Defines the keyCode for the current keyboard event.
  47090. * @return {number}
  47091. */
  47092. static GetTypeFromCharacter(keyCode: number): number;
  47093. }
  47094. }
  47095. declare module "babylonjs/Events/index" {
  47096. export * from "babylonjs/Events/keyboardEvents";
  47097. export * from "babylonjs/Events/pointerEvents";
  47098. export * from "babylonjs/Events/clipboardEvents";
  47099. }
  47100. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47101. import { Scene } from "babylonjs/scene";
  47102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47103. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47104. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47105. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47106. /**
  47107. * Google Daydream controller
  47108. */
  47109. export class DaydreamController extends WebVRController {
  47110. /**
  47111. * Base Url for the controller model.
  47112. */
  47113. static MODEL_BASE_URL: string;
  47114. /**
  47115. * File name for the controller model.
  47116. */
  47117. static MODEL_FILENAME: string;
  47118. /**
  47119. * Gamepad Id prefix used to identify Daydream Controller.
  47120. */
  47121. static readonly GAMEPAD_ID_PREFIX: string;
  47122. /**
  47123. * Creates a new DaydreamController from a gamepad
  47124. * @param vrGamepad the gamepad that the controller should be created from
  47125. */
  47126. constructor(vrGamepad: any);
  47127. /**
  47128. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47129. * @param scene scene in which to add meshes
  47130. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47131. */
  47132. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47133. /**
  47134. * Called once for each button that changed state since the last frame
  47135. * @param buttonIdx Which button index changed
  47136. * @param state New state of the button
  47137. * @param changes Which properties on the state changed since last frame
  47138. */
  47139. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47140. }
  47141. }
  47142. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47143. import { Scene } from "babylonjs/scene";
  47144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47145. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47146. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47147. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47148. /**
  47149. * Gear VR Controller
  47150. */
  47151. export class GearVRController extends WebVRController {
  47152. /**
  47153. * Base Url for the controller model.
  47154. */
  47155. static MODEL_BASE_URL: string;
  47156. /**
  47157. * File name for the controller model.
  47158. */
  47159. static MODEL_FILENAME: string;
  47160. /**
  47161. * Gamepad Id prefix used to identify this controller.
  47162. */
  47163. static readonly GAMEPAD_ID_PREFIX: string;
  47164. private readonly _buttonIndexToObservableNameMap;
  47165. /**
  47166. * Creates a new GearVRController from a gamepad
  47167. * @param vrGamepad the gamepad that the controller should be created from
  47168. */
  47169. constructor(vrGamepad: any);
  47170. /**
  47171. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47172. * @param scene scene in which to add meshes
  47173. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47174. */
  47175. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47176. /**
  47177. * Called once for each button that changed state since the last frame
  47178. * @param buttonIdx Which button index changed
  47179. * @param state New state of the button
  47180. * @param changes Which properties on the state changed since last frame
  47181. */
  47182. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47183. }
  47184. }
  47185. declare module "babylonjs/Gamepads/Controllers/index" {
  47186. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47187. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47188. export * from "babylonjs/Gamepads/Controllers/genericController";
  47189. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47190. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47191. export * from "babylonjs/Gamepads/Controllers/viveController";
  47192. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47193. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47194. }
  47195. declare module "babylonjs/Gamepads/index" {
  47196. export * from "babylonjs/Gamepads/Controllers/index";
  47197. export * from "babylonjs/Gamepads/gamepad";
  47198. export * from "babylonjs/Gamepads/gamepadManager";
  47199. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47200. export * from "babylonjs/Gamepads/xboxGamepad";
  47201. export * from "babylonjs/Gamepads/dualShockGamepad";
  47202. }
  47203. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47204. import { Scene } from "babylonjs/scene";
  47205. import { Vector4 } from "babylonjs/Maths/math.vector";
  47206. import { Color4 } from "babylonjs/Maths/math.color";
  47207. import { Mesh } from "babylonjs/Meshes/mesh";
  47208. import { Nullable } from "babylonjs/types";
  47209. /**
  47210. * Class containing static functions to help procedurally build meshes
  47211. */
  47212. export class PolyhedronBuilder {
  47213. /**
  47214. * Creates a polyhedron mesh
  47215. * * 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
  47216. * * The parameter `size` (positive float, default 1) sets the polygon size
  47217. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47218. * * 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`
  47219. * * 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
  47220. * * 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)`)
  47221. * * 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
  47222. * * 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
  47223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47226. * @param name defines the name of the mesh
  47227. * @param options defines the options used to create the mesh
  47228. * @param scene defines the hosting scene
  47229. * @returns the polyhedron mesh
  47230. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47231. */
  47232. static CreatePolyhedron(name: string, options: {
  47233. type?: number;
  47234. size?: number;
  47235. sizeX?: number;
  47236. sizeY?: number;
  47237. sizeZ?: number;
  47238. custom?: any;
  47239. faceUV?: Vector4[];
  47240. faceColors?: Color4[];
  47241. flat?: boolean;
  47242. updatable?: boolean;
  47243. sideOrientation?: number;
  47244. frontUVs?: Vector4;
  47245. backUVs?: Vector4;
  47246. }, scene?: Nullable<Scene>): Mesh;
  47247. }
  47248. }
  47249. declare module "babylonjs/Gizmos/scaleGizmo" {
  47250. import { Observable } from "babylonjs/Misc/observable";
  47251. import { Nullable } from "babylonjs/types";
  47252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47253. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47254. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47255. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47256. /**
  47257. * Gizmo that enables scaling a mesh along 3 axis
  47258. */
  47259. export class ScaleGizmo extends Gizmo {
  47260. /**
  47261. * Internal gizmo used for interactions on the x axis
  47262. */
  47263. xGizmo: AxisScaleGizmo;
  47264. /**
  47265. * Internal gizmo used for interactions on the y axis
  47266. */
  47267. yGizmo: AxisScaleGizmo;
  47268. /**
  47269. * Internal gizmo used for interactions on the z axis
  47270. */
  47271. zGizmo: AxisScaleGizmo;
  47272. /**
  47273. * Internal gizmo used to scale all axis equally
  47274. */
  47275. uniformScaleGizmo: AxisScaleGizmo;
  47276. private _meshAttached;
  47277. private _updateGizmoRotationToMatchAttachedMesh;
  47278. private _snapDistance;
  47279. private _scaleRatio;
  47280. private _uniformScalingMesh;
  47281. private _octahedron;
  47282. /** Fires an event when any of it's sub gizmos are dragged */
  47283. onDragStartObservable: Observable<unknown>;
  47284. /** Fires an event when any of it's sub gizmos are released from dragging */
  47285. onDragEndObservable: Observable<unknown>;
  47286. attachedMesh: Nullable<AbstractMesh>;
  47287. /**
  47288. * Creates a ScaleGizmo
  47289. * @param gizmoLayer The utility layer the gizmo will be added to
  47290. */
  47291. constructor(gizmoLayer?: UtilityLayerRenderer);
  47292. updateGizmoRotationToMatchAttachedMesh: boolean;
  47293. /**
  47294. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47295. */
  47296. snapDistance: number;
  47297. /**
  47298. * Ratio for the scale of the gizmo (Default: 1)
  47299. */
  47300. scaleRatio: number;
  47301. /**
  47302. * Disposes of the gizmo
  47303. */
  47304. dispose(): void;
  47305. }
  47306. }
  47307. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47308. import { Observable } from "babylonjs/Misc/observable";
  47309. import { Nullable } from "babylonjs/types";
  47310. import { Vector3 } from "babylonjs/Maths/math.vector";
  47311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47312. import { Mesh } from "babylonjs/Meshes/mesh";
  47313. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47314. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47315. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47316. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47317. import { Color3 } from "babylonjs/Maths/math.color";
  47318. /**
  47319. * Single axis scale gizmo
  47320. */
  47321. export class AxisScaleGizmo extends Gizmo {
  47322. /**
  47323. * Drag behavior responsible for the gizmos dragging interactions
  47324. */
  47325. dragBehavior: PointerDragBehavior;
  47326. private _pointerObserver;
  47327. /**
  47328. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47329. */
  47330. snapDistance: number;
  47331. /**
  47332. * Event that fires each time the gizmo snaps to a new location.
  47333. * * snapDistance is the the change in distance
  47334. */
  47335. onSnapObservable: Observable<{
  47336. snapDistance: number;
  47337. }>;
  47338. /**
  47339. * If the scaling operation should be done on all axis (default: false)
  47340. */
  47341. uniformScaling: boolean;
  47342. private _isEnabled;
  47343. private _parent;
  47344. private _arrow;
  47345. private _coloredMaterial;
  47346. private _hoverMaterial;
  47347. /**
  47348. * Creates an AxisScaleGizmo
  47349. * @param gizmoLayer The utility layer the gizmo will be added to
  47350. * @param dragAxis The axis which the gizmo will be able to scale on
  47351. * @param color The color of the gizmo
  47352. */
  47353. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47354. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47355. /**
  47356. * If the gizmo is enabled
  47357. */
  47358. isEnabled: boolean;
  47359. /**
  47360. * Disposes of the gizmo
  47361. */
  47362. dispose(): void;
  47363. /**
  47364. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47365. * @param mesh The mesh to replace the default mesh of the gizmo
  47366. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47367. */
  47368. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47369. }
  47370. }
  47371. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47372. import { Observable } from "babylonjs/Misc/observable";
  47373. import { Nullable } from "babylonjs/types";
  47374. import { Vector3 } from "babylonjs/Maths/math.vector";
  47375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47376. import { Mesh } from "babylonjs/Meshes/mesh";
  47377. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47378. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47379. import { Color3 } from "babylonjs/Maths/math.color";
  47380. import "babylonjs/Meshes/Builders/boxBuilder";
  47381. /**
  47382. * Bounding box gizmo
  47383. */
  47384. export class BoundingBoxGizmo extends Gizmo {
  47385. private _lineBoundingBox;
  47386. private _rotateSpheresParent;
  47387. private _scaleBoxesParent;
  47388. private _boundingDimensions;
  47389. private _renderObserver;
  47390. private _pointerObserver;
  47391. private _scaleDragSpeed;
  47392. private _tmpQuaternion;
  47393. private _tmpVector;
  47394. private _tmpRotationMatrix;
  47395. /**
  47396. * 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)
  47397. */
  47398. ignoreChildren: boolean;
  47399. /**
  47400. * 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)
  47401. */
  47402. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47403. /**
  47404. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47405. */
  47406. rotationSphereSize: number;
  47407. /**
  47408. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47409. */
  47410. scaleBoxSize: number;
  47411. /**
  47412. * 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)
  47413. */
  47414. fixedDragMeshScreenSize: boolean;
  47415. /**
  47416. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47417. */
  47418. fixedDragMeshScreenSizeDistanceFactor: number;
  47419. /**
  47420. * Fired when a rotation sphere or scale box is dragged
  47421. */
  47422. onDragStartObservable: Observable<{}>;
  47423. /**
  47424. * Fired when a scale box is dragged
  47425. */
  47426. onScaleBoxDragObservable: Observable<{}>;
  47427. /**
  47428. * Fired when a scale box drag is ended
  47429. */
  47430. onScaleBoxDragEndObservable: Observable<{}>;
  47431. /**
  47432. * Fired when a rotation sphere is dragged
  47433. */
  47434. onRotationSphereDragObservable: Observable<{}>;
  47435. /**
  47436. * Fired when a rotation sphere drag is ended
  47437. */
  47438. onRotationSphereDragEndObservable: Observable<{}>;
  47439. /**
  47440. * 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)
  47441. */
  47442. scalePivot: Nullable<Vector3>;
  47443. /**
  47444. * Mesh used as a pivot to rotate the attached mesh
  47445. */
  47446. private _anchorMesh;
  47447. private _existingMeshScale;
  47448. private _dragMesh;
  47449. private pointerDragBehavior;
  47450. private coloredMaterial;
  47451. private hoverColoredMaterial;
  47452. /**
  47453. * Sets the color of the bounding box gizmo
  47454. * @param color the color to set
  47455. */
  47456. setColor(color: Color3): void;
  47457. /**
  47458. * Creates an BoundingBoxGizmo
  47459. * @param gizmoLayer The utility layer the gizmo will be added to
  47460. * @param color The color of the gizmo
  47461. */
  47462. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47463. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47464. private _selectNode;
  47465. /**
  47466. * Updates the bounding box information for the Gizmo
  47467. */
  47468. updateBoundingBox(): void;
  47469. private _updateRotationSpheres;
  47470. private _updateScaleBoxes;
  47471. /**
  47472. * Enables rotation on the specified axis and disables rotation on the others
  47473. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47474. */
  47475. setEnabledRotationAxis(axis: string): void;
  47476. /**
  47477. * Enables/disables scaling
  47478. * @param enable if scaling should be enabled
  47479. */
  47480. setEnabledScaling(enable: boolean): void;
  47481. private _updateDummy;
  47482. /**
  47483. * Enables a pointer drag behavior on the bounding box of the gizmo
  47484. */
  47485. enableDragBehavior(): void;
  47486. /**
  47487. * Disposes of the gizmo
  47488. */
  47489. dispose(): void;
  47490. /**
  47491. * 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)
  47492. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47493. * @returns the bounding box mesh with the passed in mesh as a child
  47494. */
  47495. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47496. /**
  47497. * CustomMeshes are not supported by this gizmo
  47498. * @param mesh The mesh to replace the default mesh of the gizmo
  47499. */
  47500. setCustomMesh(mesh: Mesh): void;
  47501. }
  47502. }
  47503. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47504. import { Observable } from "babylonjs/Misc/observable";
  47505. import { Nullable } from "babylonjs/types";
  47506. import { Vector3 } from "babylonjs/Maths/math.vector";
  47507. import { Color3 } from "babylonjs/Maths/math.color";
  47508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47509. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47510. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47511. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47512. import "babylonjs/Meshes/Builders/linesBuilder";
  47513. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47514. /**
  47515. * Single plane rotation gizmo
  47516. */
  47517. export class PlaneRotationGizmo extends Gizmo {
  47518. /**
  47519. * Drag behavior responsible for the gizmos dragging interactions
  47520. */
  47521. dragBehavior: PointerDragBehavior;
  47522. private _pointerObserver;
  47523. /**
  47524. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47525. */
  47526. snapDistance: number;
  47527. /**
  47528. * Event that fires each time the gizmo snaps to a new location.
  47529. * * snapDistance is the the change in distance
  47530. */
  47531. onSnapObservable: Observable<{
  47532. snapDistance: number;
  47533. }>;
  47534. private _isEnabled;
  47535. private _parent;
  47536. /**
  47537. * Creates a PlaneRotationGizmo
  47538. * @param gizmoLayer The utility layer the gizmo will be added to
  47539. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47540. * @param color The color of the gizmo
  47541. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47542. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47543. */
  47544. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47545. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47546. /**
  47547. * If the gizmo is enabled
  47548. */
  47549. isEnabled: boolean;
  47550. /**
  47551. * Disposes of the gizmo
  47552. */
  47553. dispose(): void;
  47554. }
  47555. }
  47556. declare module "babylonjs/Gizmos/rotationGizmo" {
  47557. import { Observable } from "babylonjs/Misc/observable";
  47558. import { Nullable } from "babylonjs/types";
  47559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47560. import { Mesh } from "babylonjs/Meshes/mesh";
  47561. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47562. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47563. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47564. /**
  47565. * Gizmo that enables rotating a mesh along 3 axis
  47566. */
  47567. export class RotationGizmo extends Gizmo {
  47568. /**
  47569. * Internal gizmo used for interactions on the x axis
  47570. */
  47571. xGizmo: PlaneRotationGizmo;
  47572. /**
  47573. * Internal gizmo used for interactions on the y axis
  47574. */
  47575. yGizmo: PlaneRotationGizmo;
  47576. /**
  47577. * Internal gizmo used for interactions on the z axis
  47578. */
  47579. zGizmo: PlaneRotationGizmo;
  47580. /** Fires an event when any of it's sub gizmos are dragged */
  47581. onDragStartObservable: Observable<unknown>;
  47582. /** Fires an event when any of it's sub gizmos are released from dragging */
  47583. onDragEndObservable: Observable<unknown>;
  47584. private _meshAttached;
  47585. attachedMesh: Nullable<AbstractMesh>;
  47586. /**
  47587. * Creates a RotationGizmo
  47588. * @param gizmoLayer The utility layer the gizmo will be added to
  47589. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47590. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47591. */
  47592. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47593. updateGizmoRotationToMatchAttachedMesh: boolean;
  47594. /**
  47595. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47596. */
  47597. snapDistance: number;
  47598. /**
  47599. * Ratio for the scale of the gizmo (Default: 1)
  47600. */
  47601. scaleRatio: number;
  47602. /**
  47603. * Disposes of the gizmo
  47604. */
  47605. dispose(): void;
  47606. /**
  47607. * CustomMeshes are not supported by this gizmo
  47608. * @param mesh The mesh to replace the default mesh of the gizmo
  47609. */
  47610. setCustomMesh(mesh: Mesh): void;
  47611. }
  47612. }
  47613. declare module "babylonjs/Gizmos/gizmoManager" {
  47614. import { Observable } from "babylonjs/Misc/observable";
  47615. import { Nullable } from "babylonjs/types";
  47616. import { Scene, IDisposable } from "babylonjs/scene";
  47617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47618. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47619. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47620. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47621. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47622. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47623. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47624. /**
  47625. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47626. */
  47627. export class GizmoManager implements IDisposable {
  47628. private scene;
  47629. /**
  47630. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47631. */
  47632. gizmos: {
  47633. positionGizmo: Nullable<PositionGizmo>;
  47634. rotationGizmo: Nullable<RotationGizmo>;
  47635. scaleGizmo: Nullable<ScaleGizmo>;
  47636. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47637. };
  47638. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47639. clearGizmoOnEmptyPointerEvent: boolean;
  47640. /** Fires an event when the manager is attached to a mesh */
  47641. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47642. private _gizmosEnabled;
  47643. private _pointerObserver;
  47644. private _attachedMesh;
  47645. private _boundingBoxColor;
  47646. private _defaultUtilityLayer;
  47647. private _defaultKeepDepthUtilityLayer;
  47648. /**
  47649. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47650. */
  47651. boundingBoxDragBehavior: SixDofDragBehavior;
  47652. /**
  47653. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47654. */
  47655. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47656. /**
  47657. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47658. */
  47659. usePointerToAttachGizmos: boolean;
  47660. /**
  47661. * Utility layer that the bounding box gizmo belongs to
  47662. */
  47663. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47664. /**
  47665. * Utility layer that all gizmos besides bounding box belong to
  47666. */
  47667. readonly utilityLayer: UtilityLayerRenderer;
  47668. /**
  47669. * Instatiates a gizmo manager
  47670. * @param scene the scene to overlay the gizmos on top of
  47671. */
  47672. constructor(scene: Scene);
  47673. /**
  47674. * Attaches a set of gizmos to the specified mesh
  47675. * @param mesh The mesh the gizmo's should be attached to
  47676. */
  47677. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47678. /**
  47679. * If the position gizmo is enabled
  47680. */
  47681. positionGizmoEnabled: boolean;
  47682. /**
  47683. * If the rotation gizmo is enabled
  47684. */
  47685. rotationGizmoEnabled: boolean;
  47686. /**
  47687. * If the scale gizmo is enabled
  47688. */
  47689. scaleGizmoEnabled: boolean;
  47690. /**
  47691. * If the boundingBox gizmo is enabled
  47692. */
  47693. boundingBoxGizmoEnabled: boolean;
  47694. /**
  47695. * Disposes of the gizmo manager
  47696. */
  47697. dispose(): void;
  47698. }
  47699. }
  47700. declare module "babylonjs/Lights/directionalLight" {
  47701. import { Camera } from "babylonjs/Cameras/camera";
  47702. import { Scene } from "babylonjs/scene";
  47703. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47705. import { Light } from "babylonjs/Lights/light";
  47706. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47707. import { Effect } from "babylonjs/Materials/effect";
  47708. /**
  47709. * A directional light is defined by a direction (what a surprise!).
  47710. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47711. * 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.
  47712. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47713. */
  47714. export class DirectionalLight extends ShadowLight {
  47715. private _shadowFrustumSize;
  47716. /**
  47717. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47718. */
  47719. /**
  47720. * Specifies a fix frustum size for the shadow generation.
  47721. */
  47722. shadowFrustumSize: number;
  47723. private _shadowOrthoScale;
  47724. /**
  47725. * Gets the shadow projection scale against the optimal computed one.
  47726. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47727. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47728. */
  47729. /**
  47730. * Sets the shadow projection scale against the optimal computed one.
  47731. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47732. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47733. */
  47734. shadowOrthoScale: number;
  47735. /**
  47736. * Automatically compute the projection matrix to best fit (including all the casters)
  47737. * on each frame.
  47738. */
  47739. autoUpdateExtends: boolean;
  47740. private _orthoLeft;
  47741. private _orthoRight;
  47742. private _orthoTop;
  47743. private _orthoBottom;
  47744. /**
  47745. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47746. * The directional light is emitted from everywhere in the given direction.
  47747. * It can cast shadows.
  47748. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47749. * @param name The friendly name of the light
  47750. * @param direction The direction of the light
  47751. * @param scene The scene the light belongs to
  47752. */
  47753. constructor(name: string, direction: Vector3, scene: Scene);
  47754. /**
  47755. * Returns the string "DirectionalLight".
  47756. * @return The class name
  47757. */
  47758. getClassName(): string;
  47759. /**
  47760. * Returns the integer 1.
  47761. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47762. */
  47763. getTypeID(): number;
  47764. /**
  47765. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47766. * Returns the DirectionalLight Shadow projection matrix.
  47767. */
  47768. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47769. /**
  47770. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47771. * Returns the DirectionalLight Shadow projection matrix.
  47772. */
  47773. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47774. /**
  47775. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47776. * Returns the DirectionalLight Shadow projection matrix.
  47777. */
  47778. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47779. protected _buildUniformLayout(): void;
  47780. /**
  47781. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47782. * @param effect The effect to update
  47783. * @param lightIndex The index of the light in the effect to update
  47784. * @returns The directional light
  47785. */
  47786. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47787. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47788. /**
  47789. * Gets the minZ used for shadow according to both the scene and the light.
  47790. *
  47791. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47792. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47793. * @param activeCamera The camera we are returning the min for
  47794. * @returns the depth min z
  47795. */
  47796. getDepthMinZ(activeCamera: Camera): number;
  47797. /**
  47798. * Gets the maxZ used for shadow according to both the scene and the light.
  47799. *
  47800. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47801. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47802. * @param activeCamera The camera we are returning the max for
  47803. * @returns the depth max z
  47804. */
  47805. getDepthMaxZ(activeCamera: Camera): number;
  47806. /**
  47807. * Prepares the list of defines specific to the light type.
  47808. * @param defines the list of defines
  47809. * @param lightIndex defines the index of the light for the effect
  47810. */
  47811. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47812. }
  47813. }
  47814. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47815. import { Mesh } from "babylonjs/Meshes/mesh";
  47816. /**
  47817. * Class containing static functions to help procedurally build meshes
  47818. */
  47819. export class HemisphereBuilder {
  47820. /**
  47821. * Creates a hemisphere mesh
  47822. * @param name defines the name of the mesh
  47823. * @param options defines the options used to create the mesh
  47824. * @param scene defines the hosting scene
  47825. * @returns the hemisphere mesh
  47826. */
  47827. static CreateHemisphere(name: string, options: {
  47828. segments?: number;
  47829. diameter?: number;
  47830. sideOrientation?: number;
  47831. }, scene: any): Mesh;
  47832. }
  47833. }
  47834. declare module "babylonjs/Lights/spotLight" {
  47835. import { Nullable } from "babylonjs/types";
  47836. import { Scene } from "babylonjs/scene";
  47837. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47839. import { Effect } from "babylonjs/Materials/effect";
  47840. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47841. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47842. /**
  47843. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47844. * These values define a cone of light starting from the position, emitting toward the direction.
  47845. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47846. * and the exponent defines the speed of the decay of the light with distance (reach).
  47847. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47848. */
  47849. export class SpotLight extends ShadowLight {
  47850. private _angle;
  47851. private _innerAngle;
  47852. private _cosHalfAngle;
  47853. private _lightAngleScale;
  47854. private _lightAngleOffset;
  47855. /**
  47856. * Gets the cone angle of the spot light in Radians.
  47857. */
  47858. /**
  47859. * Sets the cone angle of the spot light in Radians.
  47860. */
  47861. angle: number;
  47862. /**
  47863. * Only used in gltf falloff mode, this defines the angle where
  47864. * the directional falloff will start before cutting at angle which could be seen
  47865. * as outer angle.
  47866. */
  47867. /**
  47868. * Only used in gltf falloff mode, this defines the angle where
  47869. * the directional falloff will start before cutting at angle which could be seen
  47870. * as outer angle.
  47871. */
  47872. innerAngle: number;
  47873. private _shadowAngleScale;
  47874. /**
  47875. * Allows scaling the angle of the light for shadow generation only.
  47876. */
  47877. /**
  47878. * Allows scaling the angle of the light for shadow generation only.
  47879. */
  47880. shadowAngleScale: number;
  47881. /**
  47882. * The light decay speed with the distance from the emission spot.
  47883. */
  47884. exponent: number;
  47885. private _projectionTextureMatrix;
  47886. /**
  47887. * Allows reading the projecton texture
  47888. */
  47889. readonly projectionTextureMatrix: Matrix;
  47890. protected _projectionTextureLightNear: number;
  47891. /**
  47892. * Gets the near clip of the Spotlight for texture projection.
  47893. */
  47894. /**
  47895. * Sets the near clip of the Spotlight for texture projection.
  47896. */
  47897. projectionTextureLightNear: number;
  47898. protected _projectionTextureLightFar: number;
  47899. /**
  47900. * Gets the far clip of the Spotlight for texture projection.
  47901. */
  47902. /**
  47903. * Sets the far clip of the Spotlight for texture projection.
  47904. */
  47905. projectionTextureLightFar: number;
  47906. protected _projectionTextureUpDirection: Vector3;
  47907. /**
  47908. * Gets the Up vector of the Spotlight for texture projection.
  47909. */
  47910. /**
  47911. * Sets the Up vector of the Spotlight for texture projection.
  47912. */
  47913. projectionTextureUpDirection: Vector3;
  47914. private _projectionTexture;
  47915. /**
  47916. * Gets the projection texture of the light.
  47917. */
  47918. /**
  47919. * Sets the projection texture of the light.
  47920. */
  47921. projectionTexture: Nullable<BaseTexture>;
  47922. private _projectionTextureViewLightDirty;
  47923. private _projectionTextureProjectionLightDirty;
  47924. private _projectionTextureDirty;
  47925. private _projectionTextureViewTargetVector;
  47926. private _projectionTextureViewLightMatrix;
  47927. private _projectionTextureProjectionLightMatrix;
  47928. private _projectionTextureScalingMatrix;
  47929. /**
  47930. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47931. * It can cast shadows.
  47932. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47933. * @param name The light friendly name
  47934. * @param position The position of the spot light in the scene
  47935. * @param direction The direction of the light in the scene
  47936. * @param angle The cone angle of the light in Radians
  47937. * @param exponent The light decay speed with the distance from the emission spot
  47938. * @param scene The scene the lights belongs to
  47939. */
  47940. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47941. /**
  47942. * Returns the string "SpotLight".
  47943. * @returns the class name
  47944. */
  47945. getClassName(): string;
  47946. /**
  47947. * Returns the integer 2.
  47948. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47949. */
  47950. getTypeID(): number;
  47951. /**
  47952. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47953. */
  47954. protected _setDirection(value: Vector3): void;
  47955. /**
  47956. * Overrides the position setter to recompute the projection texture view light Matrix.
  47957. */
  47958. protected _setPosition(value: Vector3): void;
  47959. /**
  47960. * 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.
  47961. * Returns the SpotLight.
  47962. */
  47963. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47964. protected _computeProjectionTextureViewLightMatrix(): void;
  47965. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47966. /**
  47967. * Main function for light texture projection matrix computing.
  47968. */
  47969. protected _computeProjectionTextureMatrix(): void;
  47970. protected _buildUniformLayout(): void;
  47971. private _computeAngleValues;
  47972. /**
  47973. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47974. * @param effect The effect to update
  47975. * @param lightIndex The index of the light in the effect to update
  47976. * @returns The spot light
  47977. */
  47978. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47979. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47980. /**
  47981. * Disposes the light and the associated resources.
  47982. */
  47983. dispose(): void;
  47984. /**
  47985. * Prepares the list of defines specific to the light type.
  47986. * @param defines the list of defines
  47987. * @param lightIndex defines the index of the light for the effect
  47988. */
  47989. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47990. }
  47991. }
  47992. declare module "babylonjs/Gizmos/lightGizmo" {
  47993. import { Nullable } from "babylonjs/types";
  47994. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47995. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47996. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47997. import { Light } from "babylonjs/Lights/light";
  47998. /**
  47999. * Gizmo that enables viewing a light
  48000. */
  48001. export class LightGizmo extends Gizmo {
  48002. private _lightMesh;
  48003. private _material;
  48004. private cachedPosition;
  48005. private cachedForward;
  48006. /**
  48007. * Creates a LightGizmo
  48008. * @param gizmoLayer The utility layer the gizmo will be added to
  48009. */
  48010. constructor(gizmoLayer?: UtilityLayerRenderer);
  48011. private _light;
  48012. /**
  48013. * The light that the gizmo is attached to
  48014. */
  48015. light: Nullable<Light>;
  48016. /**
  48017. * Gets the material used to render the light gizmo
  48018. */
  48019. readonly material: StandardMaterial;
  48020. /**
  48021. * @hidden
  48022. * Updates the gizmo to match the attached mesh's position/rotation
  48023. */
  48024. protected _update(): void;
  48025. private static _Scale;
  48026. /**
  48027. * Creates the lines for a light mesh
  48028. */
  48029. private static _createLightLines;
  48030. /**
  48031. * Disposes of the light gizmo
  48032. */
  48033. dispose(): void;
  48034. private static _CreateHemisphericLightMesh;
  48035. private static _CreatePointLightMesh;
  48036. private static _CreateSpotLightMesh;
  48037. private static _CreateDirectionalLightMesh;
  48038. }
  48039. }
  48040. declare module "babylonjs/Gizmos/index" {
  48041. export * from "babylonjs/Gizmos/axisDragGizmo";
  48042. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48043. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48044. export * from "babylonjs/Gizmos/gizmo";
  48045. export * from "babylonjs/Gizmos/gizmoManager";
  48046. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48047. export * from "babylonjs/Gizmos/positionGizmo";
  48048. export * from "babylonjs/Gizmos/rotationGizmo";
  48049. export * from "babylonjs/Gizmos/scaleGizmo";
  48050. export * from "babylonjs/Gizmos/lightGizmo";
  48051. export * from "babylonjs/Gizmos/planeDragGizmo";
  48052. }
  48053. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48054. /** @hidden */
  48055. export var backgroundFragmentDeclaration: {
  48056. name: string;
  48057. shader: string;
  48058. };
  48059. }
  48060. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48061. /** @hidden */
  48062. export var backgroundUboDeclaration: {
  48063. name: string;
  48064. shader: string;
  48065. };
  48066. }
  48067. declare module "babylonjs/Shaders/background.fragment" {
  48068. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48069. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48070. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48071. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48072. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48073. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48074. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48075. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48076. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48077. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48078. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48079. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48080. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48081. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48082. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48083. /** @hidden */
  48084. export var backgroundPixelShader: {
  48085. name: string;
  48086. shader: string;
  48087. };
  48088. }
  48089. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48090. /** @hidden */
  48091. export var backgroundVertexDeclaration: {
  48092. name: string;
  48093. shader: string;
  48094. };
  48095. }
  48096. declare module "babylonjs/Shaders/background.vertex" {
  48097. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48098. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48099. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48100. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48101. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48103. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48104. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48105. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48106. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48107. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48108. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48109. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48110. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48111. /** @hidden */
  48112. export var backgroundVertexShader: {
  48113. name: string;
  48114. shader: string;
  48115. };
  48116. }
  48117. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48118. import { Nullable, int, float } from "babylonjs/types";
  48119. import { Scene } from "babylonjs/scene";
  48120. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48123. import { Mesh } from "babylonjs/Meshes/mesh";
  48124. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48125. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48126. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48128. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48129. import { Color3 } from "babylonjs/Maths/math.color";
  48130. import "babylonjs/Shaders/background.fragment";
  48131. import "babylonjs/Shaders/background.vertex";
  48132. /**
  48133. * Background material used to create an efficient environement around your scene.
  48134. */
  48135. export class BackgroundMaterial extends PushMaterial {
  48136. /**
  48137. * Standard reflectance value at parallel view angle.
  48138. */
  48139. static StandardReflectance0: number;
  48140. /**
  48141. * Standard reflectance value at grazing angle.
  48142. */
  48143. static StandardReflectance90: number;
  48144. protected _primaryColor: Color3;
  48145. /**
  48146. * Key light Color (multiply against the environement texture)
  48147. */
  48148. primaryColor: Color3;
  48149. protected __perceptualColor: Nullable<Color3>;
  48150. /**
  48151. * Experimental Internal Use Only.
  48152. *
  48153. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48154. * This acts as a helper to set the primary color to a more "human friendly" value.
  48155. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48156. * output color as close as possible from the chosen value.
  48157. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48158. * part of lighting setup.)
  48159. */
  48160. _perceptualColor: Nullable<Color3>;
  48161. protected _primaryColorShadowLevel: float;
  48162. /**
  48163. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48164. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48165. */
  48166. primaryColorShadowLevel: float;
  48167. protected _primaryColorHighlightLevel: float;
  48168. /**
  48169. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48170. * The primary color is used at the level chosen to define what the white area would look.
  48171. */
  48172. primaryColorHighlightLevel: float;
  48173. protected _reflectionTexture: Nullable<BaseTexture>;
  48174. /**
  48175. * Reflection Texture used in the material.
  48176. * Should be author in a specific way for the best result (refer to the documentation).
  48177. */
  48178. reflectionTexture: Nullable<BaseTexture>;
  48179. protected _reflectionBlur: float;
  48180. /**
  48181. * Reflection Texture level of blur.
  48182. *
  48183. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48184. * texture twice.
  48185. */
  48186. reflectionBlur: float;
  48187. protected _diffuseTexture: Nullable<BaseTexture>;
  48188. /**
  48189. * Diffuse Texture used in the material.
  48190. * Should be author in a specific way for the best result (refer to the documentation).
  48191. */
  48192. diffuseTexture: Nullable<BaseTexture>;
  48193. protected _shadowLights: Nullable<IShadowLight[]>;
  48194. /**
  48195. * Specify the list of lights casting shadow on the material.
  48196. * All scene shadow lights will be included if null.
  48197. */
  48198. shadowLights: Nullable<IShadowLight[]>;
  48199. protected _shadowLevel: float;
  48200. /**
  48201. * Helps adjusting the shadow to a softer level if required.
  48202. * 0 means black shadows and 1 means no shadows.
  48203. */
  48204. shadowLevel: float;
  48205. protected _sceneCenter: Vector3;
  48206. /**
  48207. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48208. * It is usually zero but might be interesting to modify according to your setup.
  48209. */
  48210. sceneCenter: Vector3;
  48211. protected _opacityFresnel: boolean;
  48212. /**
  48213. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48214. * This helps ensuring a nice transition when the camera goes under the ground.
  48215. */
  48216. opacityFresnel: boolean;
  48217. protected _reflectionFresnel: boolean;
  48218. /**
  48219. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48220. * This helps adding a mirror texture on the ground.
  48221. */
  48222. reflectionFresnel: boolean;
  48223. protected _reflectionFalloffDistance: number;
  48224. /**
  48225. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48226. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48227. */
  48228. reflectionFalloffDistance: number;
  48229. protected _reflectionAmount: number;
  48230. /**
  48231. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48232. */
  48233. reflectionAmount: number;
  48234. protected _reflectionReflectance0: number;
  48235. /**
  48236. * This specifies the weight of the reflection at grazing angle.
  48237. */
  48238. reflectionReflectance0: number;
  48239. protected _reflectionReflectance90: number;
  48240. /**
  48241. * This specifies the weight of the reflection at a perpendicular point of view.
  48242. */
  48243. reflectionReflectance90: number;
  48244. /**
  48245. * Sets the reflection reflectance fresnel values according to the default standard
  48246. * empirically know to work well :-)
  48247. */
  48248. reflectionStandardFresnelWeight: number;
  48249. protected _useRGBColor: boolean;
  48250. /**
  48251. * Helps to directly use the maps channels instead of their level.
  48252. */
  48253. useRGBColor: boolean;
  48254. protected _enableNoise: boolean;
  48255. /**
  48256. * This helps reducing the banding effect that could occur on the background.
  48257. */
  48258. enableNoise: boolean;
  48259. /**
  48260. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48261. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48262. * Recommended to be keep at 1.0 except for special cases.
  48263. */
  48264. fovMultiplier: number;
  48265. private _fovMultiplier;
  48266. /**
  48267. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48268. */
  48269. useEquirectangularFOV: boolean;
  48270. private _maxSimultaneousLights;
  48271. /**
  48272. * Number of Simultaneous lights allowed on the material.
  48273. */
  48274. maxSimultaneousLights: int;
  48275. /**
  48276. * Default configuration related to image processing available in the Background Material.
  48277. */
  48278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48279. /**
  48280. * Keep track of the image processing observer to allow dispose and replace.
  48281. */
  48282. private _imageProcessingObserver;
  48283. /**
  48284. * Attaches a new image processing configuration to the PBR Material.
  48285. * @param configuration (if null the scene configuration will be use)
  48286. */
  48287. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48288. /**
  48289. * Gets the image processing configuration used either in this material.
  48290. */
  48291. /**
  48292. * Sets the Default image processing configuration used either in the this material.
  48293. *
  48294. * If sets to null, the scene one is in use.
  48295. */
  48296. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48297. /**
  48298. * Gets wether the color curves effect is enabled.
  48299. */
  48300. /**
  48301. * Sets wether the color curves effect is enabled.
  48302. */
  48303. cameraColorCurvesEnabled: boolean;
  48304. /**
  48305. * Gets wether the color grading effect is enabled.
  48306. */
  48307. /**
  48308. * Gets wether the color grading effect is enabled.
  48309. */
  48310. cameraColorGradingEnabled: boolean;
  48311. /**
  48312. * Gets wether tonemapping is enabled or not.
  48313. */
  48314. /**
  48315. * Sets wether tonemapping is enabled or not
  48316. */
  48317. cameraToneMappingEnabled: boolean;
  48318. /**
  48319. * The camera exposure used on this material.
  48320. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48321. * This corresponds to a photographic exposure.
  48322. */
  48323. /**
  48324. * The camera exposure used on this material.
  48325. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48326. * This corresponds to a photographic exposure.
  48327. */
  48328. cameraExposure: float;
  48329. /**
  48330. * Gets The camera contrast used on this material.
  48331. */
  48332. /**
  48333. * Sets The camera contrast used on this material.
  48334. */
  48335. cameraContrast: float;
  48336. /**
  48337. * Gets the Color Grading 2D Lookup Texture.
  48338. */
  48339. /**
  48340. * Sets the Color Grading 2D Lookup Texture.
  48341. */
  48342. cameraColorGradingTexture: Nullable<BaseTexture>;
  48343. /**
  48344. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48345. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48346. * 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;
  48347. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48348. */
  48349. /**
  48350. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48351. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48352. * 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;
  48353. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48354. */
  48355. cameraColorCurves: Nullable<ColorCurves>;
  48356. /**
  48357. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48358. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48359. */
  48360. switchToBGR: boolean;
  48361. private _renderTargets;
  48362. private _reflectionControls;
  48363. private _white;
  48364. private _primaryShadowColor;
  48365. private _primaryHighlightColor;
  48366. /**
  48367. * Instantiates a Background Material in the given scene
  48368. * @param name The friendly name of the material
  48369. * @param scene The scene to add the material to
  48370. */
  48371. constructor(name: string, scene: Scene);
  48372. /**
  48373. * Gets a boolean indicating that current material needs to register RTT
  48374. */
  48375. readonly hasRenderTargetTextures: boolean;
  48376. /**
  48377. * The entire material has been created in order to prevent overdraw.
  48378. * @returns false
  48379. */
  48380. needAlphaTesting(): boolean;
  48381. /**
  48382. * The entire material has been created in order to prevent overdraw.
  48383. * @returns true if blending is enable
  48384. */
  48385. needAlphaBlending(): boolean;
  48386. /**
  48387. * Checks wether the material is ready to be rendered for a given mesh.
  48388. * @param mesh The mesh to render
  48389. * @param subMesh The submesh to check against
  48390. * @param useInstances Specify wether or not the material is used with instances
  48391. * @returns true if all the dependencies are ready (Textures, Effects...)
  48392. */
  48393. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48394. /**
  48395. * Compute the primary color according to the chosen perceptual color.
  48396. */
  48397. private _computePrimaryColorFromPerceptualColor;
  48398. /**
  48399. * Compute the highlights and shadow colors according to their chosen levels.
  48400. */
  48401. private _computePrimaryColors;
  48402. /**
  48403. * Build the uniform buffer used in the material.
  48404. */
  48405. buildUniformLayout(): void;
  48406. /**
  48407. * Unbind the material.
  48408. */
  48409. unbind(): void;
  48410. /**
  48411. * Bind only the world matrix to the material.
  48412. * @param world The world matrix to bind.
  48413. */
  48414. bindOnlyWorldMatrix(world: Matrix): void;
  48415. /**
  48416. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48417. * @param world The world matrix to bind.
  48418. * @param subMesh The submesh to bind for.
  48419. */
  48420. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48421. /**
  48422. * Checks to see if a texture is used in the material.
  48423. * @param texture - Base texture to use.
  48424. * @returns - Boolean specifying if a texture is used in the material.
  48425. */
  48426. hasTexture(texture: BaseTexture): boolean;
  48427. /**
  48428. * Dispose the material.
  48429. * @param forceDisposeEffect Force disposal of the associated effect.
  48430. * @param forceDisposeTextures Force disposal of the associated textures.
  48431. */
  48432. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48433. /**
  48434. * Clones the material.
  48435. * @param name The cloned name.
  48436. * @returns The cloned material.
  48437. */
  48438. clone(name: string): BackgroundMaterial;
  48439. /**
  48440. * Serializes the current material to its JSON representation.
  48441. * @returns The JSON representation.
  48442. */
  48443. serialize(): any;
  48444. /**
  48445. * Gets the class name of the material
  48446. * @returns "BackgroundMaterial"
  48447. */
  48448. getClassName(): string;
  48449. /**
  48450. * Parse a JSON input to create back a background material.
  48451. * @param source The JSON data to parse
  48452. * @param scene The scene to create the parsed material in
  48453. * @param rootUrl The root url of the assets the material depends upon
  48454. * @returns the instantiated BackgroundMaterial.
  48455. */
  48456. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48457. }
  48458. }
  48459. declare module "babylonjs/Helpers/environmentHelper" {
  48460. import { Observable } from "babylonjs/Misc/observable";
  48461. import { Nullable } from "babylonjs/types";
  48462. import { Scene } from "babylonjs/scene";
  48463. import { Vector3 } from "babylonjs/Maths/math.vector";
  48464. import { Color3 } from "babylonjs/Maths/math.color";
  48465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48466. import { Mesh } from "babylonjs/Meshes/mesh";
  48467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48468. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48469. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48470. import "babylonjs/Meshes/Builders/planeBuilder";
  48471. import "babylonjs/Meshes/Builders/boxBuilder";
  48472. /**
  48473. * Represents the different options available during the creation of
  48474. * a Environment helper.
  48475. *
  48476. * This can control the default ground, skybox and image processing setup of your scene.
  48477. */
  48478. export interface IEnvironmentHelperOptions {
  48479. /**
  48480. * Specifies wether or not to create a ground.
  48481. * True by default.
  48482. */
  48483. createGround: boolean;
  48484. /**
  48485. * Specifies the ground size.
  48486. * 15 by default.
  48487. */
  48488. groundSize: number;
  48489. /**
  48490. * The texture used on the ground for the main color.
  48491. * Comes from the BabylonJS CDN by default.
  48492. *
  48493. * Remarks: Can be either a texture or a url.
  48494. */
  48495. groundTexture: string | BaseTexture;
  48496. /**
  48497. * The color mixed in the ground texture by default.
  48498. * BabylonJS clearColor by default.
  48499. */
  48500. groundColor: Color3;
  48501. /**
  48502. * Specifies the ground opacity.
  48503. * 1 by default.
  48504. */
  48505. groundOpacity: number;
  48506. /**
  48507. * Enables the ground to receive shadows.
  48508. * True by default.
  48509. */
  48510. enableGroundShadow: boolean;
  48511. /**
  48512. * Helps preventing the shadow to be fully black on the ground.
  48513. * 0.5 by default.
  48514. */
  48515. groundShadowLevel: number;
  48516. /**
  48517. * Creates a mirror texture attach to the ground.
  48518. * false by default.
  48519. */
  48520. enableGroundMirror: boolean;
  48521. /**
  48522. * Specifies the ground mirror size ratio.
  48523. * 0.3 by default as the default kernel is 64.
  48524. */
  48525. groundMirrorSizeRatio: number;
  48526. /**
  48527. * Specifies the ground mirror blur kernel size.
  48528. * 64 by default.
  48529. */
  48530. groundMirrorBlurKernel: number;
  48531. /**
  48532. * Specifies the ground mirror visibility amount.
  48533. * 1 by default
  48534. */
  48535. groundMirrorAmount: number;
  48536. /**
  48537. * Specifies the ground mirror reflectance weight.
  48538. * This uses the standard weight of the background material to setup the fresnel effect
  48539. * of the mirror.
  48540. * 1 by default.
  48541. */
  48542. groundMirrorFresnelWeight: number;
  48543. /**
  48544. * Specifies the ground mirror Falloff distance.
  48545. * This can helps reducing the size of the reflection.
  48546. * 0 by Default.
  48547. */
  48548. groundMirrorFallOffDistance: number;
  48549. /**
  48550. * Specifies the ground mirror texture type.
  48551. * Unsigned Int by Default.
  48552. */
  48553. groundMirrorTextureType: number;
  48554. /**
  48555. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48556. * the shown objects.
  48557. */
  48558. groundYBias: number;
  48559. /**
  48560. * Specifies wether or not to create a skybox.
  48561. * True by default.
  48562. */
  48563. createSkybox: boolean;
  48564. /**
  48565. * Specifies the skybox size.
  48566. * 20 by default.
  48567. */
  48568. skyboxSize: number;
  48569. /**
  48570. * The texture used on the skybox for the main color.
  48571. * Comes from the BabylonJS CDN by default.
  48572. *
  48573. * Remarks: Can be either a texture or a url.
  48574. */
  48575. skyboxTexture: string | BaseTexture;
  48576. /**
  48577. * The color mixed in the skybox texture by default.
  48578. * BabylonJS clearColor by default.
  48579. */
  48580. skyboxColor: Color3;
  48581. /**
  48582. * The background rotation around the Y axis of the scene.
  48583. * This helps aligning the key lights of your scene with the background.
  48584. * 0 by default.
  48585. */
  48586. backgroundYRotation: number;
  48587. /**
  48588. * Compute automatically the size of the elements to best fit with the scene.
  48589. */
  48590. sizeAuto: boolean;
  48591. /**
  48592. * Default position of the rootMesh if autoSize is not true.
  48593. */
  48594. rootPosition: Vector3;
  48595. /**
  48596. * Sets up the image processing in the scene.
  48597. * true by default.
  48598. */
  48599. setupImageProcessing: boolean;
  48600. /**
  48601. * The texture used as your environment texture in the scene.
  48602. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48603. *
  48604. * Remarks: Can be either a texture or a url.
  48605. */
  48606. environmentTexture: string | BaseTexture;
  48607. /**
  48608. * The value of the exposure to apply to the scene.
  48609. * 0.6 by default if setupImageProcessing is true.
  48610. */
  48611. cameraExposure: number;
  48612. /**
  48613. * The value of the contrast to apply to the scene.
  48614. * 1.6 by default if setupImageProcessing is true.
  48615. */
  48616. cameraContrast: number;
  48617. /**
  48618. * Specifies wether or not tonemapping should be enabled in the scene.
  48619. * true by default if setupImageProcessing is true.
  48620. */
  48621. toneMappingEnabled: boolean;
  48622. }
  48623. /**
  48624. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48625. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48626. * It also helps with the default setup of your imageProcessing configuration.
  48627. */
  48628. export class EnvironmentHelper {
  48629. /**
  48630. * Default ground texture URL.
  48631. */
  48632. private static _groundTextureCDNUrl;
  48633. /**
  48634. * Default skybox texture URL.
  48635. */
  48636. private static _skyboxTextureCDNUrl;
  48637. /**
  48638. * Default environment texture URL.
  48639. */
  48640. private static _environmentTextureCDNUrl;
  48641. /**
  48642. * Creates the default options for the helper.
  48643. */
  48644. private static _getDefaultOptions;
  48645. private _rootMesh;
  48646. /**
  48647. * Gets the root mesh created by the helper.
  48648. */
  48649. readonly rootMesh: Mesh;
  48650. private _skybox;
  48651. /**
  48652. * Gets the skybox created by the helper.
  48653. */
  48654. readonly skybox: Nullable<Mesh>;
  48655. private _skyboxTexture;
  48656. /**
  48657. * Gets the skybox texture created by the helper.
  48658. */
  48659. readonly skyboxTexture: Nullable<BaseTexture>;
  48660. private _skyboxMaterial;
  48661. /**
  48662. * Gets the skybox material created by the helper.
  48663. */
  48664. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48665. private _ground;
  48666. /**
  48667. * Gets the ground mesh created by the helper.
  48668. */
  48669. readonly ground: Nullable<Mesh>;
  48670. private _groundTexture;
  48671. /**
  48672. * Gets the ground texture created by the helper.
  48673. */
  48674. readonly groundTexture: Nullable<BaseTexture>;
  48675. private _groundMirror;
  48676. /**
  48677. * Gets the ground mirror created by the helper.
  48678. */
  48679. readonly groundMirror: Nullable<MirrorTexture>;
  48680. /**
  48681. * Gets the ground mirror render list to helps pushing the meshes
  48682. * you wish in the ground reflection.
  48683. */
  48684. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48685. private _groundMaterial;
  48686. /**
  48687. * Gets the ground material created by the helper.
  48688. */
  48689. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48690. /**
  48691. * Stores the creation options.
  48692. */
  48693. private readonly _scene;
  48694. private _options;
  48695. /**
  48696. * This observable will be notified with any error during the creation of the environment,
  48697. * mainly texture creation errors.
  48698. */
  48699. onErrorObservable: Observable<{
  48700. message?: string;
  48701. exception?: any;
  48702. }>;
  48703. /**
  48704. * constructor
  48705. * @param options Defines the options we want to customize the helper
  48706. * @param scene The scene to add the material to
  48707. */
  48708. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48709. /**
  48710. * Updates the background according to the new options
  48711. * @param options
  48712. */
  48713. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48714. /**
  48715. * Sets the primary color of all the available elements.
  48716. * @param color the main color to affect to the ground and the background
  48717. */
  48718. setMainColor(color: Color3): void;
  48719. /**
  48720. * Setup the image processing according to the specified options.
  48721. */
  48722. private _setupImageProcessing;
  48723. /**
  48724. * Setup the environment texture according to the specified options.
  48725. */
  48726. private _setupEnvironmentTexture;
  48727. /**
  48728. * Setup the background according to the specified options.
  48729. */
  48730. private _setupBackground;
  48731. /**
  48732. * Get the scene sizes according to the setup.
  48733. */
  48734. private _getSceneSize;
  48735. /**
  48736. * Setup the ground according to the specified options.
  48737. */
  48738. private _setupGround;
  48739. /**
  48740. * Setup the ground material according to the specified options.
  48741. */
  48742. private _setupGroundMaterial;
  48743. /**
  48744. * Setup the ground diffuse texture according to the specified options.
  48745. */
  48746. private _setupGroundDiffuseTexture;
  48747. /**
  48748. * Setup the ground mirror texture according to the specified options.
  48749. */
  48750. private _setupGroundMirrorTexture;
  48751. /**
  48752. * Setup the ground to receive the mirror texture.
  48753. */
  48754. private _setupMirrorInGroundMaterial;
  48755. /**
  48756. * Setup the skybox according to the specified options.
  48757. */
  48758. private _setupSkybox;
  48759. /**
  48760. * Setup the skybox material according to the specified options.
  48761. */
  48762. private _setupSkyboxMaterial;
  48763. /**
  48764. * Setup the skybox reflection texture according to the specified options.
  48765. */
  48766. private _setupSkyboxReflectionTexture;
  48767. private _errorHandler;
  48768. /**
  48769. * Dispose all the elements created by the Helper.
  48770. */
  48771. dispose(): void;
  48772. }
  48773. }
  48774. declare module "babylonjs/Helpers/photoDome" {
  48775. import { Observable } from "babylonjs/Misc/observable";
  48776. import { Nullable } from "babylonjs/types";
  48777. import { Scene } from "babylonjs/scene";
  48778. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48779. import { Mesh } from "babylonjs/Meshes/mesh";
  48780. import { Texture } from "babylonjs/Materials/Textures/texture";
  48781. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48782. import "babylonjs/Meshes/Builders/sphereBuilder";
  48783. /**
  48784. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48785. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48786. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48787. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48788. */
  48789. export class PhotoDome extends TransformNode {
  48790. /**
  48791. * Define the image as a Monoscopic panoramic 360 image.
  48792. */
  48793. static readonly MODE_MONOSCOPIC: number;
  48794. /**
  48795. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48796. */
  48797. static readonly MODE_TOPBOTTOM: number;
  48798. /**
  48799. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48800. */
  48801. static readonly MODE_SIDEBYSIDE: number;
  48802. private _useDirectMapping;
  48803. /**
  48804. * The texture being displayed on the sphere
  48805. */
  48806. protected _photoTexture: Texture;
  48807. /**
  48808. * Gets or sets the texture being displayed on the sphere
  48809. */
  48810. photoTexture: Texture;
  48811. /**
  48812. * Observable raised when an error occured while loading the 360 image
  48813. */
  48814. onLoadErrorObservable: Observable<string>;
  48815. /**
  48816. * The skybox material
  48817. */
  48818. protected _material: BackgroundMaterial;
  48819. /**
  48820. * The surface used for the skybox
  48821. */
  48822. protected _mesh: Mesh;
  48823. /**
  48824. * Gets the mesh used for the skybox.
  48825. */
  48826. readonly mesh: Mesh;
  48827. /**
  48828. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48829. * Also see the options.resolution property.
  48830. */
  48831. fovMultiplier: number;
  48832. private _imageMode;
  48833. /**
  48834. * Gets or set the current video mode for the video. It can be:
  48835. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48836. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48837. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48838. */
  48839. imageMode: number;
  48840. /**
  48841. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48842. * @param name Element's name, child elements will append suffixes for their own names.
  48843. * @param urlsOfPhoto defines the url of the photo to display
  48844. * @param options defines an object containing optional or exposed sub element properties
  48845. * @param onError defines a callback called when an error occured while loading the texture
  48846. */
  48847. constructor(name: string, urlOfPhoto: string, options: {
  48848. resolution?: number;
  48849. size?: number;
  48850. useDirectMapping?: boolean;
  48851. faceForward?: boolean;
  48852. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48853. private _onBeforeCameraRenderObserver;
  48854. private _changeImageMode;
  48855. /**
  48856. * Releases resources associated with this node.
  48857. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48858. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48859. */
  48860. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48861. }
  48862. }
  48863. declare module "babylonjs/Misc/rgbdTextureTools" {
  48864. import "babylonjs/Shaders/rgbdDecode.fragment";
  48865. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48866. import { Texture } from "babylonjs/Materials/Textures/texture";
  48867. /**
  48868. * Class used to host RGBD texture specific utilities
  48869. */
  48870. export class RGBDTextureTools {
  48871. /**
  48872. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48873. * @param texture the texture to expand.
  48874. */
  48875. static ExpandRGBDTexture(texture: Texture): void;
  48876. }
  48877. }
  48878. declare module "babylonjs/Misc/brdfTextureTools" {
  48879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48880. import { Scene } from "babylonjs/scene";
  48881. /**
  48882. * Class used to host texture specific utilities
  48883. */
  48884. export class BRDFTextureTools {
  48885. /**
  48886. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48887. * @param scene defines the hosting scene
  48888. * @returns the environment BRDF texture
  48889. */
  48890. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48891. private static _environmentBRDFBase64Texture;
  48892. }
  48893. }
  48894. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48895. import { Nullable } from "babylonjs/types";
  48896. import { Color3 } from "babylonjs/Maths/math.color";
  48897. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48898. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48900. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48901. import { Engine } from "babylonjs/Engines/engine";
  48902. import { Scene } from "babylonjs/scene";
  48903. /**
  48904. * @hidden
  48905. */
  48906. export interface IMaterialClearCoatDefines {
  48907. CLEARCOAT: boolean;
  48908. CLEARCOAT_DEFAULTIOR: boolean;
  48909. CLEARCOAT_TEXTURE: boolean;
  48910. CLEARCOAT_TEXTUREDIRECTUV: number;
  48911. CLEARCOAT_BUMP: boolean;
  48912. CLEARCOAT_BUMPDIRECTUV: number;
  48913. CLEARCOAT_TINT: boolean;
  48914. CLEARCOAT_TINT_TEXTURE: boolean;
  48915. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48916. /** @hidden */
  48917. _areTexturesDirty: boolean;
  48918. }
  48919. /**
  48920. * Define the code related to the clear coat parameters of the pbr material.
  48921. */
  48922. export class PBRClearCoatConfiguration {
  48923. /**
  48924. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48925. * The default fits with a polyurethane material.
  48926. */
  48927. private static readonly _DefaultIndexOfRefraction;
  48928. private _isEnabled;
  48929. /**
  48930. * Defines if the clear coat is enabled in the material.
  48931. */
  48932. isEnabled: boolean;
  48933. /**
  48934. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48935. */
  48936. intensity: number;
  48937. /**
  48938. * Defines the clear coat layer roughness.
  48939. */
  48940. roughness: number;
  48941. private _indexOfRefraction;
  48942. /**
  48943. * Defines the index of refraction of the clear coat.
  48944. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48945. * The default fits with a polyurethane material.
  48946. * Changing the default value is more performance intensive.
  48947. */
  48948. indexOfRefraction: number;
  48949. private _texture;
  48950. /**
  48951. * Stores the clear coat values in a texture.
  48952. */
  48953. texture: Nullable<BaseTexture>;
  48954. private _bumpTexture;
  48955. /**
  48956. * Define the clear coat specific bump texture.
  48957. */
  48958. bumpTexture: Nullable<BaseTexture>;
  48959. private _isTintEnabled;
  48960. /**
  48961. * Defines if the clear coat tint is enabled in the material.
  48962. */
  48963. isTintEnabled: boolean;
  48964. /**
  48965. * Defines the clear coat tint of the material.
  48966. * This is only use if tint is enabled
  48967. */
  48968. tintColor: Color3;
  48969. /**
  48970. * Defines the distance at which the tint color should be found in the
  48971. * clear coat media.
  48972. * This is only use if tint is enabled
  48973. */
  48974. tintColorAtDistance: number;
  48975. /**
  48976. * Defines the clear coat layer thickness.
  48977. * This is only use if tint is enabled
  48978. */
  48979. tintThickness: number;
  48980. private _tintTexture;
  48981. /**
  48982. * Stores the clear tint values in a texture.
  48983. * rgb is tint
  48984. * a is a thickness factor
  48985. */
  48986. tintTexture: Nullable<BaseTexture>;
  48987. /** @hidden */
  48988. private _internalMarkAllSubMeshesAsTexturesDirty;
  48989. /** @hidden */
  48990. _markAllSubMeshesAsTexturesDirty(): void;
  48991. /**
  48992. * Instantiate a new istance of clear coat configuration.
  48993. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48994. */
  48995. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48996. /**
  48997. * Gets wehter the submesh is ready to be used or not.
  48998. * @param defines the list of "defines" to update.
  48999. * @param scene defines the scene the material belongs to.
  49000. * @param engine defines the engine the material belongs to.
  49001. * @param disableBumpMap defines wether the material disables bump or not.
  49002. * @returns - boolean indicating that the submesh is ready or not.
  49003. */
  49004. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49005. /**
  49006. * Checks to see if a texture is used in the material.
  49007. * @param defines the list of "defines" to update.
  49008. * @param scene defines the scene to the material belongs to.
  49009. */
  49010. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49011. /**
  49012. * Binds the material data.
  49013. * @param uniformBuffer defines the Uniform buffer to fill in.
  49014. * @param scene defines the scene the material belongs to.
  49015. * @param engine defines the engine the material belongs to.
  49016. * @param disableBumpMap defines wether the material disables bump or not.
  49017. * @param isFrozen defines wether the material is frozen or not.
  49018. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49019. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49020. */
  49021. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49022. /**
  49023. * Checks to see if a texture is used in the material.
  49024. * @param texture - Base texture to use.
  49025. * @returns - Boolean specifying if a texture is used in the material.
  49026. */
  49027. hasTexture(texture: BaseTexture): boolean;
  49028. /**
  49029. * Returns an array of the actively used textures.
  49030. * @param activeTextures Array of BaseTextures
  49031. */
  49032. getActiveTextures(activeTextures: BaseTexture[]): void;
  49033. /**
  49034. * Returns the animatable textures.
  49035. * @param animatables Array of animatable textures.
  49036. */
  49037. getAnimatables(animatables: IAnimatable[]): void;
  49038. /**
  49039. * Disposes the resources of the material.
  49040. * @param forceDisposeTextures - Forces the disposal of all textures.
  49041. */
  49042. dispose(forceDisposeTextures?: boolean): void;
  49043. /**
  49044. * Get the current class name of the texture useful for serialization or dynamic coding.
  49045. * @returns "PBRClearCoatConfiguration"
  49046. */
  49047. getClassName(): string;
  49048. /**
  49049. * Add fallbacks to the effect fallbacks list.
  49050. * @param defines defines the Base texture to use.
  49051. * @param fallbacks defines the current fallback list.
  49052. * @param currentRank defines the current fallback rank.
  49053. * @returns the new fallback rank.
  49054. */
  49055. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49056. /**
  49057. * Add the required uniforms to the current list.
  49058. * @param uniforms defines the current uniform list.
  49059. */
  49060. static AddUniforms(uniforms: string[]): void;
  49061. /**
  49062. * Add the required samplers to the current list.
  49063. * @param samplers defines the current sampler list.
  49064. */
  49065. static AddSamplers(samplers: string[]): void;
  49066. /**
  49067. * Add the required uniforms to the current buffer.
  49068. * @param uniformBuffer defines the current uniform buffer.
  49069. */
  49070. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49071. /**
  49072. * Makes a duplicate of the current configuration into another one.
  49073. * @param clearCoatConfiguration define the config where to copy the info
  49074. */
  49075. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49076. /**
  49077. * Serializes this clear coat configuration.
  49078. * @returns - An object with the serialized config.
  49079. */
  49080. serialize(): any;
  49081. /**
  49082. * Parses a anisotropy Configuration from a serialized object.
  49083. * @param source - Serialized object.
  49084. * @param scene Defines the scene we are parsing for
  49085. * @param rootUrl Defines the rootUrl to load from
  49086. */
  49087. parse(source: any, scene: Scene, rootUrl: string): void;
  49088. }
  49089. }
  49090. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49091. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49093. import { Vector2 } from "babylonjs/Maths/math.vector";
  49094. import { Scene } from "babylonjs/scene";
  49095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49096. import { Nullable } from "babylonjs/types";
  49097. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49098. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49099. /**
  49100. * @hidden
  49101. */
  49102. export interface IMaterialAnisotropicDefines {
  49103. ANISOTROPIC: boolean;
  49104. ANISOTROPIC_TEXTURE: boolean;
  49105. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49106. MAINUV1: boolean;
  49107. _areTexturesDirty: boolean;
  49108. _needUVs: boolean;
  49109. }
  49110. /**
  49111. * Define the code related to the anisotropic parameters of the pbr material.
  49112. */
  49113. export class PBRAnisotropicConfiguration {
  49114. private _isEnabled;
  49115. /**
  49116. * Defines if the anisotropy is enabled in the material.
  49117. */
  49118. isEnabled: boolean;
  49119. /**
  49120. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49121. */
  49122. intensity: number;
  49123. /**
  49124. * Defines if the effect is along the tangents, bitangents or in between.
  49125. * By default, the effect is "strectching" the highlights along the tangents.
  49126. */
  49127. direction: Vector2;
  49128. private _texture;
  49129. /**
  49130. * Stores the anisotropy values in a texture.
  49131. * rg is direction (like normal from -1 to 1)
  49132. * b is a intensity
  49133. */
  49134. texture: Nullable<BaseTexture>;
  49135. /** @hidden */
  49136. private _internalMarkAllSubMeshesAsTexturesDirty;
  49137. /** @hidden */
  49138. _markAllSubMeshesAsTexturesDirty(): void;
  49139. /**
  49140. * Instantiate a new istance of anisotropy configuration.
  49141. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49142. */
  49143. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49144. /**
  49145. * Specifies that the submesh is ready to be used.
  49146. * @param defines the list of "defines" to update.
  49147. * @param scene defines the scene the material belongs to.
  49148. * @returns - boolean indicating that the submesh is ready or not.
  49149. */
  49150. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49151. /**
  49152. * Checks to see if a texture is used in the material.
  49153. * @param defines the list of "defines" to update.
  49154. * @param mesh the mesh we are preparing the defines for.
  49155. * @param scene defines the scene the material belongs to.
  49156. */
  49157. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49158. /**
  49159. * Binds the material data.
  49160. * @param uniformBuffer defines the Uniform buffer to fill in.
  49161. * @param scene defines the scene the material belongs to.
  49162. * @param isFrozen defines wether the material is frozen or not.
  49163. */
  49164. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49165. /**
  49166. * Checks to see if a texture is used in the material.
  49167. * @param texture - Base texture to use.
  49168. * @returns - Boolean specifying if a texture is used in the material.
  49169. */
  49170. hasTexture(texture: BaseTexture): boolean;
  49171. /**
  49172. * Returns an array of the actively used textures.
  49173. * @param activeTextures Array of BaseTextures
  49174. */
  49175. getActiveTextures(activeTextures: BaseTexture[]): void;
  49176. /**
  49177. * Returns the animatable textures.
  49178. * @param animatables Array of animatable textures.
  49179. */
  49180. getAnimatables(animatables: IAnimatable[]): void;
  49181. /**
  49182. * Disposes the resources of the material.
  49183. * @param forceDisposeTextures - Forces the disposal of all textures.
  49184. */
  49185. dispose(forceDisposeTextures?: boolean): void;
  49186. /**
  49187. * Get the current class name of the texture useful for serialization or dynamic coding.
  49188. * @returns "PBRAnisotropicConfiguration"
  49189. */
  49190. getClassName(): string;
  49191. /**
  49192. * Add fallbacks to the effect fallbacks list.
  49193. * @param defines defines the Base texture to use.
  49194. * @param fallbacks defines the current fallback list.
  49195. * @param currentRank defines the current fallback rank.
  49196. * @returns the new fallback rank.
  49197. */
  49198. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49199. /**
  49200. * Add the required uniforms to the current list.
  49201. * @param uniforms defines the current uniform list.
  49202. */
  49203. static AddUniforms(uniforms: string[]): void;
  49204. /**
  49205. * Add the required uniforms to the current buffer.
  49206. * @param uniformBuffer defines the current uniform buffer.
  49207. */
  49208. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49209. /**
  49210. * Add the required samplers to the current list.
  49211. * @param samplers defines the current sampler list.
  49212. */
  49213. static AddSamplers(samplers: string[]): void;
  49214. /**
  49215. * Makes a duplicate of the current configuration into another one.
  49216. * @param anisotropicConfiguration define the config where to copy the info
  49217. */
  49218. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49219. /**
  49220. * Serializes this anisotropy configuration.
  49221. * @returns - An object with the serialized config.
  49222. */
  49223. serialize(): any;
  49224. /**
  49225. * Parses a anisotropy Configuration from a serialized object.
  49226. * @param source - Serialized object.
  49227. * @param scene Defines the scene we are parsing for
  49228. * @param rootUrl Defines the rootUrl to load from
  49229. */
  49230. parse(source: any, scene: Scene, rootUrl: string): void;
  49231. }
  49232. }
  49233. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49234. import { Scene } from "babylonjs/scene";
  49235. /**
  49236. * @hidden
  49237. */
  49238. export interface IMaterialBRDFDefines {
  49239. BRDF_V_HEIGHT_CORRELATED: boolean;
  49240. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49241. SPHERICAL_HARMONICS: boolean;
  49242. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49243. /** @hidden */
  49244. _areMiscDirty: boolean;
  49245. }
  49246. /**
  49247. * Define the code related to the BRDF parameters of the pbr material.
  49248. */
  49249. export class PBRBRDFConfiguration {
  49250. /**
  49251. * Default value used for the energy conservation.
  49252. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49253. */
  49254. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49255. /**
  49256. * Default value used for the Smith Visibility Height Correlated mode.
  49257. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49258. */
  49259. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49260. /**
  49261. * Default value used for the IBL diffuse part.
  49262. * This can help switching back to the polynomials mode globally which is a tiny bit
  49263. * less GPU intensive at the drawback of a lower quality.
  49264. */
  49265. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49266. /**
  49267. * Default value used for activating energy conservation for the specular workflow.
  49268. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49269. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49270. */
  49271. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49272. private _useEnergyConservation;
  49273. /**
  49274. * Defines if the material uses energy conservation.
  49275. */
  49276. useEnergyConservation: boolean;
  49277. private _useSmithVisibilityHeightCorrelated;
  49278. /**
  49279. * LEGACY Mode set to false
  49280. * Defines if the material uses height smith correlated visibility term.
  49281. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49282. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49283. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49284. * Not relying on height correlated will also disable energy conservation.
  49285. */
  49286. useSmithVisibilityHeightCorrelated: boolean;
  49287. private _useSphericalHarmonics;
  49288. /**
  49289. * LEGACY Mode set to false
  49290. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49291. * diffuse part of the IBL.
  49292. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49293. * to the ground truth.
  49294. */
  49295. useSphericalHarmonics: boolean;
  49296. private _useSpecularGlossinessInputEnergyConservation;
  49297. /**
  49298. * Defines if the material uses energy conservation, when the specular workflow is active.
  49299. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49300. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49301. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49302. */
  49303. useSpecularGlossinessInputEnergyConservation: boolean;
  49304. /** @hidden */
  49305. private _internalMarkAllSubMeshesAsMiscDirty;
  49306. /** @hidden */
  49307. _markAllSubMeshesAsMiscDirty(): void;
  49308. /**
  49309. * Instantiate a new istance of clear coat configuration.
  49310. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49311. */
  49312. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49313. /**
  49314. * Checks to see if a texture is used in the material.
  49315. * @param defines the list of "defines" to update.
  49316. */
  49317. prepareDefines(defines: IMaterialBRDFDefines): void;
  49318. /**
  49319. * Get the current class name of the texture useful for serialization or dynamic coding.
  49320. * @returns "PBRClearCoatConfiguration"
  49321. */
  49322. getClassName(): string;
  49323. /**
  49324. * Makes a duplicate of the current configuration into another one.
  49325. * @param brdfConfiguration define the config where to copy the info
  49326. */
  49327. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49328. /**
  49329. * Serializes this BRDF configuration.
  49330. * @returns - An object with the serialized config.
  49331. */
  49332. serialize(): any;
  49333. /**
  49334. * Parses a anisotropy Configuration from a serialized object.
  49335. * @param source - Serialized object.
  49336. * @param scene Defines the scene we are parsing for
  49337. * @param rootUrl Defines the rootUrl to load from
  49338. */
  49339. parse(source: any, scene: Scene, rootUrl: string): void;
  49340. }
  49341. }
  49342. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49343. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49344. import { Color3 } from "babylonjs/Maths/math.color";
  49345. import { Scene } from "babylonjs/scene";
  49346. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49347. import { Nullable } from "babylonjs/types";
  49348. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49349. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49350. /**
  49351. * @hidden
  49352. */
  49353. export interface IMaterialSheenDefines {
  49354. SHEEN: boolean;
  49355. SHEEN_TEXTURE: boolean;
  49356. SHEEN_TEXTUREDIRECTUV: number;
  49357. SHEEN_LINKWITHALBEDO: boolean;
  49358. /** @hidden */
  49359. _areTexturesDirty: boolean;
  49360. }
  49361. /**
  49362. * Define the code related to the Sheen parameters of the pbr material.
  49363. */
  49364. export class PBRSheenConfiguration {
  49365. private _isEnabled;
  49366. /**
  49367. * Defines if the material uses sheen.
  49368. */
  49369. isEnabled: boolean;
  49370. private _linkSheenWithAlbedo;
  49371. /**
  49372. * Defines if the sheen is linked to the sheen color.
  49373. */
  49374. linkSheenWithAlbedo: boolean;
  49375. /**
  49376. * Defines the sheen intensity.
  49377. */
  49378. intensity: number;
  49379. /**
  49380. * Defines the sheen color.
  49381. */
  49382. color: Color3;
  49383. private _texture;
  49384. /**
  49385. * Stores the sheen tint values in a texture.
  49386. * rgb is tint
  49387. * a is a intensity
  49388. */
  49389. texture: Nullable<BaseTexture>;
  49390. /** @hidden */
  49391. private _internalMarkAllSubMeshesAsTexturesDirty;
  49392. /** @hidden */
  49393. _markAllSubMeshesAsTexturesDirty(): void;
  49394. /**
  49395. * Instantiate a new istance of clear coat configuration.
  49396. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49397. */
  49398. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49399. /**
  49400. * Specifies that the submesh is ready to be used.
  49401. * @param defines the list of "defines" to update.
  49402. * @param scene defines the scene the material belongs to.
  49403. * @returns - boolean indicating that the submesh is ready or not.
  49404. */
  49405. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49406. /**
  49407. * Checks to see if a texture is used in the material.
  49408. * @param defines the list of "defines" to update.
  49409. * @param scene defines the scene the material belongs to.
  49410. */
  49411. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49412. /**
  49413. * Binds the material data.
  49414. * @param uniformBuffer defines the Uniform buffer to fill in.
  49415. * @param scene defines the scene the material belongs to.
  49416. * @param isFrozen defines wether the material is frozen or not.
  49417. */
  49418. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49419. /**
  49420. * Checks to see if a texture is used in the material.
  49421. * @param texture - Base texture to use.
  49422. * @returns - Boolean specifying if a texture is used in the material.
  49423. */
  49424. hasTexture(texture: BaseTexture): boolean;
  49425. /**
  49426. * Returns an array of the actively used textures.
  49427. * @param activeTextures Array of BaseTextures
  49428. */
  49429. getActiveTextures(activeTextures: BaseTexture[]): void;
  49430. /**
  49431. * Returns the animatable textures.
  49432. * @param animatables Array of animatable textures.
  49433. */
  49434. getAnimatables(animatables: IAnimatable[]): void;
  49435. /**
  49436. * Disposes the resources of the material.
  49437. * @param forceDisposeTextures - Forces the disposal of all textures.
  49438. */
  49439. dispose(forceDisposeTextures?: boolean): void;
  49440. /**
  49441. * Get the current class name of the texture useful for serialization or dynamic coding.
  49442. * @returns "PBRSheenConfiguration"
  49443. */
  49444. getClassName(): string;
  49445. /**
  49446. * Add fallbacks to the effect fallbacks list.
  49447. * @param defines defines the Base texture to use.
  49448. * @param fallbacks defines the current fallback list.
  49449. * @param currentRank defines the current fallback rank.
  49450. * @returns the new fallback rank.
  49451. */
  49452. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49453. /**
  49454. * Add the required uniforms to the current list.
  49455. * @param uniforms defines the current uniform list.
  49456. */
  49457. static AddUniforms(uniforms: string[]): void;
  49458. /**
  49459. * Add the required uniforms to the current buffer.
  49460. * @param uniformBuffer defines the current uniform buffer.
  49461. */
  49462. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49463. /**
  49464. * Add the required samplers to the current list.
  49465. * @param samplers defines the current sampler list.
  49466. */
  49467. static AddSamplers(samplers: string[]): void;
  49468. /**
  49469. * Makes a duplicate of the current configuration into another one.
  49470. * @param sheenConfiguration define the config where to copy the info
  49471. */
  49472. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49473. /**
  49474. * Serializes this BRDF configuration.
  49475. * @returns - An object with the serialized config.
  49476. */
  49477. serialize(): any;
  49478. /**
  49479. * Parses a anisotropy Configuration from a serialized object.
  49480. * @param source - Serialized object.
  49481. * @param scene Defines the scene we are parsing for
  49482. * @param rootUrl Defines the rootUrl to load from
  49483. */
  49484. parse(source: any, scene: Scene, rootUrl: string): void;
  49485. }
  49486. }
  49487. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49488. import { Nullable } from "babylonjs/types";
  49489. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49490. import { Color3 } from "babylonjs/Maths/math.color";
  49491. import { SmartArray } from "babylonjs/Misc/smartArray";
  49492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49493. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49494. import { Effect } from "babylonjs/Materials/effect";
  49495. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49496. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49497. import { Engine } from "babylonjs/Engines/engine";
  49498. import { Scene } from "babylonjs/scene";
  49499. /**
  49500. * @hidden
  49501. */
  49502. export interface IMaterialSubSurfaceDefines {
  49503. SUBSURFACE: boolean;
  49504. SS_REFRACTION: boolean;
  49505. SS_TRANSLUCENCY: boolean;
  49506. SS_SCATERRING: boolean;
  49507. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49508. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49509. SS_REFRACTIONMAP_3D: boolean;
  49510. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49511. SS_LODINREFRACTIONALPHA: boolean;
  49512. SS_GAMMAREFRACTION: boolean;
  49513. SS_RGBDREFRACTION: boolean;
  49514. SS_LINEARSPECULARREFRACTION: boolean;
  49515. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49516. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49517. /** @hidden */
  49518. _areTexturesDirty: boolean;
  49519. }
  49520. /**
  49521. * Define the code related to the sub surface parameters of the pbr material.
  49522. */
  49523. export class PBRSubSurfaceConfiguration {
  49524. private _isRefractionEnabled;
  49525. /**
  49526. * Defines if the refraction is enabled in the material.
  49527. */
  49528. isRefractionEnabled: boolean;
  49529. private _isTranslucencyEnabled;
  49530. /**
  49531. * Defines if the translucency is enabled in the material.
  49532. */
  49533. isTranslucencyEnabled: boolean;
  49534. private _isScatteringEnabled;
  49535. /**
  49536. * Defines the refraction intensity of the material.
  49537. * The refraction when enabled replaces the Diffuse part of the material.
  49538. * The intensity helps transitionning between diffuse and refraction.
  49539. */
  49540. refractionIntensity: number;
  49541. /**
  49542. * Defines the translucency intensity of the material.
  49543. * When translucency has been enabled, this defines how much of the "translucency"
  49544. * is addded to the diffuse part of the material.
  49545. */
  49546. translucencyIntensity: number;
  49547. /**
  49548. * Defines the scattering intensity of the material.
  49549. * When scattering has been enabled, this defines how much of the "scattered light"
  49550. * is addded to the diffuse part of the material.
  49551. */
  49552. scatteringIntensity: number;
  49553. private _thicknessTexture;
  49554. /**
  49555. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49556. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49557. * 0 would mean minimumThickness
  49558. * 1 would mean maximumThickness
  49559. * The other channels might be use as a mask to vary the different effects intensity.
  49560. */
  49561. thicknessTexture: Nullable<BaseTexture>;
  49562. private _refractionTexture;
  49563. /**
  49564. * Defines the texture to use for refraction.
  49565. */
  49566. refractionTexture: Nullable<BaseTexture>;
  49567. private _indexOfRefraction;
  49568. /**
  49569. * Defines the index of refraction used in the material.
  49570. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49571. */
  49572. indexOfRefraction: number;
  49573. private _invertRefractionY;
  49574. /**
  49575. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49576. */
  49577. invertRefractionY: boolean;
  49578. private _linkRefractionWithTransparency;
  49579. /**
  49580. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49581. * Materials half opaque for instance using refraction could benefit from this control.
  49582. */
  49583. linkRefractionWithTransparency: boolean;
  49584. /**
  49585. * Defines the minimum thickness stored in the thickness map.
  49586. * If no thickness map is defined, this value will be used to simulate thickness.
  49587. */
  49588. minimumThickness: number;
  49589. /**
  49590. * Defines the maximum thickness stored in the thickness map.
  49591. */
  49592. maximumThickness: number;
  49593. /**
  49594. * Defines the volume tint of the material.
  49595. * This is used for both translucency and scattering.
  49596. */
  49597. tintColor: Color3;
  49598. /**
  49599. * Defines the distance at which the tint color should be found in the media.
  49600. * This is used for refraction only.
  49601. */
  49602. tintColorAtDistance: number;
  49603. /**
  49604. * Defines how far each channel transmit through the media.
  49605. * It is defined as a color to simplify it selection.
  49606. */
  49607. diffusionDistance: Color3;
  49608. private _useMaskFromThicknessTexture;
  49609. /**
  49610. * Stores the intensity of the different subsurface effects in the thickness texture.
  49611. * * the green channel is the translucency intensity.
  49612. * * the blue channel is the scattering intensity.
  49613. * * the alpha channel is the refraction intensity.
  49614. */
  49615. useMaskFromThicknessTexture: boolean;
  49616. /** @hidden */
  49617. private _internalMarkAllSubMeshesAsTexturesDirty;
  49618. /** @hidden */
  49619. _markAllSubMeshesAsTexturesDirty(): void;
  49620. /**
  49621. * Instantiate a new istance of sub surface configuration.
  49622. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49623. */
  49624. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49625. /**
  49626. * Gets wehter the submesh is ready to be used or not.
  49627. * @param defines the list of "defines" to update.
  49628. * @param scene defines the scene the material belongs to.
  49629. * @returns - boolean indicating that the submesh is ready or not.
  49630. */
  49631. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49632. /**
  49633. * Checks to see if a texture is used in the material.
  49634. * @param defines the list of "defines" to update.
  49635. * @param scene defines the scene to the material belongs to.
  49636. */
  49637. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49638. /**
  49639. * Binds the material data.
  49640. * @param uniformBuffer defines the Uniform buffer to fill in.
  49641. * @param scene defines the scene the material belongs to.
  49642. * @param engine defines the engine the material belongs to.
  49643. * @param isFrozen defines wether the material is frozen or not.
  49644. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49645. */
  49646. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49647. /**
  49648. * Unbinds the material from the mesh.
  49649. * @param activeEffect defines the effect that should be unbound from.
  49650. * @returns true if unbound, otherwise false
  49651. */
  49652. unbind(activeEffect: Effect): boolean;
  49653. /**
  49654. * Returns the texture used for refraction or null if none is used.
  49655. * @param scene defines the scene the material belongs to.
  49656. * @returns - Refraction texture if present. If no refraction texture and refraction
  49657. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49658. */
  49659. private _getRefractionTexture;
  49660. /**
  49661. * Returns true if alpha blending should be disabled.
  49662. */
  49663. readonly disableAlphaBlending: boolean;
  49664. /**
  49665. * Fills the list of render target textures.
  49666. * @param renderTargets the list of render targets to update
  49667. */
  49668. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49669. /**
  49670. * Checks to see if a texture is used in the material.
  49671. * @param texture - Base texture to use.
  49672. * @returns - Boolean specifying if a texture is used in the material.
  49673. */
  49674. hasTexture(texture: BaseTexture): boolean;
  49675. /**
  49676. * Gets a boolean indicating that current material needs to register RTT
  49677. * @returns true if this uses a render target otherwise false.
  49678. */
  49679. hasRenderTargetTextures(): boolean;
  49680. /**
  49681. * Returns an array of the actively used textures.
  49682. * @param activeTextures Array of BaseTextures
  49683. */
  49684. getActiveTextures(activeTextures: BaseTexture[]): void;
  49685. /**
  49686. * Returns the animatable textures.
  49687. * @param animatables Array of animatable textures.
  49688. */
  49689. getAnimatables(animatables: IAnimatable[]): void;
  49690. /**
  49691. * Disposes the resources of the material.
  49692. * @param forceDisposeTextures - Forces the disposal of all textures.
  49693. */
  49694. dispose(forceDisposeTextures?: boolean): void;
  49695. /**
  49696. * Get the current class name of the texture useful for serialization or dynamic coding.
  49697. * @returns "PBRSubSurfaceConfiguration"
  49698. */
  49699. getClassName(): string;
  49700. /**
  49701. * Add fallbacks to the effect fallbacks list.
  49702. * @param defines defines the Base texture to use.
  49703. * @param fallbacks defines the current fallback list.
  49704. * @param currentRank defines the current fallback rank.
  49705. * @returns the new fallback rank.
  49706. */
  49707. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49708. /**
  49709. * Add the required uniforms to the current list.
  49710. * @param uniforms defines the current uniform list.
  49711. */
  49712. static AddUniforms(uniforms: string[]): void;
  49713. /**
  49714. * Add the required samplers to the current list.
  49715. * @param samplers defines the current sampler list.
  49716. */
  49717. static AddSamplers(samplers: string[]): void;
  49718. /**
  49719. * Add the required uniforms to the current buffer.
  49720. * @param uniformBuffer defines the current uniform buffer.
  49721. */
  49722. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49723. /**
  49724. * Makes a duplicate of the current configuration into another one.
  49725. * @param configuration define the config where to copy the info
  49726. */
  49727. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49728. /**
  49729. * Serializes this Sub Surface configuration.
  49730. * @returns - An object with the serialized config.
  49731. */
  49732. serialize(): any;
  49733. /**
  49734. * Parses a anisotropy Configuration from a serialized object.
  49735. * @param source - Serialized object.
  49736. * @param scene Defines the scene we are parsing for
  49737. * @param rootUrl Defines the rootUrl to load from
  49738. */
  49739. parse(source: any, scene: Scene, rootUrl: string): void;
  49740. }
  49741. }
  49742. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49743. /** @hidden */
  49744. export var pbrFragmentDeclaration: {
  49745. name: string;
  49746. shader: string;
  49747. };
  49748. }
  49749. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49750. /** @hidden */
  49751. export var pbrUboDeclaration: {
  49752. name: string;
  49753. shader: string;
  49754. };
  49755. }
  49756. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49757. /** @hidden */
  49758. export var pbrFragmentExtraDeclaration: {
  49759. name: string;
  49760. shader: string;
  49761. };
  49762. }
  49763. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49764. /** @hidden */
  49765. export var pbrFragmentSamplersDeclaration: {
  49766. name: string;
  49767. shader: string;
  49768. };
  49769. }
  49770. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49771. /** @hidden */
  49772. export var pbrHelperFunctions: {
  49773. name: string;
  49774. shader: string;
  49775. };
  49776. }
  49777. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49778. /** @hidden */
  49779. export var harmonicsFunctions: {
  49780. name: string;
  49781. shader: string;
  49782. };
  49783. }
  49784. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49785. /** @hidden */
  49786. export var pbrDirectLightingSetupFunctions: {
  49787. name: string;
  49788. shader: string;
  49789. };
  49790. }
  49791. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49792. /** @hidden */
  49793. export var pbrDirectLightingFalloffFunctions: {
  49794. name: string;
  49795. shader: string;
  49796. };
  49797. }
  49798. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49799. /** @hidden */
  49800. export var pbrBRDFFunctions: {
  49801. name: string;
  49802. shader: string;
  49803. };
  49804. }
  49805. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49806. /** @hidden */
  49807. export var pbrDirectLightingFunctions: {
  49808. name: string;
  49809. shader: string;
  49810. };
  49811. }
  49812. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49813. /** @hidden */
  49814. export var pbrIBLFunctions: {
  49815. name: string;
  49816. shader: string;
  49817. };
  49818. }
  49819. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49820. /** @hidden */
  49821. export var pbrDebug: {
  49822. name: string;
  49823. shader: string;
  49824. };
  49825. }
  49826. declare module "babylonjs/Shaders/pbr.fragment" {
  49827. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49828. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49829. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49830. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49831. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49832. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49833. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49834. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49835. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49836. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49837. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49838. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49839. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49840. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49841. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49842. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49843. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49844. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49845. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49846. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49847. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49848. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49849. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49850. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49851. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49852. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49853. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49854. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49855. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49856. /** @hidden */
  49857. export var pbrPixelShader: {
  49858. name: string;
  49859. shader: string;
  49860. };
  49861. }
  49862. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49863. /** @hidden */
  49864. export var pbrVertexDeclaration: {
  49865. name: string;
  49866. shader: string;
  49867. };
  49868. }
  49869. declare module "babylonjs/Shaders/pbr.vertex" {
  49870. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49871. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49872. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49873. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49874. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49875. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49876. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49877. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49878. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49879. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49880. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49881. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49882. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49883. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49884. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49885. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49886. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49887. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49888. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49889. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49890. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49891. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49892. /** @hidden */
  49893. export var pbrVertexShader: {
  49894. name: string;
  49895. shader: string;
  49896. };
  49897. }
  49898. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49899. import { Nullable } from "babylonjs/types";
  49900. import { Scene } from "babylonjs/scene";
  49901. import { Matrix } from "babylonjs/Maths/math.vector";
  49902. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49904. import { Mesh } from "babylonjs/Meshes/mesh";
  49905. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49906. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49907. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49908. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49909. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49910. import { Color3 } from "babylonjs/Maths/math.color";
  49911. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49912. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  49913. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49914. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49916. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49917. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49918. import "babylonjs/Shaders/pbr.fragment";
  49919. import "babylonjs/Shaders/pbr.vertex";
  49920. /**
  49921. * Manages the defines for the PBR Material.
  49922. * @hidden
  49923. */
  49924. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49925. PBR: boolean;
  49926. MAINUV1: boolean;
  49927. MAINUV2: boolean;
  49928. UV1: boolean;
  49929. UV2: boolean;
  49930. ALBEDO: boolean;
  49931. ALBEDODIRECTUV: number;
  49932. VERTEXCOLOR: boolean;
  49933. AMBIENT: boolean;
  49934. AMBIENTDIRECTUV: number;
  49935. AMBIENTINGRAYSCALE: boolean;
  49936. OPACITY: boolean;
  49937. VERTEXALPHA: boolean;
  49938. OPACITYDIRECTUV: number;
  49939. OPACITYRGB: boolean;
  49940. ALPHATEST: boolean;
  49941. DEPTHPREPASS: boolean;
  49942. ALPHABLEND: boolean;
  49943. ALPHAFROMALBEDO: boolean;
  49944. ALPHATESTVALUE: string;
  49945. SPECULAROVERALPHA: boolean;
  49946. RADIANCEOVERALPHA: boolean;
  49947. ALPHAFRESNEL: boolean;
  49948. LINEARALPHAFRESNEL: boolean;
  49949. PREMULTIPLYALPHA: boolean;
  49950. EMISSIVE: boolean;
  49951. EMISSIVEDIRECTUV: number;
  49952. REFLECTIVITY: boolean;
  49953. REFLECTIVITYDIRECTUV: number;
  49954. SPECULARTERM: boolean;
  49955. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49956. MICROSURFACEAUTOMATIC: boolean;
  49957. LODBASEDMICROSFURACE: boolean;
  49958. MICROSURFACEMAP: boolean;
  49959. MICROSURFACEMAPDIRECTUV: number;
  49960. METALLICWORKFLOW: boolean;
  49961. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49962. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49963. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49964. AOSTOREINMETALMAPRED: boolean;
  49965. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49966. ENVIRONMENTBRDF: boolean;
  49967. ENVIRONMENTBRDF_RGBD: boolean;
  49968. NORMAL: boolean;
  49969. TANGENT: boolean;
  49970. BUMP: boolean;
  49971. BUMPDIRECTUV: number;
  49972. OBJECTSPACE_NORMALMAP: boolean;
  49973. PARALLAX: boolean;
  49974. PARALLAXOCCLUSION: boolean;
  49975. NORMALXYSCALE: boolean;
  49976. LIGHTMAP: boolean;
  49977. LIGHTMAPDIRECTUV: number;
  49978. USELIGHTMAPASSHADOWMAP: boolean;
  49979. GAMMALIGHTMAP: boolean;
  49980. RGBDLIGHTMAP: boolean;
  49981. REFLECTION: boolean;
  49982. REFLECTIONMAP_3D: boolean;
  49983. REFLECTIONMAP_SPHERICAL: boolean;
  49984. REFLECTIONMAP_PLANAR: boolean;
  49985. REFLECTIONMAP_CUBIC: boolean;
  49986. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49987. REFLECTIONMAP_PROJECTION: boolean;
  49988. REFLECTIONMAP_SKYBOX: boolean;
  49989. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49990. REFLECTIONMAP_EXPLICIT: boolean;
  49991. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49992. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49993. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49994. INVERTCUBICMAP: boolean;
  49995. USESPHERICALFROMREFLECTIONMAP: boolean;
  49996. USEIRRADIANCEMAP: boolean;
  49997. SPHERICAL_HARMONICS: boolean;
  49998. USESPHERICALINVERTEX: boolean;
  49999. REFLECTIONMAP_OPPOSITEZ: boolean;
  50000. LODINREFLECTIONALPHA: boolean;
  50001. GAMMAREFLECTION: boolean;
  50002. RGBDREFLECTION: boolean;
  50003. LINEARSPECULARREFLECTION: boolean;
  50004. RADIANCEOCCLUSION: boolean;
  50005. HORIZONOCCLUSION: boolean;
  50006. INSTANCES: boolean;
  50007. NUM_BONE_INFLUENCERS: number;
  50008. BonesPerMesh: number;
  50009. BONETEXTURE: boolean;
  50010. NONUNIFORMSCALING: boolean;
  50011. MORPHTARGETS: boolean;
  50012. MORPHTARGETS_NORMAL: boolean;
  50013. MORPHTARGETS_TANGENT: boolean;
  50014. MORPHTARGETS_UV: boolean;
  50015. NUM_MORPH_INFLUENCERS: number;
  50016. IMAGEPROCESSING: boolean;
  50017. VIGNETTE: boolean;
  50018. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50019. VIGNETTEBLENDMODEOPAQUE: boolean;
  50020. TONEMAPPING: boolean;
  50021. TONEMAPPING_ACES: boolean;
  50022. CONTRAST: boolean;
  50023. COLORCURVES: boolean;
  50024. COLORGRADING: boolean;
  50025. COLORGRADING3D: boolean;
  50026. SAMPLER3DGREENDEPTH: boolean;
  50027. SAMPLER3DBGRMAP: boolean;
  50028. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50029. EXPOSURE: boolean;
  50030. MULTIVIEW: boolean;
  50031. USEPHYSICALLIGHTFALLOFF: boolean;
  50032. USEGLTFLIGHTFALLOFF: boolean;
  50033. TWOSIDEDLIGHTING: boolean;
  50034. SHADOWFLOAT: boolean;
  50035. CLIPPLANE: boolean;
  50036. CLIPPLANE2: boolean;
  50037. CLIPPLANE3: boolean;
  50038. CLIPPLANE4: boolean;
  50039. POINTSIZE: boolean;
  50040. FOG: boolean;
  50041. LOGARITHMICDEPTH: boolean;
  50042. FORCENORMALFORWARD: boolean;
  50043. SPECULARAA: boolean;
  50044. CLEARCOAT: boolean;
  50045. CLEARCOAT_DEFAULTIOR: boolean;
  50046. CLEARCOAT_TEXTURE: boolean;
  50047. CLEARCOAT_TEXTUREDIRECTUV: number;
  50048. CLEARCOAT_BUMP: boolean;
  50049. CLEARCOAT_BUMPDIRECTUV: number;
  50050. CLEARCOAT_TINT: boolean;
  50051. CLEARCOAT_TINT_TEXTURE: boolean;
  50052. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50053. ANISOTROPIC: boolean;
  50054. ANISOTROPIC_TEXTURE: boolean;
  50055. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50056. BRDF_V_HEIGHT_CORRELATED: boolean;
  50057. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50058. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50059. SHEEN: boolean;
  50060. SHEEN_TEXTURE: boolean;
  50061. SHEEN_TEXTUREDIRECTUV: number;
  50062. SHEEN_LINKWITHALBEDO: boolean;
  50063. SUBSURFACE: boolean;
  50064. SS_REFRACTION: boolean;
  50065. SS_TRANSLUCENCY: boolean;
  50066. SS_SCATERRING: boolean;
  50067. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50068. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50069. SS_REFRACTIONMAP_3D: boolean;
  50070. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50071. SS_LODINREFRACTIONALPHA: boolean;
  50072. SS_GAMMAREFRACTION: boolean;
  50073. SS_RGBDREFRACTION: boolean;
  50074. SS_LINEARSPECULARREFRACTION: boolean;
  50075. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50076. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50077. UNLIT: boolean;
  50078. DEBUGMODE: number;
  50079. /**
  50080. * Initializes the PBR Material defines.
  50081. */
  50082. constructor();
  50083. /**
  50084. * Resets the PBR Material defines.
  50085. */
  50086. reset(): void;
  50087. }
  50088. /**
  50089. * The Physically based material base class of BJS.
  50090. *
  50091. * This offers the main features of a standard PBR material.
  50092. * For more information, please refer to the documentation :
  50093. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50094. */
  50095. export abstract class PBRBaseMaterial extends PushMaterial {
  50096. /**
  50097. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50098. */
  50099. static readonly PBRMATERIAL_OPAQUE: number;
  50100. /**
  50101. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50102. */
  50103. static readonly PBRMATERIAL_ALPHATEST: number;
  50104. /**
  50105. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50106. */
  50107. static readonly PBRMATERIAL_ALPHABLEND: number;
  50108. /**
  50109. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50110. * They are also discarded below the alpha cutoff threshold to improve performances.
  50111. */
  50112. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50113. /**
  50114. * Defines the default value of how much AO map is occluding the analytical lights
  50115. * (point spot...).
  50116. */
  50117. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50118. /**
  50119. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50120. */
  50121. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50122. /**
  50123. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50124. * to enhance interoperability with other engines.
  50125. */
  50126. static readonly LIGHTFALLOFF_GLTF: number;
  50127. /**
  50128. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50129. * to enhance interoperability with other materials.
  50130. */
  50131. static readonly LIGHTFALLOFF_STANDARD: number;
  50132. /**
  50133. * Intensity of the direct lights e.g. the four lights available in your scene.
  50134. * This impacts both the direct diffuse and specular highlights.
  50135. */
  50136. protected _directIntensity: number;
  50137. /**
  50138. * Intensity of the emissive part of the material.
  50139. * This helps controlling the emissive effect without modifying the emissive color.
  50140. */
  50141. protected _emissiveIntensity: number;
  50142. /**
  50143. * Intensity of the environment e.g. how much the environment will light the object
  50144. * either through harmonics for rough material or through the refelction for shiny ones.
  50145. */
  50146. protected _environmentIntensity: number;
  50147. /**
  50148. * This is a special control allowing the reduction of the specular highlights coming from the
  50149. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50150. */
  50151. protected _specularIntensity: number;
  50152. /**
  50153. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50154. */
  50155. private _lightingInfos;
  50156. /**
  50157. * Debug Control allowing disabling the bump map on this material.
  50158. */
  50159. protected _disableBumpMap: boolean;
  50160. /**
  50161. * AKA Diffuse Texture in standard nomenclature.
  50162. */
  50163. protected _albedoTexture: Nullable<BaseTexture>;
  50164. /**
  50165. * AKA Occlusion Texture in other nomenclature.
  50166. */
  50167. protected _ambientTexture: Nullable<BaseTexture>;
  50168. /**
  50169. * AKA Occlusion Texture Intensity in other nomenclature.
  50170. */
  50171. protected _ambientTextureStrength: number;
  50172. /**
  50173. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50174. * 1 means it completely occludes it
  50175. * 0 mean it has no impact
  50176. */
  50177. protected _ambientTextureImpactOnAnalyticalLights: number;
  50178. /**
  50179. * Stores the alpha values in a texture.
  50180. */
  50181. protected _opacityTexture: Nullable<BaseTexture>;
  50182. /**
  50183. * Stores the reflection values in a texture.
  50184. */
  50185. protected _reflectionTexture: Nullable<BaseTexture>;
  50186. /**
  50187. * Stores the emissive values in a texture.
  50188. */
  50189. protected _emissiveTexture: Nullable<BaseTexture>;
  50190. /**
  50191. * AKA Specular texture in other nomenclature.
  50192. */
  50193. protected _reflectivityTexture: Nullable<BaseTexture>;
  50194. /**
  50195. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50196. */
  50197. protected _metallicTexture: Nullable<BaseTexture>;
  50198. /**
  50199. * Specifies the metallic scalar of the metallic/roughness workflow.
  50200. * Can also be used to scale the metalness values of the metallic texture.
  50201. */
  50202. protected _metallic: Nullable<number>;
  50203. /**
  50204. * Specifies the roughness scalar of the metallic/roughness workflow.
  50205. * Can also be used to scale the roughness values of the metallic texture.
  50206. */
  50207. protected _roughness: Nullable<number>;
  50208. /**
  50209. * Specifies the an F0 factor to help configuring the material F0.
  50210. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50211. * to 0.5 the previously hard coded value stays the same.
  50212. * Can also be used to scale the F0 values of the metallic texture.
  50213. */
  50214. protected _metallicF0Factor: number;
  50215. /**
  50216. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50217. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50218. * your expectation as it multiplies with the texture data.
  50219. */
  50220. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50221. /**
  50222. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50223. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50224. */
  50225. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50226. /**
  50227. * Stores surface normal data used to displace a mesh in a texture.
  50228. */
  50229. protected _bumpTexture: Nullable<BaseTexture>;
  50230. /**
  50231. * Stores the pre-calculated light information of a mesh in a texture.
  50232. */
  50233. protected _lightmapTexture: Nullable<BaseTexture>;
  50234. /**
  50235. * The color of a material in ambient lighting.
  50236. */
  50237. protected _ambientColor: Color3;
  50238. /**
  50239. * AKA Diffuse Color in other nomenclature.
  50240. */
  50241. protected _albedoColor: Color3;
  50242. /**
  50243. * AKA Specular Color in other nomenclature.
  50244. */
  50245. protected _reflectivityColor: Color3;
  50246. /**
  50247. * The color applied when light is reflected from a material.
  50248. */
  50249. protected _reflectionColor: Color3;
  50250. /**
  50251. * The color applied when light is emitted from a material.
  50252. */
  50253. protected _emissiveColor: Color3;
  50254. /**
  50255. * AKA Glossiness in other nomenclature.
  50256. */
  50257. protected _microSurface: number;
  50258. /**
  50259. * Specifies that the material will use the light map as a show map.
  50260. */
  50261. protected _useLightmapAsShadowmap: boolean;
  50262. /**
  50263. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50264. * makes the reflect vector face the model (under horizon).
  50265. */
  50266. protected _useHorizonOcclusion: boolean;
  50267. /**
  50268. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50269. * too much the area relying on ambient texture to define their ambient occlusion.
  50270. */
  50271. protected _useRadianceOcclusion: boolean;
  50272. /**
  50273. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50274. */
  50275. protected _useAlphaFromAlbedoTexture: boolean;
  50276. /**
  50277. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50278. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50279. */
  50280. protected _useSpecularOverAlpha: boolean;
  50281. /**
  50282. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50283. */
  50284. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50285. /**
  50286. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50287. */
  50288. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50289. /**
  50290. * Specifies if the metallic texture contains the roughness information in its green channel.
  50291. */
  50292. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50293. /**
  50294. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50295. */
  50296. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50297. /**
  50298. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50299. */
  50300. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50301. /**
  50302. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50303. */
  50304. protected _useAmbientInGrayScale: boolean;
  50305. /**
  50306. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50307. * The material will try to infer what glossiness each pixel should be.
  50308. */
  50309. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50310. /**
  50311. * Defines the falloff type used in this material.
  50312. * It by default is Physical.
  50313. */
  50314. protected _lightFalloff: number;
  50315. /**
  50316. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50317. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50318. */
  50319. protected _useRadianceOverAlpha: boolean;
  50320. /**
  50321. * Allows using an object space normal map (instead of tangent space).
  50322. */
  50323. protected _useObjectSpaceNormalMap: boolean;
  50324. /**
  50325. * Allows using the bump map in parallax mode.
  50326. */
  50327. protected _useParallax: boolean;
  50328. /**
  50329. * Allows using the bump map in parallax occlusion mode.
  50330. */
  50331. protected _useParallaxOcclusion: boolean;
  50332. /**
  50333. * Controls the scale bias of the parallax mode.
  50334. */
  50335. protected _parallaxScaleBias: number;
  50336. /**
  50337. * If sets to true, disables all the lights affecting the material.
  50338. */
  50339. protected _disableLighting: boolean;
  50340. /**
  50341. * Number of Simultaneous lights allowed on the material.
  50342. */
  50343. protected _maxSimultaneousLights: number;
  50344. /**
  50345. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50346. */
  50347. protected _invertNormalMapX: boolean;
  50348. /**
  50349. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50350. */
  50351. protected _invertNormalMapY: boolean;
  50352. /**
  50353. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50354. */
  50355. protected _twoSidedLighting: boolean;
  50356. /**
  50357. * Defines the alpha limits in alpha test mode.
  50358. */
  50359. protected _alphaCutOff: number;
  50360. /**
  50361. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50362. */
  50363. protected _forceAlphaTest: boolean;
  50364. /**
  50365. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50366. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50367. */
  50368. protected _useAlphaFresnel: boolean;
  50369. /**
  50370. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50371. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50372. */
  50373. protected _useLinearAlphaFresnel: boolean;
  50374. /**
  50375. * The transparency mode of the material.
  50376. */
  50377. protected _transparencyMode: Nullable<number>;
  50378. /**
  50379. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50380. * from cos thetav and roughness:
  50381. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50382. */
  50383. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50384. /**
  50385. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50386. */
  50387. protected _forceIrradianceInFragment: boolean;
  50388. /**
  50389. * Force normal to face away from face.
  50390. */
  50391. protected _forceNormalForward: boolean;
  50392. /**
  50393. * Enables specular anti aliasing in the PBR shader.
  50394. * It will both interacts on the Geometry for analytical and IBL lighting.
  50395. * It also prefilter the roughness map based on the bump values.
  50396. */
  50397. protected _enableSpecularAntiAliasing: boolean;
  50398. /**
  50399. * Default configuration related to image processing available in the PBR Material.
  50400. */
  50401. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50402. /**
  50403. * Keep track of the image processing observer to allow dispose and replace.
  50404. */
  50405. private _imageProcessingObserver;
  50406. /**
  50407. * Attaches a new image processing configuration to the PBR Material.
  50408. * @param configuration
  50409. */
  50410. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50411. /**
  50412. * Stores the available render targets.
  50413. */
  50414. private _renderTargets;
  50415. /**
  50416. * Sets the global ambient color for the material used in lighting calculations.
  50417. */
  50418. private _globalAmbientColor;
  50419. /**
  50420. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50421. */
  50422. private _useLogarithmicDepth;
  50423. /**
  50424. * If set to true, no lighting calculations will be applied.
  50425. */
  50426. private _unlit;
  50427. private _debugMode;
  50428. /**
  50429. * @hidden
  50430. * This is reserved for the inspector.
  50431. * Defines the material debug mode.
  50432. * It helps seeing only some components of the material while troubleshooting.
  50433. */
  50434. debugMode: number;
  50435. /**
  50436. * @hidden
  50437. * This is reserved for the inspector.
  50438. * Specify from where on screen the debug mode should start.
  50439. * The value goes from -1 (full screen) to 1 (not visible)
  50440. * It helps with side by side comparison against the final render
  50441. * This defaults to -1
  50442. */
  50443. private debugLimit;
  50444. /**
  50445. * @hidden
  50446. * This is reserved for the inspector.
  50447. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50448. * You can use the factor to better multiply the final value.
  50449. */
  50450. private debugFactor;
  50451. /**
  50452. * Defines the clear coat layer parameters for the material.
  50453. */
  50454. readonly clearCoat: PBRClearCoatConfiguration;
  50455. /**
  50456. * Defines the anisotropic parameters for the material.
  50457. */
  50458. readonly anisotropy: PBRAnisotropicConfiguration;
  50459. /**
  50460. * Defines the BRDF parameters for the material.
  50461. */
  50462. readonly brdf: PBRBRDFConfiguration;
  50463. /**
  50464. * Defines the Sheen parameters for the material.
  50465. */
  50466. readonly sheen: PBRSheenConfiguration;
  50467. /**
  50468. * Defines the SubSurface parameters for the material.
  50469. */
  50470. readonly subSurface: PBRSubSurfaceConfiguration;
  50471. /**
  50472. * Custom callback helping to override the default shader used in the material.
  50473. */
  50474. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50475. protected _rebuildInParallel: boolean;
  50476. /**
  50477. * Instantiates a new PBRMaterial instance.
  50478. *
  50479. * @param name The material name
  50480. * @param scene The scene the material will be use in.
  50481. */
  50482. constructor(name: string, scene: Scene);
  50483. /**
  50484. * Gets a boolean indicating that current material needs to register RTT
  50485. */
  50486. readonly hasRenderTargetTextures: boolean;
  50487. /**
  50488. * Gets the name of the material class.
  50489. */
  50490. getClassName(): string;
  50491. /**
  50492. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50493. */
  50494. /**
  50495. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50496. */
  50497. useLogarithmicDepth: boolean;
  50498. /**
  50499. * Gets the current transparency mode.
  50500. */
  50501. /**
  50502. * Sets the transparency mode of the material.
  50503. *
  50504. * | Value | Type | Description |
  50505. * | ----- | ----------------------------------- | ----------- |
  50506. * | 0 | OPAQUE | |
  50507. * | 1 | ALPHATEST | |
  50508. * | 2 | ALPHABLEND | |
  50509. * | 3 | ALPHATESTANDBLEND | |
  50510. *
  50511. */
  50512. transparencyMode: Nullable<number>;
  50513. /**
  50514. * Returns true if alpha blending should be disabled.
  50515. */
  50516. private readonly _disableAlphaBlending;
  50517. /**
  50518. * Specifies whether or not this material should be rendered in alpha blend mode.
  50519. */
  50520. needAlphaBlending(): boolean;
  50521. /**
  50522. * Specifies if the mesh will require alpha blending.
  50523. * @param mesh - BJS mesh.
  50524. */
  50525. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50526. /**
  50527. * Specifies whether or not this material should be rendered in alpha test mode.
  50528. */
  50529. needAlphaTesting(): boolean;
  50530. /**
  50531. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50532. */
  50533. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50534. /**
  50535. * Gets the texture used for the alpha test.
  50536. */
  50537. getAlphaTestTexture(): Nullable<BaseTexture>;
  50538. /**
  50539. * Specifies that the submesh is ready to be used.
  50540. * @param mesh - BJS mesh.
  50541. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50542. * @param useInstances - Specifies that instances should be used.
  50543. * @returns - boolean indicating that the submesh is ready or not.
  50544. */
  50545. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50546. /**
  50547. * Specifies if the material uses metallic roughness workflow.
  50548. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50549. */
  50550. isMetallicWorkflow(): boolean;
  50551. private _prepareEffect;
  50552. private _prepareDefines;
  50553. /**
  50554. * Force shader compilation
  50555. */
  50556. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50557. /**
  50558. * Initializes the uniform buffer layout for the shader.
  50559. */
  50560. buildUniformLayout(): void;
  50561. /**
  50562. * Unbinds the material from the mesh
  50563. */
  50564. unbind(): void;
  50565. /**
  50566. * Binds the submesh data.
  50567. * @param world - The world matrix.
  50568. * @param mesh - The BJS mesh.
  50569. * @param subMesh - A submesh of the BJS mesh.
  50570. */
  50571. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50572. /**
  50573. * Returns the animatable textures.
  50574. * @returns - Array of animatable textures.
  50575. */
  50576. getAnimatables(): IAnimatable[];
  50577. /**
  50578. * Returns the texture used for reflections.
  50579. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50580. */
  50581. private _getReflectionTexture;
  50582. /**
  50583. * Returns an array of the actively used textures.
  50584. * @returns - Array of BaseTextures
  50585. */
  50586. getActiveTextures(): BaseTexture[];
  50587. /**
  50588. * Checks to see if a texture is used in the material.
  50589. * @param texture - Base texture to use.
  50590. * @returns - Boolean specifying if a texture is used in the material.
  50591. */
  50592. hasTexture(texture: BaseTexture): boolean;
  50593. /**
  50594. * Disposes the resources of the material.
  50595. * @param forceDisposeEffect - Forces the disposal of effects.
  50596. * @param forceDisposeTextures - Forces the disposal of all textures.
  50597. */
  50598. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50599. }
  50600. }
  50601. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50602. import { Nullable } from "babylonjs/types";
  50603. import { Scene } from "babylonjs/scene";
  50604. import { Color3 } from "babylonjs/Maths/math.color";
  50605. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50606. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50608. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50609. /**
  50610. * The Physically based material of BJS.
  50611. *
  50612. * This offers the main features of a standard PBR material.
  50613. * For more information, please refer to the documentation :
  50614. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50615. */
  50616. export class PBRMaterial extends PBRBaseMaterial {
  50617. /**
  50618. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50619. */
  50620. static readonly PBRMATERIAL_OPAQUE: number;
  50621. /**
  50622. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50623. */
  50624. static readonly PBRMATERIAL_ALPHATEST: number;
  50625. /**
  50626. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50627. */
  50628. static readonly PBRMATERIAL_ALPHABLEND: number;
  50629. /**
  50630. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50631. * They are also discarded below the alpha cutoff threshold to improve performances.
  50632. */
  50633. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50634. /**
  50635. * Defines the default value of how much AO map is occluding the analytical lights
  50636. * (point spot...).
  50637. */
  50638. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50639. /**
  50640. * Intensity of the direct lights e.g. the four lights available in your scene.
  50641. * This impacts both the direct diffuse and specular highlights.
  50642. */
  50643. directIntensity: number;
  50644. /**
  50645. * Intensity of the emissive part of the material.
  50646. * This helps controlling the emissive effect without modifying the emissive color.
  50647. */
  50648. emissiveIntensity: number;
  50649. /**
  50650. * Intensity of the environment e.g. how much the environment will light the object
  50651. * either through harmonics for rough material or through the refelction for shiny ones.
  50652. */
  50653. environmentIntensity: number;
  50654. /**
  50655. * This is a special control allowing the reduction of the specular highlights coming from the
  50656. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50657. */
  50658. specularIntensity: number;
  50659. /**
  50660. * Debug Control allowing disabling the bump map on this material.
  50661. */
  50662. disableBumpMap: boolean;
  50663. /**
  50664. * AKA Diffuse Texture in standard nomenclature.
  50665. */
  50666. albedoTexture: BaseTexture;
  50667. /**
  50668. * AKA Occlusion Texture in other nomenclature.
  50669. */
  50670. ambientTexture: BaseTexture;
  50671. /**
  50672. * AKA Occlusion Texture Intensity in other nomenclature.
  50673. */
  50674. ambientTextureStrength: number;
  50675. /**
  50676. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50677. * 1 means it completely occludes it
  50678. * 0 mean it has no impact
  50679. */
  50680. ambientTextureImpactOnAnalyticalLights: number;
  50681. /**
  50682. * Stores the alpha values in a texture.
  50683. */
  50684. opacityTexture: BaseTexture;
  50685. /**
  50686. * Stores the reflection values in a texture.
  50687. */
  50688. reflectionTexture: Nullable<BaseTexture>;
  50689. /**
  50690. * Stores the emissive values in a texture.
  50691. */
  50692. emissiveTexture: BaseTexture;
  50693. /**
  50694. * AKA Specular texture in other nomenclature.
  50695. */
  50696. reflectivityTexture: BaseTexture;
  50697. /**
  50698. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50699. */
  50700. metallicTexture: BaseTexture;
  50701. /**
  50702. * Specifies the metallic scalar of the metallic/roughness workflow.
  50703. * Can also be used to scale the metalness values of the metallic texture.
  50704. */
  50705. metallic: Nullable<number>;
  50706. /**
  50707. * Specifies the roughness scalar of the metallic/roughness workflow.
  50708. * Can also be used to scale the roughness values of the metallic texture.
  50709. */
  50710. roughness: Nullable<number>;
  50711. /**
  50712. * Specifies the an F0 factor to help configuring the material F0.
  50713. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50714. * to 0.5 the previously hard coded value stays the same.
  50715. * Can also be used to scale the F0 values of the metallic texture.
  50716. */
  50717. metallicF0Factor: number;
  50718. /**
  50719. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50720. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50721. * your expectation as it multiplies with the texture data.
  50722. */
  50723. useMetallicF0FactorFromMetallicTexture: boolean;
  50724. /**
  50725. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50726. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50727. */
  50728. microSurfaceTexture: BaseTexture;
  50729. /**
  50730. * Stores surface normal data used to displace a mesh in a texture.
  50731. */
  50732. bumpTexture: BaseTexture;
  50733. /**
  50734. * Stores the pre-calculated light information of a mesh in a texture.
  50735. */
  50736. lightmapTexture: BaseTexture;
  50737. /**
  50738. * Stores the refracted light information in a texture.
  50739. */
  50740. refractionTexture: Nullable<BaseTexture>;
  50741. /**
  50742. * The color of a material in ambient lighting.
  50743. */
  50744. ambientColor: Color3;
  50745. /**
  50746. * AKA Diffuse Color in other nomenclature.
  50747. */
  50748. albedoColor: Color3;
  50749. /**
  50750. * AKA Specular Color in other nomenclature.
  50751. */
  50752. reflectivityColor: Color3;
  50753. /**
  50754. * The color reflected from the material.
  50755. */
  50756. reflectionColor: Color3;
  50757. /**
  50758. * The color emitted from the material.
  50759. */
  50760. emissiveColor: Color3;
  50761. /**
  50762. * AKA Glossiness in other nomenclature.
  50763. */
  50764. microSurface: number;
  50765. /**
  50766. * source material index of refraction (IOR)' / 'destination material IOR.
  50767. */
  50768. indexOfRefraction: number;
  50769. /**
  50770. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50771. */
  50772. invertRefractionY: boolean;
  50773. /**
  50774. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50775. * Materials half opaque for instance using refraction could benefit from this control.
  50776. */
  50777. linkRefractionWithTransparency: boolean;
  50778. /**
  50779. * If true, the light map contains occlusion information instead of lighting info.
  50780. */
  50781. useLightmapAsShadowmap: boolean;
  50782. /**
  50783. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50784. */
  50785. useAlphaFromAlbedoTexture: boolean;
  50786. /**
  50787. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50788. */
  50789. forceAlphaTest: boolean;
  50790. /**
  50791. * Defines the alpha limits in alpha test mode.
  50792. */
  50793. alphaCutOff: number;
  50794. /**
  50795. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50796. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50797. */
  50798. useSpecularOverAlpha: boolean;
  50799. /**
  50800. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50801. */
  50802. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50803. /**
  50804. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50805. */
  50806. useRoughnessFromMetallicTextureAlpha: boolean;
  50807. /**
  50808. * Specifies if the metallic texture contains the roughness information in its green channel.
  50809. */
  50810. useRoughnessFromMetallicTextureGreen: boolean;
  50811. /**
  50812. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50813. */
  50814. useMetallnessFromMetallicTextureBlue: boolean;
  50815. /**
  50816. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50817. */
  50818. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50819. /**
  50820. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50821. */
  50822. useAmbientInGrayScale: boolean;
  50823. /**
  50824. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50825. * The material will try to infer what glossiness each pixel should be.
  50826. */
  50827. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50828. /**
  50829. * BJS is using an harcoded light falloff based on a manually sets up range.
  50830. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50831. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50832. */
  50833. /**
  50834. * BJS is using an harcoded light falloff based on a manually sets up range.
  50835. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50836. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50837. */
  50838. usePhysicalLightFalloff: boolean;
  50839. /**
  50840. * In order to support the falloff compatibility with gltf, a special mode has been added
  50841. * to reproduce the gltf light falloff.
  50842. */
  50843. /**
  50844. * In order to support the falloff compatibility with gltf, a special mode has been added
  50845. * to reproduce the gltf light falloff.
  50846. */
  50847. useGLTFLightFalloff: boolean;
  50848. /**
  50849. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50850. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50851. */
  50852. useRadianceOverAlpha: boolean;
  50853. /**
  50854. * Allows using an object space normal map (instead of tangent space).
  50855. */
  50856. useObjectSpaceNormalMap: boolean;
  50857. /**
  50858. * Allows using the bump map in parallax mode.
  50859. */
  50860. useParallax: boolean;
  50861. /**
  50862. * Allows using the bump map in parallax occlusion mode.
  50863. */
  50864. useParallaxOcclusion: boolean;
  50865. /**
  50866. * Controls the scale bias of the parallax mode.
  50867. */
  50868. parallaxScaleBias: number;
  50869. /**
  50870. * If sets to true, disables all the lights affecting the material.
  50871. */
  50872. disableLighting: boolean;
  50873. /**
  50874. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50875. */
  50876. forceIrradianceInFragment: boolean;
  50877. /**
  50878. * Number of Simultaneous lights allowed on the material.
  50879. */
  50880. maxSimultaneousLights: number;
  50881. /**
  50882. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50883. */
  50884. invertNormalMapX: boolean;
  50885. /**
  50886. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50887. */
  50888. invertNormalMapY: boolean;
  50889. /**
  50890. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50891. */
  50892. twoSidedLighting: boolean;
  50893. /**
  50894. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50895. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50896. */
  50897. useAlphaFresnel: boolean;
  50898. /**
  50899. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50900. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50901. */
  50902. useLinearAlphaFresnel: boolean;
  50903. /**
  50904. * Let user defines the brdf lookup texture used for IBL.
  50905. * A default 8bit version is embedded but you could point at :
  50906. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50907. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50908. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50909. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50910. */
  50911. environmentBRDFTexture: Nullable<BaseTexture>;
  50912. /**
  50913. * Force normal to face away from face.
  50914. */
  50915. forceNormalForward: boolean;
  50916. /**
  50917. * Enables specular anti aliasing in the PBR shader.
  50918. * It will both interacts on the Geometry for analytical and IBL lighting.
  50919. * It also prefilter the roughness map based on the bump values.
  50920. */
  50921. enableSpecularAntiAliasing: boolean;
  50922. /**
  50923. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50924. * makes the reflect vector face the model (under horizon).
  50925. */
  50926. useHorizonOcclusion: boolean;
  50927. /**
  50928. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50929. * too much the area relying on ambient texture to define their ambient occlusion.
  50930. */
  50931. useRadianceOcclusion: boolean;
  50932. /**
  50933. * If set to true, no lighting calculations will be applied.
  50934. */
  50935. unlit: boolean;
  50936. /**
  50937. * Gets the image processing configuration used either in this material.
  50938. */
  50939. /**
  50940. * Sets the Default image processing configuration used either in the this material.
  50941. *
  50942. * If sets to null, the scene one is in use.
  50943. */
  50944. imageProcessingConfiguration: ImageProcessingConfiguration;
  50945. /**
  50946. * Gets wether the color curves effect is enabled.
  50947. */
  50948. /**
  50949. * Sets wether the color curves effect is enabled.
  50950. */
  50951. cameraColorCurvesEnabled: boolean;
  50952. /**
  50953. * Gets wether the color grading effect is enabled.
  50954. */
  50955. /**
  50956. * Gets wether the color grading effect is enabled.
  50957. */
  50958. cameraColorGradingEnabled: boolean;
  50959. /**
  50960. * Gets wether tonemapping is enabled or not.
  50961. */
  50962. /**
  50963. * Sets wether tonemapping is enabled or not
  50964. */
  50965. cameraToneMappingEnabled: boolean;
  50966. /**
  50967. * The camera exposure used on this material.
  50968. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50969. * This corresponds to a photographic exposure.
  50970. */
  50971. /**
  50972. * The camera exposure used on this material.
  50973. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50974. * This corresponds to a photographic exposure.
  50975. */
  50976. cameraExposure: number;
  50977. /**
  50978. * Gets The camera contrast used on this material.
  50979. */
  50980. /**
  50981. * Sets The camera contrast used on this material.
  50982. */
  50983. cameraContrast: number;
  50984. /**
  50985. * Gets the Color Grading 2D Lookup Texture.
  50986. */
  50987. /**
  50988. * Sets the Color Grading 2D Lookup Texture.
  50989. */
  50990. cameraColorGradingTexture: Nullable<BaseTexture>;
  50991. /**
  50992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50994. * 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;
  50995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50996. */
  50997. /**
  50998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51000. * 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;
  51001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51002. */
  51003. cameraColorCurves: Nullable<ColorCurves>;
  51004. /**
  51005. * Instantiates a new PBRMaterial instance.
  51006. *
  51007. * @param name The material name
  51008. * @param scene The scene the material will be use in.
  51009. */
  51010. constructor(name: string, scene: Scene);
  51011. /**
  51012. * Returns the name of this material class.
  51013. */
  51014. getClassName(): string;
  51015. /**
  51016. * Makes a duplicate of the current material.
  51017. * @param name - name to use for the new material.
  51018. */
  51019. clone(name: string): PBRMaterial;
  51020. /**
  51021. * Serializes this PBR Material.
  51022. * @returns - An object with the serialized material.
  51023. */
  51024. serialize(): any;
  51025. /**
  51026. * Parses a PBR Material from a serialized object.
  51027. * @param source - Serialized object.
  51028. * @param scene - BJS scene instance.
  51029. * @param rootUrl - url for the scene object
  51030. * @returns - PBRMaterial
  51031. */
  51032. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51033. }
  51034. }
  51035. declare module "babylonjs/Misc/dds" {
  51036. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51037. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51038. import { Nullable } from "babylonjs/types";
  51039. import { Scene } from "babylonjs/scene";
  51040. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51041. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51042. /**
  51043. * Direct draw surface info
  51044. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51045. */
  51046. export interface DDSInfo {
  51047. /**
  51048. * Width of the texture
  51049. */
  51050. width: number;
  51051. /**
  51052. * Width of the texture
  51053. */
  51054. height: number;
  51055. /**
  51056. * Number of Mipmaps for the texture
  51057. * @see https://en.wikipedia.org/wiki/Mipmap
  51058. */
  51059. mipmapCount: number;
  51060. /**
  51061. * If the textures format is a known fourCC format
  51062. * @see https://www.fourcc.org/
  51063. */
  51064. isFourCC: boolean;
  51065. /**
  51066. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51067. */
  51068. isRGB: boolean;
  51069. /**
  51070. * If the texture is a lumincance format
  51071. */
  51072. isLuminance: boolean;
  51073. /**
  51074. * If this is a cube texture
  51075. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51076. */
  51077. isCube: boolean;
  51078. /**
  51079. * If the texture is a compressed format eg. FOURCC_DXT1
  51080. */
  51081. isCompressed: boolean;
  51082. /**
  51083. * The dxgiFormat of the texture
  51084. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51085. */
  51086. dxgiFormat: number;
  51087. /**
  51088. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51089. */
  51090. textureType: number;
  51091. /**
  51092. * Sphericle polynomial created for the dds texture
  51093. */
  51094. sphericalPolynomial?: SphericalPolynomial;
  51095. }
  51096. /**
  51097. * Class used to provide DDS decompression tools
  51098. */
  51099. export class DDSTools {
  51100. /**
  51101. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51102. */
  51103. static StoreLODInAlphaChannel: boolean;
  51104. /**
  51105. * Gets DDS information from an array buffer
  51106. * @param arrayBuffer defines the array buffer to read data from
  51107. * @returns the DDS information
  51108. */
  51109. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51110. private static _FloatView;
  51111. private static _Int32View;
  51112. private static _ToHalfFloat;
  51113. private static _FromHalfFloat;
  51114. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51115. private static _GetHalfFloatRGBAArrayBuffer;
  51116. private static _GetFloatRGBAArrayBuffer;
  51117. private static _GetFloatAsUIntRGBAArrayBuffer;
  51118. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51119. private static _GetRGBAArrayBuffer;
  51120. private static _ExtractLongWordOrder;
  51121. private static _GetRGBArrayBuffer;
  51122. private static _GetLuminanceArrayBuffer;
  51123. /**
  51124. * Uploads DDS Levels to a Babylon Texture
  51125. * @hidden
  51126. */
  51127. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51128. }
  51129. module "babylonjs/Engines/thinEngine" {
  51130. interface ThinEngine {
  51131. /**
  51132. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51133. * @param rootUrl defines the url where the file to load is located
  51134. * @param scene defines the current scene
  51135. * @param lodScale defines scale to apply to the mip map selection
  51136. * @param lodOffset defines offset to apply to the mip map selection
  51137. * @param onLoad defines an optional callback raised when the texture is loaded
  51138. * @param onError defines an optional callback raised if there is an issue to load the texture
  51139. * @param format defines the format of the data
  51140. * @param forcedExtension defines the extension to use to pick the right loader
  51141. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51142. * @returns the cube texture as an InternalTexture
  51143. */
  51144. 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;
  51145. }
  51146. }
  51147. }
  51148. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51149. import { Nullable } from "babylonjs/types";
  51150. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51151. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51152. /**
  51153. * Implementation of the DDS Texture Loader.
  51154. * @hidden
  51155. */
  51156. export class _DDSTextureLoader implements IInternalTextureLoader {
  51157. /**
  51158. * Defines wether the loader supports cascade loading the different faces.
  51159. */
  51160. readonly supportCascades: boolean;
  51161. /**
  51162. * This returns if the loader support the current file information.
  51163. * @param extension defines the file extension of the file being loaded
  51164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51165. * @param fallback defines the fallback internal texture if any
  51166. * @param isBase64 defines whether the texture is encoded as a base64
  51167. * @param isBuffer defines whether the texture data are stored as a buffer
  51168. * @returns true if the loader can load the specified file
  51169. */
  51170. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51171. /**
  51172. * Transform the url before loading if required.
  51173. * @param rootUrl the url of the texture
  51174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51175. * @returns the transformed texture
  51176. */
  51177. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51178. /**
  51179. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51180. * @param rootUrl the url of the texture
  51181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51182. * @returns the fallback texture
  51183. */
  51184. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51185. /**
  51186. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51187. * @param data contains the texture data
  51188. * @param texture defines the BabylonJS internal texture
  51189. * @param createPolynomials will be true if polynomials have been requested
  51190. * @param onLoad defines the callback to trigger once the texture is ready
  51191. * @param onError defines the callback to trigger in case of error
  51192. */
  51193. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51194. /**
  51195. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51196. * @param data contains the texture data
  51197. * @param texture defines the BabylonJS internal texture
  51198. * @param callback defines the method to call once ready to upload
  51199. */
  51200. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51201. }
  51202. }
  51203. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51204. import { Nullable } from "babylonjs/types";
  51205. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51206. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51207. /**
  51208. * Implementation of the ENV Texture Loader.
  51209. * @hidden
  51210. */
  51211. export class _ENVTextureLoader implements IInternalTextureLoader {
  51212. /**
  51213. * Defines wether the loader supports cascade loading the different faces.
  51214. */
  51215. readonly supportCascades: boolean;
  51216. /**
  51217. * This returns if the loader support the current file information.
  51218. * @param extension defines the file extension of the file being loaded
  51219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51220. * @param fallback defines the fallback internal texture if any
  51221. * @param isBase64 defines whether the texture is encoded as a base64
  51222. * @param isBuffer defines whether the texture data are stored as a buffer
  51223. * @returns true if the loader can load the specified file
  51224. */
  51225. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51226. /**
  51227. * Transform the url before loading if required.
  51228. * @param rootUrl the url of the texture
  51229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51230. * @returns the transformed texture
  51231. */
  51232. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51233. /**
  51234. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51235. * @param rootUrl the url of the texture
  51236. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51237. * @returns the fallback texture
  51238. */
  51239. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51240. /**
  51241. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51242. * @param data contains the texture data
  51243. * @param texture defines the BabylonJS internal texture
  51244. * @param createPolynomials will be true if polynomials have been requested
  51245. * @param onLoad defines the callback to trigger once the texture is ready
  51246. * @param onError defines the callback to trigger in case of error
  51247. */
  51248. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51249. /**
  51250. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51251. * @param data contains the texture data
  51252. * @param texture defines the BabylonJS internal texture
  51253. * @param callback defines the method to call once ready to upload
  51254. */
  51255. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51256. }
  51257. }
  51258. declare module "babylonjs/Misc/khronosTextureContainer" {
  51259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51260. /**
  51261. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51262. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51263. */
  51264. export class KhronosTextureContainer {
  51265. /** contents of the KTX container file */
  51266. arrayBuffer: any;
  51267. private static HEADER_LEN;
  51268. private static COMPRESSED_2D;
  51269. private static COMPRESSED_3D;
  51270. private static TEX_2D;
  51271. private static TEX_3D;
  51272. /**
  51273. * Gets the openGL type
  51274. */
  51275. glType: number;
  51276. /**
  51277. * Gets the openGL type size
  51278. */
  51279. glTypeSize: number;
  51280. /**
  51281. * Gets the openGL format
  51282. */
  51283. glFormat: number;
  51284. /**
  51285. * Gets the openGL internal format
  51286. */
  51287. glInternalFormat: number;
  51288. /**
  51289. * Gets the base internal format
  51290. */
  51291. glBaseInternalFormat: number;
  51292. /**
  51293. * Gets image width in pixel
  51294. */
  51295. pixelWidth: number;
  51296. /**
  51297. * Gets image height in pixel
  51298. */
  51299. pixelHeight: number;
  51300. /**
  51301. * Gets image depth in pixels
  51302. */
  51303. pixelDepth: number;
  51304. /**
  51305. * Gets the number of array elements
  51306. */
  51307. numberOfArrayElements: number;
  51308. /**
  51309. * Gets the number of faces
  51310. */
  51311. numberOfFaces: number;
  51312. /**
  51313. * Gets the number of mipmap levels
  51314. */
  51315. numberOfMipmapLevels: number;
  51316. /**
  51317. * Gets the bytes of key value data
  51318. */
  51319. bytesOfKeyValueData: number;
  51320. /**
  51321. * Gets the load type
  51322. */
  51323. loadType: number;
  51324. /**
  51325. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51326. */
  51327. isInvalid: boolean;
  51328. /**
  51329. * Creates a new KhronosTextureContainer
  51330. * @param arrayBuffer contents of the KTX container file
  51331. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51332. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51333. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51334. */
  51335. constructor(
  51336. /** contents of the KTX container file */
  51337. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51338. /**
  51339. * Uploads KTX content to a Babylon Texture.
  51340. * It is assumed that the texture has already been created & is currently bound
  51341. * @hidden
  51342. */
  51343. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51344. private _upload2DCompressedLevels;
  51345. }
  51346. }
  51347. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51348. import { Nullable } from "babylonjs/types";
  51349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51350. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51351. /**
  51352. * Implementation of the KTX Texture Loader.
  51353. * @hidden
  51354. */
  51355. export class _KTXTextureLoader implements IInternalTextureLoader {
  51356. /**
  51357. * Defines wether the loader supports cascade loading the different faces.
  51358. */
  51359. readonly supportCascades: boolean;
  51360. /**
  51361. * This returns if the loader support the current file information.
  51362. * @param extension defines the file extension of the file being loaded
  51363. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51364. * @param fallback defines the fallback internal texture if any
  51365. * @param isBase64 defines whether the texture is encoded as a base64
  51366. * @param isBuffer defines whether the texture data are stored as a buffer
  51367. * @returns true if the loader can load the specified file
  51368. */
  51369. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51370. /**
  51371. * Transform the url before loading if required.
  51372. * @param rootUrl the url of the texture
  51373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51374. * @returns the transformed texture
  51375. */
  51376. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51377. /**
  51378. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51379. * @param rootUrl the url of the texture
  51380. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51381. * @returns the fallback texture
  51382. */
  51383. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51384. /**
  51385. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51386. * @param data contains the texture data
  51387. * @param texture defines the BabylonJS internal texture
  51388. * @param createPolynomials will be true if polynomials have been requested
  51389. * @param onLoad defines the callback to trigger once the texture is ready
  51390. * @param onError defines the callback to trigger in case of error
  51391. */
  51392. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51393. /**
  51394. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51395. * @param data contains the texture data
  51396. * @param texture defines the BabylonJS internal texture
  51397. * @param callback defines the method to call once ready to upload
  51398. */
  51399. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51400. }
  51401. }
  51402. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51403. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51404. import { Scene } from "babylonjs/scene";
  51405. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51406. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51407. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51408. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51409. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  51410. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51412. /**
  51413. * Options for the default xr helper
  51414. */
  51415. export class WebXRDefaultExperienceOptions {
  51416. /**
  51417. * Floor meshes that should be used for teleporting
  51418. */
  51419. floorMeshes: Array<AbstractMesh>;
  51420. /**
  51421. * Enable or disable default UI to enter XR
  51422. */
  51423. disableDefaultUI: boolean;
  51424. }
  51425. /**
  51426. * Default experience which provides a similar setup to the previous webVRExperience
  51427. */
  51428. export class WebXRDefaultExperience {
  51429. /**
  51430. * Base experience
  51431. */
  51432. baseExperience: WebXRExperienceHelper;
  51433. /**
  51434. * Input experience extension
  51435. */
  51436. input: WebXRInput;
  51437. /**
  51438. * Loads the controller models
  51439. */
  51440. controllerModelLoader: WebXRControllerModelLoader;
  51441. /**
  51442. * Enables laser pointer and selection
  51443. */
  51444. pointerSelection: WebXRControllerPointerSelection;
  51445. /**
  51446. * Enables teleportation
  51447. */
  51448. teleportation: WebXRControllerTeleportation;
  51449. /**
  51450. * Enables ui for enetering/exiting xr
  51451. */
  51452. enterExitUI: WebXREnterExitUI;
  51453. /**
  51454. * Default target xr should render to
  51455. */
  51456. renderTarget: WebXRRenderTarget;
  51457. /**
  51458. * Creates the default xr experience
  51459. * @param scene scene
  51460. * @param options options for basic configuration
  51461. * @returns resulting WebXRDefaultExperience
  51462. */
  51463. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51464. private constructor();
  51465. /**
  51466. * DIsposes of the experience helper
  51467. */
  51468. dispose(): void;
  51469. }
  51470. }
  51471. declare module "babylonjs/Helpers/sceneHelpers" {
  51472. import { Nullable } from "babylonjs/types";
  51473. import { Mesh } from "babylonjs/Meshes/mesh";
  51474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51475. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51476. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51477. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51478. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51479. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51480. import "babylonjs/Meshes/Builders/boxBuilder";
  51481. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51482. /** @hidden */
  51483. export var _forceSceneHelpersToBundle: boolean;
  51484. module "babylonjs/scene" {
  51485. interface Scene {
  51486. /**
  51487. * Creates a default light for the scene.
  51488. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51489. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51490. */
  51491. createDefaultLight(replace?: boolean): void;
  51492. /**
  51493. * Creates a default camera for the scene.
  51494. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51495. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51496. * @param replace has default false, when true replaces the active camera in the scene
  51497. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51498. */
  51499. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51500. /**
  51501. * Creates a default camera and a default light.
  51502. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51503. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51504. * @param replace has the default false, when true replaces the active camera/light in the scene
  51505. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51506. */
  51507. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51508. /**
  51509. * Creates a new sky box
  51510. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51511. * @param environmentTexture defines the texture to use as environment texture
  51512. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51513. * @param scale defines the overall scale of the skybox
  51514. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51515. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51516. * @returns a new mesh holding the sky box
  51517. */
  51518. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51519. /**
  51520. * Creates a new environment
  51521. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51522. * @param options defines the options you can use to configure the environment
  51523. * @returns the new EnvironmentHelper
  51524. */
  51525. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51526. /**
  51527. * Creates a new VREXperienceHelper
  51528. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51529. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51530. * @returns a new VREXperienceHelper
  51531. */
  51532. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51533. /**
  51534. * Creates a new WebXRDefaultExperience
  51535. * @see http://doc.babylonjs.com/how_to/webxr
  51536. * @param options experience options
  51537. * @returns a promise for a new WebXRDefaultExperience
  51538. */
  51539. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51540. }
  51541. }
  51542. }
  51543. declare module "babylonjs/Helpers/videoDome" {
  51544. import { Scene } from "babylonjs/scene";
  51545. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51546. import { Mesh } from "babylonjs/Meshes/mesh";
  51547. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51548. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51549. import "babylonjs/Meshes/Builders/sphereBuilder";
  51550. /**
  51551. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51552. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51553. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51554. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51555. */
  51556. export class VideoDome extends TransformNode {
  51557. /**
  51558. * Define the video source as a Monoscopic panoramic 360 video.
  51559. */
  51560. static readonly MODE_MONOSCOPIC: number;
  51561. /**
  51562. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51563. */
  51564. static readonly MODE_TOPBOTTOM: number;
  51565. /**
  51566. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51567. */
  51568. static readonly MODE_SIDEBYSIDE: number;
  51569. private _halfDome;
  51570. private _useDirectMapping;
  51571. /**
  51572. * The video texture being displayed on the sphere
  51573. */
  51574. protected _videoTexture: VideoTexture;
  51575. /**
  51576. * Gets the video texture being displayed on the sphere
  51577. */
  51578. readonly videoTexture: VideoTexture;
  51579. /**
  51580. * The skybox material
  51581. */
  51582. protected _material: BackgroundMaterial;
  51583. /**
  51584. * The surface used for the skybox
  51585. */
  51586. protected _mesh: Mesh;
  51587. /**
  51588. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51589. */
  51590. private _halfDomeMask;
  51591. /**
  51592. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51593. * Also see the options.resolution property.
  51594. */
  51595. fovMultiplier: number;
  51596. private _videoMode;
  51597. /**
  51598. * Gets or set the current video mode for the video. It can be:
  51599. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51600. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51601. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51602. */
  51603. videoMode: number;
  51604. /**
  51605. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51606. *
  51607. */
  51608. /**
  51609. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51610. */
  51611. halfDome: boolean;
  51612. /**
  51613. * Oberserver used in Stereoscopic VR Mode.
  51614. */
  51615. private _onBeforeCameraRenderObserver;
  51616. /**
  51617. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51618. * @param name Element's name, child elements will append suffixes for their own names.
  51619. * @param urlsOrVideo defines the url(s) or the video element to use
  51620. * @param options An object containing optional or exposed sub element properties
  51621. */
  51622. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51623. resolution?: number;
  51624. clickToPlay?: boolean;
  51625. autoPlay?: boolean;
  51626. loop?: boolean;
  51627. size?: number;
  51628. poster?: string;
  51629. faceForward?: boolean;
  51630. useDirectMapping?: boolean;
  51631. halfDomeMode?: boolean;
  51632. }, scene: Scene);
  51633. private _changeVideoMode;
  51634. /**
  51635. * Releases resources associated with this node.
  51636. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51637. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51638. */
  51639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51640. }
  51641. }
  51642. declare module "babylonjs/Helpers/index" {
  51643. export * from "babylonjs/Helpers/environmentHelper";
  51644. export * from "babylonjs/Helpers/photoDome";
  51645. export * from "babylonjs/Helpers/sceneHelpers";
  51646. export * from "babylonjs/Helpers/videoDome";
  51647. }
  51648. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51649. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51650. import { IDisposable } from "babylonjs/scene";
  51651. import { Engine } from "babylonjs/Engines/engine";
  51652. /**
  51653. * This class can be used to get instrumentation data from a Babylon engine
  51654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51655. */
  51656. export class EngineInstrumentation implements IDisposable {
  51657. /**
  51658. * Define the instrumented engine.
  51659. */
  51660. engine: Engine;
  51661. private _captureGPUFrameTime;
  51662. private _gpuFrameTimeToken;
  51663. private _gpuFrameTime;
  51664. private _captureShaderCompilationTime;
  51665. private _shaderCompilationTime;
  51666. private _onBeginFrameObserver;
  51667. private _onEndFrameObserver;
  51668. private _onBeforeShaderCompilationObserver;
  51669. private _onAfterShaderCompilationObserver;
  51670. /**
  51671. * Gets the perf counter used for GPU frame time
  51672. */
  51673. readonly gpuFrameTimeCounter: PerfCounter;
  51674. /**
  51675. * Gets the GPU frame time capture status
  51676. */
  51677. /**
  51678. * Enable or disable the GPU frame time capture
  51679. */
  51680. captureGPUFrameTime: boolean;
  51681. /**
  51682. * Gets the perf counter used for shader compilation time
  51683. */
  51684. readonly shaderCompilationTimeCounter: PerfCounter;
  51685. /**
  51686. * Gets the shader compilation time capture status
  51687. */
  51688. /**
  51689. * Enable or disable the shader compilation time capture
  51690. */
  51691. captureShaderCompilationTime: boolean;
  51692. /**
  51693. * Instantiates a new engine instrumentation.
  51694. * This class can be used to get instrumentation data from a Babylon engine
  51695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51696. * @param engine Defines the engine to instrument
  51697. */
  51698. constructor(
  51699. /**
  51700. * Define the instrumented engine.
  51701. */
  51702. engine: Engine);
  51703. /**
  51704. * Dispose and release associated resources.
  51705. */
  51706. dispose(): void;
  51707. }
  51708. }
  51709. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51710. import { Scene, IDisposable } from "babylonjs/scene";
  51711. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51712. /**
  51713. * This class can be used to get instrumentation data from a Babylon engine
  51714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51715. */
  51716. export class SceneInstrumentation implements IDisposable {
  51717. /**
  51718. * Defines the scene to instrument
  51719. */
  51720. scene: Scene;
  51721. private _captureActiveMeshesEvaluationTime;
  51722. private _activeMeshesEvaluationTime;
  51723. private _captureRenderTargetsRenderTime;
  51724. private _renderTargetsRenderTime;
  51725. private _captureFrameTime;
  51726. private _frameTime;
  51727. private _captureRenderTime;
  51728. private _renderTime;
  51729. private _captureInterFrameTime;
  51730. private _interFrameTime;
  51731. private _captureParticlesRenderTime;
  51732. private _particlesRenderTime;
  51733. private _captureSpritesRenderTime;
  51734. private _spritesRenderTime;
  51735. private _capturePhysicsTime;
  51736. private _physicsTime;
  51737. private _captureAnimationsTime;
  51738. private _animationsTime;
  51739. private _captureCameraRenderTime;
  51740. private _cameraRenderTime;
  51741. private _onBeforeActiveMeshesEvaluationObserver;
  51742. private _onAfterActiveMeshesEvaluationObserver;
  51743. private _onBeforeRenderTargetsRenderObserver;
  51744. private _onAfterRenderTargetsRenderObserver;
  51745. private _onAfterRenderObserver;
  51746. private _onBeforeDrawPhaseObserver;
  51747. private _onAfterDrawPhaseObserver;
  51748. private _onBeforeAnimationsObserver;
  51749. private _onBeforeParticlesRenderingObserver;
  51750. private _onAfterParticlesRenderingObserver;
  51751. private _onBeforeSpritesRenderingObserver;
  51752. private _onAfterSpritesRenderingObserver;
  51753. private _onBeforePhysicsObserver;
  51754. private _onAfterPhysicsObserver;
  51755. private _onAfterAnimationsObserver;
  51756. private _onBeforeCameraRenderObserver;
  51757. private _onAfterCameraRenderObserver;
  51758. /**
  51759. * Gets the perf counter used for active meshes evaluation time
  51760. */
  51761. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51762. /**
  51763. * Gets the active meshes evaluation time capture status
  51764. */
  51765. /**
  51766. * Enable or disable the active meshes evaluation time capture
  51767. */
  51768. captureActiveMeshesEvaluationTime: boolean;
  51769. /**
  51770. * Gets the perf counter used for render targets render time
  51771. */
  51772. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51773. /**
  51774. * Gets the render targets render time capture status
  51775. */
  51776. /**
  51777. * Enable or disable the render targets render time capture
  51778. */
  51779. captureRenderTargetsRenderTime: boolean;
  51780. /**
  51781. * Gets the perf counter used for particles render time
  51782. */
  51783. readonly particlesRenderTimeCounter: PerfCounter;
  51784. /**
  51785. * Gets the particles render time capture status
  51786. */
  51787. /**
  51788. * Enable or disable the particles render time capture
  51789. */
  51790. captureParticlesRenderTime: boolean;
  51791. /**
  51792. * Gets the perf counter used for sprites render time
  51793. */
  51794. readonly spritesRenderTimeCounter: PerfCounter;
  51795. /**
  51796. * Gets the sprites render time capture status
  51797. */
  51798. /**
  51799. * Enable or disable the sprites render time capture
  51800. */
  51801. captureSpritesRenderTime: boolean;
  51802. /**
  51803. * Gets the perf counter used for physics time
  51804. */
  51805. readonly physicsTimeCounter: PerfCounter;
  51806. /**
  51807. * Gets the physics time capture status
  51808. */
  51809. /**
  51810. * Enable or disable the physics time capture
  51811. */
  51812. capturePhysicsTime: boolean;
  51813. /**
  51814. * Gets the perf counter used for animations time
  51815. */
  51816. readonly animationsTimeCounter: PerfCounter;
  51817. /**
  51818. * Gets the animations time capture status
  51819. */
  51820. /**
  51821. * Enable or disable the animations time capture
  51822. */
  51823. captureAnimationsTime: boolean;
  51824. /**
  51825. * Gets the perf counter used for frame time capture
  51826. */
  51827. readonly frameTimeCounter: PerfCounter;
  51828. /**
  51829. * Gets the frame time capture status
  51830. */
  51831. /**
  51832. * Enable or disable the frame time capture
  51833. */
  51834. captureFrameTime: boolean;
  51835. /**
  51836. * Gets the perf counter used for inter-frames time capture
  51837. */
  51838. readonly interFrameTimeCounter: PerfCounter;
  51839. /**
  51840. * Gets the inter-frames time capture status
  51841. */
  51842. /**
  51843. * Enable or disable the inter-frames time capture
  51844. */
  51845. captureInterFrameTime: boolean;
  51846. /**
  51847. * Gets the perf counter used for render time capture
  51848. */
  51849. readonly renderTimeCounter: PerfCounter;
  51850. /**
  51851. * Gets the render time capture status
  51852. */
  51853. /**
  51854. * Enable or disable the render time capture
  51855. */
  51856. captureRenderTime: boolean;
  51857. /**
  51858. * Gets the perf counter used for camera render time capture
  51859. */
  51860. readonly cameraRenderTimeCounter: PerfCounter;
  51861. /**
  51862. * Gets the camera render time capture status
  51863. */
  51864. /**
  51865. * Enable or disable the camera render time capture
  51866. */
  51867. captureCameraRenderTime: boolean;
  51868. /**
  51869. * Gets the perf counter used for draw calls
  51870. */
  51871. readonly drawCallsCounter: PerfCounter;
  51872. /**
  51873. * Instantiates a new scene instrumentation.
  51874. * This class can be used to get instrumentation data from a Babylon engine
  51875. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51876. * @param scene Defines the scene to instrument
  51877. */
  51878. constructor(
  51879. /**
  51880. * Defines the scene to instrument
  51881. */
  51882. scene: Scene);
  51883. /**
  51884. * Dispose and release associated resources.
  51885. */
  51886. dispose(): void;
  51887. }
  51888. }
  51889. declare module "babylonjs/Instrumentation/index" {
  51890. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51891. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51892. export * from "babylonjs/Instrumentation/timeToken";
  51893. }
  51894. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51895. /** @hidden */
  51896. export var glowMapGenerationPixelShader: {
  51897. name: string;
  51898. shader: string;
  51899. };
  51900. }
  51901. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51902. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51903. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51904. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51905. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51907. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51908. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51909. /** @hidden */
  51910. export var glowMapGenerationVertexShader: {
  51911. name: string;
  51912. shader: string;
  51913. };
  51914. }
  51915. declare module "babylonjs/Layers/effectLayer" {
  51916. import { Observable } from "babylonjs/Misc/observable";
  51917. import { Nullable } from "babylonjs/types";
  51918. import { Camera } from "babylonjs/Cameras/camera";
  51919. import { Scene } from "babylonjs/scene";
  51920. import { ISize } from "babylonjs/Maths/math.size";
  51921. import { Color4 } from "babylonjs/Maths/math.color";
  51922. import { Engine } from "babylonjs/Engines/engine";
  51923. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51925. import { Mesh } from "babylonjs/Meshes/mesh";
  51926. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51928. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51929. import { Effect } from "babylonjs/Materials/effect";
  51930. import { Material } from "babylonjs/Materials/material";
  51931. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51932. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51933. /**
  51934. * Effect layer options. This helps customizing the behaviour
  51935. * of the effect layer.
  51936. */
  51937. export interface IEffectLayerOptions {
  51938. /**
  51939. * Multiplication factor apply to the canvas size to compute the render target size
  51940. * used to generated the objects (the smaller the faster).
  51941. */
  51942. mainTextureRatio: number;
  51943. /**
  51944. * Enforces a fixed size texture to ensure effect stability across devices.
  51945. */
  51946. mainTextureFixedSize?: number;
  51947. /**
  51948. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51949. */
  51950. alphaBlendingMode: number;
  51951. /**
  51952. * The camera attached to the layer.
  51953. */
  51954. camera: Nullable<Camera>;
  51955. /**
  51956. * The rendering group to draw the layer in.
  51957. */
  51958. renderingGroupId: number;
  51959. }
  51960. /**
  51961. * The effect layer Helps adding post process effect blended with the main pass.
  51962. *
  51963. * This can be for instance use to generate glow or higlight effects on the scene.
  51964. *
  51965. * The effect layer class can not be used directly and is intented to inherited from to be
  51966. * customized per effects.
  51967. */
  51968. export abstract class EffectLayer {
  51969. private _vertexBuffers;
  51970. private _indexBuffer;
  51971. private _cachedDefines;
  51972. private _effectLayerMapGenerationEffect;
  51973. private _effectLayerOptions;
  51974. private _mergeEffect;
  51975. protected _scene: Scene;
  51976. protected _engine: Engine;
  51977. protected _maxSize: number;
  51978. protected _mainTextureDesiredSize: ISize;
  51979. protected _mainTexture: RenderTargetTexture;
  51980. protected _shouldRender: boolean;
  51981. protected _postProcesses: PostProcess[];
  51982. protected _textures: BaseTexture[];
  51983. protected _emissiveTextureAndColor: {
  51984. texture: Nullable<BaseTexture>;
  51985. color: Color4;
  51986. };
  51987. /**
  51988. * The name of the layer
  51989. */
  51990. name: string;
  51991. /**
  51992. * The clear color of the texture used to generate the glow map.
  51993. */
  51994. neutralColor: Color4;
  51995. /**
  51996. * Specifies wether the highlight layer is enabled or not.
  51997. */
  51998. isEnabled: boolean;
  51999. /**
  52000. * Gets the camera attached to the layer.
  52001. */
  52002. readonly camera: Nullable<Camera>;
  52003. /**
  52004. * Gets the rendering group id the layer should render in.
  52005. */
  52006. renderingGroupId: number;
  52007. /**
  52008. * An event triggered when the effect layer has been disposed.
  52009. */
  52010. onDisposeObservable: Observable<EffectLayer>;
  52011. /**
  52012. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52013. */
  52014. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52015. /**
  52016. * An event triggered when the generated texture is being merged in the scene.
  52017. */
  52018. onBeforeComposeObservable: Observable<EffectLayer>;
  52019. /**
  52020. * An event triggered when the mesh is rendered into the effect render target.
  52021. */
  52022. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52023. /**
  52024. * An event triggered after the mesh has been rendered into the effect render target.
  52025. */
  52026. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52027. /**
  52028. * An event triggered when the generated texture has been merged in the scene.
  52029. */
  52030. onAfterComposeObservable: Observable<EffectLayer>;
  52031. /**
  52032. * An event triggered when the efffect layer changes its size.
  52033. */
  52034. onSizeChangedObservable: Observable<EffectLayer>;
  52035. /** @hidden */
  52036. static _SceneComponentInitialization: (scene: Scene) => void;
  52037. /**
  52038. * Instantiates a new effect Layer and references it in the scene.
  52039. * @param name The name of the layer
  52040. * @param scene The scene to use the layer in
  52041. */
  52042. constructor(
  52043. /** The Friendly of the effect in the scene */
  52044. name: string, scene: Scene);
  52045. /**
  52046. * Get the effect name of the layer.
  52047. * @return The effect name
  52048. */
  52049. abstract getEffectName(): string;
  52050. /**
  52051. * Checks for the readiness of the element composing the layer.
  52052. * @param subMesh the mesh to check for
  52053. * @param useInstances specify wether or not to use instances to render the mesh
  52054. * @return true if ready otherwise, false
  52055. */
  52056. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52057. /**
  52058. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52059. * @returns true if the effect requires stencil during the main canvas render pass.
  52060. */
  52061. abstract needStencil(): boolean;
  52062. /**
  52063. * Create the merge effect. This is the shader use to blit the information back
  52064. * to the main canvas at the end of the scene rendering.
  52065. * @returns The effect containing the shader used to merge the effect on the main canvas
  52066. */
  52067. protected abstract _createMergeEffect(): Effect;
  52068. /**
  52069. * Creates the render target textures and post processes used in the effect layer.
  52070. */
  52071. protected abstract _createTextureAndPostProcesses(): void;
  52072. /**
  52073. * Implementation specific of rendering the generating effect on the main canvas.
  52074. * @param effect The effect used to render through
  52075. */
  52076. protected abstract _internalRender(effect: Effect): void;
  52077. /**
  52078. * Sets the required values for both the emissive texture and and the main color.
  52079. */
  52080. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52081. /**
  52082. * Free any resources and references associated to a mesh.
  52083. * Internal use
  52084. * @param mesh The mesh to free.
  52085. */
  52086. abstract _disposeMesh(mesh: Mesh): void;
  52087. /**
  52088. * Serializes this layer (Glow or Highlight for example)
  52089. * @returns a serialized layer object
  52090. */
  52091. abstract serialize?(): any;
  52092. /**
  52093. * Initializes the effect layer with the required options.
  52094. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52095. */
  52096. protected _init(options: Partial<IEffectLayerOptions>): void;
  52097. /**
  52098. * Generates the index buffer of the full screen quad blending to the main canvas.
  52099. */
  52100. private _generateIndexBuffer;
  52101. /**
  52102. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52103. */
  52104. private _generateVertexBuffer;
  52105. /**
  52106. * Sets the main texture desired size which is the closest power of two
  52107. * of the engine canvas size.
  52108. */
  52109. private _setMainTextureSize;
  52110. /**
  52111. * Creates the main texture for the effect layer.
  52112. */
  52113. protected _createMainTexture(): void;
  52114. /**
  52115. * Adds specific effects defines.
  52116. * @param defines The defines to add specifics to.
  52117. */
  52118. protected _addCustomEffectDefines(defines: string[]): void;
  52119. /**
  52120. * Checks for the readiness of the element composing the layer.
  52121. * @param subMesh the mesh to check for
  52122. * @param useInstances specify wether or not to use instances to render the mesh
  52123. * @param emissiveTexture the associated emissive texture used to generate the glow
  52124. * @return true if ready otherwise, false
  52125. */
  52126. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52127. /**
  52128. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52129. */
  52130. render(): void;
  52131. /**
  52132. * Determine if a given mesh will be used in the current effect.
  52133. * @param mesh mesh to test
  52134. * @returns true if the mesh will be used
  52135. */
  52136. hasMesh(mesh: AbstractMesh): boolean;
  52137. /**
  52138. * Returns true if the layer contains information to display, otherwise false.
  52139. * @returns true if the glow layer should be rendered
  52140. */
  52141. shouldRender(): boolean;
  52142. /**
  52143. * Returns true if the mesh should render, otherwise false.
  52144. * @param mesh The mesh to render
  52145. * @returns true if it should render otherwise false
  52146. */
  52147. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52148. /**
  52149. * Returns true if the mesh can be rendered, otherwise false.
  52150. * @param mesh The mesh to render
  52151. * @param material The material used on the mesh
  52152. * @returns true if it can be rendered otherwise false
  52153. */
  52154. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52155. /**
  52156. * Returns true if the mesh should render, otherwise false.
  52157. * @param mesh The mesh to render
  52158. * @returns true if it should render otherwise false
  52159. */
  52160. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52161. /**
  52162. * Renders the submesh passed in parameter to the generation map.
  52163. */
  52164. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52165. /**
  52166. * Defines wether the current material of the mesh should be use to render the effect.
  52167. * @param mesh defines the current mesh to render
  52168. */
  52169. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52170. /**
  52171. * Rebuild the required buffers.
  52172. * @hidden Internal use only.
  52173. */
  52174. _rebuild(): void;
  52175. /**
  52176. * Dispose only the render target textures and post process.
  52177. */
  52178. private _disposeTextureAndPostProcesses;
  52179. /**
  52180. * Dispose the highlight layer and free resources.
  52181. */
  52182. dispose(): void;
  52183. /**
  52184. * Gets the class name of the effect layer
  52185. * @returns the string with the class name of the effect layer
  52186. */
  52187. getClassName(): string;
  52188. /**
  52189. * Creates an effect layer from parsed effect layer data
  52190. * @param parsedEffectLayer defines effect layer data
  52191. * @param scene defines the current scene
  52192. * @param rootUrl defines the root URL containing the effect layer information
  52193. * @returns a parsed effect Layer
  52194. */
  52195. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52196. }
  52197. }
  52198. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52199. import { Scene } from "babylonjs/scene";
  52200. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52201. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52202. import { AbstractScene } from "babylonjs/abstractScene";
  52203. module "babylonjs/abstractScene" {
  52204. interface AbstractScene {
  52205. /**
  52206. * The list of effect layers (highlights/glow) added to the scene
  52207. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52208. * @see http://doc.babylonjs.com/how_to/glow_layer
  52209. */
  52210. effectLayers: Array<EffectLayer>;
  52211. /**
  52212. * Removes the given effect layer from this scene.
  52213. * @param toRemove defines the effect layer to remove
  52214. * @returns the index of the removed effect layer
  52215. */
  52216. removeEffectLayer(toRemove: EffectLayer): number;
  52217. /**
  52218. * Adds the given effect layer to this scene
  52219. * @param newEffectLayer defines the effect layer to add
  52220. */
  52221. addEffectLayer(newEffectLayer: EffectLayer): void;
  52222. }
  52223. }
  52224. /**
  52225. * Defines the layer scene component responsible to manage any effect layers
  52226. * in a given scene.
  52227. */
  52228. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52229. /**
  52230. * The component name helpfull to identify the component in the list of scene components.
  52231. */
  52232. readonly name: string;
  52233. /**
  52234. * The scene the component belongs to.
  52235. */
  52236. scene: Scene;
  52237. private _engine;
  52238. private _renderEffects;
  52239. private _needStencil;
  52240. private _previousStencilState;
  52241. /**
  52242. * Creates a new instance of the component for the given scene
  52243. * @param scene Defines the scene to register the component in
  52244. */
  52245. constructor(scene: Scene);
  52246. /**
  52247. * Registers the component in a given scene
  52248. */
  52249. register(): void;
  52250. /**
  52251. * Rebuilds the elements related to this component in case of
  52252. * context lost for instance.
  52253. */
  52254. rebuild(): void;
  52255. /**
  52256. * Serializes the component data to the specified json object
  52257. * @param serializationObject The object to serialize to
  52258. */
  52259. serialize(serializationObject: any): void;
  52260. /**
  52261. * Adds all the elements from the container to the scene
  52262. * @param container the container holding the elements
  52263. */
  52264. addFromContainer(container: AbstractScene): void;
  52265. /**
  52266. * Removes all the elements in the container from the scene
  52267. * @param container contains the elements to remove
  52268. * @param dispose if the removed element should be disposed (default: false)
  52269. */
  52270. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52271. /**
  52272. * Disposes the component and the associated ressources.
  52273. */
  52274. dispose(): void;
  52275. private _isReadyForMesh;
  52276. private _renderMainTexture;
  52277. private _setStencil;
  52278. private _setStencilBack;
  52279. private _draw;
  52280. private _drawCamera;
  52281. private _drawRenderingGroup;
  52282. }
  52283. }
  52284. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52285. /** @hidden */
  52286. export var glowMapMergePixelShader: {
  52287. name: string;
  52288. shader: string;
  52289. };
  52290. }
  52291. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52292. /** @hidden */
  52293. export var glowMapMergeVertexShader: {
  52294. name: string;
  52295. shader: string;
  52296. };
  52297. }
  52298. declare module "babylonjs/Layers/glowLayer" {
  52299. import { Nullable } from "babylonjs/types";
  52300. import { Camera } from "babylonjs/Cameras/camera";
  52301. import { Scene } from "babylonjs/scene";
  52302. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52304. import { Mesh } from "babylonjs/Meshes/mesh";
  52305. import { Texture } from "babylonjs/Materials/Textures/texture";
  52306. import { Effect } from "babylonjs/Materials/effect";
  52307. import { Material } from "babylonjs/Materials/material";
  52308. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52309. import { Color4 } from "babylonjs/Maths/math.color";
  52310. import "babylonjs/Shaders/glowMapMerge.fragment";
  52311. import "babylonjs/Shaders/glowMapMerge.vertex";
  52312. import "babylonjs/Layers/effectLayerSceneComponent";
  52313. module "babylonjs/abstractScene" {
  52314. interface AbstractScene {
  52315. /**
  52316. * Return a the first highlight layer of the scene with a given name.
  52317. * @param name The name of the highlight layer to look for.
  52318. * @return The highlight layer if found otherwise null.
  52319. */
  52320. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52321. }
  52322. }
  52323. /**
  52324. * Glow layer options. This helps customizing the behaviour
  52325. * of the glow layer.
  52326. */
  52327. export interface IGlowLayerOptions {
  52328. /**
  52329. * Multiplication factor apply to the canvas size to compute the render target size
  52330. * used to generated the glowing objects (the smaller the faster).
  52331. */
  52332. mainTextureRatio: number;
  52333. /**
  52334. * Enforces a fixed size texture to ensure resize independant blur.
  52335. */
  52336. mainTextureFixedSize?: number;
  52337. /**
  52338. * How big is the kernel of the blur texture.
  52339. */
  52340. blurKernelSize: number;
  52341. /**
  52342. * The camera attached to the layer.
  52343. */
  52344. camera: Nullable<Camera>;
  52345. /**
  52346. * Enable MSAA by chosing the number of samples.
  52347. */
  52348. mainTextureSamples?: number;
  52349. /**
  52350. * The rendering group to draw the layer in.
  52351. */
  52352. renderingGroupId: number;
  52353. }
  52354. /**
  52355. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52356. *
  52357. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52358. *
  52359. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52360. */
  52361. export class GlowLayer extends EffectLayer {
  52362. /**
  52363. * Effect Name of the layer.
  52364. */
  52365. static readonly EffectName: string;
  52366. /**
  52367. * The default blur kernel size used for the glow.
  52368. */
  52369. static DefaultBlurKernelSize: number;
  52370. /**
  52371. * The default texture size ratio used for the glow.
  52372. */
  52373. static DefaultTextureRatio: number;
  52374. /**
  52375. * Sets the kernel size of the blur.
  52376. */
  52377. /**
  52378. * Gets the kernel size of the blur.
  52379. */
  52380. blurKernelSize: number;
  52381. /**
  52382. * Sets the glow intensity.
  52383. */
  52384. /**
  52385. * Gets the glow intensity.
  52386. */
  52387. intensity: number;
  52388. private _options;
  52389. private _intensity;
  52390. private _horizontalBlurPostprocess1;
  52391. private _verticalBlurPostprocess1;
  52392. private _horizontalBlurPostprocess2;
  52393. private _verticalBlurPostprocess2;
  52394. private _blurTexture1;
  52395. private _blurTexture2;
  52396. private _postProcesses1;
  52397. private _postProcesses2;
  52398. private _includedOnlyMeshes;
  52399. private _excludedMeshes;
  52400. private _meshesUsingTheirOwnMaterials;
  52401. /**
  52402. * Callback used to let the user override the color selection on a per mesh basis
  52403. */
  52404. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52405. /**
  52406. * Callback used to let the user override the texture selection on a per mesh basis
  52407. */
  52408. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52409. /**
  52410. * Instantiates a new glow Layer and references it to the scene.
  52411. * @param name The name of the layer
  52412. * @param scene The scene to use the layer in
  52413. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52414. */
  52415. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52416. /**
  52417. * Get the effect name of the layer.
  52418. * @return The effect name
  52419. */
  52420. getEffectName(): string;
  52421. /**
  52422. * Create the merge effect. This is the shader use to blit the information back
  52423. * to the main canvas at the end of the scene rendering.
  52424. */
  52425. protected _createMergeEffect(): Effect;
  52426. /**
  52427. * Creates the render target textures and post processes used in the glow layer.
  52428. */
  52429. protected _createTextureAndPostProcesses(): void;
  52430. /**
  52431. * Checks for the readiness of the element composing the layer.
  52432. * @param subMesh the mesh to check for
  52433. * @param useInstances specify wether or not to use instances to render the mesh
  52434. * @param emissiveTexture the associated emissive texture used to generate the glow
  52435. * @return true if ready otherwise, false
  52436. */
  52437. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52438. /**
  52439. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52440. */
  52441. needStencil(): boolean;
  52442. /**
  52443. * Returns true if the mesh can be rendered, otherwise false.
  52444. * @param mesh The mesh to render
  52445. * @param material The material used on the mesh
  52446. * @returns true if it can be rendered otherwise false
  52447. */
  52448. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52449. /**
  52450. * Implementation specific of rendering the generating effect on the main canvas.
  52451. * @param effect The effect used to render through
  52452. */
  52453. protected _internalRender(effect: Effect): void;
  52454. /**
  52455. * Sets the required values for both the emissive texture and and the main color.
  52456. */
  52457. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52458. /**
  52459. * Returns true if the mesh should render, otherwise false.
  52460. * @param mesh The mesh to render
  52461. * @returns true if it should render otherwise false
  52462. */
  52463. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52464. /**
  52465. * Adds specific effects defines.
  52466. * @param defines The defines to add specifics to.
  52467. */
  52468. protected _addCustomEffectDefines(defines: string[]): void;
  52469. /**
  52470. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52471. * @param mesh The mesh to exclude from the glow layer
  52472. */
  52473. addExcludedMesh(mesh: Mesh): void;
  52474. /**
  52475. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52476. * @param mesh The mesh to remove
  52477. */
  52478. removeExcludedMesh(mesh: Mesh): void;
  52479. /**
  52480. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52481. * @param mesh The mesh to include in the glow layer
  52482. */
  52483. addIncludedOnlyMesh(mesh: Mesh): void;
  52484. /**
  52485. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52486. * @param mesh The mesh to remove
  52487. */
  52488. removeIncludedOnlyMesh(mesh: Mesh): void;
  52489. /**
  52490. * Determine if a given mesh will be used in the glow layer
  52491. * @param mesh The mesh to test
  52492. * @returns true if the mesh will be highlighted by the current glow layer
  52493. */
  52494. hasMesh(mesh: AbstractMesh): boolean;
  52495. /**
  52496. * Defines wether the current material of the mesh should be use to render the effect.
  52497. * @param mesh defines the current mesh to render
  52498. */
  52499. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52500. /**
  52501. * Add a mesh to be rendered through its own material and not with emissive only.
  52502. * @param mesh The mesh for which we need to use its material
  52503. */
  52504. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52505. /**
  52506. * Remove a mesh from being rendered through its own material and not with emissive only.
  52507. * @param mesh The mesh for which we need to not use its material
  52508. */
  52509. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52510. /**
  52511. * Free any resources and references associated to a mesh.
  52512. * Internal use
  52513. * @param mesh The mesh to free.
  52514. * @hidden
  52515. */
  52516. _disposeMesh(mesh: Mesh): void;
  52517. /**
  52518. * Gets the class name of the effect layer
  52519. * @returns the string with the class name of the effect layer
  52520. */
  52521. getClassName(): string;
  52522. /**
  52523. * Serializes this glow layer
  52524. * @returns a serialized glow layer object
  52525. */
  52526. serialize(): any;
  52527. /**
  52528. * Creates a Glow Layer from parsed glow layer data
  52529. * @param parsedGlowLayer defines glow layer data
  52530. * @param scene defines the current scene
  52531. * @param rootUrl defines the root URL containing the glow layer information
  52532. * @returns a parsed Glow Layer
  52533. */
  52534. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52535. }
  52536. }
  52537. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52538. /** @hidden */
  52539. export var glowBlurPostProcessPixelShader: {
  52540. name: string;
  52541. shader: string;
  52542. };
  52543. }
  52544. declare module "babylonjs/Layers/highlightLayer" {
  52545. import { Observable } from "babylonjs/Misc/observable";
  52546. import { Nullable } from "babylonjs/types";
  52547. import { Camera } from "babylonjs/Cameras/camera";
  52548. import { Scene } from "babylonjs/scene";
  52549. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52551. import { Mesh } from "babylonjs/Meshes/mesh";
  52552. import { Effect } from "babylonjs/Materials/effect";
  52553. import { Material } from "babylonjs/Materials/material";
  52554. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52555. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52556. import "babylonjs/Shaders/glowMapMerge.fragment";
  52557. import "babylonjs/Shaders/glowMapMerge.vertex";
  52558. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52559. module "babylonjs/abstractScene" {
  52560. interface AbstractScene {
  52561. /**
  52562. * Return a the first highlight layer of the scene with a given name.
  52563. * @param name The name of the highlight layer to look for.
  52564. * @return The highlight layer if found otherwise null.
  52565. */
  52566. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52567. }
  52568. }
  52569. /**
  52570. * Highlight layer options. This helps customizing the behaviour
  52571. * of the highlight layer.
  52572. */
  52573. export interface IHighlightLayerOptions {
  52574. /**
  52575. * Multiplication factor apply to the canvas size to compute the render target size
  52576. * used to generated the glowing objects (the smaller the faster).
  52577. */
  52578. mainTextureRatio: number;
  52579. /**
  52580. * Enforces a fixed size texture to ensure resize independant blur.
  52581. */
  52582. mainTextureFixedSize?: number;
  52583. /**
  52584. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52585. * of the picture to blur (the smaller the faster).
  52586. */
  52587. blurTextureSizeRatio: number;
  52588. /**
  52589. * How big in texel of the blur texture is the vertical blur.
  52590. */
  52591. blurVerticalSize: number;
  52592. /**
  52593. * How big in texel of the blur texture is the horizontal blur.
  52594. */
  52595. blurHorizontalSize: number;
  52596. /**
  52597. * Alpha blending mode used to apply the blur. Default is combine.
  52598. */
  52599. alphaBlendingMode: number;
  52600. /**
  52601. * The camera attached to the layer.
  52602. */
  52603. camera: Nullable<Camera>;
  52604. /**
  52605. * Should we display highlight as a solid stroke?
  52606. */
  52607. isStroke?: boolean;
  52608. /**
  52609. * The rendering group to draw the layer in.
  52610. */
  52611. renderingGroupId: number;
  52612. }
  52613. /**
  52614. * The highlight layer Helps adding a glow effect around a mesh.
  52615. *
  52616. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52617. * glowy meshes to your scene.
  52618. *
  52619. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52620. */
  52621. export class HighlightLayer extends EffectLayer {
  52622. name: string;
  52623. /**
  52624. * Effect Name of the highlight layer.
  52625. */
  52626. static readonly EffectName: string;
  52627. /**
  52628. * The neutral color used during the preparation of the glow effect.
  52629. * This is black by default as the blend operation is a blend operation.
  52630. */
  52631. static NeutralColor: Color4;
  52632. /**
  52633. * Stencil value used for glowing meshes.
  52634. */
  52635. static GlowingMeshStencilReference: number;
  52636. /**
  52637. * Stencil value used for the other meshes in the scene.
  52638. */
  52639. static NormalMeshStencilReference: number;
  52640. /**
  52641. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52642. */
  52643. innerGlow: boolean;
  52644. /**
  52645. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52646. */
  52647. outerGlow: boolean;
  52648. /**
  52649. * Specifies the horizontal size of the blur.
  52650. */
  52651. /**
  52652. * Gets the horizontal size of the blur.
  52653. */
  52654. blurHorizontalSize: number;
  52655. /**
  52656. * Specifies the vertical size of the blur.
  52657. */
  52658. /**
  52659. * Gets the vertical size of the blur.
  52660. */
  52661. blurVerticalSize: number;
  52662. /**
  52663. * An event triggered when the highlight layer is being blurred.
  52664. */
  52665. onBeforeBlurObservable: Observable<HighlightLayer>;
  52666. /**
  52667. * An event triggered when the highlight layer has been blurred.
  52668. */
  52669. onAfterBlurObservable: Observable<HighlightLayer>;
  52670. private _instanceGlowingMeshStencilReference;
  52671. private _options;
  52672. private _downSamplePostprocess;
  52673. private _horizontalBlurPostprocess;
  52674. private _verticalBlurPostprocess;
  52675. private _blurTexture;
  52676. private _meshes;
  52677. private _excludedMeshes;
  52678. /**
  52679. * Instantiates a new highlight Layer and references it to the scene..
  52680. * @param name The name of the layer
  52681. * @param scene The scene to use the layer in
  52682. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52683. */
  52684. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52685. /**
  52686. * Get the effect name of the layer.
  52687. * @return The effect name
  52688. */
  52689. getEffectName(): string;
  52690. /**
  52691. * Create the merge effect. This is the shader use to blit the information back
  52692. * to the main canvas at the end of the scene rendering.
  52693. */
  52694. protected _createMergeEffect(): Effect;
  52695. /**
  52696. * Creates the render target textures and post processes used in the highlight layer.
  52697. */
  52698. protected _createTextureAndPostProcesses(): void;
  52699. /**
  52700. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52701. */
  52702. needStencil(): boolean;
  52703. /**
  52704. * Checks for the readiness of the element composing the layer.
  52705. * @param subMesh the mesh to check for
  52706. * @param useInstances specify wether or not to use instances to render the mesh
  52707. * @param emissiveTexture the associated emissive texture used to generate the glow
  52708. * @return true if ready otherwise, false
  52709. */
  52710. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52711. /**
  52712. * Implementation specific of rendering the generating effect on the main canvas.
  52713. * @param effect The effect used to render through
  52714. */
  52715. protected _internalRender(effect: Effect): void;
  52716. /**
  52717. * Returns true if the layer contains information to display, otherwise false.
  52718. */
  52719. shouldRender(): boolean;
  52720. /**
  52721. * Returns true if the mesh should render, otherwise false.
  52722. * @param mesh The mesh to render
  52723. * @returns true if it should render otherwise false
  52724. */
  52725. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52726. /**
  52727. * Sets the required values for both the emissive texture and and the main color.
  52728. */
  52729. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52730. /**
  52731. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52732. * @param mesh The mesh to exclude from the highlight layer
  52733. */
  52734. addExcludedMesh(mesh: Mesh): void;
  52735. /**
  52736. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52737. * @param mesh The mesh to highlight
  52738. */
  52739. removeExcludedMesh(mesh: Mesh): void;
  52740. /**
  52741. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52742. * @param mesh mesh to test
  52743. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52744. */
  52745. hasMesh(mesh: AbstractMesh): boolean;
  52746. /**
  52747. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52748. * @param mesh The mesh to highlight
  52749. * @param color The color of the highlight
  52750. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52751. */
  52752. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52753. /**
  52754. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52755. * @param mesh The mesh to highlight
  52756. */
  52757. removeMesh(mesh: Mesh): void;
  52758. /**
  52759. * Force the stencil to the normal expected value for none glowing parts
  52760. */
  52761. private _defaultStencilReference;
  52762. /**
  52763. * Free any resources and references associated to a mesh.
  52764. * Internal use
  52765. * @param mesh The mesh to free.
  52766. * @hidden
  52767. */
  52768. _disposeMesh(mesh: Mesh): void;
  52769. /**
  52770. * Dispose the highlight layer and free resources.
  52771. */
  52772. dispose(): void;
  52773. /**
  52774. * Gets the class name of the effect layer
  52775. * @returns the string with the class name of the effect layer
  52776. */
  52777. getClassName(): string;
  52778. /**
  52779. * Serializes this Highlight layer
  52780. * @returns a serialized Highlight layer object
  52781. */
  52782. serialize(): any;
  52783. /**
  52784. * Creates a Highlight layer from parsed Highlight layer data
  52785. * @param parsedHightlightLayer defines the Highlight layer data
  52786. * @param scene defines the current scene
  52787. * @param rootUrl defines the root URL containing the Highlight layer information
  52788. * @returns a parsed Highlight layer
  52789. */
  52790. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52791. }
  52792. }
  52793. declare module "babylonjs/Layers/layerSceneComponent" {
  52794. import { Scene } from "babylonjs/scene";
  52795. import { ISceneComponent } from "babylonjs/sceneComponent";
  52796. import { Layer } from "babylonjs/Layers/layer";
  52797. import { AbstractScene } from "babylonjs/abstractScene";
  52798. module "babylonjs/abstractScene" {
  52799. interface AbstractScene {
  52800. /**
  52801. * The list of layers (background and foreground) of the scene
  52802. */
  52803. layers: Array<Layer>;
  52804. }
  52805. }
  52806. /**
  52807. * Defines the layer scene component responsible to manage any layers
  52808. * in a given scene.
  52809. */
  52810. export class LayerSceneComponent implements ISceneComponent {
  52811. /**
  52812. * The component name helpfull to identify the component in the list of scene components.
  52813. */
  52814. readonly name: string;
  52815. /**
  52816. * The scene the component belongs to.
  52817. */
  52818. scene: Scene;
  52819. private _engine;
  52820. /**
  52821. * Creates a new instance of the component for the given scene
  52822. * @param scene Defines the scene to register the component in
  52823. */
  52824. constructor(scene: Scene);
  52825. /**
  52826. * Registers the component in a given scene
  52827. */
  52828. register(): void;
  52829. /**
  52830. * Rebuilds the elements related to this component in case of
  52831. * context lost for instance.
  52832. */
  52833. rebuild(): void;
  52834. /**
  52835. * Disposes the component and the associated ressources.
  52836. */
  52837. dispose(): void;
  52838. private _draw;
  52839. private _drawCameraPredicate;
  52840. private _drawCameraBackground;
  52841. private _drawCameraForeground;
  52842. private _drawRenderTargetPredicate;
  52843. private _drawRenderTargetBackground;
  52844. private _drawRenderTargetForeground;
  52845. /**
  52846. * Adds all the elements from the container to the scene
  52847. * @param container the container holding the elements
  52848. */
  52849. addFromContainer(container: AbstractScene): void;
  52850. /**
  52851. * Removes all the elements in the container from the scene
  52852. * @param container contains the elements to remove
  52853. * @param dispose if the removed element should be disposed (default: false)
  52854. */
  52855. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52856. }
  52857. }
  52858. declare module "babylonjs/Shaders/layer.fragment" {
  52859. /** @hidden */
  52860. export var layerPixelShader: {
  52861. name: string;
  52862. shader: string;
  52863. };
  52864. }
  52865. declare module "babylonjs/Shaders/layer.vertex" {
  52866. /** @hidden */
  52867. export var layerVertexShader: {
  52868. name: string;
  52869. shader: string;
  52870. };
  52871. }
  52872. declare module "babylonjs/Layers/layer" {
  52873. import { Observable } from "babylonjs/Misc/observable";
  52874. import { Nullable } from "babylonjs/types";
  52875. import { Scene } from "babylonjs/scene";
  52876. import { Vector2 } from "babylonjs/Maths/math.vector";
  52877. import { Color4 } from "babylonjs/Maths/math.color";
  52878. import { Texture } from "babylonjs/Materials/Textures/texture";
  52879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52880. import "babylonjs/Shaders/layer.fragment";
  52881. import "babylonjs/Shaders/layer.vertex";
  52882. /**
  52883. * This represents a full screen 2d layer.
  52884. * This can be useful to display a picture in the background of your scene for instance.
  52885. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52886. */
  52887. export class Layer {
  52888. /**
  52889. * Define the name of the layer.
  52890. */
  52891. name: string;
  52892. /**
  52893. * Define the texture the layer should display.
  52894. */
  52895. texture: Nullable<Texture>;
  52896. /**
  52897. * Is the layer in background or foreground.
  52898. */
  52899. isBackground: boolean;
  52900. /**
  52901. * Define the color of the layer (instead of texture).
  52902. */
  52903. color: Color4;
  52904. /**
  52905. * Define the scale of the layer in order to zoom in out of the texture.
  52906. */
  52907. scale: Vector2;
  52908. /**
  52909. * Define an offset for the layer in order to shift the texture.
  52910. */
  52911. offset: Vector2;
  52912. /**
  52913. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52914. */
  52915. alphaBlendingMode: number;
  52916. /**
  52917. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52918. * Alpha test will not mix with the background color in case of transparency.
  52919. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52920. */
  52921. alphaTest: boolean;
  52922. /**
  52923. * Define a mask to restrict the layer to only some of the scene cameras.
  52924. */
  52925. layerMask: number;
  52926. /**
  52927. * Define the list of render target the layer is visible into.
  52928. */
  52929. renderTargetTextures: RenderTargetTexture[];
  52930. /**
  52931. * Define if the layer is only used in renderTarget or if it also
  52932. * renders in the main frame buffer of the canvas.
  52933. */
  52934. renderOnlyInRenderTargetTextures: boolean;
  52935. private _scene;
  52936. private _vertexBuffers;
  52937. private _indexBuffer;
  52938. private _effect;
  52939. private _alphaTestEffect;
  52940. /**
  52941. * An event triggered when the layer is disposed.
  52942. */
  52943. onDisposeObservable: Observable<Layer>;
  52944. private _onDisposeObserver;
  52945. /**
  52946. * Back compatibility with callback before the onDisposeObservable existed.
  52947. * The set callback will be triggered when the layer has been disposed.
  52948. */
  52949. onDispose: () => void;
  52950. /**
  52951. * An event triggered before rendering the scene
  52952. */
  52953. onBeforeRenderObservable: Observable<Layer>;
  52954. private _onBeforeRenderObserver;
  52955. /**
  52956. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52957. * The set callback will be triggered just before rendering the layer.
  52958. */
  52959. onBeforeRender: () => void;
  52960. /**
  52961. * An event triggered after rendering the scene
  52962. */
  52963. onAfterRenderObservable: Observable<Layer>;
  52964. private _onAfterRenderObserver;
  52965. /**
  52966. * Back compatibility with callback before the onAfterRenderObservable existed.
  52967. * The set callback will be triggered just after rendering the layer.
  52968. */
  52969. onAfterRender: () => void;
  52970. /**
  52971. * Instantiates a new layer.
  52972. * This represents a full screen 2d layer.
  52973. * This can be useful to display a picture in the background of your scene for instance.
  52974. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52975. * @param name Define the name of the layer in the scene
  52976. * @param imgUrl Define the url of the texture to display in the layer
  52977. * @param scene Define the scene the layer belongs to
  52978. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52979. * @param color Defines a color for the layer
  52980. */
  52981. constructor(
  52982. /**
  52983. * Define the name of the layer.
  52984. */
  52985. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52986. private _createIndexBuffer;
  52987. /** @hidden */
  52988. _rebuild(): void;
  52989. /**
  52990. * Renders the layer in the scene.
  52991. */
  52992. render(): void;
  52993. /**
  52994. * Disposes and releases the associated ressources.
  52995. */
  52996. dispose(): void;
  52997. }
  52998. }
  52999. declare module "babylonjs/Layers/index" {
  53000. export * from "babylonjs/Layers/effectLayer";
  53001. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53002. export * from "babylonjs/Layers/glowLayer";
  53003. export * from "babylonjs/Layers/highlightLayer";
  53004. export * from "babylonjs/Layers/layer";
  53005. export * from "babylonjs/Layers/layerSceneComponent";
  53006. }
  53007. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53008. /** @hidden */
  53009. export var lensFlarePixelShader: {
  53010. name: string;
  53011. shader: string;
  53012. };
  53013. }
  53014. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53015. /** @hidden */
  53016. export var lensFlareVertexShader: {
  53017. name: string;
  53018. shader: string;
  53019. };
  53020. }
  53021. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53022. import { Scene } from "babylonjs/scene";
  53023. import { Vector3 } from "babylonjs/Maths/math.vector";
  53024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53025. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53026. import "babylonjs/Shaders/lensFlare.fragment";
  53027. import "babylonjs/Shaders/lensFlare.vertex";
  53028. import { Viewport } from "babylonjs/Maths/math.viewport";
  53029. /**
  53030. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53031. * It is usually composed of several `lensFlare`.
  53032. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53033. */
  53034. export class LensFlareSystem {
  53035. /**
  53036. * Define the name of the lens flare system
  53037. */
  53038. name: string;
  53039. /**
  53040. * List of lens flares used in this system.
  53041. */
  53042. lensFlares: LensFlare[];
  53043. /**
  53044. * Define a limit from the border the lens flare can be visible.
  53045. */
  53046. borderLimit: number;
  53047. /**
  53048. * Define a viewport border we do not want to see the lens flare in.
  53049. */
  53050. viewportBorder: number;
  53051. /**
  53052. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53053. */
  53054. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53055. /**
  53056. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53057. */
  53058. layerMask: number;
  53059. /**
  53060. * Define the id of the lens flare system in the scene.
  53061. * (equal to name by default)
  53062. */
  53063. id: string;
  53064. private _scene;
  53065. private _emitter;
  53066. private _vertexBuffers;
  53067. private _indexBuffer;
  53068. private _effect;
  53069. private _positionX;
  53070. private _positionY;
  53071. private _isEnabled;
  53072. /** @hidden */
  53073. static _SceneComponentInitialization: (scene: Scene) => void;
  53074. /**
  53075. * Instantiates a lens flare system.
  53076. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53077. * It is usually composed of several `lensFlare`.
  53078. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53079. * @param name Define the name of the lens flare system in the scene
  53080. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53081. * @param scene Define the scene the lens flare system belongs to
  53082. */
  53083. constructor(
  53084. /**
  53085. * Define the name of the lens flare system
  53086. */
  53087. name: string, emitter: any, scene: Scene);
  53088. /**
  53089. * Define if the lens flare system is enabled.
  53090. */
  53091. isEnabled: boolean;
  53092. /**
  53093. * Get the scene the effects belongs to.
  53094. * @returns the scene holding the lens flare system
  53095. */
  53096. getScene(): Scene;
  53097. /**
  53098. * Get the emitter of the lens flare system.
  53099. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53100. * @returns the emitter of the lens flare system
  53101. */
  53102. getEmitter(): any;
  53103. /**
  53104. * Set the emitter of the lens flare system.
  53105. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53106. * @param newEmitter Define the new emitter of the system
  53107. */
  53108. setEmitter(newEmitter: any): void;
  53109. /**
  53110. * Get the lens flare system emitter position.
  53111. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53112. * @returns the position
  53113. */
  53114. getEmitterPosition(): Vector3;
  53115. /**
  53116. * @hidden
  53117. */
  53118. computeEffectivePosition(globalViewport: Viewport): boolean;
  53119. /** @hidden */
  53120. _isVisible(): boolean;
  53121. /**
  53122. * @hidden
  53123. */
  53124. render(): boolean;
  53125. /**
  53126. * Dispose and release the lens flare with its associated resources.
  53127. */
  53128. dispose(): void;
  53129. /**
  53130. * Parse a lens flare system from a JSON repressentation
  53131. * @param parsedLensFlareSystem Define the JSON to parse
  53132. * @param scene Define the scene the parsed system should be instantiated in
  53133. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53134. * @returns the parsed system
  53135. */
  53136. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53137. /**
  53138. * Serialize the current Lens Flare System into a JSON representation.
  53139. * @returns the serialized JSON
  53140. */
  53141. serialize(): any;
  53142. }
  53143. }
  53144. declare module "babylonjs/LensFlares/lensFlare" {
  53145. import { Nullable } from "babylonjs/types";
  53146. import { Color3 } from "babylonjs/Maths/math.color";
  53147. import { Texture } from "babylonjs/Materials/Textures/texture";
  53148. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53149. /**
  53150. * This represents one of the lens effect in a `lensFlareSystem`.
  53151. * It controls one of the indiviual texture used in the effect.
  53152. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53153. */
  53154. export class LensFlare {
  53155. /**
  53156. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53157. */
  53158. size: number;
  53159. /**
  53160. * 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.
  53161. */
  53162. position: number;
  53163. /**
  53164. * Define the lens color.
  53165. */
  53166. color: Color3;
  53167. /**
  53168. * Define the lens texture.
  53169. */
  53170. texture: Nullable<Texture>;
  53171. /**
  53172. * Define the alpha mode to render this particular lens.
  53173. */
  53174. alphaMode: number;
  53175. private _system;
  53176. /**
  53177. * Creates a new Lens Flare.
  53178. * This represents one of the lens effect in a `lensFlareSystem`.
  53179. * It controls one of the indiviual texture used in the effect.
  53180. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53181. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53182. * @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.
  53183. * @param color Define the lens color
  53184. * @param imgUrl Define the lens texture url
  53185. * @param system Define the `lensFlareSystem` this flare is part of
  53186. * @returns The newly created Lens Flare
  53187. */
  53188. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53189. /**
  53190. * Instantiates a new Lens Flare.
  53191. * This represents one of the lens effect in a `lensFlareSystem`.
  53192. * It controls one of the indiviual texture used in the effect.
  53193. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53194. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53195. * @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.
  53196. * @param color Define the lens color
  53197. * @param imgUrl Define the lens texture url
  53198. * @param system Define the `lensFlareSystem` this flare is part of
  53199. */
  53200. constructor(
  53201. /**
  53202. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53203. */
  53204. size: number,
  53205. /**
  53206. * 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.
  53207. */
  53208. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53209. /**
  53210. * Dispose and release the lens flare with its associated resources.
  53211. */
  53212. dispose(): void;
  53213. }
  53214. }
  53215. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53216. import { Nullable } from "babylonjs/types";
  53217. import { Scene } from "babylonjs/scene";
  53218. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53219. import { AbstractScene } from "babylonjs/abstractScene";
  53220. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53221. module "babylonjs/abstractScene" {
  53222. interface AbstractScene {
  53223. /**
  53224. * The list of lens flare system added to the scene
  53225. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53226. */
  53227. lensFlareSystems: Array<LensFlareSystem>;
  53228. /**
  53229. * Removes the given lens flare system from this scene.
  53230. * @param toRemove The lens flare system to remove
  53231. * @returns The index of the removed lens flare system
  53232. */
  53233. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53234. /**
  53235. * Adds the given lens flare system to this scene
  53236. * @param newLensFlareSystem The lens flare system to add
  53237. */
  53238. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53239. /**
  53240. * Gets a lens flare system using its name
  53241. * @param name defines the name to look for
  53242. * @returns the lens flare system or null if not found
  53243. */
  53244. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53245. /**
  53246. * Gets a lens flare system using its id
  53247. * @param id defines the id to look for
  53248. * @returns the lens flare system or null if not found
  53249. */
  53250. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53251. }
  53252. }
  53253. /**
  53254. * Defines the lens flare scene component responsible to manage any lens flares
  53255. * in a given scene.
  53256. */
  53257. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53258. /**
  53259. * The component name helpfull to identify the component in the list of scene components.
  53260. */
  53261. readonly name: string;
  53262. /**
  53263. * The scene the component belongs to.
  53264. */
  53265. scene: Scene;
  53266. /**
  53267. * Creates a new instance of the component for the given scene
  53268. * @param scene Defines the scene to register the component in
  53269. */
  53270. constructor(scene: Scene);
  53271. /**
  53272. * Registers the component in a given scene
  53273. */
  53274. register(): void;
  53275. /**
  53276. * Rebuilds the elements related to this component in case of
  53277. * context lost for instance.
  53278. */
  53279. rebuild(): void;
  53280. /**
  53281. * Adds all the elements from the container to the scene
  53282. * @param container the container holding the elements
  53283. */
  53284. addFromContainer(container: AbstractScene): void;
  53285. /**
  53286. * Removes all the elements in the container from the scene
  53287. * @param container contains the elements to remove
  53288. * @param dispose if the removed element should be disposed (default: false)
  53289. */
  53290. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53291. /**
  53292. * Serializes the component data to the specified json object
  53293. * @param serializationObject The object to serialize to
  53294. */
  53295. serialize(serializationObject: any): void;
  53296. /**
  53297. * Disposes the component and the associated ressources.
  53298. */
  53299. dispose(): void;
  53300. private _draw;
  53301. }
  53302. }
  53303. declare module "babylonjs/LensFlares/index" {
  53304. export * from "babylonjs/LensFlares/lensFlare";
  53305. export * from "babylonjs/LensFlares/lensFlareSystem";
  53306. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53307. }
  53308. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53309. import { Scene } from "babylonjs/scene";
  53310. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53311. import { AbstractScene } from "babylonjs/abstractScene";
  53312. /**
  53313. * Defines the shadow generator component responsible to manage any shadow generators
  53314. * in a given scene.
  53315. */
  53316. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53317. /**
  53318. * The component name helpfull to identify the component in the list of scene components.
  53319. */
  53320. readonly name: string;
  53321. /**
  53322. * The scene the component belongs to.
  53323. */
  53324. scene: Scene;
  53325. /**
  53326. * Creates a new instance of the component for the given scene
  53327. * @param scene Defines the scene to register the component in
  53328. */
  53329. constructor(scene: Scene);
  53330. /**
  53331. * Registers the component in a given scene
  53332. */
  53333. register(): void;
  53334. /**
  53335. * Rebuilds the elements related to this component in case of
  53336. * context lost for instance.
  53337. */
  53338. rebuild(): void;
  53339. /**
  53340. * Serializes the component data to the specified json object
  53341. * @param serializationObject The object to serialize to
  53342. */
  53343. serialize(serializationObject: any): void;
  53344. /**
  53345. * Adds all the elements from the container to the scene
  53346. * @param container the container holding the elements
  53347. */
  53348. addFromContainer(container: AbstractScene): void;
  53349. /**
  53350. * Removes all the elements in the container from the scene
  53351. * @param container contains the elements to remove
  53352. * @param dispose if the removed element should be disposed (default: false)
  53353. */
  53354. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53355. /**
  53356. * Rebuilds the elements related to this component in case of
  53357. * context lost for instance.
  53358. */
  53359. dispose(): void;
  53360. private _gatherRenderTargets;
  53361. }
  53362. }
  53363. declare module "babylonjs/Lights/Shadows/index" {
  53364. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53365. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53366. }
  53367. declare module "babylonjs/Lights/pointLight" {
  53368. import { Scene } from "babylonjs/scene";
  53369. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53371. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53372. import { Effect } from "babylonjs/Materials/effect";
  53373. /**
  53374. * A point light is a light defined by an unique point in world space.
  53375. * The light is emitted in every direction from this point.
  53376. * A good example of a point light is a standard light bulb.
  53377. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53378. */
  53379. export class PointLight extends ShadowLight {
  53380. private _shadowAngle;
  53381. /**
  53382. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53383. * This specifies what angle the shadow will use to be created.
  53384. *
  53385. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53386. */
  53387. /**
  53388. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53389. * This specifies what angle the shadow will use to be created.
  53390. *
  53391. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53392. */
  53393. shadowAngle: number;
  53394. /**
  53395. * Gets the direction if it has been set.
  53396. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53397. */
  53398. /**
  53399. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53400. */
  53401. direction: Vector3;
  53402. /**
  53403. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53404. * A PointLight emits the light in every direction.
  53405. * It can cast shadows.
  53406. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53407. * ```javascript
  53408. * var pointLight = new PointLight("pl", camera.position, scene);
  53409. * ```
  53410. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53411. * @param name The light friendly name
  53412. * @param position The position of the point light in the scene
  53413. * @param scene The scene the lights belongs to
  53414. */
  53415. constructor(name: string, position: Vector3, scene: Scene);
  53416. /**
  53417. * Returns the string "PointLight"
  53418. * @returns the class name
  53419. */
  53420. getClassName(): string;
  53421. /**
  53422. * Returns the integer 0.
  53423. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53424. */
  53425. getTypeID(): number;
  53426. /**
  53427. * Specifies wether or not the shadowmap should be a cube texture.
  53428. * @returns true if the shadowmap needs to be a cube texture.
  53429. */
  53430. needCube(): boolean;
  53431. /**
  53432. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53433. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53434. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53435. */
  53436. getShadowDirection(faceIndex?: number): Vector3;
  53437. /**
  53438. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53439. * - fov = PI / 2
  53440. * - aspect ratio : 1.0
  53441. * - z-near and far equal to the active camera minZ and maxZ.
  53442. * Returns the PointLight.
  53443. */
  53444. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53445. protected _buildUniformLayout(): void;
  53446. /**
  53447. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53448. * @param effect The effect to update
  53449. * @param lightIndex The index of the light in the effect to update
  53450. * @returns The point light
  53451. */
  53452. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53453. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53454. /**
  53455. * Prepares the list of defines specific to the light type.
  53456. * @param defines the list of defines
  53457. * @param lightIndex defines the index of the light for the effect
  53458. */
  53459. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53460. }
  53461. }
  53462. declare module "babylonjs/Lights/index" {
  53463. export * from "babylonjs/Lights/light";
  53464. export * from "babylonjs/Lights/shadowLight";
  53465. export * from "babylonjs/Lights/Shadows/index";
  53466. export * from "babylonjs/Lights/directionalLight";
  53467. export * from "babylonjs/Lights/hemisphericLight";
  53468. export * from "babylonjs/Lights/pointLight";
  53469. export * from "babylonjs/Lights/spotLight";
  53470. }
  53471. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53472. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53473. /**
  53474. * Header information of HDR texture files.
  53475. */
  53476. export interface HDRInfo {
  53477. /**
  53478. * The height of the texture in pixels.
  53479. */
  53480. height: number;
  53481. /**
  53482. * The width of the texture in pixels.
  53483. */
  53484. width: number;
  53485. /**
  53486. * The index of the beginning of the data in the binary file.
  53487. */
  53488. dataPosition: number;
  53489. }
  53490. /**
  53491. * This groups tools to convert HDR texture to native colors array.
  53492. */
  53493. export class HDRTools {
  53494. private static Ldexp;
  53495. private static Rgbe2float;
  53496. private static readStringLine;
  53497. /**
  53498. * Reads header information from an RGBE texture stored in a native array.
  53499. * More information on this format are available here:
  53500. * https://en.wikipedia.org/wiki/RGBE_image_format
  53501. *
  53502. * @param uint8array The binary file stored in native array.
  53503. * @return The header information.
  53504. */
  53505. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53506. /**
  53507. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53508. * This RGBE texture needs to store the information as a panorama.
  53509. *
  53510. * More information on this format are available here:
  53511. * https://en.wikipedia.org/wiki/RGBE_image_format
  53512. *
  53513. * @param buffer The binary file stored in an array buffer.
  53514. * @param size The expected size of the extracted cubemap.
  53515. * @return The Cube Map information.
  53516. */
  53517. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53518. /**
  53519. * Returns the pixels data extracted from an RGBE texture.
  53520. * This pixels will be stored left to right up to down in the R G B order in one array.
  53521. *
  53522. * More information on this format are available here:
  53523. * https://en.wikipedia.org/wiki/RGBE_image_format
  53524. *
  53525. * @param uint8array The binary file stored in an array buffer.
  53526. * @param hdrInfo The header information of the file.
  53527. * @return The pixels data in RGB right to left up to down order.
  53528. */
  53529. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53530. private static RGBE_ReadPixels_RLE;
  53531. }
  53532. }
  53533. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53534. import { Nullable } from "babylonjs/types";
  53535. import { Scene } from "babylonjs/scene";
  53536. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53538. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53539. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53540. /**
  53541. * This represents a texture coming from an HDR input.
  53542. *
  53543. * The only supported format is currently panorama picture stored in RGBE format.
  53544. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53545. */
  53546. export class HDRCubeTexture extends BaseTexture {
  53547. private static _facesMapping;
  53548. private _generateHarmonics;
  53549. private _noMipmap;
  53550. private _textureMatrix;
  53551. private _size;
  53552. private _onLoad;
  53553. private _onError;
  53554. /**
  53555. * The texture URL.
  53556. */
  53557. url: string;
  53558. /**
  53559. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53560. */
  53561. coordinatesMode: number;
  53562. protected _isBlocking: boolean;
  53563. /**
  53564. * Sets wether or not the texture is blocking during loading.
  53565. */
  53566. /**
  53567. * Gets wether or not the texture is blocking during loading.
  53568. */
  53569. isBlocking: boolean;
  53570. protected _rotationY: number;
  53571. /**
  53572. * Sets texture matrix rotation angle around Y axis in radians.
  53573. */
  53574. /**
  53575. * Gets texture matrix rotation angle around Y axis radians.
  53576. */
  53577. rotationY: number;
  53578. /**
  53579. * Gets or sets the center of the bounding box associated with the cube texture
  53580. * It must define where the camera used to render the texture was set
  53581. */
  53582. boundingBoxPosition: Vector3;
  53583. private _boundingBoxSize;
  53584. /**
  53585. * Gets or sets the size of the bounding box associated with the cube texture
  53586. * When defined, the cubemap will switch to local mode
  53587. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53588. * @example https://www.babylonjs-playground.com/#RNASML
  53589. */
  53590. boundingBoxSize: Vector3;
  53591. /**
  53592. * Instantiates an HDRTexture from the following parameters.
  53593. *
  53594. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53595. * @param scene The scene the texture will be used in
  53596. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53597. * @param noMipmap Forces to not generate the mipmap if true
  53598. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53599. * @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)
  53600. * @param reserved Reserved flag for internal use.
  53601. */
  53602. 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>);
  53603. /**
  53604. * Get the current class name of the texture useful for serialization or dynamic coding.
  53605. * @returns "HDRCubeTexture"
  53606. */
  53607. getClassName(): string;
  53608. /**
  53609. * Occurs when the file is raw .hdr file.
  53610. */
  53611. private loadTexture;
  53612. clone(): HDRCubeTexture;
  53613. delayLoad(): void;
  53614. /**
  53615. * Get the texture reflection matrix used to rotate/transform the reflection.
  53616. * @returns the reflection matrix
  53617. */
  53618. getReflectionTextureMatrix(): Matrix;
  53619. /**
  53620. * Set the texture reflection matrix used to rotate/transform the reflection.
  53621. * @param value Define the reflection matrix to set
  53622. */
  53623. setReflectionTextureMatrix(value: Matrix): void;
  53624. /**
  53625. * Parses a JSON representation of an HDR Texture in order to create the texture
  53626. * @param parsedTexture Define the JSON representation
  53627. * @param scene Define the scene the texture should be created in
  53628. * @param rootUrl Define the root url in case we need to load relative dependencies
  53629. * @returns the newly created texture after parsing
  53630. */
  53631. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53632. serialize(): any;
  53633. }
  53634. }
  53635. declare module "babylonjs/Physics/physicsEngine" {
  53636. import { Nullable } from "babylonjs/types";
  53637. import { Vector3 } from "babylonjs/Maths/math.vector";
  53638. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53639. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53640. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53641. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53642. /**
  53643. * Class used to control physics engine
  53644. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53645. */
  53646. export class PhysicsEngine implements IPhysicsEngine {
  53647. private _physicsPlugin;
  53648. /**
  53649. * Global value used to control the smallest number supported by the simulation
  53650. */
  53651. static Epsilon: number;
  53652. private _impostors;
  53653. private _joints;
  53654. /**
  53655. * Gets the gravity vector used by the simulation
  53656. */
  53657. gravity: Vector3;
  53658. /**
  53659. * Factory used to create the default physics plugin.
  53660. * @returns The default physics plugin
  53661. */
  53662. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53663. /**
  53664. * Creates a new Physics Engine
  53665. * @param gravity defines the gravity vector used by the simulation
  53666. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53667. */
  53668. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53669. /**
  53670. * Sets the gravity vector used by the simulation
  53671. * @param gravity defines the gravity vector to use
  53672. */
  53673. setGravity(gravity: Vector3): void;
  53674. /**
  53675. * Set the time step of the physics engine.
  53676. * Default is 1/60.
  53677. * To slow it down, enter 1/600 for example.
  53678. * To speed it up, 1/30
  53679. * @param newTimeStep defines the new timestep to apply to this world.
  53680. */
  53681. setTimeStep(newTimeStep?: number): void;
  53682. /**
  53683. * Get the time step of the physics engine.
  53684. * @returns the current time step
  53685. */
  53686. getTimeStep(): number;
  53687. /**
  53688. * Release all resources
  53689. */
  53690. dispose(): void;
  53691. /**
  53692. * Gets the name of the current physics plugin
  53693. * @returns the name of the plugin
  53694. */
  53695. getPhysicsPluginName(): string;
  53696. /**
  53697. * Adding a new impostor for the impostor tracking.
  53698. * This will be done by the impostor itself.
  53699. * @param impostor the impostor to add
  53700. */
  53701. addImpostor(impostor: PhysicsImpostor): void;
  53702. /**
  53703. * Remove an impostor from the engine.
  53704. * This impostor and its mesh will not longer be updated by the physics engine.
  53705. * @param impostor the impostor to remove
  53706. */
  53707. removeImpostor(impostor: PhysicsImpostor): void;
  53708. /**
  53709. * Add a joint to the physics engine
  53710. * @param mainImpostor defines the main impostor to which the joint is added.
  53711. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53712. * @param joint defines the joint that will connect both impostors.
  53713. */
  53714. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53715. /**
  53716. * Removes a joint from the simulation
  53717. * @param mainImpostor defines the impostor used with the joint
  53718. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53719. * @param joint defines the joint to remove
  53720. */
  53721. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53722. /**
  53723. * Called by the scene. No need to call it.
  53724. * @param delta defines the timespam between frames
  53725. */
  53726. _step(delta: number): void;
  53727. /**
  53728. * Gets the current plugin used to run the simulation
  53729. * @returns current plugin
  53730. */
  53731. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53732. /**
  53733. * Gets the list of physic impostors
  53734. * @returns an array of PhysicsImpostor
  53735. */
  53736. getImpostors(): Array<PhysicsImpostor>;
  53737. /**
  53738. * Gets the impostor for a physics enabled object
  53739. * @param object defines the object impersonated by the impostor
  53740. * @returns the PhysicsImpostor or null if not found
  53741. */
  53742. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53743. /**
  53744. * Gets the impostor for a physics body object
  53745. * @param body defines physics body used by the impostor
  53746. * @returns the PhysicsImpostor or null if not found
  53747. */
  53748. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53749. /**
  53750. * Does a raycast in the physics world
  53751. * @param from when should the ray start?
  53752. * @param to when should the ray end?
  53753. * @returns PhysicsRaycastResult
  53754. */
  53755. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53756. }
  53757. }
  53758. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53759. import { Nullable } from "babylonjs/types";
  53760. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53762. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53763. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53764. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53765. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53766. /** @hidden */
  53767. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53768. private _useDeltaForWorldStep;
  53769. world: any;
  53770. name: string;
  53771. private _physicsMaterials;
  53772. private _fixedTimeStep;
  53773. private _cannonRaycastResult;
  53774. private _raycastResult;
  53775. private _physicsBodysToRemoveAfterStep;
  53776. BJSCANNON: any;
  53777. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53778. setGravity(gravity: Vector3): void;
  53779. setTimeStep(timeStep: number): void;
  53780. getTimeStep(): number;
  53781. executeStep(delta: number): void;
  53782. private _removeMarkedPhysicsBodiesFromWorld;
  53783. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53784. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53785. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53786. private _processChildMeshes;
  53787. removePhysicsBody(impostor: PhysicsImpostor): void;
  53788. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53789. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53790. private _addMaterial;
  53791. private _checkWithEpsilon;
  53792. private _createShape;
  53793. private _createHeightmap;
  53794. private _minus90X;
  53795. private _plus90X;
  53796. private _tmpPosition;
  53797. private _tmpDeltaPosition;
  53798. private _tmpUnityRotation;
  53799. private _updatePhysicsBodyTransformation;
  53800. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53801. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53802. isSupported(): boolean;
  53803. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53804. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53805. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53806. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53807. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53808. getBodyMass(impostor: PhysicsImpostor): number;
  53809. getBodyFriction(impostor: PhysicsImpostor): number;
  53810. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53811. getBodyRestitution(impostor: PhysicsImpostor): number;
  53812. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53813. sleepBody(impostor: PhysicsImpostor): void;
  53814. wakeUpBody(impostor: PhysicsImpostor): void;
  53815. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53816. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53817. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53818. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53819. getRadius(impostor: PhysicsImpostor): number;
  53820. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53821. dispose(): void;
  53822. private _extendNamespace;
  53823. /**
  53824. * Does a raycast in the physics world
  53825. * @param from when should the ray start?
  53826. * @param to when should the ray end?
  53827. * @returns PhysicsRaycastResult
  53828. */
  53829. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53830. }
  53831. }
  53832. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53833. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53834. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53835. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53837. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53838. import { Nullable } from "babylonjs/types";
  53839. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53840. /** @hidden */
  53841. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53842. world: any;
  53843. name: string;
  53844. BJSOIMO: any;
  53845. private _raycastResult;
  53846. constructor(iterations?: number, oimoInjection?: any);
  53847. setGravity(gravity: Vector3): void;
  53848. setTimeStep(timeStep: number): void;
  53849. getTimeStep(): number;
  53850. private _tmpImpostorsArray;
  53851. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53852. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53853. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53854. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53855. private _tmpPositionVector;
  53856. removePhysicsBody(impostor: PhysicsImpostor): void;
  53857. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53858. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53859. isSupported(): boolean;
  53860. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53861. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53862. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53863. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53864. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53865. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53866. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53867. getBodyMass(impostor: PhysicsImpostor): number;
  53868. getBodyFriction(impostor: PhysicsImpostor): number;
  53869. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53870. getBodyRestitution(impostor: PhysicsImpostor): number;
  53871. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53872. sleepBody(impostor: PhysicsImpostor): void;
  53873. wakeUpBody(impostor: PhysicsImpostor): void;
  53874. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53875. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53876. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53877. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53878. getRadius(impostor: PhysicsImpostor): number;
  53879. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53880. dispose(): void;
  53881. /**
  53882. * Does a raycast in the physics world
  53883. * @param from when should the ray start?
  53884. * @param to when should the ray end?
  53885. * @returns PhysicsRaycastResult
  53886. */
  53887. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53888. }
  53889. }
  53890. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53891. import { Nullable } from "babylonjs/types";
  53892. import { Scene } from "babylonjs/scene";
  53893. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53894. import { Color4 } from "babylonjs/Maths/math.color";
  53895. import { Mesh } from "babylonjs/Meshes/mesh";
  53896. /**
  53897. * Class containing static functions to help procedurally build meshes
  53898. */
  53899. export class RibbonBuilder {
  53900. /**
  53901. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53902. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53903. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53904. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53905. * * 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
  53906. * * 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
  53907. * * 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
  53908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53911. * * 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
  53912. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53913. * * 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
  53914. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53916. * @param name defines the name of the mesh
  53917. * @param options defines the options used to create the mesh
  53918. * @param scene defines the hosting scene
  53919. * @returns the ribbon mesh
  53920. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53921. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53922. */
  53923. static CreateRibbon(name: string, options: {
  53924. pathArray: Vector3[][];
  53925. closeArray?: boolean;
  53926. closePath?: boolean;
  53927. offset?: number;
  53928. updatable?: boolean;
  53929. sideOrientation?: number;
  53930. frontUVs?: Vector4;
  53931. backUVs?: Vector4;
  53932. instance?: Mesh;
  53933. invertUV?: boolean;
  53934. uvs?: Vector2[];
  53935. colors?: Color4[];
  53936. }, scene?: Nullable<Scene>): Mesh;
  53937. }
  53938. }
  53939. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53940. import { Nullable } from "babylonjs/types";
  53941. import { Scene } from "babylonjs/scene";
  53942. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53943. import { Mesh } from "babylonjs/Meshes/mesh";
  53944. /**
  53945. * Class containing static functions to help procedurally build meshes
  53946. */
  53947. export class ShapeBuilder {
  53948. /**
  53949. * 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.
  53950. * * 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.
  53951. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53952. * * 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.
  53953. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53954. * * 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
  53955. * * 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
  53956. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53959. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53961. * @param name defines the name of the mesh
  53962. * @param options defines the options used to create the mesh
  53963. * @param scene defines the hosting scene
  53964. * @returns the extruded shape mesh
  53965. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53967. */
  53968. static ExtrudeShape(name: string, options: {
  53969. shape: Vector3[];
  53970. path: Vector3[];
  53971. scale?: number;
  53972. rotation?: number;
  53973. cap?: number;
  53974. updatable?: boolean;
  53975. sideOrientation?: number;
  53976. frontUVs?: Vector4;
  53977. backUVs?: Vector4;
  53978. instance?: Mesh;
  53979. invertUV?: boolean;
  53980. }, scene?: Nullable<Scene>): Mesh;
  53981. /**
  53982. * Creates an custom extruded shape mesh.
  53983. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53984. * * 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.
  53985. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53986. * * 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
  53987. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53988. * * 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
  53989. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53990. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53991. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53992. * * 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
  53993. * * 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
  53994. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53999. * @param name defines the name of the mesh
  54000. * @param options defines the options used to create the mesh
  54001. * @param scene defines the hosting scene
  54002. * @returns the custom extruded shape mesh
  54003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54004. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54006. */
  54007. static ExtrudeShapeCustom(name: string, options: {
  54008. shape: Vector3[];
  54009. path: Vector3[];
  54010. scaleFunction?: any;
  54011. rotationFunction?: any;
  54012. ribbonCloseArray?: boolean;
  54013. ribbonClosePath?: boolean;
  54014. cap?: number;
  54015. updatable?: boolean;
  54016. sideOrientation?: number;
  54017. frontUVs?: Vector4;
  54018. backUVs?: Vector4;
  54019. instance?: Mesh;
  54020. invertUV?: boolean;
  54021. }, scene?: Nullable<Scene>): Mesh;
  54022. private static _ExtrudeShapeGeneric;
  54023. }
  54024. }
  54025. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54026. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54027. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54028. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54029. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54030. import { Nullable } from "babylonjs/types";
  54031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54032. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54033. /**
  54034. * AmmoJS Physics plugin
  54035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54036. * @see https://github.com/kripken/ammo.js/
  54037. */
  54038. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54039. private _useDeltaForWorldStep;
  54040. /**
  54041. * Reference to the Ammo library
  54042. */
  54043. bjsAMMO: any;
  54044. /**
  54045. * Created ammoJS world which physics bodies are added to
  54046. */
  54047. world: any;
  54048. /**
  54049. * Name of the plugin
  54050. */
  54051. name: string;
  54052. private _timeStep;
  54053. private _fixedTimeStep;
  54054. private _maxSteps;
  54055. private _tmpQuaternion;
  54056. private _tmpAmmoTransform;
  54057. private _tmpAmmoQuaternion;
  54058. private _tmpAmmoConcreteContactResultCallback;
  54059. private _collisionConfiguration;
  54060. private _dispatcher;
  54061. private _overlappingPairCache;
  54062. private _solver;
  54063. private _softBodySolver;
  54064. private _tmpAmmoVectorA;
  54065. private _tmpAmmoVectorB;
  54066. private _tmpAmmoVectorC;
  54067. private _tmpAmmoVectorD;
  54068. private _tmpContactCallbackResult;
  54069. private _tmpAmmoVectorRCA;
  54070. private _tmpAmmoVectorRCB;
  54071. private _raycastResult;
  54072. private static readonly DISABLE_COLLISION_FLAG;
  54073. private static readonly KINEMATIC_FLAG;
  54074. private static readonly DISABLE_DEACTIVATION_FLAG;
  54075. /**
  54076. * Initializes the ammoJS plugin
  54077. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54078. * @param ammoInjection can be used to inject your own ammo reference
  54079. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54080. */
  54081. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54082. /**
  54083. * Sets the gravity of the physics world (m/(s^2))
  54084. * @param gravity Gravity to set
  54085. */
  54086. setGravity(gravity: Vector3): void;
  54087. /**
  54088. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54089. * @param timeStep timestep to use in seconds
  54090. */
  54091. setTimeStep(timeStep: number): void;
  54092. /**
  54093. * 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)
  54094. * @param fixedTimeStep fixedTimeStep to use in seconds
  54095. */
  54096. setFixedTimeStep(fixedTimeStep: number): void;
  54097. /**
  54098. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54099. * @param maxSteps the maximum number of steps by the physics engine per frame
  54100. */
  54101. setMaxSteps(maxSteps: number): void;
  54102. /**
  54103. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54104. * @returns the current timestep in seconds
  54105. */
  54106. getTimeStep(): number;
  54107. private _isImpostorInContact;
  54108. private _isImpostorPairInContact;
  54109. private _stepSimulation;
  54110. /**
  54111. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54112. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54113. * After the step the babylon meshes are set to the position of the physics imposters
  54114. * @param delta amount of time to step forward
  54115. * @param impostors array of imposters to update before/after the step
  54116. */
  54117. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54118. /**
  54119. * Update babylon mesh to match physics world object
  54120. * @param impostor imposter to match
  54121. */
  54122. private _afterSoftStep;
  54123. /**
  54124. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54125. * @param impostor imposter to match
  54126. */
  54127. private _ropeStep;
  54128. /**
  54129. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54130. * @param impostor imposter to match
  54131. */
  54132. private _softbodyOrClothStep;
  54133. private _tmpVector;
  54134. private _tmpMatrix;
  54135. /**
  54136. * Applies an impulse on the imposter
  54137. * @param impostor imposter to apply impulse to
  54138. * @param force amount of force to be applied to the imposter
  54139. * @param contactPoint the location to apply the impulse on the imposter
  54140. */
  54141. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54142. /**
  54143. * Applies a force on the imposter
  54144. * @param impostor imposter to apply force
  54145. * @param force amount of force to be applied to the imposter
  54146. * @param contactPoint the location to apply the force on the imposter
  54147. */
  54148. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54149. /**
  54150. * Creates a physics body using the plugin
  54151. * @param impostor the imposter to create the physics body on
  54152. */
  54153. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54154. /**
  54155. * Removes the physics body from the imposter and disposes of the body's memory
  54156. * @param impostor imposter to remove the physics body from
  54157. */
  54158. removePhysicsBody(impostor: PhysicsImpostor): void;
  54159. /**
  54160. * Generates a joint
  54161. * @param impostorJoint the imposter joint to create the joint with
  54162. */
  54163. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54164. /**
  54165. * Removes a joint
  54166. * @param impostorJoint the imposter joint to remove the joint from
  54167. */
  54168. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54169. private _addMeshVerts;
  54170. /**
  54171. * Initialise the soft body vertices to match its object's (mesh) vertices
  54172. * Softbody vertices (nodes) are in world space and to match this
  54173. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54174. * @param impostor to create the softbody for
  54175. */
  54176. private _softVertexData;
  54177. /**
  54178. * Create an impostor's soft body
  54179. * @param impostor to create the softbody for
  54180. */
  54181. private _createSoftbody;
  54182. /**
  54183. * Create cloth for an impostor
  54184. * @param impostor to create the softbody for
  54185. */
  54186. private _createCloth;
  54187. /**
  54188. * Create rope for an impostor
  54189. * @param impostor to create the softbody for
  54190. */
  54191. private _createRope;
  54192. private _addHullVerts;
  54193. private _createShape;
  54194. /**
  54195. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54196. * @param impostor imposter containing the physics body and babylon object
  54197. */
  54198. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54199. /**
  54200. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54201. * @param impostor imposter containing the physics body and babylon object
  54202. * @param newPosition new position
  54203. * @param newRotation new rotation
  54204. */
  54205. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54206. /**
  54207. * If this plugin is supported
  54208. * @returns true if its supported
  54209. */
  54210. isSupported(): boolean;
  54211. /**
  54212. * Sets the linear velocity of the physics body
  54213. * @param impostor imposter to set the velocity on
  54214. * @param velocity velocity to set
  54215. */
  54216. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54217. /**
  54218. * Sets the angular velocity of the physics body
  54219. * @param impostor imposter to set the velocity on
  54220. * @param velocity velocity to set
  54221. */
  54222. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54223. /**
  54224. * gets the linear velocity
  54225. * @param impostor imposter to get linear velocity from
  54226. * @returns linear velocity
  54227. */
  54228. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54229. /**
  54230. * gets the angular velocity
  54231. * @param impostor imposter to get angular velocity from
  54232. * @returns angular velocity
  54233. */
  54234. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54235. /**
  54236. * Sets the mass of physics body
  54237. * @param impostor imposter to set the mass on
  54238. * @param mass mass to set
  54239. */
  54240. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54241. /**
  54242. * Gets the mass of the physics body
  54243. * @param impostor imposter to get the mass from
  54244. * @returns mass
  54245. */
  54246. getBodyMass(impostor: PhysicsImpostor): number;
  54247. /**
  54248. * Gets friction of the impostor
  54249. * @param impostor impostor to get friction from
  54250. * @returns friction value
  54251. */
  54252. getBodyFriction(impostor: PhysicsImpostor): number;
  54253. /**
  54254. * Sets friction of the impostor
  54255. * @param impostor impostor to set friction on
  54256. * @param friction friction value
  54257. */
  54258. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54259. /**
  54260. * Gets restitution of the impostor
  54261. * @param impostor impostor to get restitution from
  54262. * @returns restitution value
  54263. */
  54264. getBodyRestitution(impostor: PhysicsImpostor): number;
  54265. /**
  54266. * Sets resitution of the impostor
  54267. * @param impostor impostor to set resitution on
  54268. * @param restitution resitution value
  54269. */
  54270. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54271. /**
  54272. * Gets pressure inside the impostor
  54273. * @param impostor impostor to get pressure from
  54274. * @returns pressure value
  54275. */
  54276. getBodyPressure(impostor: PhysicsImpostor): number;
  54277. /**
  54278. * Sets pressure inside a soft body impostor
  54279. * Cloth and rope must remain 0 pressure
  54280. * @param impostor impostor to set pressure on
  54281. * @param pressure pressure value
  54282. */
  54283. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54284. /**
  54285. * Gets stiffness of the impostor
  54286. * @param impostor impostor to get stiffness from
  54287. * @returns pressure value
  54288. */
  54289. getBodyStiffness(impostor: PhysicsImpostor): number;
  54290. /**
  54291. * Sets stiffness of the impostor
  54292. * @param impostor impostor to set stiffness on
  54293. * @param stiffness stiffness value from 0 to 1
  54294. */
  54295. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54296. /**
  54297. * Gets velocityIterations of the impostor
  54298. * @param impostor impostor to get velocity iterations from
  54299. * @returns velocityIterations value
  54300. */
  54301. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54302. /**
  54303. * Sets velocityIterations of the impostor
  54304. * @param impostor impostor to set velocity iterations on
  54305. * @param velocityIterations velocityIterations value
  54306. */
  54307. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54308. /**
  54309. * Gets positionIterations of the impostor
  54310. * @param impostor impostor to get position iterations from
  54311. * @returns positionIterations value
  54312. */
  54313. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54314. /**
  54315. * Sets positionIterations of the impostor
  54316. * @param impostor impostor to set position on
  54317. * @param positionIterations positionIterations value
  54318. */
  54319. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54320. /**
  54321. * Append an anchor to a cloth object
  54322. * @param impostor is the cloth impostor to add anchor to
  54323. * @param otherImpostor is the rigid impostor to anchor to
  54324. * @param width ratio across width from 0 to 1
  54325. * @param height ratio up height from 0 to 1
  54326. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54327. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54328. */
  54329. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54330. /**
  54331. * Append an hook to a rope object
  54332. * @param impostor is the rope impostor to add hook to
  54333. * @param otherImpostor is the rigid impostor to hook to
  54334. * @param length ratio along the rope from 0 to 1
  54335. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54336. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54337. */
  54338. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54339. /**
  54340. * Sleeps the physics body and stops it from being active
  54341. * @param impostor impostor to sleep
  54342. */
  54343. sleepBody(impostor: PhysicsImpostor): void;
  54344. /**
  54345. * Activates the physics body
  54346. * @param impostor impostor to activate
  54347. */
  54348. wakeUpBody(impostor: PhysicsImpostor): void;
  54349. /**
  54350. * Updates the distance parameters of the joint
  54351. * @param joint joint to update
  54352. * @param maxDistance maximum distance of the joint
  54353. * @param minDistance minimum distance of the joint
  54354. */
  54355. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54356. /**
  54357. * Sets a motor on the joint
  54358. * @param joint joint to set motor on
  54359. * @param speed speed of the motor
  54360. * @param maxForce maximum force of the motor
  54361. * @param motorIndex index of the motor
  54362. */
  54363. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54364. /**
  54365. * Sets the motors limit
  54366. * @param joint joint to set limit on
  54367. * @param upperLimit upper limit
  54368. * @param lowerLimit lower limit
  54369. */
  54370. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54371. /**
  54372. * Syncs the position and rotation of a mesh with the impostor
  54373. * @param mesh mesh to sync
  54374. * @param impostor impostor to update the mesh with
  54375. */
  54376. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54377. /**
  54378. * Gets the radius of the impostor
  54379. * @param impostor impostor to get radius from
  54380. * @returns the radius
  54381. */
  54382. getRadius(impostor: PhysicsImpostor): number;
  54383. /**
  54384. * Gets the box size of the impostor
  54385. * @param impostor impostor to get box size from
  54386. * @param result the resulting box size
  54387. */
  54388. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54389. /**
  54390. * Disposes of the impostor
  54391. */
  54392. dispose(): void;
  54393. /**
  54394. * Does a raycast in the physics world
  54395. * @param from when should the ray start?
  54396. * @param to when should the ray end?
  54397. * @returns PhysicsRaycastResult
  54398. */
  54399. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54400. }
  54401. }
  54402. declare module "babylonjs/Probes/reflectionProbe" {
  54403. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54404. import { Vector3 } from "babylonjs/Maths/math.vector";
  54405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54406. import { Nullable } from "babylonjs/types";
  54407. import { Scene } from "babylonjs/scene";
  54408. module "babylonjs/abstractScene" {
  54409. interface AbstractScene {
  54410. /**
  54411. * The list of reflection probes added to the scene
  54412. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54413. */
  54414. reflectionProbes: Array<ReflectionProbe>;
  54415. /**
  54416. * Removes the given reflection probe from this scene.
  54417. * @param toRemove The reflection probe to remove
  54418. * @returns The index of the removed reflection probe
  54419. */
  54420. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54421. /**
  54422. * Adds the given reflection probe to this scene.
  54423. * @param newReflectionProbe The reflection probe to add
  54424. */
  54425. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54426. }
  54427. }
  54428. /**
  54429. * Class used to generate realtime reflection / refraction cube textures
  54430. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54431. */
  54432. export class ReflectionProbe {
  54433. /** defines the name of the probe */
  54434. name: string;
  54435. private _scene;
  54436. private _renderTargetTexture;
  54437. private _projectionMatrix;
  54438. private _viewMatrix;
  54439. private _target;
  54440. private _add;
  54441. private _attachedMesh;
  54442. private _invertYAxis;
  54443. /** Gets or sets probe position (center of the cube map) */
  54444. position: Vector3;
  54445. /**
  54446. * Creates a new reflection probe
  54447. * @param name defines the name of the probe
  54448. * @param size defines the texture resolution (for each face)
  54449. * @param scene defines the hosting scene
  54450. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54451. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54452. */
  54453. constructor(
  54454. /** defines the name of the probe */
  54455. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54456. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54457. samples: number;
  54458. /** Gets or sets the refresh rate to use (on every frame by default) */
  54459. refreshRate: number;
  54460. /**
  54461. * Gets the hosting scene
  54462. * @returns a Scene
  54463. */
  54464. getScene(): Scene;
  54465. /** Gets the internal CubeTexture used to render to */
  54466. readonly cubeTexture: RenderTargetTexture;
  54467. /** Gets the list of meshes to render */
  54468. readonly renderList: Nullable<AbstractMesh[]>;
  54469. /**
  54470. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54471. * @param mesh defines the mesh to attach to
  54472. */
  54473. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54474. /**
  54475. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54476. * @param renderingGroupId The rendering group id corresponding to its index
  54477. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54478. */
  54479. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54480. /**
  54481. * Clean all associated resources
  54482. */
  54483. dispose(): void;
  54484. /**
  54485. * Converts the reflection probe information to a readable string for debug purpose.
  54486. * @param fullDetails Supports for multiple levels of logging within scene loading
  54487. * @returns the human readable reflection probe info
  54488. */
  54489. toString(fullDetails?: boolean): string;
  54490. /**
  54491. * Get the class name of the relfection probe.
  54492. * @returns "ReflectionProbe"
  54493. */
  54494. getClassName(): string;
  54495. /**
  54496. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54497. * @returns The JSON representation of the texture
  54498. */
  54499. serialize(): any;
  54500. /**
  54501. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54502. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54503. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54504. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54505. * @returns The parsed reflection probe if successful
  54506. */
  54507. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54508. }
  54509. }
  54510. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54511. /** @hidden */
  54512. export var _BabylonLoaderRegistered: boolean;
  54513. /**
  54514. * Helps setting up some configuration for the babylon file loader.
  54515. */
  54516. export class BabylonFileLoaderConfiguration {
  54517. /**
  54518. * The loader does not allow injecting custom physix engine into the plugins.
  54519. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54520. * So you could set this variable to your engine import to make it work.
  54521. */
  54522. static LoaderInjectedPhysicsEngine: any;
  54523. }
  54524. }
  54525. declare module "babylonjs/Loading/Plugins/index" {
  54526. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54527. }
  54528. declare module "babylonjs/Loading/index" {
  54529. export * from "babylonjs/Loading/loadingScreen";
  54530. export * from "babylonjs/Loading/Plugins/index";
  54531. export * from "babylonjs/Loading/sceneLoader";
  54532. export * from "babylonjs/Loading/sceneLoaderFlags";
  54533. }
  54534. declare module "babylonjs/Materials/Background/index" {
  54535. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54536. }
  54537. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54538. import { Scene } from "babylonjs/scene";
  54539. import { Color3 } from "babylonjs/Maths/math.color";
  54540. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54541. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54542. /**
  54543. * The Physically based simple base material of BJS.
  54544. *
  54545. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54546. * It is used as the base class for both the specGloss and metalRough conventions.
  54547. */
  54548. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54549. /**
  54550. * Number of Simultaneous lights allowed on the material.
  54551. */
  54552. maxSimultaneousLights: number;
  54553. /**
  54554. * If sets to true, disables all the lights affecting the material.
  54555. */
  54556. disableLighting: boolean;
  54557. /**
  54558. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54559. */
  54560. environmentTexture: BaseTexture;
  54561. /**
  54562. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54563. */
  54564. invertNormalMapX: boolean;
  54565. /**
  54566. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54567. */
  54568. invertNormalMapY: boolean;
  54569. /**
  54570. * Normal map used in the model.
  54571. */
  54572. normalTexture: BaseTexture;
  54573. /**
  54574. * Emissivie color used to self-illuminate the model.
  54575. */
  54576. emissiveColor: Color3;
  54577. /**
  54578. * Emissivie texture used to self-illuminate the model.
  54579. */
  54580. emissiveTexture: BaseTexture;
  54581. /**
  54582. * Occlusion Channel Strenght.
  54583. */
  54584. occlusionStrength: number;
  54585. /**
  54586. * Occlusion Texture of the material (adding extra occlusion effects).
  54587. */
  54588. occlusionTexture: BaseTexture;
  54589. /**
  54590. * Defines the alpha limits in alpha test mode.
  54591. */
  54592. alphaCutOff: number;
  54593. /**
  54594. * Gets the current double sided mode.
  54595. */
  54596. /**
  54597. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54598. */
  54599. doubleSided: boolean;
  54600. /**
  54601. * Stores the pre-calculated light information of a mesh in a texture.
  54602. */
  54603. lightmapTexture: BaseTexture;
  54604. /**
  54605. * If true, the light map contains occlusion information instead of lighting info.
  54606. */
  54607. useLightmapAsShadowmap: boolean;
  54608. /**
  54609. * Instantiates a new PBRMaterial instance.
  54610. *
  54611. * @param name The material name
  54612. * @param scene The scene the material will be use in.
  54613. */
  54614. constructor(name: string, scene: Scene);
  54615. getClassName(): string;
  54616. }
  54617. }
  54618. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54619. import { Scene } from "babylonjs/scene";
  54620. import { Color3 } from "babylonjs/Maths/math.color";
  54621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54622. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54623. /**
  54624. * The PBR material of BJS following the metal roughness convention.
  54625. *
  54626. * This fits to the PBR convention in the GLTF definition:
  54627. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54628. */
  54629. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54630. /**
  54631. * The base color has two different interpretations depending on the value of metalness.
  54632. * When the material is a metal, the base color is the specific measured reflectance value
  54633. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54634. * of the material.
  54635. */
  54636. baseColor: Color3;
  54637. /**
  54638. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54639. * well as opacity information in the alpha channel.
  54640. */
  54641. baseTexture: BaseTexture;
  54642. /**
  54643. * Specifies the metallic scalar value of the material.
  54644. * Can also be used to scale the metalness values of the metallic texture.
  54645. */
  54646. metallic: number;
  54647. /**
  54648. * Specifies the roughness scalar value of the material.
  54649. * Can also be used to scale the roughness values of the metallic texture.
  54650. */
  54651. roughness: number;
  54652. /**
  54653. * Texture containing both the metallic value in the B channel and the
  54654. * roughness value in the G channel to keep better precision.
  54655. */
  54656. metallicRoughnessTexture: BaseTexture;
  54657. /**
  54658. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54659. *
  54660. * @param name The material name
  54661. * @param scene The scene the material will be use in.
  54662. */
  54663. constructor(name: string, scene: Scene);
  54664. /**
  54665. * Return the currrent class name of the material.
  54666. */
  54667. getClassName(): string;
  54668. /**
  54669. * Makes a duplicate of the current material.
  54670. * @param name - name to use for the new material.
  54671. */
  54672. clone(name: string): PBRMetallicRoughnessMaterial;
  54673. /**
  54674. * Serialize the material to a parsable JSON object.
  54675. */
  54676. serialize(): any;
  54677. /**
  54678. * Parses a JSON object correponding to the serialize function.
  54679. */
  54680. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54681. }
  54682. }
  54683. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54684. import { Scene } from "babylonjs/scene";
  54685. import { Color3 } from "babylonjs/Maths/math.color";
  54686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54687. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54688. /**
  54689. * The PBR material of BJS following the specular glossiness convention.
  54690. *
  54691. * This fits to the PBR convention in the GLTF definition:
  54692. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54693. */
  54694. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54695. /**
  54696. * Specifies the diffuse color of the material.
  54697. */
  54698. diffuseColor: Color3;
  54699. /**
  54700. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54701. * channel.
  54702. */
  54703. diffuseTexture: BaseTexture;
  54704. /**
  54705. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54706. */
  54707. specularColor: Color3;
  54708. /**
  54709. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54710. */
  54711. glossiness: number;
  54712. /**
  54713. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54714. */
  54715. specularGlossinessTexture: BaseTexture;
  54716. /**
  54717. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54718. *
  54719. * @param name The material name
  54720. * @param scene The scene the material will be use in.
  54721. */
  54722. constructor(name: string, scene: Scene);
  54723. /**
  54724. * Return the currrent class name of the material.
  54725. */
  54726. getClassName(): string;
  54727. /**
  54728. * Makes a duplicate of the current material.
  54729. * @param name - name to use for the new material.
  54730. */
  54731. clone(name: string): PBRSpecularGlossinessMaterial;
  54732. /**
  54733. * Serialize the material to a parsable JSON object.
  54734. */
  54735. serialize(): any;
  54736. /**
  54737. * Parses a JSON object correponding to the serialize function.
  54738. */
  54739. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54740. }
  54741. }
  54742. declare module "babylonjs/Materials/PBR/index" {
  54743. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54744. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54745. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54746. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54747. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54748. }
  54749. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54750. import { Nullable } from "babylonjs/types";
  54751. import { Scene } from "babylonjs/scene";
  54752. import { Matrix } from "babylonjs/Maths/math.vector";
  54753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54754. /**
  54755. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54756. * It can help converting any input color in a desired output one. This can then be used to create effects
  54757. * from sepia, black and white to sixties or futuristic rendering...
  54758. *
  54759. * The only supported format is currently 3dl.
  54760. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54761. */
  54762. export class ColorGradingTexture extends BaseTexture {
  54763. /**
  54764. * The current texture matrix. (will always be identity in color grading texture)
  54765. */
  54766. private _textureMatrix;
  54767. /**
  54768. * The texture URL.
  54769. */
  54770. url: string;
  54771. /**
  54772. * Empty line regex stored for GC.
  54773. */
  54774. private static _noneEmptyLineRegex;
  54775. private _engine;
  54776. /**
  54777. * Instantiates a ColorGradingTexture from the following parameters.
  54778. *
  54779. * @param url The location of the color gradind data (currently only supporting 3dl)
  54780. * @param scene The scene the texture will be used in
  54781. */
  54782. constructor(url: string, scene: Scene);
  54783. /**
  54784. * Returns the texture matrix used in most of the material.
  54785. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54786. */
  54787. getTextureMatrix(): Matrix;
  54788. /**
  54789. * Occurs when the file being loaded is a .3dl LUT file.
  54790. */
  54791. private load3dlTexture;
  54792. /**
  54793. * Starts the loading process of the texture.
  54794. */
  54795. private loadTexture;
  54796. /**
  54797. * Clones the color gradind texture.
  54798. */
  54799. clone(): ColorGradingTexture;
  54800. /**
  54801. * Called during delayed load for textures.
  54802. */
  54803. delayLoad(): void;
  54804. /**
  54805. * Parses a color grading texture serialized by Babylon.
  54806. * @param parsedTexture The texture information being parsedTexture
  54807. * @param scene The scene to load the texture in
  54808. * @param rootUrl The root url of the data assets to load
  54809. * @return A color gradind texture
  54810. */
  54811. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54812. /**
  54813. * Serializes the LUT texture to json format.
  54814. */
  54815. serialize(): any;
  54816. }
  54817. }
  54818. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54819. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54820. import { Scene } from "babylonjs/scene";
  54821. import { Nullable } from "babylonjs/types";
  54822. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54823. /**
  54824. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54825. */
  54826. export class EquiRectangularCubeTexture extends BaseTexture {
  54827. /** The six faces of the cube. */
  54828. private static _FacesMapping;
  54829. private _noMipmap;
  54830. private _onLoad;
  54831. private _onError;
  54832. /** The size of the cubemap. */
  54833. private _size;
  54834. /** The buffer of the image. */
  54835. private _buffer;
  54836. /** The width of the input image. */
  54837. private _width;
  54838. /** The height of the input image. */
  54839. private _height;
  54840. /** The URL to the image. */
  54841. url: string;
  54842. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54843. coordinatesMode: number;
  54844. /**
  54845. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54846. * @param url The location of the image
  54847. * @param scene The scene the texture will be used in
  54848. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54849. * @param noMipmap Forces to not generate the mipmap if true
  54850. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54851. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54852. * @param onLoad — defines a callback called when texture is loaded
  54853. * @param onError — defines a callback called if there is an error
  54854. */
  54855. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54856. /**
  54857. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54858. */
  54859. private loadImage;
  54860. /**
  54861. * Convert the image buffer into a cubemap and create a CubeTexture.
  54862. */
  54863. private loadTexture;
  54864. /**
  54865. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54866. * @param buffer The ArrayBuffer that should be converted.
  54867. * @returns The buffer as Float32Array.
  54868. */
  54869. private getFloat32ArrayFromArrayBuffer;
  54870. /**
  54871. * Get the current class name of the texture useful for serialization or dynamic coding.
  54872. * @returns "EquiRectangularCubeTexture"
  54873. */
  54874. getClassName(): string;
  54875. /**
  54876. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54877. * @returns A clone of the current EquiRectangularCubeTexture.
  54878. */
  54879. clone(): EquiRectangularCubeTexture;
  54880. }
  54881. }
  54882. declare module "babylonjs/Misc/tga" {
  54883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54884. /**
  54885. * Based on jsTGALoader - Javascript loader for TGA file
  54886. * By Vincent Thibault
  54887. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54888. */
  54889. export class TGATools {
  54890. private static _TYPE_INDEXED;
  54891. private static _TYPE_RGB;
  54892. private static _TYPE_GREY;
  54893. private static _TYPE_RLE_INDEXED;
  54894. private static _TYPE_RLE_RGB;
  54895. private static _TYPE_RLE_GREY;
  54896. private static _ORIGIN_MASK;
  54897. private static _ORIGIN_SHIFT;
  54898. private static _ORIGIN_BL;
  54899. private static _ORIGIN_BR;
  54900. private static _ORIGIN_UL;
  54901. private static _ORIGIN_UR;
  54902. /**
  54903. * Gets the header of a TGA file
  54904. * @param data defines the TGA data
  54905. * @returns the header
  54906. */
  54907. static GetTGAHeader(data: Uint8Array): any;
  54908. /**
  54909. * Uploads TGA content to a Babylon Texture
  54910. * @hidden
  54911. */
  54912. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54913. /** @hidden */
  54914. 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;
  54915. /** @hidden */
  54916. 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;
  54917. /** @hidden */
  54918. 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;
  54919. /** @hidden */
  54920. 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;
  54921. /** @hidden */
  54922. 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;
  54923. /** @hidden */
  54924. 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;
  54925. }
  54926. }
  54927. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54928. import { Nullable } from "babylonjs/types";
  54929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54930. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54931. /**
  54932. * Implementation of the TGA Texture Loader.
  54933. * @hidden
  54934. */
  54935. export class _TGATextureLoader implements IInternalTextureLoader {
  54936. /**
  54937. * Defines wether the loader supports cascade loading the different faces.
  54938. */
  54939. readonly supportCascades: boolean;
  54940. /**
  54941. * This returns if the loader support the current file information.
  54942. * @param extension defines the file extension of the file being loaded
  54943. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54944. * @param fallback defines the fallback internal texture if any
  54945. * @param isBase64 defines whether the texture is encoded as a base64
  54946. * @param isBuffer defines whether the texture data are stored as a buffer
  54947. * @returns true if the loader can load the specified file
  54948. */
  54949. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54950. /**
  54951. * Transform the url before loading if required.
  54952. * @param rootUrl the url of the texture
  54953. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54954. * @returns the transformed texture
  54955. */
  54956. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54957. /**
  54958. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54959. * @param rootUrl the url of the texture
  54960. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54961. * @returns the fallback texture
  54962. */
  54963. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54964. /**
  54965. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54966. * @param data contains the texture data
  54967. * @param texture defines the BabylonJS internal texture
  54968. * @param createPolynomials will be true if polynomials have been requested
  54969. * @param onLoad defines the callback to trigger once the texture is ready
  54970. * @param onError defines the callback to trigger in case of error
  54971. */
  54972. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54973. /**
  54974. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54975. * @param data contains the texture data
  54976. * @param texture defines the BabylonJS internal texture
  54977. * @param callback defines the method to call once ready to upload
  54978. */
  54979. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54980. }
  54981. }
  54982. declare module "babylonjs/Misc/basis" {
  54983. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54984. /**
  54985. * Info about the .basis files
  54986. */
  54987. class BasisFileInfo {
  54988. /**
  54989. * If the file has alpha
  54990. */
  54991. hasAlpha: boolean;
  54992. /**
  54993. * Info about each image of the basis file
  54994. */
  54995. images: Array<{
  54996. levels: Array<{
  54997. width: number;
  54998. height: number;
  54999. transcodedPixels: ArrayBufferView;
  55000. }>;
  55001. }>;
  55002. }
  55003. /**
  55004. * Result of transcoding a basis file
  55005. */
  55006. class TranscodeResult {
  55007. /**
  55008. * Info about the .basis file
  55009. */
  55010. fileInfo: BasisFileInfo;
  55011. /**
  55012. * Format to use when loading the file
  55013. */
  55014. format: number;
  55015. }
  55016. /**
  55017. * Configuration options for the Basis transcoder
  55018. */
  55019. export class BasisTranscodeConfiguration {
  55020. /**
  55021. * Supported compression formats used to determine the supported output format of the transcoder
  55022. */
  55023. supportedCompressionFormats?: {
  55024. /**
  55025. * etc1 compression format
  55026. */
  55027. etc1?: boolean;
  55028. /**
  55029. * s3tc compression format
  55030. */
  55031. s3tc?: boolean;
  55032. /**
  55033. * pvrtc compression format
  55034. */
  55035. pvrtc?: boolean;
  55036. /**
  55037. * etc2 compression format
  55038. */
  55039. etc2?: boolean;
  55040. };
  55041. /**
  55042. * If mipmap levels should be loaded for transcoded images (Default: true)
  55043. */
  55044. loadMipmapLevels?: boolean;
  55045. /**
  55046. * Index of a single image to load (Default: all images)
  55047. */
  55048. loadSingleImage?: number;
  55049. }
  55050. /**
  55051. * Used to load .Basis files
  55052. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55053. */
  55054. export class BasisTools {
  55055. private static _IgnoreSupportedFormats;
  55056. /**
  55057. * URL to use when loading the basis transcoder
  55058. */
  55059. static JSModuleURL: string;
  55060. /**
  55061. * URL to use when loading the wasm module for the transcoder
  55062. */
  55063. static WasmModuleURL: string;
  55064. /**
  55065. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55066. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55067. * @returns internal format corresponding to the Basis format
  55068. */
  55069. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55070. private static _WorkerPromise;
  55071. private static _Worker;
  55072. private static _actionId;
  55073. private static _CreateWorkerAsync;
  55074. /**
  55075. * Transcodes a loaded image file to compressed pixel data
  55076. * @param imageData image data to transcode
  55077. * @param config configuration options for the transcoding
  55078. * @returns a promise resulting in the transcoded image
  55079. */
  55080. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55081. /**
  55082. * Loads a texture from the transcode result
  55083. * @param texture texture load to
  55084. * @param transcodeResult the result of transcoding the basis file to load from
  55085. */
  55086. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55087. }
  55088. }
  55089. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55090. import { Nullable } from "babylonjs/types";
  55091. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55092. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55093. /**
  55094. * Loader for .basis file format
  55095. */
  55096. export class _BasisTextureLoader implements IInternalTextureLoader {
  55097. /**
  55098. * Defines whether the loader supports cascade loading the different faces.
  55099. */
  55100. readonly supportCascades: boolean;
  55101. /**
  55102. * This returns if the loader support the current file information.
  55103. * @param extension defines the file extension of the file being loaded
  55104. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55105. * @param fallback defines the fallback internal texture if any
  55106. * @param isBase64 defines whether the texture is encoded as a base64
  55107. * @param isBuffer defines whether the texture data are stored as a buffer
  55108. * @returns true if the loader can load the specified file
  55109. */
  55110. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55111. /**
  55112. * Transform the url before loading if required.
  55113. * @param rootUrl the url of the texture
  55114. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55115. * @returns the transformed texture
  55116. */
  55117. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55118. /**
  55119. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55120. * @param rootUrl the url of the texture
  55121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55122. * @returns the fallback texture
  55123. */
  55124. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55125. /**
  55126. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55127. * @param data contains the texture data
  55128. * @param texture defines the BabylonJS internal texture
  55129. * @param createPolynomials will be true if polynomials have been requested
  55130. * @param onLoad defines the callback to trigger once the texture is ready
  55131. * @param onError defines the callback to trigger in case of error
  55132. */
  55133. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55134. /**
  55135. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55136. * @param data contains the texture data
  55137. * @param texture defines the BabylonJS internal texture
  55138. * @param callback defines the method to call once ready to upload
  55139. */
  55140. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55141. }
  55142. }
  55143. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55144. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55145. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55146. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55147. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55148. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55149. }
  55150. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55151. import { Scene } from "babylonjs/scene";
  55152. import { Texture } from "babylonjs/Materials/Textures/texture";
  55153. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55154. /**
  55155. * 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.
  55156. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55157. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55158. */
  55159. export class CustomProceduralTexture extends ProceduralTexture {
  55160. private _animate;
  55161. private _time;
  55162. private _config;
  55163. private _texturePath;
  55164. /**
  55165. * Instantiates a new Custom Procedural Texture.
  55166. * 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.
  55167. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55168. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55169. * @param name Define the name of the texture
  55170. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55171. * @param size Define the size of the texture to create
  55172. * @param scene Define the scene the texture belongs to
  55173. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55174. * @param generateMipMaps Define if the texture should creates mip maps or not
  55175. */
  55176. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55177. private _loadJson;
  55178. /**
  55179. * Is the texture ready to be used ? (rendered at least once)
  55180. * @returns true if ready, otherwise, false.
  55181. */
  55182. isReady(): boolean;
  55183. /**
  55184. * Render the texture to its associated render target.
  55185. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55186. */
  55187. render(useCameraPostProcess?: boolean): void;
  55188. /**
  55189. * Update the list of dependant textures samplers in the shader.
  55190. */
  55191. updateTextures(): void;
  55192. /**
  55193. * Update the uniform values of the procedural texture in the shader.
  55194. */
  55195. updateShaderUniforms(): void;
  55196. /**
  55197. * Define if the texture animates or not.
  55198. */
  55199. animate: boolean;
  55200. }
  55201. }
  55202. declare module "babylonjs/Shaders/noise.fragment" {
  55203. /** @hidden */
  55204. export var noisePixelShader: {
  55205. name: string;
  55206. shader: string;
  55207. };
  55208. }
  55209. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55210. import { Nullable } from "babylonjs/types";
  55211. import { Scene } from "babylonjs/scene";
  55212. import { Texture } from "babylonjs/Materials/Textures/texture";
  55213. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55214. import "babylonjs/Shaders/noise.fragment";
  55215. /**
  55216. * Class used to generate noise procedural textures
  55217. */
  55218. export class NoiseProceduralTexture extends ProceduralTexture {
  55219. private _time;
  55220. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55221. brightness: number;
  55222. /** Defines the number of octaves to process */
  55223. octaves: number;
  55224. /** Defines the level of persistence (0.8 by default) */
  55225. persistence: number;
  55226. /** Gets or sets animation speed factor (default is 1) */
  55227. animationSpeedFactor: number;
  55228. /**
  55229. * Creates a new NoiseProceduralTexture
  55230. * @param name defines the name fo the texture
  55231. * @param size defines the size of the texture (default is 256)
  55232. * @param scene defines the hosting scene
  55233. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55234. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55235. */
  55236. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55237. private _updateShaderUniforms;
  55238. protected _getDefines(): string;
  55239. /** Generate the current state of the procedural texture */
  55240. render(useCameraPostProcess?: boolean): void;
  55241. /**
  55242. * Serializes this noise procedural texture
  55243. * @returns a serialized noise procedural texture object
  55244. */
  55245. serialize(): any;
  55246. /**
  55247. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55248. * @param parsedTexture defines parsed texture data
  55249. * @param scene defines the current scene
  55250. * @param rootUrl defines the root URL containing noise procedural texture information
  55251. * @returns a parsed NoiseProceduralTexture
  55252. */
  55253. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55254. }
  55255. }
  55256. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55257. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55258. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55259. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55260. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55261. }
  55262. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55263. import { Nullable } from "babylonjs/types";
  55264. import { Scene } from "babylonjs/scene";
  55265. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55266. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55267. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55268. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55269. /**
  55270. * Raw cube texture where the raw buffers are passed in
  55271. */
  55272. export class RawCubeTexture extends CubeTexture {
  55273. /**
  55274. * Creates a cube texture where the raw buffers are passed in.
  55275. * @param scene defines the scene the texture is attached to
  55276. * @param data defines the array of data to use to create each face
  55277. * @param size defines the size of the textures
  55278. * @param format defines the format of the data
  55279. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55280. * @param generateMipMaps defines if the engine should generate the mip levels
  55281. * @param invertY defines if data must be stored with Y axis inverted
  55282. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55283. * @param compression defines the compression used (null by default)
  55284. */
  55285. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55286. /**
  55287. * Updates the raw cube texture.
  55288. * @param data defines the data to store
  55289. * @param format defines the data format
  55290. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55291. * @param invertY defines if data must be stored with Y axis inverted
  55292. * @param compression defines the compression used (null by default)
  55293. * @param level defines which level of the texture to update
  55294. */
  55295. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55296. /**
  55297. * Updates a raw cube texture with RGBD encoded data.
  55298. * @param data defines the array of data [mipmap][face] to use to create each face
  55299. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55300. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55301. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55302. * @returns a promsie that resolves when the operation is complete
  55303. */
  55304. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55305. /**
  55306. * Clones the raw cube texture.
  55307. * @return a new cube texture
  55308. */
  55309. clone(): CubeTexture;
  55310. /** @hidden */
  55311. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55312. }
  55313. }
  55314. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55315. import { Scene } from "babylonjs/scene";
  55316. import { Texture } from "babylonjs/Materials/Textures/texture";
  55317. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55318. /**
  55319. * Class used to store 3D textures containing user data
  55320. */
  55321. export class RawTexture3D extends Texture {
  55322. /** Gets or sets the texture format to use */
  55323. format: number;
  55324. private _engine;
  55325. /**
  55326. * Create a new RawTexture3D
  55327. * @param data defines the data of the texture
  55328. * @param width defines the width of the texture
  55329. * @param height defines the height of the texture
  55330. * @param depth defines the depth of the texture
  55331. * @param format defines the texture format to use
  55332. * @param scene defines the hosting scene
  55333. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55334. * @param invertY defines if texture must be stored with Y axis inverted
  55335. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55336. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55337. */
  55338. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55339. /** Gets or sets the texture format to use */
  55340. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55341. /**
  55342. * Update the texture with new data
  55343. * @param data defines the data to store in the texture
  55344. */
  55345. update(data: ArrayBufferView): void;
  55346. }
  55347. }
  55348. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55349. import { Scene } from "babylonjs/scene";
  55350. import { Texture } from "babylonjs/Materials/Textures/texture";
  55351. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55352. /**
  55353. * Class used to store 2D array textures containing user data
  55354. */
  55355. export class RawTexture2DArray extends Texture {
  55356. /** Gets or sets the texture format to use */
  55357. format: number;
  55358. private _engine;
  55359. /**
  55360. * Create a new RawTexture2DArray
  55361. * @param data defines the data of the texture
  55362. * @param width defines the width of the texture
  55363. * @param height defines the height of the texture
  55364. * @param depth defines the number of layers of the texture
  55365. * @param format defines the texture format to use
  55366. * @param scene defines the hosting scene
  55367. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55368. * @param invertY defines if texture must be stored with Y axis inverted
  55369. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55370. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55371. */
  55372. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55373. /** Gets or sets the texture format to use */
  55374. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55375. /**
  55376. * Update the texture with new data
  55377. * @param data defines the data to store in the texture
  55378. */
  55379. update(data: ArrayBufferView): void;
  55380. }
  55381. }
  55382. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55383. import { Scene } from "babylonjs/scene";
  55384. import { Plane } from "babylonjs/Maths/math.plane";
  55385. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55386. /**
  55387. * Creates a refraction texture used by refraction channel of the standard material.
  55388. * It is like a mirror but to see through a material.
  55389. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55390. */
  55391. export class RefractionTexture extends RenderTargetTexture {
  55392. /**
  55393. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55394. * 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.
  55395. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55396. */
  55397. refractionPlane: Plane;
  55398. /**
  55399. * Define how deep under the surface we should see.
  55400. */
  55401. depth: number;
  55402. /**
  55403. * Creates a refraction texture used by refraction channel of the standard material.
  55404. * It is like a mirror but to see through a material.
  55405. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55406. * @param name Define the texture name
  55407. * @param size Define the size of the underlying texture
  55408. * @param scene Define the scene the refraction belongs to
  55409. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55410. */
  55411. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55412. /**
  55413. * Clone the refraction texture.
  55414. * @returns the cloned texture
  55415. */
  55416. clone(): RefractionTexture;
  55417. /**
  55418. * Serialize the texture to a JSON representation you could use in Parse later on
  55419. * @returns the serialized JSON representation
  55420. */
  55421. serialize(): any;
  55422. }
  55423. }
  55424. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55425. import { Nullable } from "babylonjs/types";
  55426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55427. import { Matrix } from "babylonjs/Maths/math.vector";
  55428. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55429. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55430. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55431. import { Scene } from "babylonjs/scene";
  55432. /**
  55433. * Defines the options related to the creation of an HtmlElementTexture
  55434. */
  55435. export interface IHtmlElementTextureOptions {
  55436. /**
  55437. * Defines wether mip maps should be created or not.
  55438. */
  55439. generateMipMaps?: boolean;
  55440. /**
  55441. * Defines the sampling mode of the texture.
  55442. */
  55443. samplingMode?: number;
  55444. /**
  55445. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55446. */
  55447. engine: Nullable<ThinEngine>;
  55448. /**
  55449. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55450. */
  55451. scene: Nullable<Scene>;
  55452. }
  55453. /**
  55454. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55455. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55456. * is automatically managed.
  55457. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55458. * in your application.
  55459. *
  55460. * As the update is not automatic, you need to call them manually.
  55461. */
  55462. export class HtmlElementTexture extends BaseTexture {
  55463. /**
  55464. * The texture URL.
  55465. */
  55466. element: HTMLVideoElement | HTMLCanvasElement;
  55467. private static readonly DefaultOptions;
  55468. private _textureMatrix;
  55469. private _engine;
  55470. private _isVideo;
  55471. private _generateMipMaps;
  55472. private _samplingMode;
  55473. /**
  55474. * Instantiates a HtmlElementTexture from the following parameters.
  55475. *
  55476. * @param name Defines the name of the texture
  55477. * @param element Defines the video or canvas the texture is filled with
  55478. * @param options Defines the other none mandatory texture creation options
  55479. */
  55480. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55481. private _createInternalTexture;
  55482. /**
  55483. * Returns the texture matrix used in most of the material.
  55484. */
  55485. getTextureMatrix(): Matrix;
  55486. /**
  55487. * Updates the content of the texture.
  55488. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55489. */
  55490. update(invertY?: Nullable<boolean>): void;
  55491. }
  55492. }
  55493. declare module "babylonjs/Materials/Textures/index" {
  55494. export * from "babylonjs/Materials/Textures/baseTexture";
  55495. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55496. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55497. export * from "babylonjs/Materials/Textures/cubeTexture";
  55498. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55499. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55500. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55501. export * from "babylonjs/Materials/Textures/internalTexture";
  55502. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55503. export * from "babylonjs/Materials/Textures/Loaders/index";
  55504. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55505. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55506. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55507. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55508. export * from "babylonjs/Materials/Textures/rawTexture";
  55509. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55510. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55511. export * from "babylonjs/Materials/Textures/refractionTexture";
  55512. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55513. export * from "babylonjs/Materials/Textures/texture";
  55514. export * from "babylonjs/Materials/Textures/videoTexture";
  55515. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55516. }
  55517. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55518. /**
  55519. * Enum used to define the target of a block
  55520. */
  55521. export enum NodeMaterialBlockTargets {
  55522. /** Vertex shader */
  55523. Vertex = 1,
  55524. /** Fragment shader */
  55525. Fragment = 2,
  55526. /** Neutral */
  55527. Neutral = 4,
  55528. /** Vertex and Fragment */
  55529. VertexAndFragment = 3
  55530. }
  55531. }
  55532. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55533. /**
  55534. * Defines the kind of connection point for node based material
  55535. */
  55536. export enum NodeMaterialBlockConnectionPointTypes {
  55537. /** Float */
  55538. Float = 1,
  55539. /** Int */
  55540. Int = 2,
  55541. /** Vector2 */
  55542. Vector2 = 4,
  55543. /** Vector3 */
  55544. Vector3 = 8,
  55545. /** Vector4 */
  55546. Vector4 = 16,
  55547. /** Color3 */
  55548. Color3 = 32,
  55549. /** Color4 */
  55550. Color4 = 64,
  55551. /** Matrix */
  55552. Matrix = 128,
  55553. /** Detect type based on connection */
  55554. AutoDetect = 1024,
  55555. /** Output type that will be defined by input type */
  55556. BasedOnInput = 2048
  55557. }
  55558. }
  55559. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55560. /**
  55561. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55562. */
  55563. export enum NodeMaterialBlockConnectionPointMode {
  55564. /** Value is an uniform */
  55565. Uniform = 0,
  55566. /** Value is a mesh attribute */
  55567. Attribute = 1,
  55568. /** Value is a varying between vertex and fragment shaders */
  55569. Varying = 2,
  55570. /** Mode is undefined */
  55571. Undefined = 3
  55572. }
  55573. }
  55574. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55575. /**
  55576. * Enum used to define system values e.g. values automatically provided by the system
  55577. */
  55578. export enum NodeMaterialSystemValues {
  55579. /** World */
  55580. World = 1,
  55581. /** View */
  55582. View = 2,
  55583. /** Projection */
  55584. Projection = 3,
  55585. /** ViewProjection */
  55586. ViewProjection = 4,
  55587. /** WorldView */
  55588. WorldView = 5,
  55589. /** WorldViewProjection */
  55590. WorldViewProjection = 6,
  55591. /** CameraPosition */
  55592. CameraPosition = 7,
  55593. /** Fog Color */
  55594. FogColor = 8,
  55595. /** Delta time */
  55596. DeltaTime = 9
  55597. }
  55598. }
  55599. declare module "babylonjs/Materials/Node/Enums/index" {
  55600. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55601. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55602. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55603. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55604. }
  55605. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55607. /**
  55608. * Root class for all node material optimizers
  55609. */
  55610. export class NodeMaterialOptimizer {
  55611. /**
  55612. * Function used to optimize a NodeMaterial graph
  55613. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55614. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55615. */
  55616. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55617. }
  55618. }
  55619. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55623. import { Scene } from "babylonjs/scene";
  55624. /**
  55625. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55626. */
  55627. export class TransformBlock extends NodeMaterialBlock {
  55628. /**
  55629. * Defines the value to use to complement W value to transform it to a Vector4
  55630. */
  55631. complementW: number;
  55632. /**
  55633. * Defines the value to use to complement z value to transform it to a Vector4
  55634. */
  55635. complementZ: number;
  55636. /**
  55637. * Creates a new TransformBlock
  55638. * @param name defines the block name
  55639. */
  55640. constructor(name: string);
  55641. /**
  55642. * Gets the current class name
  55643. * @returns the class name
  55644. */
  55645. getClassName(): string;
  55646. /**
  55647. * Gets the vector input
  55648. */
  55649. readonly vector: NodeMaterialConnectionPoint;
  55650. /**
  55651. * Gets the output component
  55652. */
  55653. readonly output: NodeMaterialConnectionPoint;
  55654. /**
  55655. * Gets the matrix transform input
  55656. */
  55657. readonly transform: NodeMaterialConnectionPoint;
  55658. protected _buildBlock(state: NodeMaterialBuildState): this;
  55659. serialize(): any;
  55660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55661. protected _dumpPropertiesCode(): string;
  55662. }
  55663. }
  55664. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55666. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55668. /**
  55669. * Block used to output the vertex position
  55670. */
  55671. export class VertexOutputBlock extends NodeMaterialBlock {
  55672. /**
  55673. * Creates a new VertexOutputBlock
  55674. * @param name defines the block name
  55675. */
  55676. constructor(name: string);
  55677. /**
  55678. * Gets the current class name
  55679. * @returns the class name
  55680. */
  55681. getClassName(): string;
  55682. /**
  55683. * Gets the vector input component
  55684. */
  55685. readonly vector: NodeMaterialConnectionPoint;
  55686. protected _buildBlock(state: NodeMaterialBuildState): this;
  55687. }
  55688. }
  55689. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55693. /**
  55694. * Block used to output the final color
  55695. */
  55696. export class FragmentOutputBlock extends NodeMaterialBlock {
  55697. /**
  55698. * Create a new FragmentOutputBlock
  55699. * @param name defines the block name
  55700. */
  55701. constructor(name: string);
  55702. /**
  55703. * Gets the current class name
  55704. * @returns the class name
  55705. */
  55706. getClassName(): string;
  55707. /**
  55708. * Gets the rgba input component
  55709. */
  55710. readonly rgba: NodeMaterialConnectionPoint;
  55711. /**
  55712. * Gets the rgb input component
  55713. */
  55714. readonly rgb: NodeMaterialConnectionPoint;
  55715. /**
  55716. * Gets the a input component
  55717. */
  55718. readonly a: NodeMaterialConnectionPoint;
  55719. protected _buildBlock(state: NodeMaterialBuildState): this;
  55720. }
  55721. }
  55722. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55726. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55728. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55729. import { Effect } from "babylonjs/Materials/effect";
  55730. import { Mesh } from "babylonjs/Meshes/mesh";
  55731. import { Nullable } from "babylonjs/types";
  55732. import { Scene } from "babylonjs/scene";
  55733. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55734. /**
  55735. * Block used to read a reflection texture from a sampler
  55736. */
  55737. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55738. private _define3DName;
  55739. private _defineCubicName;
  55740. private _defineExplicitName;
  55741. private _defineProjectionName;
  55742. private _defineLocalCubicName;
  55743. private _defineSphericalName;
  55744. private _definePlanarName;
  55745. private _defineEquirectangularName;
  55746. private _defineMirroredEquirectangularFixedName;
  55747. private _defineEquirectangularFixedName;
  55748. private _defineSkyboxName;
  55749. private _cubeSamplerName;
  55750. private _2DSamplerName;
  55751. private _positionUVWName;
  55752. private _directionWName;
  55753. private _reflectionCoordsName;
  55754. private _reflection2DCoordsName;
  55755. private _reflectionColorName;
  55756. private _reflectionMatrixName;
  55757. /**
  55758. * Gets or sets the texture associated with the node
  55759. */
  55760. texture: Nullable<BaseTexture>;
  55761. /**
  55762. * Create a new TextureBlock
  55763. * @param name defines the block name
  55764. */
  55765. constructor(name: string);
  55766. /**
  55767. * Gets the current class name
  55768. * @returns the class name
  55769. */
  55770. getClassName(): string;
  55771. /**
  55772. * Gets the world position input component
  55773. */
  55774. readonly position: NodeMaterialConnectionPoint;
  55775. /**
  55776. * Gets the world position input component
  55777. */
  55778. readonly worldPosition: NodeMaterialConnectionPoint;
  55779. /**
  55780. * Gets the world normal input component
  55781. */
  55782. readonly worldNormal: NodeMaterialConnectionPoint;
  55783. /**
  55784. * Gets the world input component
  55785. */
  55786. readonly world: NodeMaterialConnectionPoint;
  55787. /**
  55788. * Gets the camera (or eye) position component
  55789. */
  55790. readonly cameraPosition: NodeMaterialConnectionPoint;
  55791. /**
  55792. * Gets the view input component
  55793. */
  55794. readonly view: NodeMaterialConnectionPoint;
  55795. /**
  55796. * Gets the rgb output component
  55797. */
  55798. readonly rgb: NodeMaterialConnectionPoint;
  55799. /**
  55800. * Gets the r output component
  55801. */
  55802. readonly r: NodeMaterialConnectionPoint;
  55803. /**
  55804. * Gets the g output component
  55805. */
  55806. readonly g: NodeMaterialConnectionPoint;
  55807. /**
  55808. * Gets the b output component
  55809. */
  55810. readonly b: NodeMaterialConnectionPoint;
  55811. autoConfigure(material: NodeMaterial): void;
  55812. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55813. isReady(): boolean;
  55814. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55815. private _injectVertexCode;
  55816. private _writeOutput;
  55817. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55818. protected _dumpPropertiesCode(): string;
  55819. serialize(): any;
  55820. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55821. }
  55822. }
  55823. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55825. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55826. import { Scene } from "babylonjs/scene";
  55827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55828. import { Matrix } from "babylonjs/Maths/math.vector";
  55829. import { Mesh } from "babylonjs/Meshes/mesh";
  55830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55831. import { Observable } from "babylonjs/Misc/observable";
  55832. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55833. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55834. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55835. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55836. import { Nullable } from "babylonjs/types";
  55837. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55838. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55839. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55840. /**
  55841. * Interface used to configure the node material editor
  55842. */
  55843. export interface INodeMaterialEditorOptions {
  55844. /** Define the URl to load node editor script */
  55845. editorURL?: string;
  55846. }
  55847. /** @hidden */
  55848. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55849. /** BONES */
  55850. NUM_BONE_INFLUENCERS: number;
  55851. BonesPerMesh: number;
  55852. BONETEXTURE: boolean;
  55853. /** MORPH TARGETS */
  55854. MORPHTARGETS: boolean;
  55855. MORPHTARGETS_NORMAL: boolean;
  55856. MORPHTARGETS_TANGENT: boolean;
  55857. MORPHTARGETS_UV: boolean;
  55858. NUM_MORPH_INFLUENCERS: number;
  55859. /** IMAGE PROCESSING */
  55860. IMAGEPROCESSING: boolean;
  55861. VIGNETTE: boolean;
  55862. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55863. VIGNETTEBLENDMODEOPAQUE: boolean;
  55864. TONEMAPPING: boolean;
  55865. TONEMAPPING_ACES: boolean;
  55866. CONTRAST: boolean;
  55867. EXPOSURE: boolean;
  55868. COLORCURVES: boolean;
  55869. COLORGRADING: boolean;
  55870. COLORGRADING3D: boolean;
  55871. SAMPLER3DGREENDEPTH: boolean;
  55872. SAMPLER3DBGRMAP: boolean;
  55873. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55874. /** MISC. */
  55875. BUMPDIRECTUV: number;
  55876. constructor();
  55877. setValue(name: string, value: boolean): void;
  55878. }
  55879. /**
  55880. * Class used to configure NodeMaterial
  55881. */
  55882. export interface INodeMaterialOptions {
  55883. /**
  55884. * Defines if blocks should emit comments
  55885. */
  55886. emitComments: boolean;
  55887. }
  55888. /**
  55889. * Class used to create a node based material built by assembling shader blocks
  55890. */
  55891. export class NodeMaterial extends PushMaterial {
  55892. private static _BuildIdGenerator;
  55893. private _options;
  55894. private _vertexCompilationState;
  55895. private _fragmentCompilationState;
  55896. private _sharedData;
  55897. private _buildId;
  55898. private _buildWasSuccessful;
  55899. private _cachedWorldViewMatrix;
  55900. private _cachedWorldViewProjectionMatrix;
  55901. private _optimizers;
  55902. private _animationFrame;
  55903. /** Define the URl to load node editor script */
  55904. static EditorURL: string;
  55905. private BJSNODEMATERIALEDITOR;
  55906. /** Get the inspector from bundle or global */
  55907. private _getGlobalNodeMaterialEditor;
  55908. /**
  55909. * 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)
  55910. */
  55911. ignoreAlpha: boolean;
  55912. /**
  55913. * Defines the maximum number of lights that can be used in the material
  55914. */
  55915. maxSimultaneousLights: number;
  55916. /**
  55917. * Observable raised when the material is built
  55918. */
  55919. onBuildObservable: Observable<NodeMaterial>;
  55920. /**
  55921. * Gets or sets the root nodes of the material vertex shader
  55922. */
  55923. _vertexOutputNodes: NodeMaterialBlock[];
  55924. /**
  55925. * Gets or sets the root nodes of the material fragment (pixel) shader
  55926. */
  55927. _fragmentOutputNodes: NodeMaterialBlock[];
  55928. /** Gets or sets options to control the node material overall behavior */
  55929. options: INodeMaterialOptions;
  55930. /**
  55931. * Default configuration related to image processing available in the standard Material.
  55932. */
  55933. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55934. /**
  55935. * Gets the image processing configuration used either in this material.
  55936. */
  55937. /**
  55938. * Sets the Default image processing configuration used either in the this material.
  55939. *
  55940. * If sets to null, the scene one is in use.
  55941. */
  55942. imageProcessingConfiguration: ImageProcessingConfiguration;
  55943. /**
  55944. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55945. */
  55946. attachedBlocks: NodeMaterialBlock[];
  55947. /**
  55948. * Create a new node based material
  55949. * @param name defines the material name
  55950. * @param scene defines the hosting scene
  55951. * @param options defines creation option
  55952. */
  55953. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55954. /**
  55955. * Gets the current class name of the material e.g. "NodeMaterial"
  55956. * @returns the class name
  55957. */
  55958. getClassName(): string;
  55959. /**
  55960. * Keep track of the image processing observer to allow dispose and replace.
  55961. */
  55962. private _imageProcessingObserver;
  55963. /**
  55964. * Attaches a new image processing configuration to the Standard Material.
  55965. * @param configuration
  55966. */
  55967. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55968. /**
  55969. * Get a block by its name
  55970. * @param name defines the name of the block to retrieve
  55971. * @returns the required block or null if not found
  55972. */
  55973. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55974. /**
  55975. * Get a block by its name
  55976. * @param predicate defines the predicate used to find the good candidate
  55977. * @returns the required block or null if not found
  55978. */
  55979. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55980. /**
  55981. * Get an input block by its name
  55982. * @param predicate defines the predicate used to find the good candidate
  55983. * @returns the required input block or null if not found
  55984. */
  55985. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55986. /**
  55987. * Gets the list of input blocks attached to this material
  55988. * @returns an array of InputBlocks
  55989. */
  55990. getInputBlocks(): InputBlock[];
  55991. /**
  55992. * Adds a new optimizer to the list of optimizers
  55993. * @param optimizer defines the optimizers to add
  55994. * @returns the current material
  55995. */
  55996. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55997. /**
  55998. * Remove an optimizer from the list of optimizers
  55999. * @param optimizer defines the optimizers to remove
  56000. * @returns the current material
  56001. */
  56002. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56003. /**
  56004. * Add a new block to the list of output nodes
  56005. * @param node defines the node to add
  56006. * @returns the current material
  56007. */
  56008. addOutputNode(node: NodeMaterialBlock): this;
  56009. /**
  56010. * Remove a block from the list of root nodes
  56011. * @param node defines the node to remove
  56012. * @returns the current material
  56013. */
  56014. removeOutputNode(node: NodeMaterialBlock): this;
  56015. private _addVertexOutputNode;
  56016. private _removeVertexOutputNode;
  56017. private _addFragmentOutputNode;
  56018. private _removeFragmentOutputNode;
  56019. /**
  56020. * Specifies if the material will require alpha blending
  56021. * @returns a boolean specifying if alpha blending is needed
  56022. */
  56023. needAlphaBlending(): boolean;
  56024. /**
  56025. * Specifies if this material should be rendered in alpha test mode
  56026. * @returns a boolean specifying if an alpha test is needed.
  56027. */
  56028. needAlphaTesting(): boolean;
  56029. private _initializeBlock;
  56030. private _resetDualBlocks;
  56031. /**
  56032. * Build the material and generates the inner effect
  56033. * @param verbose defines if the build should log activity
  56034. */
  56035. build(verbose?: boolean): void;
  56036. /**
  56037. * Runs an otpimization phase to try to improve the shader code
  56038. */
  56039. optimize(): void;
  56040. private _prepareDefinesForAttributes;
  56041. /**
  56042. * Get if the submesh is ready to be used and all its information available.
  56043. * Child classes can use it to update shaders
  56044. * @param mesh defines the mesh to check
  56045. * @param subMesh defines which submesh to check
  56046. * @param useInstances specifies that instances should be used
  56047. * @returns a boolean indicating that the submesh is ready or not
  56048. */
  56049. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56050. /**
  56051. * Get a string representing the shaders built by the current node graph
  56052. */
  56053. readonly compiledShaders: string;
  56054. /**
  56055. * Binds the world matrix to the material
  56056. * @param world defines the world transformation matrix
  56057. */
  56058. bindOnlyWorldMatrix(world: Matrix): void;
  56059. /**
  56060. * Binds the submesh to this material by preparing the effect and shader to draw
  56061. * @param world defines the world transformation matrix
  56062. * @param mesh defines the mesh containing the submesh
  56063. * @param subMesh defines the submesh to bind the material to
  56064. */
  56065. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56066. /**
  56067. * Gets the active textures from the material
  56068. * @returns an array of textures
  56069. */
  56070. getActiveTextures(): BaseTexture[];
  56071. /**
  56072. * Gets the list of texture blocks
  56073. * @returns an array of texture blocks
  56074. */
  56075. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56076. /**
  56077. * Specifies if the material uses a texture
  56078. * @param texture defines the texture to check against the material
  56079. * @returns a boolean specifying if the material uses the texture
  56080. */
  56081. hasTexture(texture: BaseTexture): boolean;
  56082. /**
  56083. * Disposes the material
  56084. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56085. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56086. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56087. */
  56088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56089. /** Creates the node editor window. */
  56090. private _createNodeEditor;
  56091. /**
  56092. * Launch the node material editor
  56093. * @param config Define the configuration of the editor
  56094. * @return a promise fulfilled when the node editor is visible
  56095. */
  56096. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56097. /**
  56098. * Clear the current material
  56099. */
  56100. clear(): void;
  56101. /**
  56102. * Clear the current material and set it to a default state
  56103. */
  56104. setToDefault(): void;
  56105. /**
  56106. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56107. * @param url defines the url to load from
  56108. * @returns a promise that will fullfil when the material is fully loaded
  56109. */
  56110. loadAsync(url: string): Promise<void>;
  56111. private _gatherBlocks;
  56112. /**
  56113. * Generate a string containing the code declaration required to create an equivalent of this material
  56114. * @returns a string
  56115. */
  56116. generateCode(): string;
  56117. /**
  56118. * Serializes this material in a JSON representation
  56119. * @returns the serialized material object
  56120. */
  56121. serialize(): any;
  56122. private _restoreConnections;
  56123. /**
  56124. * Clear the current graph and load a new one from a serialization object
  56125. * @param source defines the JSON representation of the material
  56126. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56127. */
  56128. loadFromSerialization(source: any, rootUrl?: string): void;
  56129. /**
  56130. * Creates a node material from parsed material data
  56131. * @param source defines the JSON representation of the material
  56132. * @param scene defines the hosting scene
  56133. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56134. * @returns a new node material
  56135. */
  56136. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56137. /**
  56138. * Creates a new node material set to default basic configuration
  56139. * @param name defines the name of the material
  56140. * @param scene defines the hosting scene
  56141. * @returns a new NodeMaterial
  56142. */
  56143. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56144. }
  56145. }
  56146. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56147. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56148. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56149. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56152. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56153. import { Effect } from "babylonjs/Materials/effect";
  56154. import { Mesh } from "babylonjs/Meshes/mesh";
  56155. import { Nullable } from "babylonjs/types";
  56156. import { Texture } from "babylonjs/Materials/Textures/texture";
  56157. import { Scene } from "babylonjs/scene";
  56158. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56159. /**
  56160. * Block used to read a texture from a sampler
  56161. */
  56162. export class TextureBlock extends NodeMaterialBlock {
  56163. private _defineName;
  56164. private _linearDefineName;
  56165. private _samplerName;
  56166. private _transformedUVName;
  56167. private _textureTransformName;
  56168. private _textureInfoName;
  56169. private _mainUVName;
  56170. private _mainUVDefineName;
  56171. /**
  56172. * Gets or sets the texture associated with the node
  56173. */
  56174. texture: Nullable<Texture>;
  56175. /**
  56176. * Create a new TextureBlock
  56177. * @param name defines the block name
  56178. */
  56179. constructor(name: string);
  56180. /**
  56181. * Gets the current class name
  56182. * @returns the class name
  56183. */
  56184. getClassName(): string;
  56185. /**
  56186. * Gets the uv input component
  56187. */
  56188. readonly uv: NodeMaterialConnectionPoint;
  56189. /**
  56190. * Gets the rgba output component
  56191. */
  56192. readonly rgba: NodeMaterialConnectionPoint;
  56193. /**
  56194. * Gets the rgb output component
  56195. */
  56196. readonly rgb: NodeMaterialConnectionPoint;
  56197. /**
  56198. * Gets the r output component
  56199. */
  56200. readonly r: NodeMaterialConnectionPoint;
  56201. /**
  56202. * Gets the g output component
  56203. */
  56204. readonly g: NodeMaterialConnectionPoint;
  56205. /**
  56206. * Gets the b output component
  56207. */
  56208. readonly b: NodeMaterialConnectionPoint;
  56209. /**
  56210. * Gets the a output component
  56211. */
  56212. readonly a: NodeMaterialConnectionPoint;
  56213. readonly target: NodeMaterialBlockTargets;
  56214. autoConfigure(material: NodeMaterial): void;
  56215. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56216. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56217. isReady(): boolean;
  56218. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56219. private readonly _isMixed;
  56220. private _injectVertexCode;
  56221. private _writeOutput;
  56222. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56223. protected _dumpPropertiesCode(): string;
  56224. serialize(): any;
  56225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56226. }
  56227. }
  56228. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56229. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56231. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56232. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56233. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56234. import { Scene } from "babylonjs/scene";
  56235. /**
  56236. * Class used to store shared data between 2 NodeMaterialBuildState
  56237. */
  56238. export class NodeMaterialBuildStateSharedData {
  56239. /**
  56240. * Gets the list of emitted varyings
  56241. */
  56242. temps: string[];
  56243. /**
  56244. * Gets the list of emitted varyings
  56245. */
  56246. varyings: string[];
  56247. /**
  56248. * Gets the varying declaration string
  56249. */
  56250. varyingDeclaration: string;
  56251. /**
  56252. * Input blocks
  56253. */
  56254. inputBlocks: InputBlock[];
  56255. /**
  56256. * Input blocks
  56257. */
  56258. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56259. /**
  56260. * Bindable blocks (Blocks that need to set data to the effect)
  56261. */
  56262. bindableBlocks: NodeMaterialBlock[];
  56263. /**
  56264. * List of blocks that can provide a compilation fallback
  56265. */
  56266. blocksWithFallbacks: NodeMaterialBlock[];
  56267. /**
  56268. * List of blocks that can provide a define update
  56269. */
  56270. blocksWithDefines: NodeMaterialBlock[];
  56271. /**
  56272. * List of blocks that can provide a repeatable content
  56273. */
  56274. repeatableContentBlocks: NodeMaterialBlock[];
  56275. /**
  56276. * List of blocks that can provide a dynamic list of uniforms
  56277. */
  56278. dynamicUniformBlocks: NodeMaterialBlock[];
  56279. /**
  56280. * List of blocks that can block the isReady function for the material
  56281. */
  56282. blockingBlocks: NodeMaterialBlock[];
  56283. /**
  56284. * Gets the list of animated inputs
  56285. */
  56286. animatedInputs: InputBlock[];
  56287. /**
  56288. * Build Id used to avoid multiple recompilations
  56289. */
  56290. buildId: number;
  56291. /** List of emitted variables */
  56292. variableNames: {
  56293. [key: string]: number;
  56294. };
  56295. /** List of emitted defines */
  56296. defineNames: {
  56297. [key: string]: number;
  56298. };
  56299. /** Should emit comments? */
  56300. emitComments: boolean;
  56301. /** Emit build activity */
  56302. verbose: boolean;
  56303. /** Gets or sets the hosting scene */
  56304. scene: Scene;
  56305. /**
  56306. * Gets the compilation hints emitted at compilation time
  56307. */
  56308. hints: {
  56309. needWorldViewMatrix: boolean;
  56310. needWorldViewProjectionMatrix: boolean;
  56311. needAlphaBlending: boolean;
  56312. needAlphaTesting: boolean;
  56313. };
  56314. /**
  56315. * List of compilation checks
  56316. */
  56317. checks: {
  56318. emitVertex: boolean;
  56319. emitFragment: boolean;
  56320. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56321. };
  56322. /** Creates a new shared data */
  56323. constructor();
  56324. /**
  56325. * Emits console errors and exceptions if there is a failing check
  56326. */
  56327. emitErrors(): void;
  56328. }
  56329. }
  56330. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56331. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56332. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56333. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56334. /**
  56335. * Class used to store node based material build state
  56336. */
  56337. export class NodeMaterialBuildState {
  56338. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56339. supportUniformBuffers: boolean;
  56340. /**
  56341. * Gets the list of emitted attributes
  56342. */
  56343. attributes: string[];
  56344. /**
  56345. * Gets the list of emitted uniforms
  56346. */
  56347. uniforms: string[];
  56348. /**
  56349. * Gets the list of emitted constants
  56350. */
  56351. constants: string[];
  56352. /**
  56353. * Gets the list of emitted samplers
  56354. */
  56355. samplers: string[];
  56356. /**
  56357. * Gets the list of emitted functions
  56358. */
  56359. functions: {
  56360. [key: string]: string;
  56361. };
  56362. /**
  56363. * Gets the list of emitted extensions
  56364. */
  56365. extensions: {
  56366. [key: string]: string;
  56367. };
  56368. /**
  56369. * Gets the target of the compilation state
  56370. */
  56371. target: NodeMaterialBlockTargets;
  56372. /**
  56373. * Gets the list of emitted counters
  56374. */
  56375. counters: {
  56376. [key: string]: number;
  56377. };
  56378. /**
  56379. * Shared data between multiple NodeMaterialBuildState instances
  56380. */
  56381. sharedData: NodeMaterialBuildStateSharedData;
  56382. /** @hidden */
  56383. _vertexState: NodeMaterialBuildState;
  56384. /** @hidden */
  56385. _attributeDeclaration: string;
  56386. /** @hidden */
  56387. _uniformDeclaration: string;
  56388. /** @hidden */
  56389. _constantDeclaration: string;
  56390. /** @hidden */
  56391. _samplerDeclaration: string;
  56392. /** @hidden */
  56393. _varyingTransfer: string;
  56394. private _repeatableContentAnchorIndex;
  56395. /** @hidden */
  56396. _builtCompilationString: string;
  56397. /**
  56398. * Gets the emitted compilation strings
  56399. */
  56400. compilationString: string;
  56401. /**
  56402. * Finalize the compilation strings
  56403. * @param state defines the current compilation state
  56404. */
  56405. finalize(state: NodeMaterialBuildState): void;
  56406. /** @hidden */
  56407. readonly _repeatableContentAnchor: string;
  56408. /** @hidden */
  56409. _getFreeVariableName(prefix: string): string;
  56410. /** @hidden */
  56411. _getFreeDefineName(prefix: string): string;
  56412. /** @hidden */
  56413. _excludeVariableName(name: string): void;
  56414. /** @hidden */
  56415. _emit2DSampler(name: string): void;
  56416. /** @hidden */
  56417. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56418. /** @hidden */
  56419. _emitExtension(name: string, extension: string): void;
  56420. /** @hidden */
  56421. _emitFunction(name: string, code: string, comments: string): void;
  56422. /** @hidden */
  56423. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56424. replaceStrings?: {
  56425. search: RegExp;
  56426. replace: string;
  56427. }[];
  56428. repeatKey?: string;
  56429. }): string;
  56430. /** @hidden */
  56431. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56432. repeatKey?: string;
  56433. removeAttributes?: boolean;
  56434. removeUniforms?: boolean;
  56435. removeVaryings?: boolean;
  56436. removeIfDef?: boolean;
  56437. replaceStrings?: {
  56438. search: RegExp;
  56439. replace: string;
  56440. }[];
  56441. }, storeKey?: string): void;
  56442. /** @hidden */
  56443. _registerTempVariable(name: string): boolean;
  56444. /** @hidden */
  56445. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56446. /** @hidden */
  56447. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56448. /** @hidden */
  56449. _emitFloat(value: number): string;
  56450. }
  56451. }
  56452. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56453. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56455. import { Nullable } from "babylonjs/types";
  56456. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56457. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56458. import { Effect } from "babylonjs/Materials/effect";
  56459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56460. import { Mesh } from "babylonjs/Meshes/mesh";
  56461. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56462. import { Scene } from "babylonjs/scene";
  56463. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56464. /**
  56465. * Defines a block that can be used inside a node based material
  56466. */
  56467. export class NodeMaterialBlock {
  56468. private _buildId;
  56469. private _buildTarget;
  56470. private _target;
  56471. private _isFinalMerger;
  56472. private _isInput;
  56473. /** @hidden */
  56474. _codeVariableName: string;
  56475. /** @hidden */
  56476. _inputs: NodeMaterialConnectionPoint[];
  56477. /** @hidden */
  56478. _outputs: NodeMaterialConnectionPoint[];
  56479. /** @hidden */
  56480. _preparationId: number;
  56481. /**
  56482. * Gets or sets the name of the block
  56483. */
  56484. name: string;
  56485. /**
  56486. * Gets or sets the unique id of the node
  56487. */
  56488. uniqueId: number;
  56489. /**
  56490. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56491. */
  56492. readonly isFinalMerger: boolean;
  56493. /**
  56494. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56495. */
  56496. readonly isInput: boolean;
  56497. /**
  56498. * Gets or sets the build Id
  56499. */
  56500. buildId: number;
  56501. /**
  56502. * Gets or sets the target of the block
  56503. */
  56504. target: NodeMaterialBlockTargets;
  56505. /**
  56506. * Gets the list of input points
  56507. */
  56508. readonly inputs: NodeMaterialConnectionPoint[];
  56509. /** Gets the list of output points */
  56510. readonly outputs: NodeMaterialConnectionPoint[];
  56511. /**
  56512. * Find an input by its name
  56513. * @param name defines the name of the input to look for
  56514. * @returns the input or null if not found
  56515. */
  56516. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56517. /**
  56518. * Find an output by its name
  56519. * @param name defines the name of the outputto look for
  56520. * @returns the output or null if not found
  56521. */
  56522. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56523. /**
  56524. * Creates a new NodeMaterialBlock
  56525. * @param name defines the block name
  56526. * @param target defines the target of that block (Vertex by default)
  56527. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56528. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56529. */
  56530. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56531. /**
  56532. * Initialize the block and prepare the context for build
  56533. * @param state defines the state that will be used for the build
  56534. */
  56535. initialize(state: NodeMaterialBuildState): void;
  56536. /**
  56537. * Bind data to effect. Will only be called for blocks with isBindable === true
  56538. * @param effect defines the effect to bind data to
  56539. * @param nodeMaterial defines the hosting NodeMaterial
  56540. * @param mesh defines the mesh that will be rendered
  56541. */
  56542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56543. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56544. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56545. protected _writeFloat(value: number): string;
  56546. /**
  56547. * Gets the current class name e.g. "NodeMaterialBlock"
  56548. * @returns the class name
  56549. */
  56550. getClassName(): string;
  56551. /**
  56552. * Register a new input. Must be called inside a block constructor
  56553. * @param name defines the connection point name
  56554. * @param type defines the connection point type
  56555. * @param isOptional defines a boolean indicating that this input can be omitted
  56556. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56557. * @returns the current block
  56558. */
  56559. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56560. /**
  56561. * Register a new output. Must be called inside a block constructor
  56562. * @param name defines the connection point name
  56563. * @param type defines the connection point type
  56564. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56565. * @returns the current block
  56566. */
  56567. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56568. /**
  56569. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56570. * @param forOutput defines an optional connection point to check compatibility with
  56571. * @returns the first available input or null
  56572. */
  56573. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56574. /**
  56575. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56576. * @param forBlock defines an optional block to check compatibility with
  56577. * @returns the first available input or null
  56578. */
  56579. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56580. /**
  56581. * Gets the sibling of the given output
  56582. * @param current defines the current output
  56583. * @returns the next output in the list or null
  56584. */
  56585. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56586. /**
  56587. * Connect current block with another block
  56588. * @param other defines the block to connect with
  56589. * @param options define the various options to help pick the right connections
  56590. * @returns the current block
  56591. */
  56592. connectTo(other: NodeMaterialBlock, options?: {
  56593. input?: string;
  56594. output?: string;
  56595. outputSwizzle?: string;
  56596. }): this | undefined;
  56597. protected _buildBlock(state: NodeMaterialBuildState): void;
  56598. /**
  56599. * Add uniforms, samplers and uniform buffers at compilation time
  56600. * @param state defines the state to update
  56601. * @param nodeMaterial defines the node material requesting the update
  56602. * @param defines defines the material defines to update
  56603. * @param uniformBuffers defines the list of uniform buffer names
  56604. */
  56605. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56606. /**
  56607. * Add potential fallbacks if shader compilation fails
  56608. * @param mesh defines the mesh to be rendered
  56609. * @param fallbacks defines the current prioritized list of fallbacks
  56610. */
  56611. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56612. /**
  56613. * Initialize defines for shader compilation
  56614. * @param mesh defines the mesh to be rendered
  56615. * @param nodeMaterial defines the node material requesting the update
  56616. * @param defines defines the material defines to update
  56617. * @param useInstances specifies that instances should be used
  56618. */
  56619. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56620. /**
  56621. * Update defines for shader compilation
  56622. * @param mesh defines the mesh to be rendered
  56623. * @param nodeMaterial defines the node material requesting the update
  56624. * @param defines defines the material defines to update
  56625. * @param useInstances specifies that instances should be used
  56626. */
  56627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56628. /**
  56629. * Lets the block try to connect some inputs automatically
  56630. * @param material defines the hosting NodeMaterial
  56631. */
  56632. autoConfigure(material: NodeMaterial): void;
  56633. /**
  56634. * Function called when a block is declared as repeatable content generator
  56635. * @param vertexShaderState defines the current compilation state for the vertex shader
  56636. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56637. * @param mesh defines the mesh to be rendered
  56638. * @param defines defines the material defines to update
  56639. */
  56640. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56641. /**
  56642. * Checks if the block is ready
  56643. * @param mesh defines the mesh to be rendered
  56644. * @param nodeMaterial defines the node material requesting the update
  56645. * @param defines defines the material defines to update
  56646. * @param useInstances specifies that instances should be used
  56647. * @returns true if the block is ready
  56648. */
  56649. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56650. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56651. private _processBuild;
  56652. /**
  56653. * Compile the current node and generate the shader code
  56654. * @param state defines the current compilation state (uniforms, samplers, current string)
  56655. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56656. * @returns true if already built
  56657. */
  56658. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56659. protected _inputRename(name: string): string;
  56660. protected _outputRename(name: string): string;
  56661. protected _dumpPropertiesCode(): string;
  56662. /** @hidden */
  56663. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56664. /** @hidden */
  56665. _dumpCodeForOutputConnections(): string;
  56666. /**
  56667. * Clone the current block to a new identical block
  56668. * @param scene defines the hosting scene
  56669. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56670. * @returns a copy of the current block
  56671. */
  56672. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56673. /**
  56674. * Serializes this block in a JSON representation
  56675. * @returns the serialized block object
  56676. */
  56677. serialize(): any;
  56678. /** @hidden */
  56679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56680. /**
  56681. * Release resources
  56682. */
  56683. dispose(): void;
  56684. }
  56685. }
  56686. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56687. /**
  56688. * Enum defining the type of animations supported by InputBlock
  56689. */
  56690. export enum AnimatedInputBlockTypes {
  56691. /** No animation */
  56692. None = 0,
  56693. /** Time based animation. Will only work for floats */
  56694. Time = 1
  56695. }
  56696. }
  56697. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56699. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56700. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56701. import { Nullable } from "babylonjs/types";
  56702. import { Effect } from "babylonjs/Materials/effect";
  56703. import { Matrix } from "babylonjs/Maths/math.vector";
  56704. import { Scene } from "babylonjs/scene";
  56705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56707. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56708. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56709. /**
  56710. * Block used to expose an input value
  56711. */
  56712. export class InputBlock extends NodeMaterialBlock {
  56713. private _mode;
  56714. private _associatedVariableName;
  56715. private _storedValue;
  56716. private _valueCallback;
  56717. private _type;
  56718. private _animationType;
  56719. /** Gets or set a value used to limit the range of float values */
  56720. min: number;
  56721. /** Gets or set a value used to limit the range of float values */
  56722. max: number;
  56723. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56724. matrixMode: number;
  56725. /** @hidden */
  56726. _systemValue: Nullable<NodeMaterialSystemValues>;
  56727. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56728. visibleInInspector: boolean;
  56729. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56730. isConstant: boolean;
  56731. /**
  56732. * Gets or sets the connection point type (default is float)
  56733. */
  56734. readonly type: NodeMaterialBlockConnectionPointTypes;
  56735. /**
  56736. * Creates a new InputBlock
  56737. * @param name defines the block name
  56738. * @param target defines the target of that block (Vertex by default)
  56739. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56740. */
  56741. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56742. /**
  56743. * Gets the output component
  56744. */
  56745. readonly output: NodeMaterialConnectionPoint;
  56746. /**
  56747. * Set the source of this connection point to a vertex attribute
  56748. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56749. * @returns the current connection point
  56750. */
  56751. setAsAttribute(attributeName?: string): InputBlock;
  56752. /**
  56753. * Set the source of this connection point to a system value
  56754. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56755. * @returns the current connection point
  56756. */
  56757. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56758. /**
  56759. * Gets or sets the value of that point.
  56760. * Please note that this value will be ignored if valueCallback is defined
  56761. */
  56762. value: any;
  56763. /**
  56764. * Gets or sets a callback used to get the value of that point.
  56765. * Please note that setting this value will force the connection point to ignore the value property
  56766. */
  56767. valueCallback: () => any;
  56768. /**
  56769. * Gets or sets the associated variable name in the shader
  56770. */
  56771. associatedVariableName: string;
  56772. /** Gets or sets the type of animation applied to the input */
  56773. animationType: AnimatedInputBlockTypes;
  56774. /**
  56775. * Gets a boolean indicating that this connection point not defined yet
  56776. */
  56777. readonly isUndefined: boolean;
  56778. /**
  56779. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56780. * In this case the connection point name must be the name of the uniform to use.
  56781. * Can only be set on inputs
  56782. */
  56783. isUniform: boolean;
  56784. /**
  56785. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56786. * In this case the connection point name must be the name of the attribute to use
  56787. * Can only be set on inputs
  56788. */
  56789. isAttribute: boolean;
  56790. /**
  56791. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56792. * Can only be set on exit points
  56793. */
  56794. isVarying: boolean;
  56795. /**
  56796. * Gets a boolean indicating that the current connection point is a system value
  56797. */
  56798. readonly isSystemValue: boolean;
  56799. /**
  56800. * Gets or sets the current well known value or null if not defined as a system value
  56801. */
  56802. systemValue: Nullable<NodeMaterialSystemValues>;
  56803. /**
  56804. * Gets the current class name
  56805. * @returns the class name
  56806. */
  56807. getClassName(): string;
  56808. /**
  56809. * Animate the input if animationType !== None
  56810. * @param scene defines the rendering scene
  56811. */
  56812. animate(scene: Scene): void;
  56813. private _emitDefine;
  56814. initialize(state: NodeMaterialBuildState): void;
  56815. /**
  56816. * Set the input block to its default value (based on its type)
  56817. */
  56818. setDefaultValue(): void;
  56819. private _emitConstant;
  56820. private _emit;
  56821. /** @hidden */
  56822. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56823. /** @hidden */
  56824. _transmit(effect: Effect, scene: Scene): void;
  56825. protected _buildBlock(state: NodeMaterialBuildState): void;
  56826. protected _dumpPropertiesCode(): string;
  56827. serialize(): any;
  56828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56829. }
  56830. }
  56831. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56832. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56833. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56834. import { Nullable } from "babylonjs/types";
  56835. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56836. import { Observable } from "babylonjs/Misc/observable";
  56837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56838. /**
  56839. * Defines a connection point for a block
  56840. */
  56841. export class NodeMaterialConnectionPoint {
  56842. /** @hidden */
  56843. _ownerBlock: NodeMaterialBlock;
  56844. /** @hidden */
  56845. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56846. private _endpoints;
  56847. private _associatedVariableName;
  56848. /** @hidden */
  56849. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56850. /** @hidden */
  56851. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56852. private _type;
  56853. /** @hidden */
  56854. _enforceAssociatedVariableName: boolean;
  56855. /**
  56856. * Gets or sets the additional types supported by this connection point
  56857. */
  56858. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56859. /**
  56860. * Gets or sets the additional types excluded by this connection point
  56861. */
  56862. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56863. /**
  56864. * Observable triggered when this point is connected
  56865. */
  56866. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56867. /**
  56868. * Gets or sets the associated variable name in the shader
  56869. */
  56870. associatedVariableName: string;
  56871. /**
  56872. * Gets or sets the connection point type (default is float)
  56873. */
  56874. type: NodeMaterialBlockConnectionPointTypes;
  56875. /**
  56876. * Gets or sets the connection point name
  56877. */
  56878. name: string;
  56879. /**
  56880. * Gets or sets a boolean indicating that this connection point can be omitted
  56881. */
  56882. isOptional: boolean;
  56883. /**
  56884. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56885. */
  56886. define: string;
  56887. /** @hidden */
  56888. _prioritizeVertex: boolean;
  56889. private _target;
  56890. /** Gets or sets the target of that connection point */
  56891. target: NodeMaterialBlockTargets;
  56892. /**
  56893. * Gets a boolean indicating that the current point is connected
  56894. */
  56895. readonly isConnected: boolean;
  56896. /**
  56897. * Gets a boolean indicating that the current point is connected to an input block
  56898. */
  56899. readonly isConnectedToInputBlock: boolean;
  56900. /**
  56901. * Gets a the connected input block (if any)
  56902. */
  56903. readonly connectInputBlock: Nullable<InputBlock>;
  56904. /** Get the other side of the connection (if any) */
  56905. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56906. /** Get the block that owns this connection point */
  56907. readonly ownerBlock: NodeMaterialBlock;
  56908. /** Get the block connected on the other side of this connection (if any) */
  56909. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56910. /** Get the block connected on the endpoints of this connection (if any) */
  56911. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56912. /** Gets the list of connected endpoints */
  56913. readonly endpoints: NodeMaterialConnectionPoint[];
  56914. /** Gets a boolean indicating if that output point is connected to at least one input */
  56915. readonly hasEndpoints: boolean;
  56916. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56917. readonly isConnectedInVertexShader: boolean;
  56918. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56919. readonly isConnectedInFragmentShader: boolean;
  56920. /**
  56921. * Creates a new connection point
  56922. * @param name defines the connection point name
  56923. * @param ownerBlock defines the block hosting this connection point
  56924. */
  56925. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56926. /**
  56927. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56928. * @returns the class name
  56929. */
  56930. getClassName(): string;
  56931. /**
  56932. * Gets an boolean indicating if the current point can be connected to another point
  56933. * @param connectionPoint defines the other connection point
  56934. * @returns true if the connection is possible
  56935. */
  56936. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56937. /**
  56938. * Connect this point to another connection point
  56939. * @param connectionPoint defines the other connection point
  56940. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56941. * @returns the current connection point
  56942. */
  56943. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56944. /**
  56945. * Disconnect this point from one of his endpoint
  56946. * @param endpoint defines the other connection point
  56947. * @returns the current connection point
  56948. */
  56949. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56950. /**
  56951. * Serializes this point in a JSON representation
  56952. * @returns the serialized point object
  56953. */
  56954. serialize(): any;
  56955. /**
  56956. * Release resources
  56957. */
  56958. dispose(): void;
  56959. }
  56960. }
  56961. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56965. import { Mesh } from "babylonjs/Meshes/mesh";
  56966. import { Effect } from "babylonjs/Materials/effect";
  56967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56968. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56969. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56970. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56971. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56972. /**
  56973. * Block used to add support for vertex skinning (bones)
  56974. */
  56975. export class BonesBlock extends NodeMaterialBlock {
  56976. /**
  56977. * Creates a new BonesBlock
  56978. * @param name defines the block name
  56979. */
  56980. constructor(name: string);
  56981. /**
  56982. * Initialize the block and prepare the context for build
  56983. * @param state defines the state that will be used for the build
  56984. */
  56985. initialize(state: NodeMaterialBuildState): void;
  56986. /**
  56987. * Gets the current class name
  56988. * @returns the class name
  56989. */
  56990. getClassName(): string;
  56991. /**
  56992. * Gets the matrix indices input component
  56993. */
  56994. readonly matricesIndices: NodeMaterialConnectionPoint;
  56995. /**
  56996. * Gets the matrix weights input component
  56997. */
  56998. readonly matricesWeights: NodeMaterialConnectionPoint;
  56999. /**
  57000. * Gets the extra matrix indices input component
  57001. */
  57002. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57003. /**
  57004. * Gets the extra matrix weights input component
  57005. */
  57006. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57007. /**
  57008. * Gets the world input component
  57009. */
  57010. readonly world: NodeMaterialConnectionPoint;
  57011. /**
  57012. * Gets the output component
  57013. */
  57014. readonly output: NodeMaterialConnectionPoint;
  57015. autoConfigure(material: NodeMaterial): void;
  57016. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57018. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57019. protected _buildBlock(state: NodeMaterialBuildState): this;
  57020. }
  57021. }
  57022. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57027. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57028. /**
  57029. * Block used to add support for instances
  57030. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57031. */
  57032. export class InstancesBlock extends NodeMaterialBlock {
  57033. /**
  57034. * Creates a new InstancesBlock
  57035. * @param name defines the block name
  57036. */
  57037. constructor(name: string);
  57038. /**
  57039. * Gets the current class name
  57040. * @returns the class name
  57041. */
  57042. getClassName(): string;
  57043. /**
  57044. * Gets the first world row input component
  57045. */
  57046. readonly world0: NodeMaterialConnectionPoint;
  57047. /**
  57048. * Gets the second world row input component
  57049. */
  57050. readonly world1: NodeMaterialConnectionPoint;
  57051. /**
  57052. * Gets the third world row input component
  57053. */
  57054. readonly world2: NodeMaterialConnectionPoint;
  57055. /**
  57056. * Gets the forth world row input component
  57057. */
  57058. readonly world3: NodeMaterialConnectionPoint;
  57059. /**
  57060. * Gets the world input component
  57061. */
  57062. readonly world: NodeMaterialConnectionPoint;
  57063. /**
  57064. * Gets the output component
  57065. */
  57066. readonly output: NodeMaterialConnectionPoint;
  57067. autoConfigure(material: NodeMaterial): void;
  57068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57069. protected _buildBlock(state: NodeMaterialBuildState): this;
  57070. }
  57071. }
  57072. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57077. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57078. import { Effect } from "babylonjs/Materials/effect";
  57079. import { Mesh } from "babylonjs/Meshes/mesh";
  57080. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57081. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57082. /**
  57083. * Block used to add morph targets support to vertex shader
  57084. */
  57085. export class MorphTargetsBlock extends NodeMaterialBlock {
  57086. private _repeatableContentAnchor;
  57087. private _repeatebleContentGenerated;
  57088. /**
  57089. * Create a new MorphTargetsBlock
  57090. * @param name defines the block name
  57091. */
  57092. constructor(name: string);
  57093. /**
  57094. * Gets the current class name
  57095. * @returns the class name
  57096. */
  57097. getClassName(): string;
  57098. /**
  57099. * Gets the position input component
  57100. */
  57101. readonly position: NodeMaterialConnectionPoint;
  57102. /**
  57103. * Gets the normal input component
  57104. */
  57105. readonly normal: NodeMaterialConnectionPoint;
  57106. /**
  57107. * Gets the tangent input component
  57108. */
  57109. readonly tangent: NodeMaterialConnectionPoint;
  57110. /**
  57111. * Gets the tangent input component
  57112. */
  57113. readonly uv: NodeMaterialConnectionPoint;
  57114. /**
  57115. * Gets the position output component
  57116. */
  57117. readonly positionOutput: NodeMaterialConnectionPoint;
  57118. /**
  57119. * Gets the normal output component
  57120. */
  57121. readonly normalOutput: NodeMaterialConnectionPoint;
  57122. /**
  57123. * Gets the tangent output component
  57124. */
  57125. readonly tangentOutput: NodeMaterialConnectionPoint;
  57126. /**
  57127. * Gets the tangent output component
  57128. */
  57129. readonly uvOutput: NodeMaterialConnectionPoint;
  57130. initialize(state: NodeMaterialBuildState): void;
  57131. autoConfigure(material: NodeMaterial): void;
  57132. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57133. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57134. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57135. protected _buildBlock(state: NodeMaterialBuildState): this;
  57136. }
  57137. }
  57138. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57142. import { Nullable } from "babylonjs/types";
  57143. import { Scene } from "babylonjs/scene";
  57144. import { Effect } from "babylonjs/Materials/effect";
  57145. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57146. import { Mesh } from "babylonjs/Meshes/mesh";
  57147. import { Light } from "babylonjs/Lights/light";
  57148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57149. /**
  57150. * Block used to get data information from a light
  57151. */
  57152. export class LightInformationBlock extends NodeMaterialBlock {
  57153. private _lightDataUniformName;
  57154. private _lightColorUniformName;
  57155. private _lightTypeDefineName;
  57156. /**
  57157. * Gets or sets the light associated with this block
  57158. */
  57159. light: Nullable<Light>;
  57160. /**
  57161. * Creates a new LightInformationBlock
  57162. * @param name defines the block name
  57163. */
  57164. constructor(name: string);
  57165. /**
  57166. * Gets the current class name
  57167. * @returns the class name
  57168. */
  57169. getClassName(): string;
  57170. /**
  57171. * Gets the world position input component
  57172. */
  57173. readonly worldPosition: NodeMaterialConnectionPoint;
  57174. /**
  57175. * Gets the direction output component
  57176. */
  57177. readonly direction: NodeMaterialConnectionPoint;
  57178. /**
  57179. * Gets the direction output component
  57180. */
  57181. readonly color: NodeMaterialConnectionPoint;
  57182. /**
  57183. * Gets the direction output component
  57184. */
  57185. readonly intensity: NodeMaterialConnectionPoint;
  57186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57187. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57188. protected _buildBlock(state: NodeMaterialBuildState): this;
  57189. serialize(): any;
  57190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57191. }
  57192. }
  57193. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57194. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57195. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57196. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57197. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57198. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57199. }
  57200. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57205. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57206. import { Effect } from "babylonjs/Materials/effect";
  57207. import { Mesh } from "babylonjs/Meshes/mesh";
  57208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57209. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57210. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57211. /**
  57212. * Block used to add image processing support to fragment shader
  57213. */
  57214. export class ImageProcessingBlock extends NodeMaterialBlock {
  57215. /**
  57216. * Create a new ImageProcessingBlock
  57217. * @param name defines the block name
  57218. */
  57219. constructor(name: string);
  57220. /**
  57221. * Gets the current class name
  57222. * @returns the class name
  57223. */
  57224. getClassName(): string;
  57225. /**
  57226. * Gets the color input component
  57227. */
  57228. readonly color: NodeMaterialConnectionPoint;
  57229. /**
  57230. * Gets the output component
  57231. */
  57232. readonly output: NodeMaterialConnectionPoint;
  57233. /**
  57234. * Initialize the block and prepare the context for build
  57235. * @param state defines the state that will be used for the build
  57236. */
  57237. initialize(state: NodeMaterialBuildState): void;
  57238. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57240. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57241. protected _buildBlock(state: NodeMaterialBuildState): this;
  57242. }
  57243. }
  57244. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57248. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57250. import { Effect } from "babylonjs/Materials/effect";
  57251. import { Mesh } from "babylonjs/Meshes/mesh";
  57252. import { Scene } from "babylonjs/scene";
  57253. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57254. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57255. /**
  57256. * Block used to pertub normals based on a normal map
  57257. */
  57258. export class PerturbNormalBlock extends NodeMaterialBlock {
  57259. private _tangentSpaceParameterName;
  57260. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57261. invertX: boolean;
  57262. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57263. invertY: boolean;
  57264. /**
  57265. * Create a new PerturbNormalBlock
  57266. * @param name defines the block name
  57267. */
  57268. constructor(name: string);
  57269. /**
  57270. * Gets the current class name
  57271. * @returns the class name
  57272. */
  57273. getClassName(): string;
  57274. /**
  57275. * Gets the world position input component
  57276. */
  57277. readonly worldPosition: NodeMaterialConnectionPoint;
  57278. /**
  57279. * Gets the world normal input component
  57280. */
  57281. readonly worldNormal: NodeMaterialConnectionPoint;
  57282. /**
  57283. * Gets the uv input component
  57284. */
  57285. readonly uv: NodeMaterialConnectionPoint;
  57286. /**
  57287. * Gets the normal map color input component
  57288. */
  57289. readonly normalMapColor: NodeMaterialConnectionPoint;
  57290. /**
  57291. * Gets the strength input component
  57292. */
  57293. readonly strength: NodeMaterialConnectionPoint;
  57294. /**
  57295. * Gets the output component
  57296. */
  57297. readonly output: NodeMaterialConnectionPoint;
  57298. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57299. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57300. autoConfigure(material: NodeMaterial): void;
  57301. protected _buildBlock(state: NodeMaterialBuildState): this;
  57302. protected _dumpPropertiesCode(): string;
  57303. serialize(): any;
  57304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57305. }
  57306. }
  57307. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57311. /**
  57312. * Block used to discard a pixel if a value is smaller than a cutoff
  57313. */
  57314. export class DiscardBlock extends NodeMaterialBlock {
  57315. /**
  57316. * Create a new DiscardBlock
  57317. * @param name defines the block name
  57318. */
  57319. constructor(name: string);
  57320. /**
  57321. * Gets the current class name
  57322. * @returns the class name
  57323. */
  57324. getClassName(): string;
  57325. /**
  57326. * Gets the color input component
  57327. */
  57328. readonly value: NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the cutoff input component
  57331. */
  57332. readonly cutoff: NodeMaterialConnectionPoint;
  57333. protected _buildBlock(state: NodeMaterialBuildState): this;
  57334. }
  57335. }
  57336. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57337. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57338. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57339. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57340. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57341. }
  57342. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57345. import { Mesh } from "babylonjs/Meshes/mesh";
  57346. import { Effect } from "babylonjs/Materials/effect";
  57347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57349. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57350. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57351. /**
  57352. * Block used to add support for scene fog
  57353. */
  57354. export class FogBlock extends NodeMaterialBlock {
  57355. private _fogDistanceName;
  57356. private _fogParameters;
  57357. /**
  57358. * Create a new FogBlock
  57359. * @param name defines the block name
  57360. */
  57361. constructor(name: string);
  57362. /**
  57363. * Gets the current class name
  57364. * @returns the class name
  57365. */
  57366. getClassName(): string;
  57367. /**
  57368. * Gets the world position input component
  57369. */
  57370. readonly worldPosition: NodeMaterialConnectionPoint;
  57371. /**
  57372. * Gets the view input component
  57373. */
  57374. readonly view: NodeMaterialConnectionPoint;
  57375. /**
  57376. * Gets the color input component
  57377. */
  57378. readonly input: NodeMaterialConnectionPoint;
  57379. /**
  57380. * Gets the fog color input component
  57381. */
  57382. readonly fogColor: NodeMaterialConnectionPoint;
  57383. /**
  57384. * Gets the output component
  57385. */
  57386. readonly output: NodeMaterialConnectionPoint;
  57387. autoConfigure(material: NodeMaterial): void;
  57388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57390. protected _buildBlock(state: NodeMaterialBuildState): this;
  57391. }
  57392. }
  57393. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57398. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57399. import { Effect } from "babylonjs/Materials/effect";
  57400. import { Mesh } from "babylonjs/Meshes/mesh";
  57401. import { Light } from "babylonjs/Lights/light";
  57402. import { Nullable } from "babylonjs/types";
  57403. import { Scene } from "babylonjs/scene";
  57404. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57405. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57406. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57407. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57408. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57409. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57410. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57411. /**
  57412. * Block used to add light in the fragment shader
  57413. */
  57414. export class LightBlock extends NodeMaterialBlock {
  57415. private _lightId;
  57416. /**
  57417. * Gets or sets the light associated with this block
  57418. */
  57419. light: Nullable<Light>;
  57420. /**
  57421. * Create a new LightBlock
  57422. * @param name defines the block name
  57423. */
  57424. constructor(name: string);
  57425. /**
  57426. * Gets the current class name
  57427. * @returns the class name
  57428. */
  57429. getClassName(): string;
  57430. /**
  57431. * Gets the world position input component
  57432. */
  57433. readonly worldPosition: NodeMaterialConnectionPoint;
  57434. /**
  57435. * Gets the world normal input component
  57436. */
  57437. readonly worldNormal: NodeMaterialConnectionPoint;
  57438. /**
  57439. * Gets the camera (or eye) position component
  57440. */
  57441. readonly cameraPosition: NodeMaterialConnectionPoint;
  57442. /**
  57443. * Gets the glossiness component
  57444. */
  57445. readonly glossiness: NodeMaterialConnectionPoint;
  57446. /**
  57447. * Gets the glossinness power component
  57448. */
  57449. readonly glossPower: NodeMaterialConnectionPoint;
  57450. /**
  57451. * Gets the diffuse color component
  57452. */
  57453. readonly diffuseColor: NodeMaterialConnectionPoint;
  57454. /**
  57455. * Gets the specular color component
  57456. */
  57457. readonly specularColor: NodeMaterialConnectionPoint;
  57458. /**
  57459. * Gets the diffuse output component
  57460. */
  57461. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57462. /**
  57463. * Gets the specular output component
  57464. */
  57465. readonly specularOutput: NodeMaterialConnectionPoint;
  57466. autoConfigure(material: NodeMaterial): void;
  57467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57468. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57469. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57470. private _injectVertexCode;
  57471. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57472. serialize(): any;
  57473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57474. }
  57475. }
  57476. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57477. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57478. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57479. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57480. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57481. }
  57482. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57483. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57484. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57485. }
  57486. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57488. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57489. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57490. /**
  57491. * Block used to multiply 2 values
  57492. */
  57493. export class MultiplyBlock extends NodeMaterialBlock {
  57494. /**
  57495. * Creates a new MultiplyBlock
  57496. * @param name defines the block name
  57497. */
  57498. constructor(name: string);
  57499. /**
  57500. * Gets the current class name
  57501. * @returns the class name
  57502. */
  57503. getClassName(): string;
  57504. /**
  57505. * Gets the left operand input component
  57506. */
  57507. readonly left: NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the right operand input component
  57510. */
  57511. readonly right: NodeMaterialConnectionPoint;
  57512. /**
  57513. * Gets the output component
  57514. */
  57515. readonly output: NodeMaterialConnectionPoint;
  57516. protected _buildBlock(state: NodeMaterialBuildState): this;
  57517. }
  57518. }
  57519. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57523. /**
  57524. * Block used to add 2 vectors
  57525. */
  57526. export class AddBlock extends NodeMaterialBlock {
  57527. /**
  57528. * Creates a new AddBlock
  57529. * @param name defines the block name
  57530. */
  57531. constructor(name: string);
  57532. /**
  57533. * Gets the current class name
  57534. * @returns the class name
  57535. */
  57536. getClassName(): string;
  57537. /**
  57538. * Gets the left operand input component
  57539. */
  57540. readonly left: NodeMaterialConnectionPoint;
  57541. /**
  57542. * Gets the right operand input component
  57543. */
  57544. readonly right: NodeMaterialConnectionPoint;
  57545. /**
  57546. * Gets the output component
  57547. */
  57548. readonly output: NodeMaterialConnectionPoint;
  57549. protected _buildBlock(state: NodeMaterialBuildState): this;
  57550. }
  57551. }
  57552. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57556. /**
  57557. * Block used to scale a vector by a float
  57558. */
  57559. export class ScaleBlock extends NodeMaterialBlock {
  57560. /**
  57561. * Creates a new ScaleBlock
  57562. * @param name defines the block name
  57563. */
  57564. constructor(name: string);
  57565. /**
  57566. * Gets the current class name
  57567. * @returns the class name
  57568. */
  57569. getClassName(): string;
  57570. /**
  57571. * Gets the input component
  57572. */
  57573. readonly input: NodeMaterialConnectionPoint;
  57574. /**
  57575. * Gets the factor input component
  57576. */
  57577. readonly factor: NodeMaterialConnectionPoint;
  57578. /**
  57579. * Gets the output component
  57580. */
  57581. readonly output: NodeMaterialConnectionPoint;
  57582. protected _buildBlock(state: NodeMaterialBuildState): this;
  57583. }
  57584. }
  57585. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57589. import { Scene } from "babylonjs/scene";
  57590. /**
  57591. * Block used to clamp a float
  57592. */
  57593. export class ClampBlock extends NodeMaterialBlock {
  57594. /** Gets or sets the minimum range */
  57595. minimum: number;
  57596. /** Gets or sets the maximum range */
  57597. maximum: number;
  57598. /**
  57599. * Creates a new ClampBlock
  57600. * @param name defines the block name
  57601. */
  57602. constructor(name: string);
  57603. /**
  57604. * Gets the current class name
  57605. * @returns the class name
  57606. */
  57607. getClassName(): string;
  57608. /**
  57609. * Gets the value input component
  57610. */
  57611. readonly value: NodeMaterialConnectionPoint;
  57612. /**
  57613. * Gets the output component
  57614. */
  57615. readonly output: NodeMaterialConnectionPoint;
  57616. protected _buildBlock(state: NodeMaterialBuildState): this;
  57617. protected _dumpPropertiesCode(): string;
  57618. serialize(): any;
  57619. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57620. }
  57621. }
  57622. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57626. /**
  57627. * Block used to apply a cross product between 2 vectors
  57628. */
  57629. export class CrossBlock extends NodeMaterialBlock {
  57630. /**
  57631. * Creates a new CrossBlock
  57632. * @param name defines the block name
  57633. */
  57634. constructor(name: string);
  57635. /**
  57636. * Gets the current class name
  57637. * @returns the class name
  57638. */
  57639. getClassName(): string;
  57640. /**
  57641. * Gets the left operand input component
  57642. */
  57643. readonly left: NodeMaterialConnectionPoint;
  57644. /**
  57645. * Gets the right operand input component
  57646. */
  57647. readonly right: NodeMaterialConnectionPoint;
  57648. /**
  57649. * Gets the output component
  57650. */
  57651. readonly output: NodeMaterialConnectionPoint;
  57652. protected _buildBlock(state: NodeMaterialBuildState): this;
  57653. }
  57654. }
  57655. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57659. /**
  57660. * Block used to apply a dot product between 2 vectors
  57661. */
  57662. export class DotBlock extends NodeMaterialBlock {
  57663. /**
  57664. * Creates a new DotBlock
  57665. * @param name defines the block name
  57666. */
  57667. constructor(name: string);
  57668. /**
  57669. * Gets the current class name
  57670. * @returns the class name
  57671. */
  57672. getClassName(): string;
  57673. /**
  57674. * Gets the left operand input component
  57675. */
  57676. readonly left: NodeMaterialConnectionPoint;
  57677. /**
  57678. * Gets the right operand input component
  57679. */
  57680. readonly right: NodeMaterialConnectionPoint;
  57681. /**
  57682. * Gets the output component
  57683. */
  57684. readonly output: NodeMaterialConnectionPoint;
  57685. protected _buildBlock(state: NodeMaterialBuildState): this;
  57686. }
  57687. }
  57688. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57692. import { Vector2 } from "babylonjs/Maths/math.vector";
  57693. import { Scene } from "babylonjs/scene";
  57694. /**
  57695. * Block used to remap a float from a range to a new one
  57696. */
  57697. export class RemapBlock extends NodeMaterialBlock {
  57698. /**
  57699. * Gets or sets the source range
  57700. */
  57701. sourceRange: Vector2;
  57702. /**
  57703. * Gets or sets the target range
  57704. */
  57705. targetRange: Vector2;
  57706. /**
  57707. * Creates a new RemapBlock
  57708. * @param name defines the block name
  57709. */
  57710. constructor(name: string);
  57711. /**
  57712. * Gets the current class name
  57713. * @returns the class name
  57714. */
  57715. getClassName(): string;
  57716. /**
  57717. * Gets the input component
  57718. */
  57719. readonly input: NodeMaterialConnectionPoint;
  57720. /**
  57721. * Gets the source min input component
  57722. */
  57723. readonly sourceMin: NodeMaterialConnectionPoint;
  57724. /**
  57725. * Gets the source max input component
  57726. */
  57727. readonly sourceMax: NodeMaterialConnectionPoint;
  57728. /**
  57729. * Gets the target min input component
  57730. */
  57731. readonly targetMin: NodeMaterialConnectionPoint;
  57732. /**
  57733. * Gets the target max input component
  57734. */
  57735. readonly targetMax: NodeMaterialConnectionPoint;
  57736. /**
  57737. * Gets the output component
  57738. */
  57739. readonly output: NodeMaterialConnectionPoint;
  57740. protected _buildBlock(state: NodeMaterialBuildState): this;
  57741. protected _dumpPropertiesCode(): string;
  57742. serialize(): any;
  57743. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57744. }
  57745. }
  57746. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57750. /**
  57751. * Block used to normalize a vector
  57752. */
  57753. export class NormalizeBlock extends NodeMaterialBlock {
  57754. /**
  57755. * Creates a new NormalizeBlock
  57756. * @param name defines the block name
  57757. */
  57758. constructor(name: string);
  57759. /**
  57760. * Gets the current class name
  57761. * @returns the class name
  57762. */
  57763. getClassName(): string;
  57764. /**
  57765. * Gets the input component
  57766. */
  57767. readonly input: NodeMaterialConnectionPoint;
  57768. /**
  57769. * Gets the output component
  57770. */
  57771. readonly output: NodeMaterialConnectionPoint;
  57772. protected _buildBlock(state: NodeMaterialBuildState): this;
  57773. }
  57774. }
  57775. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57778. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57779. import { Scene } from "babylonjs/scene";
  57780. /**
  57781. * Operations supported by the Trigonometry block
  57782. */
  57783. export enum TrigonometryBlockOperations {
  57784. /** Cos */
  57785. Cos = 0,
  57786. /** Sin */
  57787. Sin = 1,
  57788. /** Abs */
  57789. Abs = 2,
  57790. /** Exp */
  57791. Exp = 3,
  57792. /** Exp2 */
  57793. Exp2 = 4,
  57794. /** Round */
  57795. Round = 5,
  57796. /** Floor */
  57797. Floor = 6,
  57798. /** Ceiling */
  57799. Ceiling = 7,
  57800. /** Square root */
  57801. Sqrt = 8,
  57802. /** Log */
  57803. Log = 9,
  57804. /** Tangent */
  57805. Tan = 10,
  57806. /** Arc tangent */
  57807. ArcTan = 11,
  57808. /** Arc cosinus */
  57809. ArcCos = 12,
  57810. /** Arc sinus */
  57811. ArcSin = 13,
  57812. /** Fraction */
  57813. Fract = 14,
  57814. /** Sign */
  57815. Sign = 15,
  57816. /** To radians (from degrees) */
  57817. Radians = 16,
  57818. /** To degrees (from radians) */
  57819. Degrees = 17
  57820. }
  57821. /**
  57822. * Block used to apply trigonometry operation to floats
  57823. */
  57824. export class TrigonometryBlock extends NodeMaterialBlock {
  57825. /**
  57826. * Gets or sets the operation applied by the block
  57827. */
  57828. operation: TrigonometryBlockOperations;
  57829. /**
  57830. * Creates a new TrigonometryBlock
  57831. * @param name defines the block name
  57832. */
  57833. constructor(name: string);
  57834. /**
  57835. * Gets the current class name
  57836. * @returns the class name
  57837. */
  57838. getClassName(): string;
  57839. /**
  57840. * Gets the input component
  57841. */
  57842. readonly input: NodeMaterialConnectionPoint;
  57843. /**
  57844. * Gets the output component
  57845. */
  57846. readonly output: NodeMaterialConnectionPoint;
  57847. protected _buildBlock(state: NodeMaterialBuildState): this;
  57848. serialize(): any;
  57849. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57850. }
  57851. }
  57852. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57856. /**
  57857. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57858. */
  57859. export class ColorMergerBlock extends NodeMaterialBlock {
  57860. /**
  57861. * Create a new ColorMergerBlock
  57862. * @param name defines the block name
  57863. */
  57864. constructor(name: string);
  57865. /**
  57866. * Gets the current class name
  57867. * @returns the class name
  57868. */
  57869. getClassName(): string;
  57870. /**
  57871. * Gets the r component (input)
  57872. */
  57873. readonly r: NodeMaterialConnectionPoint;
  57874. /**
  57875. * Gets the g component (input)
  57876. */
  57877. readonly g: NodeMaterialConnectionPoint;
  57878. /**
  57879. * Gets the b component (input)
  57880. */
  57881. readonly b: NodeMaterialConnectionPoint;
  57882. /**
  57883. * Gets the a component (input)
  57884. */
  57885. readonly a: NodeMaterialConnectionPoint;
  57886. /**
  57887. * Gets the rgba component (output)
  57888. */
  57889. readonly rgba: NodeMaterialConnectionPoint;
  57890. /**
  57891. * Gets the rgb component (output)
  57892. */
  57893. readonly rgb: NodeMaterialConnectionPoint;
  57894. protected _buildBlock(state: NodeMaterialBuildState): this;
  57895. }
  57896. }
  57897. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57901. /**
  57902. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57903. */
  57904. export class VectorMergerBlock extends NodeMaterialBlock {
  57905. /**
  57906. * Create a new VectorMergerBlock
  57907. * @param name defines the block name
  57908. */
  57909. constructor(name: string);
  57910. /**
  57911. * Gets the current class name
  57912. * @returns the class name
  57913. */
  57914. getClassName(): string;
  57915. /**
  57916. * Gets the x component (input)
  57917. */
  57918. readonly x: NodeMaterialConnectionPoint;
  57919. /**
  57920. * Gets the y component (input)
  57921. */
  57922. readonly y: NodeMaterialConnectionPoint;
  57923. /**
  57924. * Gets the z component (input)
  57925. */
  57926. readonly z: NodeMaterialConnectionPoint;
  57927. /**
  57928. * Gets the w component (input)
  57929. */
  57930. readonly w: NodeMaterialConnectionPoint;
  57931. /**
  57932. * Gets the xyzw component (output)
  57933. */
  57934. readonly xyzw: NodeMaterialConnectionPoint;
  57935. /**
  57936. * Gets the xyz component (output)
  57937. */
  57938. readonly xyz: NodeMaterialConnectionPoint;
  57939. /**
  57940. * Gets the xy component (output)
  57941. */
  57942. readonly xy: NodeMaterialConnectionPoint;
  57943. protected _buildBlock(state: NodeMaterialBuildState): this;
  57944. }
  57945. }
  57946. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57950. /**
  57951. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57952. */
  57953. export class ColorSplitterBlock extends NodeMaterialBlock {
  57954. /**
  57955. * Create a new ColorSplitterBlock
  57956. * @param name defines the block name
  57957. */
  57958. constructor(name: string);
  57959. /**
  57960. * Gets the current class name
  57961. * @returns the class name
  57962. */
  57963. getClassName(): string;
  57964. /**
  57965. * Gets the rgba component (input)
  57966. */
  57967. readonly rgba: NodeMaterialConnectionPoint;
  57968. /**
  57969. * Gets the rgb component (input)
  57970. */
  57971. readonly rgbIn: NodeMaterialConnectionPoint;
  57972. /**
  57973. * Gets the rgb component (output)
  57974. */
  57975. readonly rgbOut: NodeMaterialConnectionPoint;
  57976. /**
  57977. * Gets the r component (output)
  57978. */
  57979. readonly r: NodeMaterialConnectionPoint;
  57980. /**
  57981. * Gets the g component (output)
  57982. */
  57983. readonly g: NodeMaterialConnectionPoint;
  57984. /**
  57985. * Gets the b component (output)
  57986. */
  57987. readonly b: NodeMaterialConnectionPoint;
  57988. /**
  57989. * Gets the a component (output)
  57990. */
  57991. readonly a: NodeMaterialConnectionPoint;
  57992. protected _inputRename(name: string): string;
  57993. protected _outputRename(name: string): string;
  57994. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57995. }
  57996. }
  57997. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58001. /**
  58002. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58003. */
  58004. export class VectorSplitterBlock extends NodeMaterialBlock {
  58005. /**
  58006. * Create a new VectorSplitterBlock
  58007. * @param name defines the block name
  58008. */
  58009. constructor(name: string);
  58010. /**
  58011. * Gets the current class name
  58012. * @returns the class name
  58013. */
  58014. getClassName(): string;
  58015. /**
  58016. * Gets the xyzw component (input)
  58017. */
  58018. readonly xyzw: NodeMaterialConnectionPoint;
  58019. /**
  58020. * Gets the xyz component (input)
  58021. */
  58022. readonly xyzIn: NodeMaterialConnectionPoint;
  58023. /**
  58024. * Gets the xy component (input)
  58025. */
  58026. readonly xyIn: NodeMaterialConnectionPoint;
  58027. /**
  58028. * Gets the xyz component (output)
  58029. */
  58030. readonly xyzOut: NodeMaterialConnectionPoint;
  58031. /**
  58032. * Gets the xy component (output)
  58033. */
  58034. readonly xyOut: NodeMaterialConnectionPoint;
  58035. /**
  58036. * Gets the x component (output)
  58037. */
  58038. readonly x: NodeMaterialConnectionPoint;
  58039. /**
  58040. * Gets the y component (output)
  58041. */
  58042. readonly y: NodeMaterialConnectionPoint;
  58043. /**
  58044. * Gets the z component (output)
  58045. */
  58046. readonly z: NodeMaterialConnectionPoint;
  58047. /**
  58048. * Gets the w component (output)
  58049. */
  58050. readonly w: NodeMaterialConnectionPoint;
  58051. protected _inputRename(name: string): string;
  58052. protected _outputRename(name: string): string;
  58053. protected _buildBlock(state: NodeMaterialBuildState): this;
  58054. }
  58055. }
  58056. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58060. /**
  58061. * Block used to lerp between 2 values
  58062. */
  58063. export class LerpBlock extends NodeMaterialBlock {
  58064. /**
  58065. * Creates a new LerpBlock
  58066. * @param name defines the block name
  58067. */
  58068. constructor(name: string);
  58069. /**
  58070. * Gets the current class name
  58071. * @returns the class name
  58072. */
  58073. getClassName(): string;
  58074. /**
  58075. * Gets the left operand input component
  58076. */
  58077. readonly left: NodeMaterialConnectionPoint;
  58078. /**
  58079. * Gets the right operand input component
  58080. */
  58081. readonly right: NodeMaterialConnectionPoint;
  58082. /**
  58083. * Gets the gradient operand input component
  58084. */
  58085. readonly gradient: NodeMaterialConnectionPoint;
  58086. /**
  58087. * Gets the output component
  58088. */
  58089. readonly output: NodeMaterialConnectionPoint;
  58090. protected _buildBlock(state: NodeMaterialBuildState): this;
  58091. }
  58092. }
  58093. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58097. /**
  58098. * Block used to divide 2 vectors
  58099. */
  58100. export class DivideBlock extends NodeMaterialBlock {
  58101. /**
  58102. * Creates a new DivideBlock
  58103. * @param name defines the block name
  58104. */
  58105. constructor(name: string);
  58106. /**
  58107. * Gets the current class name
  58108. * @returns the class name
  58109. */
  58110. getClassName(): string;
  58111. /**
  58112. * Gets the left operand input component
  58113. */
  58114. readonly left: NodeMaterialConnectionPoint;
  58115. /**
  58116. * Gets the right operand input component
  58117. */
  58118. readonly right: NodeMaterialConnectionPoint;
  58119. /**
  58120. * Gets the output component
  58121. */
  58122. readonly output: NodeMaterialConnectionPoint;
  58123. protected _buildBlock(state: NodeMaterialBuildState): this;
  58124. }
  58125. }
  58126. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58130. /**
  58131. * Block used to subtract 2 vectors
  58132. */
  58133. export class SubtractBlock extends NodeMaterialBlock {
  58134. /**
  58135. * Creates a new SubtractBlock
  58136. * @param name defines the block name
  58137. */
  58138. constructor(name: string);
  58139. /**
  58140. * Gets the current class name
  58141. * @returns the class name
  58142. */
  58143. getClassName(): string;
  58144. /**
  58145. * Gets the left operand input component
  58146. */
  58147. readonly left: NodeMaterialConnectionPoint;
  58148. /**
  58149. * Gets the right operand input component
  58150. */
  58151. readonly right: NodeMaterialConnectionPoint;
  58152. /**
  58153. * Gets the output component
  58154. */
  58155. readonly output: NodeMaterialConnectionPoint;
  58156. protected _buildBlock(state: NodeMaterialBuildState): this;
  58157. }
  58158. }
  58159. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58163. /**
  58164. * Block used to step a value
  58165. */
  58166. export class StepBlock extends NodeMaterialBlock {
  58167. /**
  58168. * Creates a new StepBlock
  58169. * @param name defines the block name
  58170. */
  58171. constructor(name: string);
  58172. /**
  58173. * Gets the current class name
  58174. * @returns the class name
  58175. */
  58176. getClassName(): string;
  58177. /**
  58178. * Gets the value operand input component
  58179. */
  58180. readonly value: NodeMaterialConnectionPoint;
  58181. /**
  58182. * Gets the edge operand input component
  58183. */
  58184. readonly edge: NodeMaterialConnectionPoint;
  58185. /**
  58186. * Gets the output component
  58187. */
  58188. readonly output: NodeMaterialConnectionPoint;
  58189. protected _buildBlock(state: NodeMaterialBuildState): this;
  58190. }
  58191. }
  58192. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58196. /**
  58197. * Block used to get the opposite (1 - x) of a value
  58198. */
  58199. export class OneMinusBlock extends NodeMaterialBlock {
  58200. /**
  58201. * Creates a new OneMinusBlock
  58202. * @param name defines the block name
  58203. */
  58204. constructor(name: string);
  58205. /**
  58206. * Gets the current class name
  58207. * @returns the class name
  58208. */
  58209. getClassName(): string;
  58210. /**
  58211. * Gets the input component
  58212. */
  58213. readonly input: NodeMaterialConnectionPoint;
  58214. /**
  58215. * Gets the output component
  58216. */
  58217. readonly output: NodeMaterialConnectionPoint;
  58218. protected _buildBlock(state: NodeMaterialBuildState): this;
  58219. }
  58220. }
  58221. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58225. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58226. /**
  58227. * Block used to get the view direction
  58228. */
  58229. export class ViewDirectionBlock extends NodeMaterialBlock {
  58230. /**
  58231. * Creates a new ViewDirectionBlock
  58232. * @param name defines the block name
  58233. */
  58234. constructor(name: string);
  58235. /**
  58236. * Gets the current class name
  58237. * @returns the class name
  58238. */
  58239. getClassName(): string;
  58240. /**
  58241. * Gets the world position component
  58242. */
  58243. readonly worldPosition: NodeMaterialConnectionPoint;
  58244. /**
  58245. * Gets the camera position component
  58246. */
  58247. readonly cameraPosition: NodeMaterialConnectionPoint;
  58248. /**
  58249. * Gets the output component
  58250. */
  58251. readonly output: NodeMaterialConnectionPoint;
  58252. autoConfigure(material: NodeMaterial): void;
  58253. protected _buildBlock(state: NodeMaterialBuildState): this;
  58254. }
  58255. }
  58256. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58260. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58261. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58262. /**
  58263. * Block used to compute fresnel value
  58264. */
  58265. export class FresnelBlock extends NodeMaterialBlock {
  58266. /**
  58267. * Create a new FresnelBlock
  58268. * @param name defines the block name
  58269. */
  58270. constructor(name: string);
  58271. /**
  58272. * Gets the current class name
  58273. * @returns the class name
  58274. */
  58275. getClassName(): string;
  58276. /**
  58277. * Gets the world normal input component
  58278. */
  58279. readonly worldNormal: NodeMaterialConnectionPoint;
  58280. /**
  58281. * Gets the view direction input component
  58282. */
  58283. readonly viewDirection: NodeMaterialConnectionPoint;
  58284. /**
  58285. * Gets the bias input component
  58286. */
  58287. readonly bias: NodeMaterialConnectionPoint;
  58288. /**
  58289. * Gets the camera (or eye) position component
  58290. */
  58291. readonly power: NodeMaterialConnectionPoint;
  58292. /**
  58293. * Gets the fresnel output component
  58294. */
  58295. readonly fresnel: NodeMaterialConnectionPoint;
  58296. autoConfigure(material: NodeMaterial): void;
  58297. protected _buildBlock(state: NodeMaterialBuildState): this;
  58298. }
  58299. }
  58300. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58304. /**
  58305. * Block used to get the max of 2 values
  58306. */
  58307. export class MaxBlock extends NodeMaterialBlock {
  58308. /**
  58309. * Creates a new MaxBlock
  58310. * @param name defines the block name
  58311. */
  58312. constructor(name: string);
  58313. /**
  58314. * Gets the current class name
  58315. * @returns the class name
  58316. */
  58317. getClassName(): string;
  58318. /**
  58319. * Gets the left operand input component
  58320. */
  58321. readonly left: NodeMaterialConnectionPoint;
  58322. /**
  58323. * Gets the right operand input component
  58324. */
  58325. readonly right: NodeMaterialConnectionPoint;
  58326. /**
  58327. * Gets the output component
  58328. */
  58329. readonly output: NodeMaterialConnectionPoint;
  58330. protected _buildBlock(state: NodeMaterialBuildState): this;
  58331. }
  58332. }
  58333. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58337. /**
  58338. * Block used to get the min of 2 values
  58339. */
  58340. export class MinBlock extends NodeMaterialBlock {
  58341. /**
  58342. * Creates a new MinBlock
  58343. * @param name defines the block name
  58344. */
  58345. constructor(name: string);
  58346. /**
  58347. * Gets the current class name
  58348. * @returns the class name
  58349. */
  58350. getClassName(): string;
  58351. /**
  58352. * Gets the left operand input component
  58353. */
  58354. readonly left: NodeMaterialConnectionPoint;
  58355. /**
  58356. * Gets the right operand input component
  58357. */
  58358. readonly right: NodeMaterialConnectionPoint;
  58359. /**
  58360. * Gets the output component
  58361. */
  58362. readonly output: NodeMaterialConnectionPoint;
  58363. protected _buildBlock(state: NodeMaterialBuildState): this;
  58364. }
  58365. }
  58366. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58370. /**
  58371. * Block used to get the distance between 2 values
  58372. */
  58373. export class DistanceBlock extends NodeMaterialBlock {
  58374. /**
  58375. * Creates a new DistanceBlock
  58376. * @param name defines the block name
  58377. */
  58378. constructor(name: string);
  58379. /**
  58380. * Gets the current class name
  58381. * @returns the class name
  58382. */
  58383. getClassName(): string;
  58384. /**
  58385. * Gets the left operand input component
  58386. */
  58387. readonly left: NodeMaterialConnectionPoint;
  58388. /**
  58389. * Gets the right operand input component
  58390. */
  58391. readonly right: NodeMaterialConnectionPoint;
  58392. /**
  58393. * Gets the output component
  58394. */
  58395. readonly output: NodeMaterialConnectionPoint;
  58396. protected _buildBlock(state: NodeMaterialBuildState): this;
  58397. }
  58398. }
  58399. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58403. /**
  58404. * Block used to get the length of a vector
  58405. */
  58406. export class LengthBlock extends NodeMaterialBlock {
  58407. /**
  58408. * Creates a new LengthBlock
  58409. * @param name defines the block name
  58410. */
  58411. constructor(name: string);
  58412. /**
  58413. * Gets the current class name
  58414. * @returns the class name
  58415. */
  58416. getClassName(): string;
  58417. /**
  58418. * Gets the value input component
  58419. */
  58420. readonly value: NodeMaterialConnectionPoint;
  58421. /**
  58422. * Gets the output component
  58423. */
  58424. readonly output: NodeMaterialConnectionPoint;
  58425. protected _buildBlock(state: NodeMaterialBuildState): this;
  58426. }
  58427. }
  58428. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58432. /**
  58433. * Block used to get negative version of a value (i.e. x * -1)
  58434. */
  58435. export class NegateBlock extends NodeMaterialBlock {
  58436. /**
  58437. * Creates a new NegateBlock
  58438. * @param name defines the block name
  58439. */
  58440. constructor(name: string);
  58441. /**
  58442. * Gets the current class name
  58443. * @returns the class name
  58444. */
  58445. getClassName(): string;
  58446. /**
  58447. * Gets the value input component
  58448. */
  58449. readonly value: NodeMaterialConnectionPoint;
  58450. /**
  58451. * Gets the output component
  58452. */
  58453. readonly output: NodeMaterialConnectionPoint;
  58454. protected _buildBlock(state: NodeMaterialBuildState): this;
  58455. }
  58456. }
  58457. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58458. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58459. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58460. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58461. /**
  58462. * Block used to get the value of the first parameter raised to the power of the second
  58463. */
  58464. export class PowBlock extends NodeMaterialBlock {
  58465. /**
  58466. * Creates a new PowBlock
  58467. * @param name defines the block name
  58468. */
  58469. constructor(name: string);
  58470. /**
  58471. * Gets the current class name
  58472. * @returns the class name
  58473. */
  58474. getClassName(): string;
  58475. /**
  58476. * Gets the value operand input component
  58477. */
  58478. readonly value: NodeMaterialConnectionPoint;
  58479. /**
  58480. * Gets the power operand input component
  58481. */
  58482. readonly power: NodeMaterialConnectionPoint;
  58483. /**
  58484. * Gets the output component
  58485. */
  58486. readonly output: NodeMaterialConnectionPoint;
  58487. protected _buildBlock(state: NodeMaterialBuildState): this;
  58488. }
  58489. }
  58490. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58494. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58495. /**
  58496. * Block used to get a random number
  58497. */
  58498. export class RandomNumberBlock extends NodeMaterialBlock {
  58499. /**
  58500. * Creates a new RandomNumberBlock
  58501. * @param name defines the block name
  58502. */
  58503. constructor(name: string);
  58504. /**
  58505. * Gets the current class name
  58506. * @returns the class name
  58507. */
  58508. getClassName(): string;
  58509. /**
  58510. * Gets the seed input component
  58511. */
  58512. readonly seed: NodeMaterialConnectionPoint;
  58513. /**
  58514. * Gets the output component
  58515. */
  58516. readonly output: NodeMaterialConnectionPoint;
  58517. protected _buildBlock(state: NodeMaterialBuildState): this;
  58518. }
  58519. }
  58520. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58524. /**
  58525. * Block used to compute arc tangent of 2 values
  58526. */
  58527. export class ArcTan2Block extends NodeMaterialBlock {
  58528. /**
  58529. * Creates a new ArcTan2Block
  58530. * @param name defines the block name
  58531. */
  58532. constructor(name: string);
  58533. /**
  58534. * Gets the current class name
  58535. * @returns the class name
  58536. */
  58537. getClassName(): string;
  58538. /**
  58539. * Gets the x operand input component
  58540. */
  58541. readonly x: NodeMaterialConnectionPoint;
  58542. /**
  58543. * Gets the y operand input component
  58544. */
  58545. readonly y: NodeMaterialConnectionPoint;
  58546. /**
  58547. * Gets the output component
  58548. */
  58549. readonly output: NodeMaterialConnectionPoint;
  58550. protected _buildBlock(state: NodeMaterialBuildState): this;
  58551. }
  58552. }
  58553. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58557. /**
  58558. * Block used to smooth step a value
  58559. */
  58560. export class SmoothStepBlock extends NodeMaterialBlock {
  58561. /**
  58562. * Creates a new SmoothStepBlock
  58563. * @param name defines the block name
  58564. */
  58565. constructor(name: string);
  58566. /**
  58567. * Gets the current class name
  58568. * @returns the class name
  58569. */
  58570. getClassName(): string;
  58571. /**
  58572. * Gets the value operand input component
  58573. */
  58574. readonly value: NodeMaterialConnectionPoint;
  58575. /**
  58576. * Gets the first edge operand input component
  58577. */
  58578. readonly edge0: NodeMaterialConnectionPoint;
  58579. /**
  58580. * Gets the second edge operand input component
  58581. */
  58582. readonly edge1: NodeMaterialConnectionPoint;
  58583. /**
  58584. * Gets the output component
  58585. */
  58586. readonly output: NodeMaterialConnectionPoint;
  58587. protected _buildBlock(state: NodeMaterialBuildState): this;
  58588. }
  58589. }
  58590. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58594. /**
  58595. * Block used to get the reciprocal (1 / x) of a value
  58596. */
  58597. export class ReciprocalBlock extends NodeMaterialBlock {
  58598. /**
  58599. * Creates a new ReciprocalBlock
  58600. * @param name defines the block name
  58601. */
  58602. constructor(name: string);
  58603. /**
  58604. * Gets the current class name
  58605. * @returns the class name
  58606. */
  58607. getClassName(): string;
  58608. /**
  58609. * Gets the input component
  58610. */
  58611. readonly input: NodeMaterialConnectionPoint;
  58612. /**
  58613. * Gets the output component
  58614. */
  58615. readonly output: NodeMaterialConnectionPoint;
  58616. protected _buildBlock(state: NodeMaterialBuildState): this;
  58617. }
  58618. }
  58619. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58623. /**
  58624. * Block used to replace a color by another one
  58625. */
  58626. export class ReplaceColorBlock extends NodeMaterialBlock {
  58627. /**
  58628. * Creates a new ReplaceColorBlock
  58629. * @param name defines the block name
  58630. */
  58631. constructor(name: string);
  58632. /**
  58633. * Gets the current class name
  58634. * @returns the class name
  58635. */
  58636. getClassName(): string;
  58637. /**
  58638. * Gets the value input component
  58639. */
  58640. readonly value: NodeMaterialConnectionPoint;
  58641. /**
  58642. * Gets the reference input component
  58643. */
  58644. readonly reference: NodeMaterialConnectionPoint;
  58645. /**
  58646. * Gets the distance input component
  58647. */
  58648. readonly distance: NodeMaterialConnectionPoint;
  58649. /**
  58650. * Gets the replacement input component
  58651. */
  58652. readonly replacement: NodeMaterialConnectionPoint;
  58653. /**
  58654. * Gets the output component
  58655. */
  58656. readonly output: NodeMaterialConnectionPoint;
  58657. protected _buildBlock(state: NodeMaterialBuildState): this;
  58658. }
  58659. }
  58660. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58664. /**
  58665. * Block used to posterize a value
  58666. * @see https://en.wikipedia.org/wiki/Posterization
  58667. */
  58668. export class PosterizeBlock extends NodeMaterialBlock {
  58669. /**
  58670. * Creates a new PosterizeBlock
  58671. * @param name defines the block name
  58672. */
  58673. constructor(name: string);
  58674. /**
  58675. * Gets the current class name
  58676. * @returns the class name
  58677. */
  58678. getClassName(): string;
  58679. /**
  58680. * Gets the value input component
  58681. */
  58682. readonly value: NodeMaterialConnectionPoint;
  58683. /**
  58684. * Gets the steps input component
  58685. */
  58686. readonly steps: NodeMaterialConnectionPoint;
  58687. /**
  58688. * Gets the output component
  58689. */
  58690. readonly output: NodeMaterialConnectionPoint;
  58691. protected _buildBlock(state: NodeMaterialBuildState): this;
  58692. }
  58693. }
  58694. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58698. import { Scene } from "babylonjs/scene";
  58699. /**
  58700. * Operations supported by the Wave block
  58701. */
  58702. export enum WaveBlockKind {
  58703. /** SawTooth */
  58704. SawTooth = 0,
  58705. /** Square */
  58706. Square = 1,
  58707. /** Triangle */
  58708. Triangle = 2
  58709. }
  58710. /**
  58711. * Block used to apply wave operation to floats
  58712. */
  58713. export class WaveBlock extends NodeMaterialBlock {
  58714. /**
  58715. * Gets or sets the kibnd of wave to be applied by the block
  58716. */
  58717. kind: WaveBlockKind;
  58718. /**
  58719. * Creates a new WaveBlock
  58720. * @param name defines the block name
  58721. */
  58722. constructor(name: string);
  58723. /**
  58724. * Gets the current class name
  58725. * @returns the class name
  58726. */
  58727. getClassName(): string;
  58728. /**
  58729. * Gets the input component
  58730. */
  58731. readonly input: NodeMaterialConnectionPoint;
  58732. /**
  58733. * Gets the output component
  58734. */
  58735. readonly output: NodeMaterialConnectionPoint;
  58736. protected _buildBlock(state: NodeMaterialBuildState): this;
  58737. serialize(): any;
  58738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58739. }
  58740. }
  58741. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58745. import { Color3 } from "babylonjs/Maths/math.color";
  58746. import { Scene } from "babylonjs/scene";
  58747. /**
  58748. * Class used to store a color step for the GradientBlock
  58749. */
  58750. export class GradientBlockColorStep {
  58751. /**
  58752. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58753. */
  58754. step: number;
  58755. /**
  58756. * Gets or sets the color associated with this step
  58757. */
  58758. color: Color3;
  58759. /**
  58760. * Creates a new GradientBlockColorStep
  58761. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58762. * @param color defines the color associated with this step
  58763. */
  58764. constructor(
  58765. /**
  58766. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58767. */
  58768. step: number,
  58769. /**
  58770. * Gets or sets the color associated with this step
  58771. */
  58772. color: Color3);
  58773. }
  58774. /**
  58775. * Block used to return a color from a gradient based on an input value between 0 and 1
  58776. */
  58777. export class GradientBlock extends NodeMaterialBlock {
  58778. /**
  58779. * Gets or sets the list of color steps
  58780. */
  58781. colorSteps: GradientBlockColorStep[];
  58782. /**
  58783. * Creates a new GradientBlock
  58784. * @param name defines the block name
  58785. */
  58786. constructor(name: string);
  58787. /**
  58788. * Gets the current class name
  58789. * @returns the class name
  58790. */
  58791. getClassName(): string;
  58792. /**
  58793. * Gets the gradient input component
  58794. */
  58795. readonly gradient: NodeMaterialConnectionPoint;
  58796. /**
  58797. * Gets the output component
  58798. */
  58799. readonly output: NodeMaterialConnectionPoint;
  58800. private _writeColorConstant;
  58801. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58802. serialize(): any;
  58803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58804. protected _dumpPropertiesCode(): string;
  58805. }
  58806. }
  58807. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58811. /**
  58812. * Block used to normalize lerp between 2 values
  58813. */
  58814. export class NLerpBlock extends NodeMaterialBlock {
  58815. /**
  58816. * Creates a new NLerpBlock
  58817. * @param name defines the block name
  58818. */
  58819. constructor(name: string);
  58820. /**
  58821. * Gets the current class name
  58822. * @returns the class name
  58823. */
  58824. getClassName(): string;
  58825. /**
  58826. * Gets the left operand input component
  58827. */
  58828. readonly left: NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the right operand input component
  58831. */
  58832. readonly right: NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the gradient operand input component
  58835. */
  58836. readonly gradient: NodeMaterialConnectionPoint;
  58837. /**
  58838. * Gets the output component
  58839. */
  58840. readonly output: NodeMaterialConnectionPoint;
  58841. protected _buildBlock(state: NodeMaterialBuildState): this;
  58842. }
  58843. }
  58844. declare module "babylonjs/Materials/Node/Blocks/frontFacingBlock" {
  58845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58848. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58849. /**
  58850. * Block used to test if the fragment shader is front facing
  58851. */
  58852. export class FrontFacingBlock extends NodeMaterialBlock {
  58853. /**
  58854. * Creates a new FrontFacingBlock
  58855. * @param name defines the block name
  58856. */
  58857. constructor(name: string);
  58858. /**
  58859. * Gets the current class name
  58860. * @returns the class name
  58861. */
  58862. getClassName(): string;
  58863. /**
  58864. * Gets the world normal component
  58865. */
  58866. readonly worldNormal: NodeMaterialConnectionPoint;
  58867. /**
  58868. * Gets the view direction input component
  58869. */
  58870. readonly viewDirection: NodeMaterialConnectionPoint;
  58871. /**
  58872. * Gets the output component
  58873. */
  58874. readonly output: NodeMaterialConnectionPoint;
  58875. autoConfigure(material: NodeMaterial): void;
  58876. protected _buildBlock(state: NodeMaterialBuildState): this;
  58877. }
  58878. }
  58879. declare module "babylonjs/Materials/Node/Blocks/index" {
  58880. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58881. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58882. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58883. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58884. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58885. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58886. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58887. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58888. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58889. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58890. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58891. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58892. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58893. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58894. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58895. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58896. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58897. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58898. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58899. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58900. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58901. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58902. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58903. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58904. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58905. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58906. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58907. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58908. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58909. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58910. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58911. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58912. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58913. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58914. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58915. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58916. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58917. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58918. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58919. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58920. export * from "babylonjs/Materials/Node/Blocks/frontFacingBlock";
  58921. }
  58922. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58923. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58924. }
  58925. declare module "babylonjs/Materials/Node/index" {
  58926. export * from "babylonjs/Materials/Node/Enums/index";
  58927. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58928. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58929. export * from "babylonjs/Materials/Node/nodeMaterial";
  58930. export * from "babylonjs/Materials/Node/Blocks/index";
  58931. export * from "babylonjs/Materials/Node/Optimizers/index";
  58932. }
  58933. declare module "babylonjs/Materials/effectRenderer" {
  58934. import { Nullable } from "babylonjs/types";
  58935. import { Texture } from "babylonjs/Materials/Textures/texture";
  58936. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58937. import { Viewport } from "babylonjs/Maths/math.viewport";
  58938. import { Observable } from "babylonjs/Misc/observable";
  58939. import { Effect } from "babylonjs/Materials/effect";
  58940. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58941. import "babylonjs/Shaders/postprocess.vertex";
  58942. /**
  58943. * Effect Render Options
  58944. */
  58945. export interface IEffectRendererOptions {
  58946. /**
  58947. * Defines the vertices positions.
  58948. */
  58949. positions?: number[];
  58950. /**
  58951. * Defines the indices.
  58952. */
  58953. indices?: number[];
  58954. }
  58955. /**
  58956. * Helper class to render one or more effects
  58957. */
  58958. export class EffectRenderer {
  58959. private engine;
  58960. private static _DefaultOptions;
  58961. private _vertexBuffers;
  58962. private _indexBuffer;
  58963. private _ringBufferIndex;
  58964. private _ringScreenBuffer;
  58965. private _fullscreenViewport;
  58966. private _getNextFrameBuffer;
  58967. /**
  58968. * Creates an effect renderer
  58969. * @param engine the engine to use for rendering
  58970. * @param options defines the options of the effect renderer
  58971. */
  58972. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58973. /**
  58974. * Sets the current viewport in normalized coordinates 0-1
  58975. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58976. */
  58977. setViewport(viewport?: Viewport): void;
  58978. /**
  58979. * Binds the embedded attributes buffer to the effect.
  58980. * @param effect Defines the effect to bind the attributes for
  58981. */
  58982. bindBuffers(effect: Effect): void;
  58983. /**
  58984. * Sets the current effect wrapper to use during draw.
  58985. * The effect needs to be ready before calling this api.
  58986. * This also sets the default full screen position attribute.
  58987. * @param effectWrapper Defines the effect to draw with
  58988. */
  58989. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58990. /**
  58991. * Draws a full screen quad.
  58992. */
  58993. draw(): void;
  58994. /**
  58995. * renders one or more effects to a specified texture
  58996. * @param effectWrappers list of effects to renderer
  58997. * @param outputTexture texture to draw to, if null it will render to the screen
  58998. */
  58999. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59000. /**
  59001. * Disposes of the effect renderer
  59002. */
  59003. dispose(): void;
  59004. }
  59005. /**
  59006. * Options to create an EffectWrapper
  59007. */
  59008. interface EffectWrapperCreationOptions {
  59009. /**
  59010. * Engine to use to create the effect
  59011. */
  59012. engine: ThinEngine;
  59013. /**
  59014. * Fragment shader for the effect
  59015. */
  59016. fragmentShader: string;
  59017. /**
  59018. * Vertex shader for the effect
  59019. */
  59020. vertexShader?: string;
  59021. /**
  59022. * Attributes to use in the shader
  59023. */
  59024. attributeNames?: Array<string>;
  59025. /**
  59026. * Uniforms to use in the shader
  59027. */
  59028. uniformNames?: Array<string>;
  59029. /**
  59030. * Texture sampler names to use in the shader
  59031. */
  59032. samplerNames?: Array<string>;
  59033. /**
  59034. * The friendly name of the effect displayed in Spector.
  59035. */
  59036. name?: string;
  59037. }
  59038. /**
  59039. * Wraps an effect to be used for rendering
  59040. */
  59041. export class EffectWrapper {
  59042. /**
  59043. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59044. */
  59045. onApplyObservable: Observable<{}>;
  59046. /**
  59047. * The underlying effect
  59048. */
  59049. effect: Effect;
  59050. /**
  59051. * Creates an effect to be renderer
  59052. * @param creationOptions options to create the effect
  59053. */
  59054. constructor(creationOptions: EffectWrapperCreationOptions);
  59055. /**
  59056. * Disposes of the effect wrapper
  59057. */
  59058. dispose(): void;
  59059. }
  59060. }
  59061. declare module "babylonjs/Materials/index" {
  59062. export * from "babylonjs/Materials/Background/index";
  59063. export * from "babylonjs/Materials/colorCurves";
  59064. export * from "babylonjs/Materials/iEffectFallbacks";
  59065. export * from "babylonjs/Materials/effectFallbacks";
  59066. export * from "babylonjs/Materials/effect";
  59067. export * from "babylonjs/Materials/fresnelParameters";
  59068. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59069. export * from "babylonjs/Materials/material";
  59070. export * from "babylonjs/Materials/materialDefines";
  59071. export * from "babylonjs/Materials/materialHelper";
  59072. export * from "babylonjs/Materials/multiMaterial";
  59073. export * from "babylonjs/Materials/PBR/index";
  59074. export * from "babylonjs/Materials/pushMaterial";
  59075. export * from "babylonjs/Materials/shaderMaterial";
  59076. export * from "babylonjs/Materials/standardMaterial";
  59077. export * from "babylonjs/Materials/Textures/index";
  59078. export * from "babylonjs/Materials/uniformBuffer";
  59079. export * from "babylonjs/Materials/materialFlags";
  59080. export * from "babylonjs/Materials/Node/index";
  59081. export * from "babylonjs/Materials/effectRenderer";
  59082. }
  59083. declare module "babylonjs/Maths/index" {
  59084. export * from "babylonjs/Maths/math.scalar";
  59085. export * from "babylonjs/Maths/math";
  59086. export * from "babylonjs/Maths/sphericalPolynomial";
  59087. }
  59088. declare module "babylonjs/Misc/workerPool" {
  59089. import { IDisposable } from "babylonjs/scene";
  59090. /**
  59091. * Helper class to push actions to a pool of workers.
  59092. */
  59093. export class WorkerPool implements IDisposable {
  59094. private _workerInfos;
  59095. private _pendingActions;
  59096. /**
  59097. * Constructor
  59098. * @param workers Array of workers to use for actions
  59099. */
  59100. constructor(workers: Array<Worker>);
  59101. /**
  59102. * Terminates all workers and clears any pending actions.
  59103. */
  59104. dispose(): void;
  59105. /**
  59106. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59107. * pended until a worker has completed its action.
  59108. * @param action The action to perform. Call onComplete when the action is complete.
  59109. */
  59110. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59111. private _execute;
  59112. }
  59113. }
  59114. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59115. import { IDisposable } from "babylonjs/scene";
  59116. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59117. /**
  59118. * Configuration for Draco compression
  59119. */
  59120. export interface IDracoCompressionConfiguration {
  59121. /**
  59122. * Configuration for the decoder.
  59123. */
  59124. decoder: {
  59125. /**
  59126. * The url to the WebAssembly module.
  59127. */
  59128. wasmUrl?: string;
  59129. /**
  59130. * The url to the WebAssembly binary.
  59131. */
  59132. wasmBinaryUrl?: string;
  59133. /**
  59134. * The url to the fallback JavaScript module.
  59135. */
  59136. fallbackUrl?: string;
  59137. };
  59138. }
  59139. /**
  59140. * Draco compression (https://google.github.io/draco/)
  59141. *
  59142. * This class wraps the Draco module.
  59143. *
  59144. * **Encoder**
  59145. *
  59146. * The encoder is not currently implemented.
  59147. *
  59148. * **Decoder**
  59149. *
  59150. * 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.
  59151. *
  59152. * To update the configuration, use the following code:
  59153. * ```javascript
  59154. * DracoCompression.Configuration = {
  59155. * decoder: {
  59156. * wasmUrl: "<url to the WebAssembly library>",
  59157. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59158. * fallbackUrl: "<url to the fallback JavaScript library>",
  59159. * }
  59160. * };
  59161. * ```
  59162. *
  59163. * 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.
  59164. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59165. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59166. *
  59167. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59168. * ```javascript
  59169. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59170. * ```
  59171. *
  59172. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59173. */
  59174. export class DracoCompression implements IDisposable {
  59175. private _workerPoolPromise?;
  59176. private _decoderModulePromise?;
  59177. /**
  59178. * The configuration. Defaults to the following urls:
  59179. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59180. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59181. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59182. */
  59183. static Configuration: IDracoCompressionConfiguration;
  59184. /**
  59185. * Returns true if the decoder configuration is available.
  59186. */
  59187. static readonly DecoderAvailable: boolean;
  59188. /**
  59189. * Default number of workers to create when creating the draco compression object.
  59190. */
  59191. static DefaultNumWorkers: number;
  59192. private static GetDefaultNumWorkers;
  59193. private static _Default;
  59194. /**
  59195. * Default instance for the draco compression object.
  59196. */
  59197. static readonly Default: DracoCompression;
  59198. /**
  59199. * Constructor
  59200. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59201. */
  59202. constructor(numWorkers?: number);
  59203. /**
  59204. * Stop all async operations and release resources.
  59205. */
  59206. dispose(): void;
  59207. /**
  59208. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59209. * @returns a promise that resolves when ready
  59210. */
  59211. whenReadyAsync(): Promise<void>;
  59212. /**
  59213. * Decode Draco compressed mesh data to vertex data.
  59214. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59215. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59216. * @returns A promise that resolves with the decoded vertex data
  59217. */
  59218. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59219. [kind: string]: number;
  59220. }): Promise<VertexData>;
  59221. }
  59222. }
  59223. declare module "babylonjs/Meshes/Compression/index" {
  59224. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59225. }
  59226. declare module "babylonjs/Meshes/csg" {
  59227. import { Nullable } from "babylonjs/types";
  59228. import { Scene } from "babylonjs/scene";
  59229. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59230. import { Mesh } from "babylonjs/Meshes/mesh";
  59231. import { Material } from "babylonjs/Materials/material";
  59232. /**
  59233. * Class for building Constructive Solid Geometry
  59234. */
  59235. export class CSG {
  59236. private polygons;
  59237. /**
  59238. * The world matrix
  59239. */
  59240. matrix: Matrix;
  59241. /**
  59242. * Stores the position
  59243. */
  59244. position: Vector3;
  59245. /**
  59246. * Stores the rotation
  59247. */
  59248. rotation: Vector3;
  59249. /**
  59250. * Stores the rotation quaternion
  59251. */
  59252. rotationQuaternion: Nullable<Quaternion>;
  59253. /**
  59254. * Stores the scaling vector
  59255. */
  59256. scaling: Vector3;
  59257. /**
  59258. * Convert the Mesh to CSG
  59259. * @param mesh The Mesh to convert to CSG
  59260. * @returns A new CSG from the Mesh
  59261. */
  59262. static FromMesh(mesh: Mesh): CSG;
  59263. /**
  59264. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59265. * @param polygons Polygons used to construct a CSG solid
  59266. */
  59267. private static FromPolygons;
  59268. /**
  59269. * Clones, or makes a deep copy, of the CSG
  59270. * @returns A new CSG
  59271. */
  59272. clone(): CSG;
  59273. /**
  59274. * Unions this CSG with another CSG
  59275. * @param csg The CSG to union against this CSG
  59276. * @returns The unioned CSG
  59277. */
  59278. union(csg: CSG): CSG;
  59279. /**
  59280. * Unions this CSG with another CSG in place
  59281. * @param csg The CSG to union against this CSG
  59282. */
  59283. unionInPlace(csg: CSG): void;
  59284. /**
  59285. * Subtracts this CSG with another CSG
  59286. * @param csg The CSG to subtract against this CSG
  59287. * @returns A new CSG
  59288. */
  59289. subtract(csg: CSG): CSG;
  59290. /**
  59291. * Subtracts this CSG with another CSG in place
  59292. * @param csg The CSG to subtact against this CSG
  59293. */
  59294. subtractInPlace(csg: CSG): void;
  59295. /**
  59296. * Intersect this CSG with another CSG
  59297. * @param csg The CSG to intersect against this CSG
  59298. * @returns A new CSG
  59299. */
  59300. intersect(csg: CSG): CSG;
  59301. /**
  59302. * Intersects this CSG with another CSG in place
  59303. * @param csg The CSG to intersect against this CSG
  59304. */
  59305. intersectInPlace(csg: CSG): void;
  59306. /**
  59307. * Return a new CSG solid with solid and empty space switched. This solid is
  59308. * not modified.
  59309. * @returns A new CSG solid with solid and empty space switched
  59310. */
  59311. inverse(): CSG;
  59312. /**
  59313. * Inverses the CSG in place
  59314. */
  59315. inverseInPlace(): void;
  59316. /**
  59317. * This is used to keep meshes transformations so they can be restored
  59318. * when we build back a Babylon Mesh
  59319. * NB : All CSG operations are performed in world coordinates
  59320. * @param csg The CSG to copy the transform attributes from
  59321. * @returns This CSG
  59322. */
  59323. copyTransformAttributes(csg: CSG): CSG;
  59324. /**
  59325. * Build Raw mesh from CSG
  59326. * Coordinates here are in world space
  59327. * @param name The name of the mesh geometry
  59328. * @param scene The Scene
  59329. * @param keepSubMeshes Specifies if the submeshes should be kept
  59330. * @returns A new Mesh
  59331. */
  59332. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59333. /**
  59334. * Build Mesh from CSG taking material and transforms into account
  59335. * @param name The name of the Mesh
  59336. * @param material The material of the Mesh
  59337. * @param scene The Scene
  59338. * @param keepSubMeshes Specifies if submeshes should be kept
  59339. * @returns The new Mesh
  59340. */
  59341. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59342. }
  59343. }
  59344. declare module "babylonjs/Meshes/trailMesh" {
  59345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59346. import { Mesh } from "babylonjs/Meshes/mesh";
  59347. import { Scene } from "babylonjs/scene";
  59348. /**
  59349. * Class used to create a trail following a mesh
  59350. */
  59351. export class TrailMesh extends Mesh {
  59352. private _generator;
  59353. private _autoStart;
  59354. private _running;
  59355. private _diameter;
  59356. private _length;
  59357. private _sectionPolygonPointsCount;
  59358. private _sectionVectors;
  59359. private _sectionNormalVectors;
  59360. private _beforeRenderObserver;
  59361. /**
  59362. * @constructor
  59363. * @param name The value used by scene.getMeshByName() to do a lookup.
  59364. * @param generator The mesh to generate a trail.
  59365. * @param scene The scene to add this mesh to.
  59366. * @param diameter Diameter of trailing mesh. Default is 1.
  59367. * @param length Length of trailing mesh. Default is 60.
  59368. * @param autoStart Automatically start trailing mesh. Default true.
  59369. */
  59370. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59371. /**
  59372. * "TrailMesh"
  59373. * @returns "TrailMesh"
  59374. */
  59375. getClassName(): string;
  59376. private _createMesh;
  59377. /**
  59378. * Start trailing mesh.
  59379. */
  59380. start(): void;
  59381. /**
  59382. * Stop trailing mesh.
  59383. */
  59384. stop(): void;
  59385. /**
  59386. * Update trailing mesh geometry.
  59387. */
  59388. update(): void;
  59389. /**
  59390. * Returns a new TrailMesh object.
  59391. * @param name is a string, the name given to the new mesh
  59392. * @param newGenerator use new generator object for cloned trail mesh
  59393. * @returns a new mesh
  59394. */
  59395. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59396. /**
  59397. * Serializes this trail mesh
  59398. * @param serializationObject object to write serialization to
  59399. */
  59400. serialize(serializationObject: any): void;
  59401. /**
  59402. * Parses a serialized trail mesh
  59403. * @param parsedMesh the serialized mesh
  59404. * @param scene the scene to create the trail mesh in
  59405. * @returns the created trail mesh
  59406. */
  59407. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59408. }
  59409. }
  59410. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59411. import { Nullable } from "babylonjs/types";
  59412. import { Scene } from "babylonjs/scene";
  59413. import { Vector4 } from "babylonjs/Maths/math.vector";
  59414. import { Color4 } from "babylonjs/Maths/math.color";
  59415. import { Mesh } from "babylonjs/Meshes/mesh";
  59416. /**
  59417. * Class containing static functions to help procedurally build meshes
  59418. */
  59419. export class TiledBoxBuilder {
  59420. /**
  59421. * Creates a box mesh
  59422. * 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)
  59423. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59427. * @param name defines the name of the mesh
  59428. * @param options defines the options used to create the mesh
  59429. * @param scene defines the hosting scene
  59430. * @returns the box mesh
  59431. */
  59432. static CreateTiledBox(name: string, options: {
  59433. pattern?: number;
  59434. width?: number;
  59435. height?: number;
  59436. depth?: number;
  59437. tileSize?: number;
  59438. tileWidth?: number;
  59439. tileHeight?: number;
  59440. alignHorizontal?: number;
  59441. alignVertical?: number;
  59442. faceUV?: Vector4[];
  59443. faceColors?: Color4[];
  59444. sideOrientation?: number;
  59445. updatable?: boolean;
  59446. }, scene?: Nullable<Scene>): Mesh;
  59447. }
  59448. }
  59449. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59450. import { Vector4 } from "babylonjs/Maths/math.vector";
  59451. import { Mesh } from "babylonjs/Meshes/mesh";
  59452. /**
  59453. * Class containing static functions to help procedurally build meshes
  59454. */
  59455. export class TorusKnotBuilder {
  59456. /**
  59457. * Creates a torus knot mesh
  59458. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59459. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59460. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59461. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59465. * @param name defines the name of the mesh
  59466. * @param options defines the options used to create the mesh
  59467. * @param scene defines the hosting scene
  59468. * @returns the torus knot mesh
  59469. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59470. */
  59471. static CreateTorusKnot(name: string, options: {
  59472. radius?: number;
  59473. tube?: number;
  59474. radialSegments?: number;
  59475. tubularSegments?: number;
  59476. p?: number;
  59477. q?: number;
  59478. updatable?: boolean;
  59479. sideOrientation?: number;
  59480. frontUVs?: Vector4;
  59481. backUVs?: Vector4;
  59482. }, scene: any): Mesh;
  59483. }
  59484. }
  59485. declare module "babylonjs/Meshes/polygonMesh" {
  59486. import { Scene } from "babylonjs/scene";
  59487. import { Vector2 } from "babylonjs/Maths/math.vector";
  59488. import { Mesh } from "babylonjs/Meshes/mesh";
  59489. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59490. import { Path2 } from "babylonjs/Maths/math.path";
  59491. /**
  59492. * Polygon
  59493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59494. */
  59495. export class Polygon {
  59496. /**
  59497. * Creates a rectangle
  59498. * @param xmin bottom X coord
  59499. * @param ymin bottom Y coord
  59500. * @param xmax top X coord
  59501. * @param ymax top Y coord
  59502. * @returns points that make the resulting rectation
  59503. */
  59504. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59505. /**
  59506. * Creates a circle
  59507. * @param radius radius of circle
  59508. * @param cx scale in x
  59509. * @param cy scale in y
  59510. * @param numberOfSides number of sides that make up the circle
  59511. * @returns points that make the resulting circle
  59512. */
  59513. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59514. /**
  59515. * Creates a polygon from input string
  59516. * @param input Input polygon data
  59517. * @returns the parsed points
  59518. */
  59519. static Parse(input: string): Vector2[];
  59520. /**
  59521. * Starts building a polygon from x and y coordinates
  59522. * @param x x coordinate
  59523. * @param y y coordinate
  59524. * @returns the started path2
  59525. */
  59526. static StartingAt(x: number, y: number): Path2;
  59527. }
  59528. /**
  59529. * Builds a polygon
  59530. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59531. */
  59532. export class PolygonMeshBuilder {
  59533. private _points;
  59534. private _outlinepoints;
  59535. private _holes;
  59536. private _name;
  59537. private _scene;
  59538. private _epoints;
  59539. private _eholes;
  59540. private _addToepoint;
  59541. /**
  59542. * Babylon reference to the earcut plugin.
  59543. */
  59544. bjsEarcut: any;
  59545. /**
  59546. * Creates a PolygonMeshBuilder
  59547. * @param name name of the builder
  59548. * @param contours Path of the polygon
  59549. * @param scene scene to add to when creating the mesh
  59550. * @param earcutInjection can be used to inject your own earcut reference
  59551. */
  59552. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59553. /**
  59554. * Adds a whole within the polygon
  59555. * @param hole Array of points defining the hole
  59556. * @returns this
  59557. */
  59558. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59559. /**
  59560. * Creates the polygon
  59561. * @param updatable If the mesh should be updatable
  59562. * @param depth The depth of the mesh created
  59563. * @returns the created mesh
  59564. */
  59565. build(updatable?: boolean, depth?: number): Mesh;
  59566. /**
  59567. * Creates the polygon
  59568. * @param depth The depth of the mesh created
  59569. * @returns the created VertexData
  59570. */
  59571. buildVertexData(depth?: number): VertexData;
  59572. /**
  59573. * Adds a side to the polygon
  59574. * @param positions points that make the polygon
  59575. * @param normals normals of the polygon
  59576. * @param uvs uvs of the polygon
  59577. * @param indices indices of the polygon
  59578. * @param bounds bounds of the polygon
  59579. * @param points points of the polygon
  59580. * @param depth depth of the polygon
  59581. * @param flip flip of the polygon
  59582. */
  59583. private addSide;
  59584. }
  59585. }
  59586. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59587. import { Scene } from "babylonjs/scene";
  59588. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59589. import { Color4 } from "babylonjs/Maths/math.color";
  59590. import { Mesh } from "babylonjs/Meshes/mesh";
  59591. import { Nullable } from "babylonjs/types";
  59592. /**
  59593. * Class containing static functions to help procedurally build meshes
  59594. */
  59595. export class PolygonBuilder {
  59596. /**
  59597. * Creates a polygon mesh
  59598. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59599. * * 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
  59600. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59603. * * Remember you can only change the shape positions, not their number when updating a polygon
  59604. * @param name defines the name of the mesh
  59605. * @param options defines the options used to create the mesh
  59606. * @param scene defines the hosting scene
  59607. * @param earcutInjection can be used to inject your own earcut reference
  59608. * @returns the polygon mesh
  59609. */
  59610. static CreatePolygon(name: string, options: {
  59611. shape: Vector3[];
  59612. holes?: Vector3[][];
  59613. depth?: number;
  59614. faceUV?: Vector4[];
  59615. faceColors?: Color4[];
  59616. updatable?: boolean;
  59617. sideOrientation?: number;
  59618. frontUVs?: Vector4;
  59619. backUVs?: Vector4;
  59620. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59621. /**
  59622. * Creates an extruded polygon mesh, with depth in the Y direction.
  59623. * * 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)
  59624. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59625. * @param name defines the name of the mesh
  59626. * @param options defines the options used to create the mesh
  59627. * @param scene defines the hosting scene
  59628. * @param earcutInjection can be used to inject your own earcut reference
  59629. * @returns the polygon mesh
  59630. */
  59631. static ExtrudePolygon(name: string, options: {
  59632. shape: Vector3[];
  59633. holes?: Vector3[][];
  59634. depth?: number;
  59635. faceUV?: Vector4[];
  59636. faceColors?: Color4[];
  59637. updatable?: boolean;
  59638. sideOrientation?: number;
  59639. frontUVs?: Vector4;
  59640. backUVs?: Vector4;
  59641. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59642. }
  59643. }
  59644. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59645. import { Scene } from "babylonjs/scene";
  59646. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59647. import { Mesh } from "babylonjs/Meshes/mesh";
  59648. import { Nullable } from "babylonjs/types";
  59649. /**
  59650. * Class containing static functions to help procedurally build meshes
  59651. */
  59652. export class LatheBuilder {
  59653. /**
  59654. * Creates lathe mesh.
  59655. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59656. * * 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
  59657. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59658. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59659. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59660. * * 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
  59661. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59662. * * 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
  59663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59665. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59667. * @param name defines the name of the mesh
  59668. * @param options defines the options used to create the mesh
  59669. * @param scene defines the hosting scene
  59670. * @returns the lathe mesh
  59671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59672. */
  59673. static CreateLathe(name: string, options: {
  59674. shape: Vector3[];
  59675. radius?: number;
  59676. tessellation?: number;
  59677. clip?: number;
  59678. arc?: number;
  59679. closed?: boolean;
  59680. updatable?: boolean;
  59681. sideOrientation?: number;
  59682. frontUVs?: Vector4;
  59683. backUVs?: Vector4;
  59684. cap?: number;
  59685. invertUV?: boolean;
  59686. }, scene?: Nullable<Scene>): Mesh;
  59687. }
  59688. }
  59689. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59690. import { Nullable } from "babylonjs/types";
  59691. import { Scene } from "babylonjs/scene";
  59692. import { Vector4 } from "babylonjs/Maths/math.vector";
  59693. import { Mesh } from "babylonjs/Meshes/mesh";
  59694. /**
  59695. * Class containing static functions to help procedurally build meshes
  59696. */
  59697. export class TiledPlaneBuilder {
  59698. /**
  59699. * Creates a tiled plane mesh
  59700. * * The parameter `pattern` will, depending on value, do nothing or
  59701. * * * flip (reflect about central vertical) alternate tiles across and up
  59702. * * * flip every tile on alternate rows
  59703. * * * rotate (180 degs) alternate tiles across and up
  59704. * * * rotate every tile on alternate rows
  59705. * * * flip and rotate alternate tiles across and up
  59706. * * * flip and rotate every tile on alternate rows
  59707. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59708. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59711. * * 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)
  59712. * * 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)
  59713. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59714. * @param name defines the name of the mesh
  59715. * @param options defines the options used to create the mesh
  59716. * @param scene defines the hosting scene
  59717. * @returns the box mesh
  59718. */
  59719. static CreateTiledPlane(name: string, options: {
  59720. pattern?: number;
  59721. tileSize?: number;
  59722. tileWidth?: number;
  59723. tileHeight?: number;
  59724. size?: number;
  59725. width?: number;
  59726. height?: number;
  59727. alignHorizontal?: number;
  59728. alignVertical?: number;
  59729. sideOrientation?: number;
  59730. frontUVs?: Vector4;
  59731. backUVs?: Vector4;
  59732. updatable?: boolean;
  59733. }, scene?: Nullable<Scene>): Mesh;
  59734. }
  59735. }
  59736. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59737. import { Nullable } from "babylonjs/types";
  59738. import { Scene } from "babylonjs/scene";
  59739. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59740. import { Mesh } from "babylonjs/Meshes/mesh";
  59741. /**
  59742. * Class containing static functions to help procedurally build meshes
  59743. */
  59744. export class TubeBuilder {
  59745. /**
  59746. * Creates a tube mesh.
  59747. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59748. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59749. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59750. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59751. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59752. * * 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)
  59753. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59754. * * 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
  59755. * * 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
  59756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59760. * @param name defines the name of the mesh
  59761. * @param options defines the options used to create the mesh
  59762. * @param scene defines the hosting scene
  59763. * @returns the tube mesh
  59764. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59765. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59766. */
  59767. static CreateTube(name: string, options: {
  59768. path: Vector3[];
  59769. radius?: number;
  59770. tessellation?: number;
  59771. radiusFunction?: {
  59772. (i: number, distance: number): number;
  59773. };
  59774. cap?: number;
  59775. arc?: number;
  59776. updatable?: boolean;
  59777. sideOrientation?: number;
  59778. frontUVs?: Vector4;
  59779. backUVs?: Vector4;
  59780. instance?: Mesh;
  59781. invertUV?: boolean;
  59782. }, scene?: Nullable<Scene>): Mesh;
  59783. }
  59784. }
  59785. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59786. import { Scene } from "babylonjs/scene";
  59787. import { Vector4 } from "babylonjs/Maths/math.vector";
  59788. import { Mesh } from "babylonjs/Meshes/mesh";
  59789. import { Nullable } from "babylonjs/types";
  59790. /**
  59791. * Class containing static functions to help procedurally build meshes
  59792. */
  59793. export class IcoSphereBuilder {
  59794. /**
  59795. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59796. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59797. * * 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`)
  59798. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59799. * * 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
  59800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59803. * @param name defines the name of the mesh
  59804. * @param options defines the options used to create the mesh
  59805. * @param scene defines the hosting scene
  59806. * @returns the icosahedron mesh
  59807. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59808. */
  59809. static CreateIcoSphere(name: string, options: {
  59810. radius?: number;
  59811. radiusX?: number;
  59812. radiusY?: number;
  59813. radiusZ?: number;
  59814. flat?: boolean;
  59815. subdivisions?: number;
  59816. sideOrientation?: number;
  59817. frontUVs?: Vector4;
  59818. backUVs?: Vector4;
  59819. updatable?: boolean;
  59820. }, scene?: Nullable<Scene>): Mesh;
  59821. }
  59822. }
  59823. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59824. import { Vector3 } from "babylonjs/Maths/math.vector";
  59825. import { Mesh } from "babylonjs/Meshes/mesh";
  59826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59827. /**
  59828. * Class containing static functions to help procedurally build meshes
  59829. */
  59830. export class DecalBuilder {
  59831. /**
  59832. * Creates a decal mesh.
  59833. * 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
  59834. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59835. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59836. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59837. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59838. * @param name defines the name of the mesh
  59839. * @param sourceMesh defines the mesh where the decal must be applied
  59840. * @param options defines the options used to create the mesh
  59841. * @param scene defines the hosting scene
  59842. * @returns the decal mesh
  59843. * @see https://doc.babylonjs.com/how_to/decals
  59844. */
  59845. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59846. position?: Vector3;
  59847. normal?: Vector3;
  59848. size?: Vector3;
  59849. angle?: number;
  59850. }): Mesh;
  59851. }
  59852. }
  59853. declare module "babylonjs/Meshes/meshBuilder" {
  59854. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59855. import { Nullable } from "babylonjs/types";
  59856. import { Scene } from "babylonjs/scene";
  59857. import { Mesh } from "babylonjs/Meshes/mesh";
  59858. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59859. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59861. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59862. import { Plane } from "babylonjs/Maths/math.plane";
  59863. /**
  59864. * Class containing static functions to help procedurally build meshes
  59865. */
  59866. export class MeshBuilder {
  59867. /**
  59868. * Creates a box mesh
  59869. * * The parameter `size` sets the size (float) of each box side (default 1)
  59870. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59871. * * 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)
  59872. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59876. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59877. * @param name defines the name of the mesh
  59878. * @param options defines the options used to create the mesh
  59879. * @param scene defines the hosting scene
  59880. * @returns the box mesh
  59881. */
  59882. static CreateBox(name: string, options: {
  59883. size?: number;
  59884. width?: number;
  59885. height?: number;
  59886. depth?: number;
  59887. faceUV?: Vector4[];
  59888. faceColors?: Color4[];
  59889. sideOrientation?: number;
  59890. frontUVs?: Vector4;
  59891. backUVs?: Vector4;
  59892. updatable?: boolean;
  59893. }, scene?: Nullable<Scene>): Mesh;
  59894. /**
  59895. * Creates a tiled box mesh
  59896. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59898. * @param name defines the name of the mesh
  59899. * @param options defines the options used to create the mesh
  59900. * @param scene defines the hosting scene
  59901. * @returns the tiled box mesh
  59902. */
  59903. static CreateTiledBox(name: string, options: {
  59904. pattern?: number;
  59905. size?: number;
  59906. width?: number;
  59907. height?: number;
  59908. depth: number;
  59909. tileSize?: number;
  59910. tileWidth?: number;
  59911. tileHeight?: number;
  59912. faceUV?: Vector4[];
  59913. faceColors?: Color4[];
  59914. alignHorizontal?: number;
  59915. alignVertical?: number;
  59916. sideOrientation?: number;
  59917. updatable?: boolean;
  59918. }, scene?: Nullable<Scene>): Mesh;
  59919. /**
  59920. * Creates a sphere mesh
  59921. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59922. * * 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`)
  59923. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59924. * * 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
  59925. * * 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)
  59926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59929. * @param name defines the name of the mesh
  59930. * @param options defines the options used to create the mesh
  59931. * @param scene defines the hosting scene
  59932. * @returns the sphere mesh
  59933. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59934. */
  59935. static CreateSphere(name: string, options: {
  59936. segments?: number;
  59937. diameter?: number;
  59938. diameterX?: number;
  59939. diameterY?: number;
  59940. diameterZ?: number;
  59941. arc?: number;
  59942. slice?: number;
  59943. sideOrientation?: number;
  59944. frontUVs?: Vector4;
  59945. backUVs?: Vector4;
  59946. updatable?: boolean;
  59947. }, scene?: Nullable<Scene>): Mesh;
  59948. /**
  59949. * Creates a plane polygonal mesh. By default, this is a disc
  59950. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59951. * * 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
  59952. * * 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
  59953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59956. * @param name defines the name of the mesh
  59957. * @param options defines the options used to create the mesh
  59958. * @param scene defines the hosting scene
  59959. * @returns the plane polygonal mesh
  59960. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59961. */
  59962. static CreateDisc(name: string, options: {
  59963. radius?: number;
  59964. tessellation?: number;
  59965. arc?: number;
  59966. updatable?: boolean;
  59967. sideOrientation?: number;
  59968. frontUVs?: Vector4;
  59969. backUVs?: Vector4;
  59970. }, scene?: Nullable<Scene>): Mesh;
  59971. /**
  59972. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59973. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59974. * * 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`)
  59975. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59976. * * 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
  59977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59980. * @param name defines the name of the mesh
  59981. * @param options defines the options used to create the mesh
  59982. * @param scene defines the hosting scene
  59983. * @returns the icosahedron mesh
  59984. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59985. */
  59986. static CreateIcoSphere(name: string, options: {
  59987. radius?: number;
  59988. radiusX?: number;
  59989. radiusY?: number;
  59990. radiusZ?: number;
  59991. flat?: boolean;
  59992. subdivisions?: number;
  59993. sideOrientation?: number;
  59994. frontUVs?: Vector4;
  59995. backUVs?: Vector4;
  59996. updatable?: boolean;
  59997. }, scene?: Nullable<Scene>): Mesh;
  59998. /**
  59999. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60000. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60001. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60002. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60003. * * 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
  60004. * * 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
  60005. * * 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
  60006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60008. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60009. * * 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
  60010. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60011. * * 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
  60012. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60014. * @param name defines the name of the mesh
  60015. * @param options defines the options used to create the mesh
  60016. * @param scene defines the hosting scene
  60017. * @returns the ribbon mesh
  60018. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60019. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60020. */
  60021. static CreateRibbon(name: string, options: {
  60022. pathArray: Vector3[][];
  60023. closeArray?: boolean;
  60024. closePath?: boolean;
  60025. offset?: number;
  60026. updatable?: boolean;
  60027. sideOrientation?: number;
  60028. frontUVs?: Vector4;
  60029. backUVs?: Vector4;
  60030. instance?: Mesh;
  60031. invertUV?: boolean;
  60032. uvs?: Vector2[];
  60033. colors?: Color4[];
  60034. }, scene?: Nullable<Scene>): Mesh;
  60035. /**
  60036. * Creates a cylinder or a cone mesh
  60037. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60038. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60039. * * 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.
  60040. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60041. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60042. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60043. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60044. * * 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).
  60045. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60046. * * 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).
  60047. * * 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
  60048. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60049. * * 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
  60050. * * 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.
  60051. * * If `enclose` is false, a ring surface is one element.
  60052. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60053. * * 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
  60054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60057. * @param name defines the name of the mesh
  60058. * @param options defines the options used to create the mesh
  60059. * @param scene defines the hosting scene
  60060. * @returns the cylinder mesh
  60061. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60062. */
  60063. static CreateCylinder(name: string, options: {
  60064. height?: number;
  60065. diameterTop?: number;
  60066. diameterBottom?: number;
  60067. diameter?: number;
  60068. tessellation?: number;
  60069. subdivisions?: number;
  60070. arc?: number;
  60071. faceColors?: Color4[];
  60072. faceUV?: Vector4[];
  60073. updatable?: boolean;
  60074. hasRings?: boolean;
  60075. enclose?: boolean;
  60076. cap?: number;
  60077. sideOrientation?: number;
  60078. frontUVs?: Vector4;
  60079. backUVs?: Vector4;
  60080. }, scene?: Nullable<Scene>): Mesh;
  60081. /**
  60082. * Creates a torus mesh
  60083. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60084. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60085. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60089. * @param name defines the name of the mesh
  60090. * @param options defines the options used to create the mesh
  60091. * @param scene defines the hosting scene
  60092. * @returns the torus mesh
  60093. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60094. */
  60095. static CreateTorus(name: string, options: {
  60096. diameter?: number;
  60097. thickness?: number;
  60098. tessellation?: number;
  60099. updatable?: boolean;
  60100. sideOrientation?: number;
  60101. frontUVs?: Vector4;
  60102. backUVs?: Vector4;
  60103. }, scene?: Nullable<Scene>): Mesh;
  60104. /**
  60105. * Creates a torus knot mesh
  60106. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60107. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60108. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60109. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60113. * @param name defines the name of the mesh
  60114. * @param options defines the options used to create the mesh
  60115. * @param scene defines the hosting scene
  60116. * @returns the torus knot mesh
  60117. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60118. */
  60119. static CreateTorusKnot(name: string, options: {
  60120. radius?: number;
  60121. tube?: number;
  60122. radialSegments?: number;
  60123. tubularSegments?: number;
  60124. p?: number;
  60125. q?: number;
  60126. updatable?: boolean;
  60127. sideOrientation?: number;
  60128. frontUVs?: Vector4;
  60129. backUVs?: Vector4;
  60130. }, scene?: Nullable<Scene>): Mesh;
  60131. /**
  60132. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60133. * * 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
  60134. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60135. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60136. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60137. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60138. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60139. * * 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
  60140. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60143. * @param name defines the name of the new line system
  60144. * @param options defines the options used to create the line system
  60145. * @param scene defines the hosting scene
  60146. * @returns a new line system mesh
  60147. */
  60148. static CreateLineSystem(name: string, options: {
  60149. lines: Vector3[][];
  60150. updatable?: boolean;
  60151. instance?: Nullable<LinesMesh>;
  60152. colors?: Nullable<Color4[][]>;
  60153. useVertexAlpha?: boolean;
  60154. }, scene: Nullable<Scene>): LinesMesh;
  60155. /**
  60156. * Creates a line mesh
  60157. * 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
  60158. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60159. * * The parameter `points` is an array successive Vector3
  60160. * * 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
  60161. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60162. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60163. * * When updating an instance, remember that only point positions can change, not the number of points
  60164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60165. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60166. * @param name defines the name of the new line system
  60167. * @param options defines the options used to create the line system
  60168. * @param scene defines the hosting scene
  60169. * @returns a new line mesh
  60170. */
  60171. static CreateLines(name: string, options: {
  60172. points: Vector3[];
  60173. updatable?: boolean;
  60174. instance?: Nullable<LinesMesh>;
  60175. colors?: Color4[];
  60176. useVertexAlpha?: boolean;
  60177. }, scene?: Nullable<Scene>): LinesMesh;
  60178. /**
  60179. * Creates a dashed line mesh
  60180. * * 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
  60181. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60182. * * The parameter `points` is an array successive Vector3
  60183. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60184. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60185. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60186. * * 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
  60187. * * When updating an instance, remember that only point positions can change, not the number of points
  60188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60189. * @param name defines the name of the mesh
  60190. * @param options defines the options used to create the mesh
  60191. * @param scene defines the hosting scene
  60192. * @returns the dashed line mesh
  60193. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60194. */
  60195. static CreateDashedLines(name: string, options: {
  60196. points: Vector3[];
  60197. dashSize?: number;
  60198. gapSize?: number;
  60199. dashNb?: number;
  60200. updatable?: boolean;
  60201. instance?: LinesMesh;
  60202. }, scene?: Nullable<Scene>): LinesMesh;
  60203. /**
  60204. * 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.
  60205. * * 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.
  60206. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60207. * * 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.
  60208. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60209. * * 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
  60210. * * 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
  60211. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60214. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60216. * @param name defines the name of the mesh
  60217. * @param options defines the options used to create the mesh
  60218. * @param scene defines the hosting scene
  60219. * @returns the extruded shape mesh
  60220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60221. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60222. */
  60223. static ExtrudeShape(name: string, options: {
  60224. shape: Vector3[];
  60225. path: Vector3[];
  60226. scale?: number;
  60227. rotation?: number;
  60228. cap?: number;
  60229. updatable?: boolean;
  60230. sideOrientation?: number;
  60231. frontUVs?: Vector4;
  60232. backUVs?: Vector4;
  60233. instance?: Mesh;
  60234. invertUV?: boolean;
  60235. }, scene?: Nullable<Scene>): Mesh;
  60236. /**
  60237. * Creates an custom extruded shape mesh.
  60238. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60239. * * 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.
  60240. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60241. * * 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
  60242. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60243. * * 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
  60244. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60245. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60246. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60247. * * 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
  60248. * * 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
  60249. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60252. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60254. * @param name defines the name of the mesh
  60255. * @param options defines the options used to create the mesh
  60256. * @param scene defines the hosting scene
  60257. * @returns the custom extruded shape mesh
  60258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60259. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60261. */
  60262. static ExtrudeShapeCustom(name: string, options: {
  60263. shape: Vector3[];
  60264. path: Vector3[];
  60265. scaleFunction?: any;
  60266. rotationFunction?: any;
  60267. ribbonCloseArray?: boolean;
  60268. ribbonClosePath?: boolean;
  60269. cap?: number;
  60270. updatable?: boolean;
  60271. sideOrientation?: number;
  60272. frontUVs?: Vector4;
  60273. backUVs?: Vector4;
  60274. instance?: Mesh;
  60275. invertUV?: boolean;
  60276. }, scene?: Nullable<Scene>): Mesh;
  60277. /**
  60278. * Creates lathe mesh.
  60279. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60280. * * 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
  60281. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60282. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60283. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60284. * * 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
  60285. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60286. * * 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
  60287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60291. * @param name defines the name of the mesh
  60292. * @param options defines the options used to create the mesh
  60293. * @param scene defines the hosting scene
  60294. * @returns the lathe mesh
  60295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60296. */
  60297. static CreateLathe(name: string, options: {
  60298. shape: Vector3[];
  60299. radius?: number;
  60300. tessellation?: number;
  60301. clip?: number;
  60302. arc?: number;
  60303. closed?: boolean;
  60304. updatable?: boolean;
  60305. sideOrientation?: number;
  60306. frontUVs?: Vector4;
  60307. backUVs?: Vector4;
  60308. cap?: number;
  60309. invertUV?: boolean;
  60310. }, scene?: Nullable<Scene>): Mesh;
  60311. /**
  60312. * Creates a tiled plane mesh
  60313. * * You can set a limited pattern arrangement with the tiles
  60314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60317. * @param name defines the name of the mesh
  60318. * @param options defines the options used to create the mesh
  60319. * @param scene defines the hosting scene
  60320. * @returns the plane mesh
  60321. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60322. */
  60323. static CreateTiledPlane(name: string, options: {
  60324. pattern?: number;
  60325. tileSize?: number;
  60326. tileWidth?: number;
  60327. tileHeight?: number;
  60328. size?: number;
  60329. width?: number;
  60330. height?: number;
  60331. alignHorizontal?: number;
  60332. alignVertical?: number;
  60333. sideOrientation?: number;
  60334. frontUVs?: Vector4;
  60335. backUVs?: Vector4;
  60336. updatable?: boolean;
  60337. }, scene?: Nullable<Scene>): Mesh;
  60338. /**
  60339. * Creates a plane mesh
  60340. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60341. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60342. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60346. * @param name defines the name of the mesh
  60347. * @param options defines the options used to create the mesh
  60348. * @param scene defines the hosting scene
  60349. * @returns the plane mesh
  60350. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60351. */
  60352. static CreatePlane(name: string, options: {
  60353. size?: number;
  60354. width?: number;
  60355. height?: number;
  60356. sideOrientation?: number;
  60357. frontUVs?: Vector4;
  60358. backUVs?: Vector4;
  60359. updatable?: boolean;
  60360. sourcePlane?: Plane;
  60361. }, scene?: Nullable<Scene>): Mesh;
  60362. /**
  60363. * Creates a ground mesh
  60364. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60365. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60367. * @param name defines the name of the mesh
  60368. * @param options defines the options used to create the mesh
  60369. * @param scene defines the hosting scene
  60370. * @returns the ground mesh
  60371. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60372. */
  60373. static CreateGround(name: string, options: {
  60374. width?: number;
  60375. height?: number;
  60376. subdivisions?: number;
  60377. subdivisionsX?: number;
  60378. subdivisionsY?: number;
  60379. updatable?: boolean;
  60380. }, scene?: Nullable<Scene>): Mesh;
  60381. /**
  60382. * Creates a tiled ground mesh
  60383. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60384. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60385. * * 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
  60386. * * 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
  60387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60388. * @param name defines the name of the mesh
  60389. * @param options defines the options used to create the mesh
  60390. * @param scene defines the hosting scene
  60391. * @returns the tiled ground mesh
  60392. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60393. */
  60394. static CreateTiledGround(name: string, options: {
  60395. xmin: number;
  60396. zmin: number;
  60397. xmax: number;
  60398. zmax: number;
  60399. subdivisions?: {
  60400. w: number;
  60401. h: number;
  60402. };
  60403. precision?: {
  60404. w: number;
  60405. h: number;
  60406. };
  60407. updatable?: boolean;
  60408. }, scene?: Nullable<Scene>): Mesh;
  60409. /**
  60410. * Creates a ground mesh from a height map
  60411. * * The parameter `url` sets the URL of the height map image resource.
  60412. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60413. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60414. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60415. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60416. * * 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.
  60417. * * 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).
  60418. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60420. * @param name defines the name of the mesh
  60421. * @param url defines the url to the height map
  60422. * @param options defines the options used to create the mesh
  60423. * @param scene defines the hosting scene
  60424. * @returns the ground mesh
  60425. * @see https://doc.babylonjs.com/babylon101/height_map
  60426. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60427. */
  60428. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60429. width?: number;
  60430. height?: number;
  60431. subdivisions?: number;
  60432. minHeight?: number;
  60433. maxHeight?: number;
  60434. colorFilter?: Color3;
  60435. alphaFilter?: number;
  60436. updatable?: boolean;
  60437. onReady?: (mesh: GroundMesh) => void;
  60438. }, scene?: Nullable<Scene>): GroundMesh;
  60439. /**
  60440. * Creates a polygon mesh
  60441. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60442. * * 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
  60443. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60446. * * Remember you can only change the shape positions, not their number when updating a polygon
  60447. * @param name defines the name of the mesh
  60448. * @param options defines the options used to create the mesh
  60449. * @param scene defines the hosting scene
  60450. * @param earcutInjection can be used to inject your own earcut reference
  60451. * @returns the polygon mesh
  60452. */
  60453. static CreatePolygon(name: string, options: {
  60454. shape: Vector3[];
  60455. holes?: Vector3[][];
  60456. depth?: number;
  60457. faceUV?: Vector4[];
  60458. faceColors?: Color4[];
  60459. updatable?: boolean;
  60460. sideOrientation?: number;
  60461. frontUVs?: Vector4;
  60462. backUVs?: Vector4;
  60463. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60464. /**
  60465. * Creates an extruded polygon mesh, with depth in the Y direction.
  60466. * * 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)
  60467. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60468. * @param name defines the name of the mesh
  60469. * @param options defines the options used to create the mesh
  60470. * @param scene defines the hosting scene
  60471. * @param earcutInjection can be used to inject your own earcut reference
  60472. * @returns the polygon mesh
  60473. */
  60474. static ExtrudePolygon(name: string, options: {
  60475. shape: Vector3[];
  60476. holes?: Vector3[][];
  60477. depth?: number;
  60478. faceUV?: Vector4[];
  60479. faceColors?: Color4[];
  60480. updatable?: boolean;
  60481. sideOrientation?: number;
  60482. frontUVs?: Vector4;
  60483. backUVs?: Vector4;
  60484. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60485. /**
  60486. * Creates a tube mesh.
  60487. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60488. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60489. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60490. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60491. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60492. * * 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)
  60493. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60494. * * 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
  60495. * * 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
  60496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60500. * @param name defines the name of the mesh
  60501. * @param options defines the options used to create the mesh
  60502. * @param scene defines the hosting scene
  60503. * @returns the tube mesh
  60504. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60505. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60506. */
  60507. static CreateTube(name: string, options: {
  60508. path: Vector3[];
  60509. radius?: number;
  60510. tessellation?: number;
  60511. radiusFunction?: {
  60512. (i: number, distance: number): number;
  60513. };
  60514. cap?: number;
  60515. arc?: number;
  60516. updatable?: boolean;
  60517. sideOrientation?: number;
  60518. frontUVs?: Vector4;
  60519. backUVs?: Vector4;
  60520. instance?: Mesh;
  60521. invertUV?: boolean;
  60522. }, scene?: Nullable<Scene>): Mesh;
  60523. /**
  60524. * Creates a polyhedron mesh
  60525. * * 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
  60526. * * The parameter `size` (positive float, default 1) sets the polygon size
  60527. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60528. * * 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`
  60529. * * 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
  60530. * * 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)`)
  60531. * * 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
  60532. * * 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
  60533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60536. * @param name defines the name of the mesh
  60537. * @param options defines the options used to create the mesh
  60538. * @param scene defines the hosting scene
  60539. * @returns the polyhedron mesh
  60540. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60541. */
  60542. static CreatePolyhedron(name: string, options: {
  60543. type?: number;
  60544. size?: number;
  60545. sizeX?: number;
  60546. sizeY?: number;
  60547. sizeZ?: number;
  60548. custom?: any;
  60549. faceUV?: Vector4[];
  60550. faceColors?: Color4[];
  60551. flat?: boolean;
  60552. updatable?: boolean;
  60553. sideOrientation?: number;
  60554. frontUVs?: Vector4;
  60555. backUVs?: Vector4;
  60556. }, scene?: Nullable<Scene>): Mesh;
  60557. /**
  60558. * Creates a decal mesh.
  60559. * 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
  60560. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60561. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60562. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60563. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60564. * @param name defines the name of the mesh
  60565. * @param sourceMesh defines the mesh where the decal must be applied
  60566. * @param options defines the options used to create the mesh
  60567. * @param scene defines the hosting scene
  60568. * @returns the decal mesh
  60569. * @see https://doc.babylonjs.com/how_to/decals
  60570. */
  60571. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60572. position?: Vector3;
  60573. normal?: Vector3;
  60574. size?: Vector3;
  60575. angle?: number;
  60576. }): Mesh;
  60577. }
  60578. }
  60579. declare module "babylonjs/Meshes/meshSimplification" {
  60580. import { Mesh } from "babylonjs/Meshes/mesh";
  60581. /**
  60582. * A simplifier interface for future simplification implementations
  60583. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60584. */
  60585. export interface ISimplifier {
  60586. /**
  60587. * Simplification of a given mesh according to the given settings.
  60588. * Since this requires computation, it is assumed that the function runs async.
  60589. * @param settings The settings of the simplification, including quality and distance
  60590. * @param successCallback A callback that will be called after the mesh was simplified.
  60591. * @param errorCallback in case of an error, this callback will be called. optional.
  60592. */
  60593. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60594. }
  60595. /**
  60596. * Expected simplification settings.
  60597. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60598. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60599. */
  60600. export interface ISimplificationSettings {
  60601. /**
  60602. * Gets or sets the expected quality
  60603. */
  60604. quality: number;
  60605. /**
  60606. * Gets or sets the distance when this optimized version should be used
  60607. */
  60608. distance: number;
  60609. /**
  60610. * Gets an already optimized mesh
  60611. */
  60612. optimizeMesh?: boolean;
  60613. }
  60614. /**
  60615. * Class used to specify simplification options
  60616. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60617. */
  60618. export class SimplificationSettings implements ISimplificationSettings {
  60619. /** expected quality */
  60620. quality: number;
  60621. /** distance when this optimized version should be used */
  60622. distance: number;
  60623. /** already optimized mesh */
  60624. optimizeMesh?: boolean | undefined;
  60625. /**
  60626. * Creates a SimplificationSettings
  60627. * @param quality expected quality
  60628. * @param distance distance when this optimized version should be used
  60629. * @param optimizeMesh already optimized mesh
  60630. */
  60631. constructor(
  60632. /** expected quality */
  60633. quality: number,
  60634. /** distance when this optimized version should be used */
  60635. distance: number,
  60636. /** already optimized mesh */
  60637. optimizeMesh?: boolean | undefined);
  60638. }
  60639. /**
  60640. * Interface used to define a simplification task
  60641. */
  60642. export interface ISimplificationTask {
  60643. /**
  60644. * Array of settings
  60645. */
  60646. settings: Array<ISimplificationSettings>;
  60647. /**
  60648. * Simplification type
  60649. */
  60650. simplificationType: SimplificationType;
  60651. /**
  60652. * Mesh to simplify
  60653. */
  60654. mesh: Mesh;
  60655. /**
  60656. * Callback called on success
  60657. */
  60658. successCallback?: () => void;
  60659. /**
  60660. * Defines if parallel processing can be used
  60661. */
  60662. parallelProcessing: boolean;
  60663. }
  60664. /**
  60665. * Queue used to order the simplification tasks
  60666. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60667. */
  60668. export class SimplificationQueue {
  60669. private _simplificationArray;
  60670. /**
  60671. * Gets a boolean indicating that the process is still running
  60672. */
  60673. running: boolean;
  60674. /**
  60675. * Creates a new queue
  60676. */
  60677. constructor();
  60678. /**
  60679. * Adds a new simplification task
  60680. * @param task defines a task to add
  60681. */
  60682. addTask(task: ISimplificationTask): void;
  60683. /**
  60684. * Execute next task
  60685. */
  60686. executeNext(): void;
  60687. /**
  60688. * Execute a simplification task
  60689. * @param task defines the task to run
  60690. */
  60691. runSimplification(task: ISimplificationTask): void;
  60692. private getSimplifier;
  60693. }
  60694. /**
  60695. * The implemented types of simplification
  60696. * At the moment only Quadratic Error Decimation is implemented
  60697. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60698. */
  60699. export enum SimplificationType {
  60700. /** Quadratic error decimation */
  60701. QUADRATIC = 0
  60702. }
  60703. }
  60704. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60705. import { Scene } from "babylonjs/scene";
  60706. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60707. import { ISceneComponent } from "babylonjs/sceneComponent";
  60708. module "babylonjs/scene" {
  60709. interface Scene {
  60710. /** @hidden (Backing field) */
  60711. _simplificationQueue: SimplificationQueue;
  60712. /**
  60713. * Gets or sets the simplification queue attached to the scene
  60714. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60715. */
  60716. simplificationQueue: SimplificationQueue;
  60717. }
  60718. }
  60719. module "babylonjs/Meshes/mesh" {
  60720. interface Mesh {
  60721. /**
  60722. * Simplify the mesh according to the given array of settings.
  60723. * Function will return immediately and will simplify async
  60724. * @param settings a collection of simplification settings
  60725. * @param parallelProcessing should all levels calculate parallel or one after the other
  60726. * @param simplificationType the type of simplification to run
  60727. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60728. * @returns the current mesh
  60729. */
  60730. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60731. }
  60732. }
  60733. /**
  60734. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60735. * created in a scene
  60736. */
  60737. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60738. /**
  60739. * The component name helpfull to identify the component in the list of scene components.
  60740. */
  60741. readonly name: string;
  60742. /**
  60743. * The scene the component belongs to.
  60744. */
  60745. scene: Scene;
  60746. /**
  60747. * Creates a new instance of the component for the given scene
  60748. * @param scene Defines the scene to register the component in
  60749. */
  60750. constructor(scene: Scene);
  60751. /**
  60752. * Registers the component in a given scene
  60753. */
  60754. register(): void;
  60755. /**
  60756. * Rebuilds the elements related to this component in case of
  60757. * context lost for instance.
  60758. */
  60759. rebuild(): void;
  60760. /**
  60761. * Disposes the component and the associated ressources
  60762. */
  60763. dispose(): void;
  60764. private _beforeCameraUpdate;
  60765. }
  60766. }
  60767. declare module "babylonjs/Meshes/Builders/index" {
  60768. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60769. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60770. export * from "babylonjs/Meshes/Builders/discBuilder";
  60771. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60772. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60773. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60774. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60775. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60776. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60777. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60778. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60779. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60780. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60781. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60782. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60783. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60784. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60785. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60786. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60787. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60788. }
  60789. declare module "babylonjs/Meshes/index" {
  60790. export * from "babylonjs/Meshes/abstractMesh";
  60791. export * from "babylonjs/Meshes/buffer";
  60792. export * from "babylonjs/Meshes/Compression/index";
  60793. export * from "babylonjs/Meshes/csg";
  60794. export * from "babylonjs/Meshes/geometry";
  60795. export * from "babylonjs/Meshes/groundMesh";
  60796. export * from "babylonjs/Meshes/trailMesh";
  60797. export * from "babylonjs/Meshes/instancedMesh";
  60798. export * from "babylonjs/Meshes/linesMesh";
  60799. export * from "babylonjs/Meshes/mesh";
  60800. export * from "babylonjs/Meshes/mesh.vertexData";
  60801. export * from "babylonjs/Meshes/meshBuilder";
  60802. export * from "babylonjs/Meshes/meshSimplification";
  60803. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60804. export * from "babylonjs/Meshes/polygonMesh";
  60805. export * from "babylonjs/Meshes/subMesh";
  60806. export * from "babylonjs/Meshes/meshLODLevel";
  60807. export * from "babylonjs/Meshes/transformNode";
  60808. export * from "babylonjs/Meshes/Builders/index";
  60809. export * from "babylonjs/Meshes/dataBuffer";
  60810. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60811. }
  60812. declare module "babylonjs/Morph/index" {
  60813. export * from "babylonjs/Morph/morphTarget";
  60814. export * from "babylonjs/Morph/morphTargetManager";
  60815. }
  60816. declare module "babylonjs/Navigation/INavigationEngine" {
  60817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60818. import { Vector3 } from "babylonjs/Maths/math";
  60819. import { Mesh } from "babylonjs/Meshes/mesh";
  60820. import { Scene } from "babylonjs/scene";
  60821. /**
  60822. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60823. */
  60824. export interface INavigationEnginePlugin {
  60825. /**
  60826. * plugin name
  60827. */
  60828. name: string;
  60829. /**
  60830. * Creates a navigation mesh
  60831. * @param meshes array of all the geometry used to compute the navigatio mesh
  60832. * @param parameters bunch of parameters used to filter geometry
  60833. */
  60834. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60835. /**
  60836. * Create a navigation mesh debug mesh
  60837. * @param scene is where the mesh will be added
  60838. * @returns debug display mesh
  60839. */
  60840. createDebugNavMesh(scene: Scene): Mesh;
  60841. /**
  60842. * Get a navigation mesh constrained position, closest to the parameter position
  60843. * @param position world position
  60844. * @returns the closest point to position constrained by the navigation mesh
  60845. */
  60846. getClosestPoint(position: Vector3): Vector3;
  60847. /**
  60848. * Get a navigation mesh constrained position, within a particular radius
  60849. * @param position world position
  60850. * @param maxRadius the maximum distance to the constrained world position
  60851. * @returns the closest point to position constrained by the navigation mesh
  60852. */
  60853. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60854. /**
  60855. * Compute the final position from a segment made of destination-position
  60856. * @param position world position
  60857. * @param destination world position
  60858. * @returns the resulting point along the navmesh
  60859. */
  60860. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60861. /**
  60862. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60863. * @param start world position
  60864. * @param end world position
  60865. * @returns array containing world position composing the path
  60866. */
  60867. computePath(start: Vector3, end: Vector3): Vector3[];
  60868. /**
  60869. * If this plugin is supported
  60870. * @returns true if plugin is supported
  60871. */
  60872. isSupported(): boolean;
  60873. /**
  60874. * Create a new Crowd so you can add agents
  60875. * @param maxAgents the maximum agent count in the crowd
  60876. * @param maxAgentRadius the maximum radius an agent can have
  60877. * @param scene to attach the crowd to
  60878. * @returns the crowd you can add agents to
  60879. */
  60880. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60881. /**
  60882. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60883. * The queries will try to find a solution within those bounds
  60884. * default is (1,1,1)
  60885. * @param extent x,y,z value that define the extent around the queries point of reference
  60886. */
  60887. setDefaultQueryExtent(extent: Vector3): void;
  60888. /**
  60889. * Get the Bounding box extent specified by setDefaultQueryExtent
  60890. * @returns the box extent values
  60891. */
  60892. getDefaultQueryExtent(): Vector3;
  60893. /**
  60894. * Release all resources
  60895. */
  60896. dispose(): void;
  60897. }
  60898. /**
  60899. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60900. */
  60901. export interface ICrowd {
  60902. /**
  60903. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60904. * You can attach anything to that node. The node position is updated in the scene update tick.
  60905. * @param pos world position that will be constrained by the navigation mesh
  60906. * @param parameters agent parameters
  60907. * @param transform hooked to the agent that will be update by the scene
  60908. * @returns agent index
  60909. */
  60910. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60911. /**
  60912. * Returns the agent position in world space
  60913. * @param index agent index returned by addAgent
  60914. * @returns world space position
  60915. */
  60916. getAgentPosition(index: number): Vector3;
  60917. /**
  60918. * Gets the agent velocity in world space
  60919. * @param index agent index returned by addAgent
  60920. * @returns world space velocity
  60921. */
  60922. getAgentVelocity(index: number): Vector3;
  60923. /**
  60924. * remove a particular agent previously created
  60925. * @param index agent index returned by addAgent
  60926. */
  60927. removeAgent(index: number): void;
  60928. /**
  60929. * get the list of all agents attached to this crowd
  60930. * @returns list of agent indices
  60931. */
  60932. getAgents(): number[];
  60933. /**
  60934. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60935. * @param deltaTime in seconds
  60936. */
  60937. update(deltaTime: number): void;
  60938. /**
  60939. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60940. * @param index agent index returned by addAgent
  60941. * @param destination targeted world position
  60942. */
  60943. agentGoto(index: number, destination: Vector3): void;
  60944. /**
  60945. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60946. * The queries will try to find a solution within those bounds
  60947. * default is (1,1,1)
  60948. * @param extent x,y,z value that define the extent around the queries point of reference
  60949. */
  60950. setDefaultQueryExtent(extent: Vector3): void;
  60951. /**
  60952. * Get the Bounding box extent specified by setDefaultQueryExtent
  60953. * @returns the box extent values
  60954. */
  60955. getDefaultQueryExtent(): Vector3;
  60956. /**
  60957. * Release all resources
  60958. */
  60959. dispose(): void;
  60960. }
  60961. /**
  60962. * Configures an agent
  60963. */
  60964. export interface IAgentParameters {
  60965. /**
  60966. * Agent radius. [Limit: >= 0]
  60967. */
  60968. radius: number;
  60969. /**
  60970. * Agent height. [Limit: > 0]
  60971. */
  60972. height: number;
  60973. /**
  60974. * Maximum allowed acceleration. [Limit: >= 0]
  60975. */
  60976. maxAcceleration: number;
  60977. /**
  60978. * Maximum allowed speed. [Limit: >= 0]
  60979. */
  60980. maxSpeed: number;
  60981. /**
  60982. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60983. */
  60984. collisionQueryRange: number;
  60985. /**
  60986. * The path visibility optimization range. [Limit: > 0]
  60987. */
  60988. pathOptimizationRange: number;
  60989. /**
  60990. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60991. */
  60992. separationWeight: number;
  60993. }
  60994. /**
  60995. * Configures the navigation mesh creation
  60996. */
  60997. export interface INavMeshParameters {
  60998. /**
  60999. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61000. */
  61001. cs: number;
  61002. /**
  61003. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61004. */
  61005. ch: number;
  61006. /**
  61007. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61008. */
  61009. walkableSlopeAngle: number;
  61010. /**
  61011. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61012. * be considered walkable. [Limit: >= 3] [Units: vx]
  61013. */
  61014. walkableHeight: number;
  61015. /**
  61016. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61017. */
  61018. walkableClimb: number;
  61019. /**
  61020. * The distance to erode/shrink the walkable area of the heightfield away from
  61021. * obstructions. [Limit: >=0] [Units: vx]
  61022. */
  61023. walkableRadius: number;
  61024. /**
  61025. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61026. */
  61027. maxEdgeLen: number;
  61028. /**
  61029. * The maximum distance a simplfied contour's border edges should deviate
  61030. * the original raw contour. [Limit: >=0] [Units: vx]
  61031. */
  61032. maxSimplificationError: number;
  61033. /**
  61034. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61035. */
  61036. minRegionArea: number;
  61037. /**
  61038. * Any regions with a span count smaller than this value will, if possible,
  61039. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61040. */
  61041. mergeRegionArea: number;
  61042. /**
  61043. * The maximum number of vertices allowed for polygons generated during the
  61044. * contour to polygon conversion process. [Limit: >= 3]
  61045. */
  61046. maxVertsPerPoly: number;
  61047. /**
  61048. * Sets the sampling distance to use when generating the detail mesh.
  61049. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61050. */
  61051. detailSampleDist: number;
  61052. /**
  61053. * The maximum distance the detail mesh surface should deviate from heightfield
  61054. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61055. */
  61056. detailSampleMaxError: number;
  61057. }
  61058. }
  61059. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61060. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61061. import { Mesh } from "babylonjs/Meshes/mesh";
  61062. import { Scene } from "babylonjs/scene";
  61063. import { Vector3 } from "babylonjs/Maths/math";
  61064. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61065. /**
  61066. * RecastJS navigation plugin
  61067. */
  61068. export class RecastJSPlugin implements INavigationEnginePlugin {
  61069. /**
  61070. * Reference to the Recast library
  61071. */
  61072. bjsRECAST: any;
  61073. /**
  61074. * plugin name
  61075. */
  61076. name: string;
  61077. /**
  61078. * the first navmesh created. We might extend this to support multiple navmeshes
  61079. */
  61080. navMesh: any;
  61081. /**
  61082. * Initializes the recastJS plugin
  61083. * @param recastInjection can be used to inject your own recast reference
  61084. */
  61085. constructor(recastInjection?: any);
  61086. /**
  61087. * Creates a navigation mesh
  61088. * @param meshes array of all the geometry used to compute the navigatio mesh
  61089. * @param parameters bunch of parameters used to filter geometry
  61090. */
  61091. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61092. /**
  61093. * Create a navigation mesh debug mesh
  61094. * @param scene is where the mesh will be added
  61095. * @returns debug display mesh
  61096. */
  61097. createDebugNavMesh(scene: Scene): Mesh;
  61098. /**
  61099. * Get a navigation mesh constrained position, closest to the parameter position
  61100. * @param position world position
  61101. * @returns the closest point to position constrained by the navigation mesh
  61102. */
  61103. getClosestPoint(position: Vector3): Vector3;
  61104. /**
  61105. * Get a navigation mesh constrained position, within a particular radius
  61106. * @param position world position
  61107. * @param maxRadius the maximum distance to the constrained world position
  61108. * @returns the closest point to position constrained by the navigation mesh
  61109. */
  61110. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61111. /**
  61112. * Compute the final position from a segment made of destination-position
  61113. * @param position world position
  61114. * @param destination world position
  61115. * @returns the resulting point along the navmesh
  61116. */
  61117. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61118. /**
  61119. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61120. * @param start world position
  61121. * @param end world position
  61122. * @returns array containing world position composing the path
  61123. */
  61124. computePath(start: Vector3, end: Vector3): Vector3[];
  61125. /**
  61126. * Create a new Crowd so you can add agents
  61127. * @param maxAgents the maximum agent count in the crowd
  61128. * @param maxAgentRadius the maximum radius an agent can have
  61129. * @param scene to attach the crowd to
  61130. * @returns the crowd you can add agents to
  61131. */
  61132. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61133. /**
  61134. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61135. * The queries will try to find a solution within those bounds
  61136. * default is (1,1,1)
  61137. * @param extent x,y,z value that define the extent around the queries point of reference
  61138. */
  61139. setDefaultQueryExtent(extent: Vector3): void;
  61140. /**
  61141. * Get the Bounding box extent specified by setDefaultQueryExtent
  61142. * @returns the box extent values
  61143. */
  61144. getDefaultQueryExtent(): Vector3;
  61145. /**
  61146. * Disposes
  61147. */
  61148. dispose(): void;
  61149. /**
  61150. * If this plugin is supported
  61151. * @returns true if plugin is supported
  61152. */
  61153. isSupported(): boolean;
  61154. }
  61155. /**
  61156. * Recast detour crowd implementation
  61157. */
  61158. export class RecastJSCrowd implements ICrowd {
  61159. /**
  61160. * Recast/detour plugin
  61161. */
  61162. bjsRECASTPlugin: RecastJSPlugin;
  61163. /**
  61164. * Link to the detour crowd
  61165. */
  61166. recastCrowd: any;
  61167. /**
  61168. * One transform per agent
  61169. */
  61170. transforms: TransformNode[];
  61171. /**
  61172. * All agents created
  61173. */
  61174. agents: number[];
  61175. /**
  61176. * Link to the scene is kept to unregister the crowd from the scene
  61177. */
  61178. private _scene;
  61179. /**
  61180. * Observer for crowd updates
  61181. */
  61182. private _onBeforeAnimationsObserver;
  61183. /**
  61184. * Constructor
  61185. * @param plugin recastJS plugin
  61186. * @param maxAgents the maximum agent count in the crowd
  61187. * @param maxAgentRadius the maximum radius an agent can have
  61188. * @param scene to attach the crowd to
  61189. * @returns the crowd you can add agents to
  61190. */
  61191. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61192. /**
  61193. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61194. * You can attach anything to that node. The node position is updated in the scene update tick.
  61195. * @param pos world position that will be constrained by the navigation mesh
  61196. * @param parameters agent parameters
  61197. * @param transform hooked to the agent that will be update by the scene
  61198. * @returns agent index
  61199. */
  61200. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61201. /**
  61202. * Returns the agent position in world space
  61203. * @param index agent index returned by addAgent
  61204. * @returns world space position
  61205. */
  61206. getAgentPosition(index: number): Vector3;
  61207. /**
  61208. * Returns the agent velocity in world space
  61209. * @param index agent index returned by addAgent
  61210. * @returns world space velocity
  61211. */
  61212. getAgentVelocity(index: number): Vector3;
  61213. /**
  61214. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61215. * @param index agent index returned by addAgent
  61216. * @param destination targeted world position
  61217. */
  61218. agentGoto(index: number, destination: Vector3): void;
  61219. /**
  61220. * remove a particular agent previously created
  61221. * @param index agent index returned by addAgent
  61222. */
  61223. removeAgent(index: number): void;
  61224. /**
  61225. * get the list of all agents attached to this crowd
  61226. * @returns list of agent indices
  61227. */
  61228. getAgents(): number[];
  61229. /**
  61230. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61231. * @param deltaTime in seconds
  61232. */
  61233. update(deltaTime: number): void;
  61234. /**
  61235. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61236. * The queries will try to find a solution within those bounds
  61237. * default is (1,1,1)
  61238. * @param extent x,y,z value that define the extent around the queries point of reference
  61239. */
  61240. setDefaultQueryExtent(extent: Vector3): void;
  61241. /**
  61242. * Get the Bounding box extent specified by setDefaultQueryExtent
  61243. * @returns the box extent values
  61244. */
  61245. getDefaultQueryExtent(): Vector3;
  61246. /**
  61247. * Release all resources
  61248. */
  61249. dispose(): void;
  61250. }
  61251. }
  61252. declare module "babylonjs/Navigation/Plugins/index" {
  61253. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61254. }
  61255. declare module "babylonjs/Navigation/index" {
  61256. export * from "babylonjs/Navigation/INavigationEngine";
  61257. export * from "babylonjs/Navigation/Plugins/index";
  61258. }
  61259. declare module "babylonjs/Offline/database" {
  61260. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61261. /**
  61262. * Class used to enable access to IndexedDB
  61263. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61264. */
  61265. export class Database implements IOfflineProvider {
  61266. private _callbackManifestChecked;
  61267. private _currentSceneUrl;
  61268. private _db;
  61269. private _enableSceneOffline;
  61270. private _enableTexturesOffline;
  61271. private _manifestVersionFound;
  61272. private _mustUpdateRessources;
  61273. private _hasReachedQuota;
  61274. private _isSupported;
  61275. private _idbFactory;
  61276. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61277. private static IsUASupportingBlobStorage;
  61278. /**
  61279. * Gets a boolean indicating if Database storate is enabled (off by default)
  61280. */
  61281. static IDBStorageEnabled: boolean;
  61282. /**
  61283. * Gets a boolean indicating if scene must be saved in the database
  61284. */
  61285. readonly enableSceneOffline: boolean;
  61286. /**
  61287. * Gets a boolean indicating if textures must be saved in the database
  61288. */
  61289. readonly enableTexturesOffline: boolean;
  61290. /**
  61291. * Creates a new Database
  61292. * @param urlToScene defines the url to load the scene
  61293. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61294. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61295. */
  61296. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61297. private static _ParseURL;
  61298. private static _ReturnFullUrlLocation;
  61299. private _checkManifestFile;
  61300. /**
  61301. * Open the database and make it available
  61302. * @param successCallback defines the callback to call on success
  61303. * @param errorCallback defines the callback to call on error
  61304. */
  61305. open(successCallback: () => void, errorCallback: () => void): void;
  61306. /**
  61307. * Loads an image from the database
  61308. * @param url defines the url to load from
  61309. * @param image defines the target DOM image
  61310. */
  61311. loadImage(url: string, image: HTMLImageElement): void;
  61312. private _loadImageFromDBAsync;
  61313. private _saveImageIntoDBAsync;
  61314. private _checkVersionFromDB;
  61315. private _loadVersionFromDBAsync;
  61316. private _saveVersionIntoDBAsync;
  61317. /**
  61318. * Loads a file from database
  61319. * @param url defines the URL to load from
  61320. * @param sceneLoaded defines a callback to call on success
  61321. * @param progressCallBack defines a callback to call when progress changed
  61322. * @param errorCallback defines a callback to call on error
  61323. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61324. */
  61325. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61326. private _loadFileAsync;
  61327. private _saveFileAsync;
  61328. /**
  61329. * Validates if xhr data is correct
  61330. * @param xhr defines the request to validate
  61331. * @param dataType defines the expected data type
  61332. * @returns true if data is correct
  61333. */
  61334. private static _ValidateXHRData;
  61335. }
  61336. }
  61337. declare module "babylonjs/Offline/index" {
  61338. export * from "babylonjs/Offline/database";
  61339. export * from "babylonjs/Offline/IOfflineProvider";
  61340. }
  61341. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61342. /** @hidden */
  61343. export var gpuUpdateParticlesPixelShader: {
  61344. name: string;
  61345. shader: string;
  61346. };
  61347. }
  61348. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61349. /** @hidden */
  61350. export var gpuUpdateParticlesVertexShader: {
  61351. name: string;
  61352. shader: string;
  61353. };
  61354. }
  61355. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61356. /** @hidden */
  61357. export var clipPlaneFragmentDeclaration2: {
  61358. name: string;
  61359. shader: string;
  61360. };
  61361. }
  61362. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61363. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61364. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61365. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61366. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61367. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61368. /** @hidden */
  61369. export var gpuRenderParticlesPixelShader: {
  61370. name: string;
  61371. shader: string;
  61372. };
  61373. }
  61374. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61375. /** @hidden */
  61376. export var clipPlaneVertexDeclaration2: {
  61377. name: string;
  61378. shader: string;
  61379. };
  61380. }
  61381. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61382. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61383. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61384. /** @hidden */
  61385. export var gpuRenderParticlesVertexShader: {
  61386. name: string;
  61387. shader: string;
  61388. };
  61389. }
  61390. declare module "babylonjs/Particles/gpuParticleSystem" {
  61391. import { Nullable } from "babylonjs/types";
  61392. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61393. import { Observable } from "babylonjs/Misc/observable";
  61394. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61395. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61396. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61397. import { Scene, IDisposable } from "babylonjs/scene";
  61398. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61399. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61400. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61401. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61402. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61403. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61404. /**
  61405. * This represents a GPU particle system in Babylon
  61406. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61407. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61408. */
  61409. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61410. /**
  61411. * The layer mask we are rendering the particles through.
  61412. */
  61413. layerMask: number;
  61414. private _capacity;
  61415. private _activeCount;
  61416. private _currentActiveCount;
  61417. private _accumulatedCount;
  61418. private _renderEffect;
  61419. private _updateEffect;
  61420. private _buffer0;
  61421. private _buffer1;
  61422. private _spriteBuffer;
  61423. private _updateVAO;
  61424. private _renderVAO;
  61425. private _targetIndex;
  61426. private _sourceBuffer;
  61427. private _targetBuffer;
  61428. private _engine;
  61429. private _currentRenderId;
  61430. private _started;
  61431. private _stopped;
  61432. private _timeDelta;
  61433. private _randomTexture;
  61434. private _randomTexture2;
  61435. private _attributesStrideSize;
  61436. private _updateEffectOptions;
  61437. private _randomTextureSize;
  61438. private _actualFrame;
  61439. private readonly _rawTextureWidth;
  61440. /**
  61441. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61442. */
  61443. static readonly IsSupported: boolean;
  61444. /**
  61445. * An event triggered when the system is disposed.
  61446. */
  61447. onDisposeObservable: Observable<GPUParticleSystem>;
  61448. /**
  61449. * Gets the maximum number of particles active at the same time.
  61450. * @returns The max number of active particles.
  61451. */
  61452. getCapacity(): number;
  61453. /**
  61454. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61455. * to override the particles.
  61456. */
  61457. forceDepthWrite: boolean;
  61458. /**
  61459. * Gets or set the number of active particles
  61460. */
  61461. activeParticleCount: number;
  61462. private _preWarmDone;
  61463. /**
  61464. * Is this system ready to be used/rendered
  61465. * @return true if the system is ready
  61466. */
  61467. isReady(): boolean;
  61468. /**
  61469. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61470. * @returns True if it has been started, otherwise false.
  61471. */
  61472. isStarted(): boolean;
  61473. /**
  61474. * Starts the particle system and begins to emit
  61475. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61476. */
  61477. start(delay?: number): void;
  61478. /**
  61479. * Stops the particle system.
  61480. */
  61481. stop(): void;
  61482. /**
  61483. * Remove all active particles
  61484. */
  61485. reset(): void;
  61486. /**
  61487. * Returns the string "GPUParticleSystem"
  61488. * @returns a string containing the class name
  61489. */
  61490. getClassName(): string;
  61491. private _colorGradientsTexture;
  61492. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61493. /**
  61494. * Adds a new color gradient
  61495. * @param gradient defines the gradient to use (between 0 and 1)
  61496. * @param color1 defines the color to affect to the specified gradient
  61497. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61498. * @returns the current particle system
  61499. */
  61500. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61501. /**
  61502. * Remove a specific color gradient
  61503. * @param gradient defines the gradient to remove
  61504. * @returns the current particle system
  61505. */
  61506. removeColorGradient(gradient: number): GPUParticleSystem;
  61507. private _angularSpeedGradientsTexture;
  61508. private _sizeGradientsTexture;
  61509. private _velocityGradientsTexture;
  61510. private _limitVelocityGradientsTexture;
  61511. private _dragGradientsTexture;
  61512. private _addFactorGradient;
  61513. /**
  61514. * Adds a new size gradient
  61515. * @param gradient defines the gradient to use (between 0 and 1)
  61516. * @param factor defines the size factor to affect to the specified gradient
  61517. * @returns the current particle system
  61518. */
  61519. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61520. /**
  61521. * Remove a specific size gradient
  61522. * @param gradient defines the gradient to remove
  61523. * @returns the current particle system
  61524. */
  61525. removeSizeGradient(gradient: number): GPUParticleSystem;
  61526. /**
  61527. * Adds a new angular speed gradient
  61528. * @param gradient defines the gradient to use (between 0 and 1)
  61529. * @param factor defines the angular speed to affect to the specified gradient
  61530. * @returns the current particle system
  61531. */
  61532. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61533. /**
  61534. * Remove a specific angular speed gradient
  61535. * @param gradient defines the gradient to remove
  61536. * @returns the current particle system
  61537. */
  61538. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61539. /**
  61540. * Adds a new velocity gradient
  61541. * @param gradient defines the gradient to use (between 0 and 1)
  61542. * @param factor defines the velocity to affect to the specified gradient
  61543. * @returns the current particle system
  61544. */
  61545. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61546. /**
  61547. * Remove a specific velocity gradient
  61548. * @param gradient defines the gradient to remove
  61549. * @returns the current particle system
  61550. */
  61551. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61552. /**
  61553. * Adds a new limit velocity gradient
  61554. * @param gradient defines the gradient to use (between 0 and 1)
  61555. * @param factor defines the limit velocity value to affect to the specified gradient
  61556. * @returns the current particle system
  61557. */
  61558. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61559. /**
  61560. * Remove a specific limit velocity gradient
  61561. * @param gradient defines the gradient to remove
  61562. * @returns the current particle system
  61563. */
  61564. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61565. /**
  61566. * Adds a new drag gradient
  61567. * @param gradient defines the gradient to use (between 0 and 1)
  61568. * @param factor defines the drag value to affect to the specified gradient
  61569. * @returns the current particle system
  61570. */
  61571. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61572. /**
  61573. * Remove a specific drag gradient
  61574. * @param gradient defines the gradient to remove
  61575. * @returns the current particle system
  61576. */
  61577. removeDragGradient(gradient: number): GPUParticleSystem;
  61578. /**
  61579. * Not supported by GPUParticleSystem
  61580. * @param gradient defines the gradient to use (between 0 and 1)
  61581. * @param factor defines the emit rate value to affect to the specified gradient
  61582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61583. * @returns the current particle system
  61584. */
  61585. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61586. /**
  61587. * Not supported by GPUParticleSystem
  61588. * @param gradient defines the gradient to remove
  61589. * @returns the current particle system
  61590. */
  61591. removeEmitRateGradient(gradient: number): IParticleSystem;
  61592. /**
  61593. * Not supported by GPUParticleSystem
  61594. * @param gradient defines the gradient to use (between 0 and 1)
  61595. * @param factor defines the start size value to affect to the specified gradient
  61596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61597. * @returns the current particle system
  61598. */
  61599. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61600. /**
  61601. * Not supported by GPUParticleSystem
  61602. * @param gradient defines the gradient to remove
  61603. * @returns the current particle system
  61604. */
  61605. removeStartSizeGradient(gradient: number): IParticleSystem;
  61606. /**
  61607. * Not supported by GPUParticleSystem
  61608. * @param gradient defines the gradient to use (between 0 and 1)
  61609. * @param min defines the color remap minimal range
  61610. * @param max defines the color remap maximal range
  61611. * @returns the current particle system
  61612. */
  61613. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61614. /**
  61615. * Not supported by GPUParticleSystem
  61616. * @param gradient defines the gradient to remove
  61617. * @returns the current particle system
  61618. */
  61619. removeColorRemapGradient(): IParticleSystem;
  61620. /**
  61621. * Not supported by GPUParticleSystem
  61622. * @param gradient defines the gradient to use (between 0 and 1)
  61623. * @param min defines the alpha remap minimal range
  61624. * @param max defines the alpha remap maximal range
  61625. * @returns the current particle system
  61626. */
  61627. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61628. /**
  61629. * Not supported by GPUParticleSystem
  61630. * @param gradient defines the gradient to remove
  61631. * @returns the current particle system
  61632. */
  61633. removeAlphaRemapGradient(): IParticleSystem;
  61634. /**
  61635. * Not supported by GPUParticleSystem
  61636. * @param gradient defines the gradient to use (between 0 and 1)
  61637. * @param color defines the color to affect to the specified gradient
  61638. * @returns the current particle system
  61639. */
  61640. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61641. /**
  61642. * Not supported by GPUParticleSystem
  61643. * @param gradient defines the gradient to remove
  61644. * @returns the current particle system
  61645. */
  61646. removeRampGradient(): IParticleSystem;
  61647. /**
  61648. * Not supported by GPUParticleSystem
  61649. * @returns the list of ramp gradients
  61650. */
  61651. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61652. /**
  61653. * Not supported by GPUParticleSystem
  61654. * Gets or sets a boolean indicating that ramp gradients must be used
  61655. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61656. */
  61657. useRampGradients: boolean;
  61658. /**
  61659. * Not supported by GPUParticleSystem
  61660. * @param gradient defines the gradient to use (between 0 and 1)
  61661. * @param factor defines the life time factor to affect to the specified gradient
  61662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61663. * @returns the current particle system
  61664. */
  61665. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61666. /**
  61667. * Not supported by GPUParticleSystem
  61668. * @param gradient defines the gradient to remove
  61669. * @returns the current particle system
  61670. */
  61671. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61672. /**
  61673. * Instantiates a GPU particle system.
  61674. * 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.
  61675. * @param name The name of the particle system
  61676. * @param options The options used to create the system
  61677. * @param scene The scene the particle system belongs to
  61678. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61679. */
  61680. constructor(name: string, options: Partial<{
  61681. capacity: number;
  61682. randomTextureSize: number;
  61683. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61684. protected _reset(): void;
  61685. private _createUpdateVAO;
  61686. private _createRenderVAO;
  61687. private _initialize;
  61688. /** @hidden */
  61689. _recreateUpdateEffect(): void;
  61690. /** @hidden */
  61691. _recreateRenderEffect(): void;
  61692. /**
  61693. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61694. * @param preWarm defines if we are in the pre-warmimg phase
  61695. */
  61696. animate(preWarm?: boolean): void;
  61697. private _createFactorGradientTexture;
  61698. private _createSizeGradientTexture;
  61699. private _createAngularSpeedGradientTexture;
  61700. private _createVelocityGradientTexture;
  61701. private _createLimitVelocityGradientTexture;
  61702. private _createDragGradientTexture;
  61703. private _createColorGradientTexture;
  61704. /**
  61705. * Renders the particle system in its current state
  61706. * @param preWarm defines if the system should only update the particles but not render them
  61707. * @returns the current number of particles
  61708. */
  61709. render(preWarm?: boolean): number;
  61710. /**
  61711. * Rebuilds the particle system
  61712. */
  61713. rebuild(): void;
  61714. private _releaseBuffers;
  61715. private _releaseVAOs;
  61716. /**
  61717. * Disposes the particle system and free the associated resources
  61718. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61719. */
  61720. dispose(disposeTexture?: boolean): void;
  61721. /**
  61722. * Clones the particle system.
  61723. * @param name The name of the cloned object
  61724. * @param newEmitter The new emitter to use
  61725. * @returns the cloned particle system
  61726. */
  61727. clone(name: string, newEmitter: any): GPUParticleSystem;
  61728. /**
  61729. * Serializes the particle system to a JSON object.
  61730. * @returns the JSON object
  61731. */
  61732. serialize(): any;
  61733. /**
  61734. * Parses a JSON object to create a GPU particle system.
  61735. * @param parsedParticleSystem The JSON object to parse
  61736. * @param scene The scene to create the particle system in
  61737. * @param rootUrl The root url to use to load external dependencies like texture
  61738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61739. * @returns the parsed GPU particle system
  61740. */
  61741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61742. }
  61743. }
  61744. declare module "babylonjs/Particles/particleSystemSet" {
  61745. import { Nullable } from "babylonjs/types";
  61746. import { Color3 } from "babylonjs/Maths/math.color";
  61747. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61749. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61750. import { Scene, IDisposable } from "babylonjs/scene";
  61751. /**
  61752. * Represents a set of particle systems working together to create a specific effect
  61753. */
  61754. export class ParticleSystemSet implements IDisposable {
  61755. /**
  61756. * Gets or sets base Assets URL
  61757. */
  61758. static BaseAssetsUrl: string;
  61759. private _emitterCreationOptions;
  61760. private _emitterNode;
  61761. /**
  61762. * Gets the particle system list
  61763. */
  61764. systems: IParticleSystem[];
  61765. /**
  61766. * Gets the emitter node used with this set
  61767. */
  61768. readonly emitterNode: Nullable<TransformNode>;
  61769. /**
  61770. * Creates a new emitter mesh as a sphere
  61771. * @param options defines the options used to create the sphere
  61772. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61773. * @param scene defines the hosting scene
  61774. */
  61775. setEmitterAsSphere(options: {
  61776. diameter: number;
  61777. segments: number;
  61778. color: Color3;
  61779. }, renderingGroupId: number, scene: Scene): void;
  61780. /**
  61781. * Starts all particle systems of the set
  61782. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61783. */
  61784. start(emitter?: AbstractMesh): void;
  61785. /**
  61786. * Release all associated resources
  61787. */
  61788. dispose(): void;
  61789. /**
  61790. * Serialize the set into a JSON compatible object
  61791. * @returns a JSON compatible representation of the set
  61792. */
  61793. serialize(): any;
  61794. /**
  61795. * Parse a new ParticleSystemSet from a serialized source
  61796. * @param data defines a JSON compatible representation of the set
  61797. * @param scene defines the hosting scene
  61798. * @param gpu defines if we want GPU particles or CPU particles
  61799. * @returns a new ParticleSystemSet
  61800. */
  61801. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61802. }
  61803. }
  61804. declare module "babylonjs/Particles/particleHelper" {
  61805. import { Nullable } from "babylonjs/types";
  61806. import { Scene } from "babylonjs/scene";
  61807. import { Vector3 } from "babylonjs/Maths/math.vector";
  61808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61809. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61810. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61811. /**
  61812. * This class is made for on one-liner static method to help creating particle system set.
  61813. */
  61814. export class ParticleHelper {
  61815. /**
  61816. * Gets or sets base Assets URL
  61817. */
  61818. static BaseAssetsUrl: string;
  61819. /**
  61820. * Create a default particle system that you can tweak
  61821. * @param emitter defines the emitter to use
  61822. * @param capacity defines the system capacity (default is 500 particles)
  61823. * @param scene defines the hosting scene
  61824. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61825. * @returns the new Particle system
  61826. */
  61827. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61828. /**
  61829. * This is the main static method (one-liner) of this helper to create different particle systems
  61830. * @param type This string represents the type to the particle system to create
  61831. * @param scene The scene where the particle system should live
  61832. * @param gpu If the system will use gpu
  61833. * @returns the ParticleSystemSet created
  61834. */
  61835. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61836. /**
  61837. * Static function used to export a particle system to a ParticleSystemSet variable.
  61838. * Please note that the emitter shape is not exported
  61839. * @param systems defines the particle systems to export
  61840. * @returns the created particle system set
  61841. */
  61842. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61843. }
  61844. }
  61845. declare module "babylonjs/Particles/particleSystemComponent" {
  61846. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61847. import { Effect } from "babylonjs/Materials/effect";
  61848. import "babylonjs/Shaders/particles.vertex";
  61849. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61850. module "babylonjs/Engines/engine" {
  61851. interface Engine {
  61852. /**
  61853. * Create an effect to use with particle systems.
  61854. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61855. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61856. * @param uniformsNames defines a list of attribute names
  61857. * @param samplers defines an array of string used to represent textures
  61858. * @param defines defines the string containing the defines to use to compile the shaders
  61859. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61860. * @param onCompiled defines a function to call when the effect creation is successful
  61861. * @param onError defines a function to call when the effect creation has failed
  61862. * @returns the new Effect
  61863. */
  61864. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61865. }
  61866. }
  61867. module "babylonjs/Meshes/mesh" {
  61868. interface Mesh {
  61869. /**
  61870. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61871. * @returns an array of IParticleSystem
  61872. */
  61873. getEmittedParticleSystems(): IParticleSystem[];
  61874. /**
  61875. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61876. * @returns an array of IParticleSystem
  61877. */
  61878. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61879. }
  61880. }
  61881. /**
  61882. * @hidden
  61883. */
  61884. export var _IDoNeedToBeInTheBuild: number;
  61885. }
  61886. declare module "babylonjs/Particles/pointsCloudSystem" {
  61887. import { Color4 } from "babylonjs/Maths/math";
  61888. import { Mesh } from "babylonjs/Meshes/mesh";
  61889. import { Scene, IDisposable } from "babylonjs/scene";
  61890. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61891. /** Defines the 4 color options */
  61892. export enum PointColor {
  61893. /** color value */
  61894. Color = 2,
  61895. /** uv value */
  61896. UV = 1,
  61897. /** random value */
  61898. Random = 0,
  61899. /** stated value */
  61900. Stated = 3
  61901. }
  61902. /**
  61903. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61904. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  61905. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61906. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61907. *
  61908. * Full documentation here : TO BE ENTERED
  61909. */
  61910. export class PointsCloudSystem implements IDisposable {
  61911. /**
  61912. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61913. * Example : var p = SPS.particles[i];
  61914. */
  61915. particles: CloudPoint[];
  61916. /**
  61917. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61918. */
  61919. nbParticles: number;
  61920. /**
  61921. * This a counter for your own usage. It's not set by any SPS functions.
  61922. */
  61923. counter: number;
  61924. /**
  61925. * The PCS name. This name is also given to the underlying mesh.
  61926. */
  61927. name: string;
  61928. /**
  61929. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61930. */
  61931. mesh: Mesh;
  61932. /**
  61933. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61934. * Please read :
  61935. */
  61936. vars: any;
  61937. /**
  61938. * @hidden
  61939. */
  61940. _size: number;
  61941. private _scene;
  61942. private _promises;
  61943. private _positions;
  61944. private _indices;
  61945. private _normals;
  61946. private _colors;
  61947. private _uvs;
  61948. private _indices32;
  61949. private _positions32;
  61950. private _colors32;
  61951. private _uvs32;
  61952. private _updatable;
  61953. private _isVisibilityBoxLocked;
  61954. private _alwaysVisible;
  61955. private _groups;
  61956. private _groupCounter;
  61957. private _computeParticleColor;
  61958. private _computeParticleTexture;
  61959. private _computeParticleRotation;
  61960. private _computeBoundingBox;
  61961. private _isReady;
  61962. /**
  61963. * Creates a PCS (Points Cloud System) object
  61964. * @param name (String) is the PCS name, this will be the underlying mesh name
  61965. * @param pointSize (number) is the size for each point
  61966. * @param scene (Scene) is the scene in which the PCS is added
  61967. * @param options defines the options of the PCS e.g.
  61968. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61969. */
  61970. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61971. updatable?: boolean;
  61972. });
  61973. /**
  61974. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61975. * If no points were added to the PCS, the returned mesh is just a single point.
  61976. * @returns a promise for the created mesh
  61977. */
  61978. buildMeshAsync(): Promise<Mesh>;
  61979. /**
  61980. * @hidden
  61981. */
  61982. private _buildMesh;
  61983. private _addParticle;
  61984. private _randomUnitVector;
  61985. private _getColorIndicesForCoord;
  61986. private _setPointsColorOrUV;
  61987. private _colorFromTexture;
  61988. private _calculateDensity;
  61989. /**
  61990. * Adds points to the PCS in random positions within a unit sphere
  61991. * @param nb (positive integer) the number of particles to be created from this model
  61992. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61993. * @returns the number of groups in the system
  61994. */
  61995. addPoints(nb: number, pointFunction?: any): number;
  61996. /**
  61997. * Adds points to the PCS from the surface of the model shape
  61998. * @param mesh is any Mesh object that will be used as a surface model for the points
  61999. * @param nb (positive integer) the number of particles to be created from this model
  62000. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62001. * @param color (color3) to be used when colorWith is stated
  62002. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62003. * @returns the number of groups in the system
  62004. */
  62005. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  62006. /**
  62007. * Adds points to the PCS inside the model shape
  62008. * @param mesh is any Mesh object that will be used as a surface model for the points
  62009. * @param nb (positive integer) the number of particles to be created from this model
  62010. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  62011. * @param color (color4) to be used when colorWith is stated
  62012. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62013. * @returns the number of groups in the system
  62014. */
  62015. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  62016. /**
  62017. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62018. * This method calls `updateParticle()` for each particle of the SPS.
  62019. * For an animated SPS, it is usually called within the render loop.
  62020. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62021. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62022. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62023. * @returns the PCS.
  62024. */
  62025. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62026. /**
  62027. * Disposes the PCS.
  62028. */
  62029. dispose(): void;
  62030. /**
  62031. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62032. * doc :
  62033. * @returns the PCS.
  62034. */
  62035. refreshVisibleSize(): PointsCloudSystem;
  62036. /**
  62037. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62038. * @param size the size (float) of the visibility box
  62039. * note : this doesn't lock the PCS mesh bounding box.
  62040. * doc :
  62041. */
  62042. setVisibilityBox(size: number): void;
  62043. /**
  62044. * Gets whether the PCS is always visible or not
  62045. * doc :
  62046. */
  62047. /**
  62048. * Sets the PCS as always visible or not
  62049. * doc :
  62050. */
  62051. isAlwaysVisible: boolean;
  62052. /**
  62053. * Tells to `setParticles()` to compute the particle rotations or not
  62054. * Default value : false. The PCS is faster when it's set to false
  62055. * Note : particle rotations are only applied to parent particles
  62056. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62057. */
  62058. computeParticleRotation: boolean;
  62059. /**
  62060. * Tells to `setParticles()` to compute the particle colors or not.
  62061. * Default value : true. The PCS is faster when it's set to false.
  62062. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62063. */
  62064. /**
  62065. * Gets if `setParticles()` computes the particle colors or not.
  62066. * Default value : false. The PCS is faster when it's set to false.
  62067. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62068. */
  62069. computeParticleColor: boolean;
  62070. /**
  62071. * Gets if `setParticles()` computes the particle textures or not.
  62072. * Default value : false. The PCS is faster when it's set to false.
  62073. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62074. */
  62075. computeParticleTexture: boolean;
  62076. /**
  62077. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62078. */
  62079. /**
  62080. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62081. */
  62082. computeBoundingBox: boolean;
  62083. /**
  62084. * This function does nothing. It may be overwritten to set all the particle first values.
  62085. * The PCS doesn't call this function, you may have to call it by your own.
  62086. * doc :
  62087. */
  62088. initParticles(): void;
  62089. /**
  62090. * This function does nothing. It may be overwritten to recycle a particle
  62091. * The PCS doesn't call this function, you can to call it
  62092. * doc :
  62093. * @param particle The particle to recycle
  62094. * @returns the recycled particle
  62095. */
  62096. recycleParticle(particle: CloudPoint): CloudPoint;
  62097. /**
  62098. * Updates a particle : this function should be overwritten by the user.
  62099. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62100. * doc :
  62101. * @example : just set a particle position or velocity and recycle conditions
  62102. * @param particle The particle to update
  62103. * @returns the updated particle
  62104. */
  62105. updateParticle(particle: CloudPoint): CloudPoint;
  62106. /**
  62107. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62108. * This does nothing and may be overwritten by the user.
  62109. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62110. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62111. * @param update the boolean update value actually passed to setParticles()
  62112. */
  62113. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62114. /**
  62115. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62116. * This will be passed three parameters.
  62117. * This does nothing and may be overwritten by the user.
  62118. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62119. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62120. * @param update the boolean update value actually passed to setParticles()
  62121. */
  62122. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62123. }
  62124. }
  62125. declare module "babylonjs/Particles/cloudPoint" {
  62126. import { Nullable } from "babylonjs/types";
  62127. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62128. import { Mesh } from "babylonjs/Meshes/mesh";
  62129. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62130. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62131. /**
  62132. * Represents one particle of a points cloud system.
  62133. */
  62134. export class CloudPoint {
  62135. /**
  62136. * particle global index
  62137. */
  62138. idx: number;
  62139. /**
  62140. * The color of the particle
  62141. */
  62142. color: Nullable<Color4>;
  62143. /**
  62144. * The world space position of the particle.
  62145. */
  62146. position: Vector3;
  62147. /**
  62148. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62149. */
  62150. rotation: Vector3;
  62151. /**
  62152. * The world space rotation quaternion of the particle.
  62153. */
  62154. rotationQuaternion: Nullable<Quaternion>;
  62155. /**
  62156. * The uv of the particle.
  62157. */
  62158. uv: Nullable<Vector2>;
  62159. /**
  62160. * The current speed of the particle.
  62161. */
  62162. velocity: Vector3;
  62163. /**
  62164. * The pivot point in the particle local space.
  62165. */
  62166. pivot: Vector3;
  62167. /**
  62168. * Must the particle be translated from its pivot point in its local space ?
  62169. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62170. * Default : false
  62171. */
  62172. translateFromPivot: boolean;
  62173. /**
  62174. * Index of this particle in the global "positions" array (Internal use)
  62175. * @hidden
  62176. */
  62177. _pos: number;
  62178. /**
  62179. * @hidden Index of this particle in the global "indices" array (Internal use)
  62180. */
  62181. _ind: number;
  62182. /**
  62183. * Group this particle belongs to
  62184. */
  62185. _group: PointsGroup;
  62186. /**
  62187. * Group id of this particle
  62188. */
  62189. groupId: number;
  62190. /**
  62191. * Index of the particle in its group id (Internal use)
  62192. */
  62193. idxInGroup: number;
  62194. /**
  62195. * @hidden Particle BoundingInfo object (Internal use)
  62196. */
  62197. _boundingInfo: BoundingInfo;
  62198. /**
  62199. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62200. */
  62201. _pcs: PointsCloudSystem;
  62202. /**
  62203. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62204. */
  62205. _stillInvisible: boolean;
  62206. /**
  62207. * @hidden Last computed particle rotation matrix
  62208. */
  62209. _rotationMatrix: number[];
  62210. /**
  62211. * Parent particle Id, if any.
  62212. * Default null.
  62213. */
  62214. parentId: Nullable<number>;
  62215. /**
  62216. * @hidden Internal global position in the PCS.
  62217. */
  62218. _globalPosition: Vector3;
  62219. /**
  62220. * Creates a Point Cloud object.
  62221. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62222. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62223. * @param group (PointsGroup) is the group the particle belongs to
  62224. * @param groupId (integer) is the group identifier in the PCS.
  62225. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62226. * @param pcs defines the PCS it is associated to
  62227. */
  62228. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62229. /**
  62230. * get point size
  62231. */
  62232. /**
  62233. * Set point size
  62234. */
  62235. size: Vector3;
  62236. /**
  62237. * Legacy support, changed quaternion to rotationQuaternion
  62238. */
  62239. /**
  62240. * Legacy support, changed quaternion to rotationQuaternion
  62241. */
  62242. quaternion: Nullable<Quaternion>;
  62243. /**
  62244. * Returns a boolean. True if the particle intersects a mesh, else false
  62245. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62246. * @param target is the object (point or mesh) what the intersection is computed against
  62247. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62248. * @returns true if it intersects
  62249. */
  62250. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62251. /**
  62252. * get the rotation matrix of the particle
  62253. * @hidden
  62254. */
  62255. getRotationMatrix(m: Matrix): void;
  62256. }
  62257. /**
  62258. * Represents a group of points in a points cloud system
  62259. * * PCS internal tool, don't use it manually.
  62260. */
  62261. export class PointsGroup {
  62262. /**
  62263. * The group id
  62264. * @hidden
  62265. */
  62266. groupID: number;
  62267. /**
  62268. * image data for group (internal use)
  62269. * @hidden
  62270. */
  62271. _groupImageData: Nullable<ArrayBufferView>;
  62272. /**
  62273. * Image Width (internal use)
  62274. * @hidden
  62275. */
  62276. _groupImgWidth: number;
  62277. /**
  62278. * Image Height (internal use)
  62279. * @hidden
  62280. */
  62281. _groupImgHeight: number;
  62282. /**
  62283. * Custom position function (internal use)
  62284. * @hidden
  62285. */
  62286. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62287. /**
  62288. * density per facet for surface points
  62289. * @hidden
  62290. */
  62291. _groupDensity: number[];
  62292. /**
  62293. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62294. * PCS internal tool, don't use it manually.
  62295. * @hidden
  62296. */
  62297. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62298. }
  62299. }
  62300. declare module "babylonjs/Particles/index" {
  62301. export * from "babylonjs/Particles/baseParticleSystem";
  62302. export * from "babylonjs/Particles/EmitterTypes/index";
  62303. export * from "babylonjs/Particles/gpuParticleSystem";
  62304. export * from "babylonjs/Particles/IParticleSystem";
  62305. export * from "babylonjs/Particles/particle";
  62306. export * from "babylonjs/Particles/particleHelper";
  62307. export * from "babylonjs/Particles/particleSystem";
  62308. export * from "babylonjs/Particles/particleSystemComponent";
  62309. export * from "babylonjs/Particles/particleSystemSet";
  62310. export * from "babylonjs/Particles/solidParticle";
  62311. export * from "babylonjs/Particles/solidParticleSystem";
  62312. export * from "babylonjs/Particles/cloudPoint";
  62313. export * from "babylonjs/Particles/pointsCloudSystem";
  62314. export * from "babylonjs/Particles/subEmitter";
  62315. }
  62316. declare module "babylonjs/Physics/physicsEngineComponent" {
  62317. import { Nullable } from "babylonjs/types";
  62318. import { Observable, Observer } from "babylonjs/Misc/observable";
  62319. import { Vector3 } from "babylonjs/Maths/math.vector";
  62320. import { Mesh } from "babylonjs/Meshes/mesh";
  62321. import { ISceneComponent } from "babylonjs/sceneComponent";
  62322. import { Scene } from "babylonjs/scene";
  62323. import { Node } from "babylonjs/node";
  62324. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62325. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62326. module "babylonjs/scene" {
  62327. interface Scene {
  62328. /** @hidden (Backing field) */
  62329. _physicsEngine: Nullable<IPhysicsEngine>;
  62330. /**
  62331. * Gets the current physics engine
  62332. * @returns a IPhysicsEngine or null if none attached
  62333. */
  62334. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62335. /**
  62336. * Enables physics to the current scene
  62337. * @param gravity defines the scene's gravity for the physics engine
  62338. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62339. * @return a boolean indicating if the physics engine was initialized
  62340. */
  62341. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62342. /**
  62343. * Disables and disposes the physics engine associated with the scene
  62344. */
  62345. disablePhysicsEngine(): void;
  62346. /**
  62347. * Gets a boolean indicating if there is an active physics engine
  62348. * @returns a boolean indicating if there is an active physics engine
  62349. */
  62350. isPhysicsEnabled(): boolean;
  62351. /**
  62352. * Deletes a physics compound impostor
  62353. * @param compound defines the compound to delete
  62354. */
  62355. deleteCompoundImpostor(compound: any): void;
  62356. /**
  62357. * An event triggered when physic simulation is about to be run
  62358. */
  62359. onBeforePhysicsObservable: Observable<Scene>;
  62360. /**
  62361. * An event triggered when physic simulation has been done
  62362. */
  62363. onAfterPhysicsObservable: Observable<Scene>;
  62364. }
  62365. }
  62366. module "babylonjs/Meshes/abstractMesh" {
  62367. interface AbstractMesh {
  62368. /** @hidden */
  62369. _physicsImpostor: Nullable<PhysicsImpostor>;
  62370. /**
  62371. * Gets or sets impostor used for physic simulation
  62372. * @see http://doc.babylonjs.com/features/physics_engine
  62373. */
  62374. physicsImpostor: Nullable<PhysicsImpostor>;
  62375. /**
  62376. * Gets the current physics impostor
  62377. * @see http://doc.babylonjs.com/features/physics_engine
  62378. * @returns a physics impostor or null
  62379. */
  62380. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62381. /** Apply a physic impulse to the mesh
  62382. * @param force defines the force to apply
  62383. * @param contactPoint defines where to apply the force
  62384. * @returns the current mesh
  62385. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62386. */
  62387. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62388. /**
  62389. * Creates a physic joint between two meshes
  62390. * @param otherMesh defines the other mesh to use
  62391. * @param pivot1 defines the pivot to use on this mesh
  62392. * @param pivot2 defines the pivot to use on the other mesh
  62393. * @param options defines additional options (can be plugin dependent)
  62394. * @returns the current mesh
  62395. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62396. */
  62397. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62398. /** @hidden */
  62399. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62400. }
  62401. }
  62402. /**
  62403. * Defines the physics engine scene component responsible to manage a physics engine
  62404. */
  62405. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62406. /**
  62407. * The component name helpful to identify the component in the list of scene components.
  62408. */
  62409. readonly name: string;
  62410. /**
  62411. * The scene the component belongs to.
  62412. */
  62413. scene: Scene;
  62414. /**
  62415. * Creates a new instance of the component for the given scene
  62416. * @param scene Defines the scene to register the component in
  62417. */
  62418. constructor(scene: Scene);
  62419. /**
  62420. * Registers the component in a given scene
  62421. */
  62422. register(): void;
  62423. /**
  62424. * Rebuilds the elements related to this component in case of
  62425. * context lost for instance.
  62426. */
  62427. rebuild(): void;
  62428. /**
  62429. * Disposes the component and the associated ressources
  62430. */
  62431. dispose(): void;
  62432. }
  62433. }
  62434. declare module "babylonjs/Physics/physicsHelper" {
  62435. import { Nullable } from "babylonjs/types";
  62436. import { Vector3 } from "babylonjs/Maths/math.vector";
  62437. import { Mesh } from "babylonjs/Meshes/mesh";
  62438. import { Scene } from "babylonjs/scene";
  62439. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62440. /**
  62441. * A helper for physics simulations
  62442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62443. */
  62444. export class PhysicsHelper {
  62445. private _scene;
  62446. private _physicsEngine;
  62447. /**
  62448. * Initializes the Physics helper
  62449. * @param scene Babylon.js scene
  62450. */
  62451. constructor(scene: Scene);
  62452. /**
  62453. * Applies a radial explosion impulse
  62454. * @param origin the origin of the explosion
  62455. * @param radiusOrEventOptions the radius or the options of radial explosion
  62456. * @param strength the explosion strength
  62457. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62458. * @returns A physics radial explosion event, or null
  62459. */
  62460. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62461. /**
  62462. * Applies a radial explosion force
  62463. * @param origin the origin of the explosion
  62464. * @param radiusOrEventOptions the radius or the options of radial explosion
  62465. * @param strength the explosion strength
  62466. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62467. * @returns A physics radial explosion event, or null
  62468. */
  62469. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62470. /**
  62471. * Creates a gravitational field
  62472. * @param origin the origin of the explosion
  62473. * @param radiusOrEventOptions the radius or the options of radial explosion
  62474. * @param strength the explosion strength
  62475. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62476. * @returns A physics gravitational field event, or null
  62477. */
  62478. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62479. /**
  62480. * Creates a physics updraft event
  62481. * @param origin the origin of the updraft
  62482. * @param radiusOrEventOptions the radius or the options of the updraft
  62483. * @param strength the strength of the updraft
  62484. * @param height the height of the updraft
  62485. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62486. * @returns A physics updraft event, or null
  62487. */
  62488. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62489. /**
  62490. * Creates a physics vortex event
  62491. * @param origin the of the vortex
  62492. * @param radiusOrEventOptions the radius or the options of the vortex
  62493. * @param strength the strength of the vortex
  62494. * @param height the height of the vortex
  62495. * @returns a Physics vortex event, or null
  62496. * A physics vortex event or null
  62497. */
  62498. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62499. }
  62500. /**
  62501. * Represents a physics radial explosion event
  62502. */
  62503. class PhysicsRadialExplosionEvent {
  62504. private _scene;
  62505. private _options;
  62506. private _sphere;
  62507. private _dataFetched;
  62508. /**
  62509. * Initializes a radial explosioin event
  62510. * @param _scene BabylonJS scene
  62511. * @param _options The options for the vortex event
  62512. */
  62513. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62514. /**
  62515. * Returns the data related to the radial explosion event (sphere).
  62516. * @returns The radial explosion event data
  62517. */
  62518. getData(): PhysicsRadialExplosionEventData;
  62519. /**
  62520. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62521. * @param impostor A physics imposter
  62522. * @param origin the origin of the explosion
  62523. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62524. */
  62525. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62526. /**
  62527. * Triggers affecterd impostors callbacks
  62528. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62529. */
  62530. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62531. /**
  62532. * Disposes the sphere.
  62533. * @param force Specifies if the sphere should be disposed by force
  62534. */
  62535. dispose(force?: boolean): void;
  62536. /*** Helpers ***/
  62537. private _prepareSphere;
  62538. private _intersectsWithSphere;
  62539. }
  62540. /**
  62541. * Represents a gravitational field event
  62542. */
  62543. class PhysicsGravitationalFieldEvent {
  62544. private _physicsHelper;
  62545. private _scene;
  62546. private _origin;
  62547. private _options;
  62548. private _tickCallback;
  62549. private _sphere;
  62550. private _dataFetched;
  62551. /**
  62552. * Initializes the physics gravitational field event
  62553. * @param _physicsHelper A physics helper
  62554. * @param _scene BabylonJS scene
  62555. * @param _origin The origin position of the gravitational field event
  62556. * @param _options The options for the vortex event
  62557. */
  62558. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62559. /**
  62560. * Returns the data related to the gravitational field event (sphere).
  62561. * @returns A gravitational field event
  62562. */
  62563. getData(): PhysicsGravitationalFieldEventData;
  62564. /**
  62565. * Enables the gravitational field.
  62566. */
  62567. enable(): void;
  62568. /**
  62569. * Disables the gravitational field.
  62570. */
  62571. disable(): void;
  62572. /**
  62573. * Disposes the sphere.
  62574. * @param force The force to dispose from the gravitational field event
  62575. */
  62576. dispose(force?: boolean): void;
  62577. private _tick;
  62578. }
  62579. /**
  62580. * Represents a physics updraft event
  62581. */
  62582. class PhysicsUpdraftEvent {
  62583. private _scene;
  62584. private _origin;
  62585. private _options;
  62586. private _physicsEngine;
  62587. private _originTop;
  62588. private _originDirection;
  62589. private _tickCallback;
  62590. private _cylinder;
  62591. private _cylinderPosition;
  62592. private _dataFetched;
  62593. /**
  62594. * Initializes the physics updraft event
  62595. * @param _scene BabylonJS scene
  62596. * @param _origin The origin position of the updraft
  62597. * @param _options The options for the updraft event
  62598. */
  62599. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62600. /**
  62601. * Returns the data related to the updraft event (cylinder).
  62602. * @returns A physics updraft event
  62603. */
  62604. getData(): PhysicsUpdraftEventData;
  62605. /**
  62606. * Enables the updraft.
  62607. */
  62608. enable(): void;
  62609. /**
  62610. * Disables the updraft.
  62611. */
  62612. disable(): void;
  62613. /**
  62614. * Disposes the cylinder.
  62615. * @param force Specifies if the updraft should be disposed by force
  62616. */
  62617. dispose(force?: boolean): void;
  62618. private getImpostorHitData;
  62619. private _tick;
  62620. /*** Helpers ***/
  62621. private _prepareCylinder;
  62622. private _intersectsWithCylinder;
  62623. }
  62624. /**
  62625. * Represents a physics vortex event
  62626. */
  62627. class PhysicsVortexEvent {
  62628. private _scene;
  62629. private _origin;
  62630. private _options;
  62631. private _physicsEngine;
  62632. private _originTop;
  62633. private _tickCallback;
  62634. private _cylinder;
  62635. private _cylinderPosition;
  62636. private _dataFetched;
  62637. /**
  62638. * Initializes the physics vortex event
  62639. * @param _scene The BabylonJS scene
  62640. * @param _origin The origin position of the vortex
  62641. * @param _options The options for the vortex event
  62642. */
  62643. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62644. /**
  62645. * Returns the data related to the vortex event (cylinder).
  62646. * @returns The physics vortex event data
  62647. */
  62648. getData(): PhysicsVortexEventData;
  62649. /**
  62650. * Enables the vortex.
  62651. */
  62652. enable(): void;
  62653. /**
  62654. * Disables the cortex.
  62655. */
  62656. disable(): void;
  62657. /**
  62658. * Disposes the sphere.
  62659. * @param force
  62660. */
  62661. dispose(force?: boolean): void;
  62662. private getImpostorHitData;
  62663. private _tick;
  62664. /*** Helpers ***/
  62665. private _prepareCylinder;
  62666. private _intersectsWithCylinder;
  62667. }
  62668. /**
  62669. * Options fot the radial explosion event
  62670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62671. */
  62672. export class PhysicsRadialExplosionEventOptions {
  62673. /**
  62674. * The radius of the sphere for the radial explosion.
  62675. */
  62676. radius: number;
  62677. /**
  62678. * The strenth of the explosion.
  62679. */
  62680. strength: number;
  62681. /**
  62682. * The strenght of the force in correspondence to the distance of the affected object
  62683. */
  62684. falloff: PhysicsRadialImpulseFalloff;
  62685. /**
  62686. * Sphere options for the radial explosion.
  62687. */
  62688. sphere: {
  62689. segments: number;
  62690. diameter: number;
  62691. };
  62692. /**
  62693. * Sphere options for the radial explosion.
  62694. */
  62695. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62696. }
  62697. /**
  62698. * Options fot the updraft event
  62699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62700. */
  62701. export class PhysicsUpdraftEventOptions {
  62702. /**
  62703. * The radius of the cylinder for the vortex
  62704. */
  62705. radius: number;
  62706. /**
  62707. * The strenth of the updraft.
  62708. */
  62709. strength: number;
  62710. /**
  62711. * The height of the cylinder for the updraft.
  62712. */
  62713. height: number;
  62714. /**
  62715. * The mode for the the updraft.
  62716. */
  62717. updraftMode: PhysicsUpdraftMode;
  62718. }
  62719. /**
  62720. * Options fot the vortex event
  62721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62722. */
  62723. export class PhysicsVortexEventOptions {
  62724. /**
  62725. * The radius of the cylinder for the vortex
  62726. */
  62727. radius: number;
  62728. /**
  62729. * The strenth of the vortex.
  62730. */
  62731. strength: number;
  62732. /**
  62733. * The height of the cylinder for the vortex.
  62734. */
  62735. height: number;
  62736. /**
  62737. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62738. */
  62739. centripetalForceThreshold: number;
  62740. /**
  62741. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62742. */
  62743. centripetalForceMultiplier: number;
  62744. /**
  62745. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62746. */
  62747. centrifugalForceMultiplier: number;
  62748. /**
  62749. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62750. */
  62751. updraftForceMultiplier: number;
  62752. }
  62753. /**
  62754. * The strenght of the force in correspondence to the distance of the affected object
  62755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62756. */
  62757. export enum PhysicsRadialImpulseFalloff {
  62758. /** Defines that impulse is constant in strength across it's whole radius */
  62759. Constant = 0,
  62760. /** Defines that impulse gets weaker if it's further from the origin */
  62761. Linear = 1
  62762. }
  62763. /**
  62764. * The strength of the force in correspondence to the distance of the affected object
  62765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62766. */
  62767. export enum PhysicsUpdraftMode {
  62768. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62769. Center = 0,
  62770. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62771. Perpendicular = 1
  62772. }
  62773. /**
  62774. * Interface for a physics hit data
  62775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62776. */
  62777. export interface PhysicsHitData {
  62778. /**
  62779. * The force applied at the contact point
  62780. */
  62781. force: Vector3;
  62782. /**
  62783. * The contact point
  62784. */
  62785. contactPoint: Vector3;
  62786. /**
  62787. * The distance from the origin to the contact point
  62788. */
  62789. distanceFromOrigin: number;
  62790. }
  62791. /**
  62792. * Interface for radial explosion event data
  62793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62794. */
  62795. export interface PhysicsRadialExplosionEventData {
  62796. /**
  62797. * A sphere used for the radial explosion event
  62798. */
  62799. sphere: Mesh;
  62800. }
  62801. /**
  62802. * Interface for gravitational field event data
  62803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62804. */
  62805. export interface PhysicsGravitationalFieldEventData {
  62806. /**
  62807. * A sphere mesh used for the gravitational field event
  62808. */
  62809. sphere: Mesh;
  62810. }
  62811. /**
  62812. * Interface for updraft event data
  62813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62814. */
  62815. export interface PhysicsUpdraftEventData {
  62816. /**
  62817. * A cylinder used for the updraft event
  62818. */
  62819. cylinder: Mesh;
  62820. }
  62821. /**
  62822. * Interface for vortex event data
  62823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62824. */
  62825. export interface PhysicsVortexEventData {
  62826. /**
  62827. * A cylinder used for the vortex event
  62828. */
  62829. cylinder: Mesh;
  62830. }
  62831. /**
  62832. * Interface for an affected physics impostor
  62833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62834. */
  62835. export interface PhysicsAffectedImpostorWithData {
  62836. /**
  62837. * The impostor affected by the effect
  62838. */
  62839. impostor: PhysicsImpostor;
  62840. /**
  62841. * The data about the hit/horce from the explosion
  62842. */
  62843. hitData: PhysicsHitData;
  62844. }
  62845. }
  62846. declare module "babylonjs/Physics/Plugins/index" {
  62847. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62848. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62849. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62850. }
  62851. declare module "babylonjs/Physics/index" {
  62852. export * from "babylonjs/Physics/IPhysicsEngine";
  62853. export * from "babylonjs/Physics/physicsEngine";
  62854. export * from "babylonjs/Physics/physicsEngineComponent";
  62855. export * from "babylonjs/Physics/physicsHelper";
  62856. export * from "babylonjs/Physics/physicsImpostor";
  62857. export * from "babylonjs/Physics/physicsJoint";
  62858. export * from "babylonjs/Physics/Plugins/index";
  62859. }
  62860. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62861. /** @hidden */
  62862. export var blackAndWhitePixelShader: {
  62863. name: string;
  62864. shader: string;
  62865. };
  62866. }
  62867. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62869. import { Camera } from "babylonjs/Cameras/camera";
  62870. import { Engine } from "babylonjs/Engines/engine";
  62871. import "babylonjs/Shaders/blackAndWhite.fragment";
  62872. /**
  62873. * Post process used to render in black and white
  62874. */
  62875. export class BlackAndWhitePostProcess extends PostProcess {
  62876. /**
  62877. * Linear about to convert he result to black and white (default: 1)
  62878. */
  62879. degree: number;
  62880. /**
  62881. * Creates a black and white post process
  62882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62883. * @param name The name of the effect.
  62884. * @param options The required width/height ratio to downsize to before computing the render pass.
  62885. * @param camera The camera to apply the render pass to.
  62886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62887. * @param engine The engine which the post process will be applied. (default: current engine)
  62888. * @param reusable If the post process can be reused on the same frame. (default: false)
  62889. */
  62890. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62891. }
  62892. }
  62893. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62894. import { Nullable } from "babylonjs/types";
  62895. import { Camera } from "babylonjs/Cameras/camera";
  62896. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62897. import { Engine } from "babylonjs/Engines/engine";
  62898. /**
  62899. * This represents a set of one or more post processes in Babylon.
  62900. * A post process can be used to apply a shader to a texture after it is rendered.
  62901. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62902. */
  62903. export class PostProcessRenderEffect {
  62904. private _postProcesses;
  62905. private _getPostProcesses;
  62906. private _singleInstance;
  62907. private _cameras;
  62908. private _indicesForCamera;
  62909. /**
  62910. * Name of the effect
  62911. * @hidden
  62912. */
  62913. _name: string;
  62914. /**
  62915. * Instantiates a post process render effect.
  62916. * A post process can be used to apply a shader to a texture after it is rendered.
  62917. * @param engine The engine the effect is tied to
  62918. * @param name The name of the effect
  62919. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62920. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62921. */
  62922. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62923. /**
  62924. * Checks if all the post processes in the effect are supported.
  62925. */
  62926. readonly isSupported: boolean;
  62927. /**
  62928. * Updates the current state of the effect
  62929. * @hidden
  62930. */
  62931. _update(): void;
  62932. /**
  62933. * Attaches the effect on cameras
  62934. * @param cameras The camera to attach to.
  62935. * @hidden
  62936. */
  62937. _attachCameras(cameras: Camera): void;
  62938. /**
  62939. * Attaches the effect on cameras
  62940. * @param cameras The camera to attach to.
  62941. * @hidden
  62942. */
  62943. _attachCameras(cameras: Camera[]): void;
  62944. /**
  62945. * Detaches the effect on cameras
  62946. * @param cameras The camera to detatch from.
  62947. * @hidden
  62948. */
  62949. _detachCameras(cameras: Camera): void;
  62950. /**
  62951. * Detatches the effect on cameras
  62952. * @param cameras The camera to detatch from.
  62953. * @hidden
  62954. */
  62955. _detachCameras(cameras: Camera[]): void;
  62956. /**
  62957. * Enables the effect on given cameras
  62958. * @param cameras The camera to enable.
  62959. * @hidden
  62960. */
  62961. _enable(cameras: Camera): void;
  62962. /**
  62963. * Enables the effect on given cameras
  62964. * @param cameras The camera to enable.
  62965. * @hidden
  62966. */
  62967. _enable(cameras: Nullable<Camera[]>): void;
  62968. /**
  62969. * Disables the effect on the given cameras
  62970. * @param cameras The camera to disable.
  62971. * @hidden
  62972. */
  62973. _disable(cameras: Camera): void;
  62974. /**
  62975. * Disables the effect on the given cameras
  62976. * @param cameras The camera to disable.
  62977. * @hidden
  62978. */
  62979. _disable(cameras: Nullable<Camera[]>): void;
  62980. /**
  62981. * Gets a list of the post processes contained in the effect.
  62982. * @param camera The camera to get the post processes on.
  62983. * @returns The list of the post processes in the effect.
  62984. */
  62985. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62986. }
  62987. }
  62988. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62990. /** @hidden */
  62991. export var extractHighlightsPixelShader: {
  62992. name: string;
  62993. shader: string;
  62994. };
  62995. }
  62996. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62997. import { Nullable } from "babylonjs/types";
  62998. import { Camera } from "babylonjs/Cameras/camera";
  62999. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63000. import { Engine } from "babylonjs/Engines/engine";
  63001. import "babylonjs/Shaders/extractHighlights.fragment";
  63002. /**
  63003. * 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.
  63004. */
  63005. export class ExtractHighlightsPostProcess extends PostProcess {
  63006. /**
  63007. * The luminance threshold, pixels below this value will be set to black.
  63008. */
  63009. threshold: number;
  63010. /** @hidden */
  63011. _exposure: number;
  63012. /**
  63013. * Post process which has the input texture to be used when performing highlight extraction
  63014. * @hidden
  63015. */
  63016. _inputPostProcess: Nullable<PostProcess>;
  63017. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63018. }
  63019. }
  63020. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63021. /** @hidden */
  63022. export var bloomMergePixelShader: {
  63023. name: string;
  63024. shader: string;
  63025. };
  63026. }
  63027. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63028. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63029. import { Nullable } from "babylonjs/types";
  63030. import { Engine } from "babylonjs/Engines/engine";
  63031. import { Camera } from "babylonjs/Cameras/camera";
  63032. import "babylonjs/Shaders/bloomMerge.fragment";
  63033. /**
  63034. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63035. */
  63036. export class BloomMergePostProcess extends PostProcess {
  63037. /** Weight of the bloom to be added to the original input. */
  63038. weight: number;
  63039. /**
  63040. * Creates a new instance of @see BloomMergePostProcess
  63041. * @param name The name of the effect.
  63042. * @param originalFromInput Post process which's input will be used for the merge.
  63043. * @param blurred Blurred highlights post process which's output will be used.
  63044. * @param weight Weight of the bloom to be added to the original input.
  63045. * @param options The required width/height ratio to downsize to before computing the render pass.
  63046. * @param camera The camera to apply the render pass to.
  63047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63048. * @param engine The engine which the post process will be applied. (default: current engine)
  63049. * @param reusable If the post process can be reused on the same frame. (default: false)
  63050. * @param textureType Type of textures used when performing the post process. (default: 0)
  63051. * @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)
  63052. */
  63053. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63054. /** Weight of the bloom to be added to the original input. */
  63055. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63056. }
  63057. }
  63058. declare module "babylonjs/PostProcesses/bloomEffect" {
  63059. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63060. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63061. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63062. import { Camera } from "babylonjs/Cameras/camera";
  63063. import { Scene } from "babylonjs/scene";
  63064. /**
  63065. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63066. */
  63067. export class BloomEffect extends PostProcessRenderEffect {
  63068. private bloomScale;
  63069. /**
  63070. * @hidden Internal
  63071. */
  63072. _effects: Array<PostProcess>;
  63073. /**
  63074. * @hidden Internal
  63075. */
  63076. _downscale: ExtractHighlightsPostProcess;
  63077. private _blurX;
  63078. private _blurY;
  63079. private _merge;
  63080. /**
  63081. * The luminance threshold to find bright areas of the image to bloom.
  63082. */
  63083. threshold: number;
  63084. /**
  63085. * The strength of the bloom.
  63086. */
  63087. weight: number;
  63088. /**
  63089. * Specifies the size of the bloom blur kernel, relative to the final output size
  63090. */
  63091. kernel: number;
  63092. /**
  63093. * Creates a new instance of @see BloomEffect
  63094. * @param scene The scene the effect belongs to.
  63095. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63096. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63097. * @param bloomWeight The the strength of bloom.
  63098. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63099. * @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)
  63100. */
  63101. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63102. /**
  63103. * Disposes each of the internal effects for a given camera.
  63104. * @param camera The camera to dispose the effect on.
  63105. */
  63106. disposeEffects(camera: Camera): void;
  63107. /**
  63108. * @hidden Internal
  63109. */
  63110. _updateEffects(): void;
  63111. /**
  63112. * Internal
  63113. * @returns if all the contained post processes are ready.
  63114. * @hidden
  63115. */
  63116. _isReady(): boolean;
  63117. }
  63118. }
  63119. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63120. /** @hidden */
  63121. export var chromaticAberrationPixelShader: {
  63122. name: string;
  63123. shader: string;
  63124. };
  63125. }
  63126. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63127. import { Vector2 } from "babylonjs/Maths/math.vector";
  63128. import { Nullable } from "babylonjs/types";
  63129. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63130. import { Camera } from "babylonjs/Cameras/camera";
  63131. import { Engine } from "babylonjs/Engines/engine";
  63132. import "babylonjs/Shaders/chromaticAberration.fragment";
  63133. /**
  63134. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63135. */
  63136. export class ChromaticAberrationPostProcess extends PostProcess {
  63137. /**
  63138. * The amount of seperation of rgb channels (default: 30)
  63139. */
  63140. aberrationAmount: number;
  63141. /**
  63142. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63143. */
  63144. radialIntensity: number;
  63145. /**
  63146. * 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))
  63147. */
  63148. direction: Vector2;
  63149. /**
  63150. * 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))
  63151. */
  63152. centerPosition: Vector2;
  63153. /**
  63154. * Creates a new instance ChromaticAberrationPostProcess
  63155. * @param name The name of the effect.
  63156. * @param screenWidth The width of the screen to apply the effect on.
  63157. * @param screenHeight The height of the screen to apply the effect on.
  63158. * @param options The required width/height ratio to downsize to before computing the render pass.
  63159. * @param camera The camera to apply the render pass to.
  63160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63161. * @param engine The engine which the post process will be applied. (default: current engine)
  63162. * @param reusable If the post process can be reused on the same frame. (default: false)
  63163. * @param textureType Type of textures used when performing the post process. (default: 0)
  63164. * @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)
  63165. */
  63166. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63167. }
  63168. }
  63169. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63170. /** @hidden */
  63171. export var circleOfConfusionPixelShader: {
  63172. name: string;
  63173. shader: string;
  63174. };
  63175. }
  63176. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63177. import { Nullable } from "babylonjs/types";
  63178. import { Engine } from "babylonjs/Engines/engine";
  63179. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63180. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63181. import { Camera } from "babylonjs/Cameras/camera";
  63182. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63183. /**
  63184. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63185. */
  63186. export class CircleOfConfusionPostProcess extends PostProcess {
  63187. /**
  63188. * 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.
  63189. */
  63190. lensSize: number;
  63191. /**
  63192. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63193. */
  63194. fStop: number;
  63195. /**
  63196. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63197. */
  63198. focusDistance: number;
  63199. /**
  63200. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63201. */
  63202. focalLength: number;
  63203. private _depthTexture;
  63204. /**
  63205. * Creates a new instance CircleOfConfusionPostProcess
  63206. * @param name The name of the effect.
  63207. * @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.
  63208. * @param options The required width/height ratio to downsize to before computing the render pass.
  63209. * @param camera The camera to apply the render pass to.
  63210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63211. * @param engine The engine which the post process will be applied. (default: current engine)
  63212. * @param reusable If the post process can be reused on the same frame. (default: false)
  63213. * @param textureType Type of textures used when performing the post process. (default: 0)
  63214. * @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)
  63215. */
  63216. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63217. /**
  63218. * 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.
  63219. */
  63220. depthTexture: RenderTargetTexture;
  63221. }
  63222. }
  63223. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63224. /** @hidden */
  63225. export var colorCorrectionPixelShader: {
  63226. name: string;
  63227. shader: string;
  63228. };
  63229. }
  63230. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63231. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63232. import { Engine } from "babylonjs/Engines/engine";
  63233. import { Camera } from "babylonjs/Cameras/camera";
  63234. import "babylonjs/Shaders/colorCorrection.fragment";
  63235. /**
  63236. *
  63237. * This post-process allows the modification of rendered colors by using
  63238. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63239. *
  63240. * The object needs to be provided an url to a texture containing the color
  63241. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63242. * Use an image editing software to tweak the LUT to match your needs.
  63243. *
  63244. * For an example of a color LUT, see here:
  63245. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63246. * For explanations on color grading, see here:
  63247. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63248. *
  63249. */
  63250. export class ColorCorrectionPostProcess extends PostProcess {
  63251. private _colorTableTexture;
  63252. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63253. }
  63254. }
  63255. declare module "babylonjs/Shaders/convolution.fragment" {
  63256. /** @hidden */
  63257. export var convolutionPixelShader: {
  63258. name: string;
  63259. shader: string;
  63260. };
  63261. }
  63262. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63263. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63264. import { Nullable } from "babylonjs/types";
  63265. import { Camera } from "babylonjs/Cameras/camera";
  63266. import { Engine } from "babylonjs/Engines/engine";
  63267. import "babylonjs/Shaders/convolution.fragment";
  63268. /**
  63269. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63270. * input texture to perform effects such as edge detection or sharpening
  63271. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63272. */
  63273. export class ConvolutionPostProcess extends PostProcess {
  63274. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63275. kernel: number[];
  63276. /**
  63277. * Creates a new instance ConvolutionPostProcess
  63278. * @param name The name of the effect.
  63279. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63280. * @param options The required width/height ratio to downsize to before computing the render pass.
  63281. * @param camera The camera to apply the render pass to.
  63282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63283. * @param engine The engine which the post process will be applied. (default: current engine)
  63284. * @param reusable If the post process can be reused on the same frame. (default: false)
  63285. * @param textureType Type of textures used when performing the post process. (default: 0)
  63286. */
  63287. constructor(name: string,
  63288. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63289. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63290. /**
  63291. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63292. */
  63293. static EdgeDetect0Kernel: number[];
  63294. /**
  63295. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63296. */
  63297. static EdgeDetect1Kernel: number[];
  63298. /**
  63299. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63300. */
  63301. static EdgeDetect2Kernel: number[];
  63302. /**
  63303. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63304. */
  63305. static SharpenKernel: number[];
  63306. /**
  63307. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63308. */
  63309. static EmbossKernel: number[];
  63310. /**
  63311. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63312. */
  63313. static GaussianKernel: number[];
  63314. }
  63315. }
  63316. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63317. import { Nullable } from "babylonjs/types";
  63318. import { Vector2 } from "babylonjs/Maths/math.vector";
  63319. import { Camera } from "babylonjs/Cameras/camera";
  63320. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63321. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63322. import { Engine } from "babylonjs/Engines/engine";
  63323. import { Scene } from "babylonjs/scene";
  63324. /**
  63325. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63326. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63327. * based on samples that have a large difference in distance than the center pixel.
  63328. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63329. */
  63330. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63331. direction: Vector2;
  63332. /**
  63333. * Creates a new instance CircleOfConfusionPostProcess
  63334. * @param name The name of the effect.
  63335. * @param scene The scene the effect belongs to.
  63336. * @param direction The direction the blur should be applied.
  63337. * @param kernel The size of the kernel used to blur.
  63338. * @param options The required width/height ratio to downsize to before computing the render pass.
  63339. * @param camera The camera to apply the render pass to.
  63340. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63341. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63343. * @param engine The engine which the post process will be applied. (default: current engine)
  63344. * @param reusable If the post process can be reused on the same frame. (default: false)
  63345. * @param textureType Type of textures used when performing the post process. (default: 0)
  63346. * @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)
  63347. */
  63348. 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);
  63349. }
  63350. }
  63351. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63352. /** @hidden */
  63353. export var depthOfFieldMergePixelShader: {
  63354. name: string;
  63355. shader: string;
  63356. };
  63357. }
  63358. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63359. import { Nullable } from "babylonjs/types";
  63360. import { Camera } from "babylonjs/Cameras/camera";
  63361. import { Effect } from "babylonjs/Materials/effect";
  63362. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63363. import { Engine } from "babylonjs/Engines/engine";
  63364. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63365. /**
  63366. * Options to be set when merging outputs from the default pipeline.
  63367. */
  63368. export class DepthOfFieldMergePostProcessOptions {
  63369. /**
  63370. * The original image to merge on top of
  63371. */
  63372. originalFromInput: PostProcess;
  63373. /**
  63374. * Parameters to perform the merge of the depth of field effect
  63375. */
  63376. depthOfField?: {
  63377. circleOfConfusion: PostProcess;
  63378. blurSteps: Array<PostProcess>;
  63379. };
  63380. /**
  63381. * Parameters to perform the merge of bloom effect
  63382. */
  63383. bloom?: {
  63384. blurred: PostProcess;
  63385. weight: number;
  63386. };
  63387. }
  63388. /**
  63389. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63390. */
  63391. export class DepthOfFieldMergePostProcess extends PostProcess {
  63392. private blurSteps;
  63393. /**
  63394. * Creates a new instance of DepthOfFieldMergePostProcess
  63395. * @param name The name of the effect.
  63396. * @param originalFromInput Post process which's input will be used for the merge.
  63397. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63398. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63399. * @param options The required width/height ratio to downsize to before computing the render pass.
  63400. * @param camera The camera to apply the render pass to.
  63401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63402. * @param engine The engine which the post process will be applied. (default: current engine)
  63403. * @param reusable If the post process can be reused on the same frame. (default: false)
  63404. * @param textureType Type of textures used when performing the post process. (default: 0)
  63405. * @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)
  63406. */
  63407. 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);
  63408. /**
  63409. * Updates the effect with the current post process compile time values and recompiles the shader.
  63410. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63411. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63412. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63413. * @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
  63414. * @param onCompiled Called when the shader has been compiled.
  63415. * @param onError Called if there is an error when compiling a shader.
  63416. */
  63417. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63418. }
  63419. }
  63420. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63421. import { Nullable } from "babylonjs/types";
  63422. import { Camera } from "babylonjs/Cameras/camera";
  63423. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63424. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63425. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63426. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63427. import { Scene } from "babylonjs/scene";
  63428. /**
  63429. * Specifies the level of max blur that should be applied when using the depth of field effect
  63430. */
  63431. export enum DepthOfFieldEffectBlurLevel {
  63432. /**
  63433. * Subtle blur
  63434. */
  63435. Low = 0,
  63436. /**
  63437. * Medium blur
  63438. */
  63439. Medium = 1,
  63440. /**
  63441. * Large blur
  63442. */
  63443. High = 2
  63444. }
  63445. /**
  63446. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63447. */
  63448. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63449. private _circleOfConfusion;
  63450. /**
  63451. * @hidden Internal, blurs from high to low
  63452. */
  63453. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63454. private _depthOfFieldBlurY;
  63455. private _dofMerge;
  63456. /**
  63457. * @hidden Internal post processes in depth of field effect
  63458. */
  63459. _effects: Array<PostProcess>;
  63460. /**
  63461. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63462. */
  63463. focalLength: number;
  63464. /**
  63465. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63466. */
  63467. fStop: number;
  63468. /**
  63469. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63470. */
  63471. focusDistance: number;
  63472. /**
  63473. * 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.
  63474. */
  63475. lensSize: number;
  63476. /**
  63477. * Creates a new instance DepthOfFieldEffect
  63478. * @param scene The scene the effect belongs to.
  63479. * @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.
  63480. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63481. * @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)
  63482. */
  63483. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63484. /**
  63485. * Get the current class name of the current effet
  63486. * @returns "DepthOfFieldEffect"
  63487. */
  63488. getClassName(): string;
  63489. /**
  63490. * 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.
  63491. */
  63492. depthTexture: RenderTargetTexture;
  63493. /**
  63494. * Disposes each of the internal effects for a given camera.
  63495. * @param camera The camera to dispose the effect on.
  63496. */
  63497. disposeEffects(camera: Camera): void;
  63498. /**
  63499. * @hidden Internal
  63500. */
  63501. _updateEffects(): void;
  63502. /**
  63503. * Internal
  63504. * @returns if all the contained post processes are ready.
  63505. * @hidden
  63506. */
  63507. _isReady(): boolean;
  63508. }
  63509. }
  63510. declare module "babylonjs/Shaders/displayPass.fragment" {
  63511. /** @hidden */
  63512. export var displayPassPixelShader: {
  63513. name: string;
  63514. shader: string;
  63515. };
  63516. }
  63517. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63518. import { Nullable } from "babylonjs/types";
  63519. import { Camera } from "babylonjs/Cameras/camera";
  63520. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63521. import { Engine } from "babylonjs/Engines/engine";
  63522. import "babylonjs/Shaders/displayPass.fragment";
  63523. /**
  63524. * DisplayPassPostProcess which produces an output the same as it's input
  63525. */
  63526. export class DisplayPassPostProcess extends PostProcess {
  63527. /**
  63528. * Creates the DisplayPassPostProcess
  63529. * @param name The name of the effect.
  63530. * @param options The required width/height ratio to downsize to before computing the render pass.
  63531. * @param camera The camera to apply the render pass to.
  63532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63533. * @param engine The engine which the post process will be applied. (default: current engine)
  63534. * @param reusable If the post process can be reused on the same frame. (default: false)
  63535. */
  63536. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63537. }
  63538. }
  63539. declare module "babylonjs/Shaders/filter.fragment" {
  63540. /** @hidden */
  63541. export var filterPixelShader: {
  63542. name: string;
  63543. shader: string;
  63544. };
  63545. }
  63546. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63547. import { Nullable } from "babylonjs/types";
  63548. import { Matrix } from "babylonjs/Maths/math.vector";
  63549. import { Camera } from "babylonjs/Cameras/camera";
  63550. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63551. import { Engine } from "babylonjs/Engines/engine";
  63552. import "babylonjs/Shaders/filter.fragment";
  63553. /**
  63554. * Applies a kernel filter to the image
  63555. */
  63556. export class FilterPostProcess extends PostProcess {
  63557. /** The matrix to be applied to the image */
  63558. kernelMatrix: Matrix;
  63559. /**
  63560. *
  63561. * @param name The name of the effect.
  63562. * @param kernelMatrix The matrix to be applied to the image
  63563. * @param options The required width/height ratio to downsize to before computing the render pass.
  63564. * @param camera The camera to apply the render pass to.
  63565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63566. * @param engine The engine which the post process will be applied. (default: current engine)
  63567. * @param reusable If the post process can be reused on the same frame. (default: false)
  63568. */
  63569. constructor(name: string,
  63570. /** The matrix to be applied to the image */
  63571. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63572. }
  63573. }
  63574. declare module "babylonjs/Shaders/fxaa.fragment" {
  63575. /** @hidden */
  63576. export var fxaaPixelShader: {
  63577. name: string;
  63578. shader: string;
  63579. };
  63580. }
  63581. declare module "babylonjs/Shaders/fxaa.vertex" {
  63582. /** @hidden */
  63583. export var fxaaVertexShader: {
  63584. name: string;
  63585. shader: string;
  63586. };
  63587. }
  63588. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63589. import { Nullable } from "babylonjs/types";
  63590. import { Camera } from "babylonjs/Cameras/camera";
  63591. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63592. import { Engine } from "babylonjs/Engines/engine";
  63593. import "babylonjs/Shaders/fxaa.fragment";
  63594. import "babylonjs/Shaders/fxaa.vertex";
  63595. /**
  63596. * Fxaa post process
  63597. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63598. */
  63599. export class FxaaPostProcess extends PostProcess {
  63600. /** @hidden */
  63601. texelWidth: number;
  63602. /** @hidden */
  63603. texelHeight: number;
  63604. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63605. private _getDefines;
  63606. }
  63607. }
  63608. declare module "babylonjs/Shaders/grain.fragment" {
  63609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63610. /** @hidden */
  63611. export var grainPixelShader: {
  63612. name: string;
  63613. shader: string;
  63614. };
  63615. }
  63616. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63617. import { Nullable } from "babylonjs/types";
  63618. import { Camera } from "babylonjs/Cameras/camera";
  63619. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63620. import { Engine } from "babylonjs/Engines/engine";
  63621. import "babylonjs/Shaders/grain.fragment";
  63622. /**
  63623. * The GrainPostProcess adds noise to the image at mid luminance levels
  63624. */
  63625. export class GrainPostProcess extends PostProcess {
  63626. /**
  63627. * The intensity of the grain added (default: 30)
  63628. */
  63629. intensity: number;
  63630. /**
  63631. * If the grain should be randomized on every frame
  63632. */
  63633. animated: boolean;
  63634. /**
  63635. * Creates a new instance of @see GrainPostProcess
  63636. * @param name The name of the effect.
  63637. * @param options The required width/height ratio to downsize to before computing the render pass.
  63638. * @param camera The camera to apply the render pass to.
  63639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63640. * @param engine The engine which the post process will be applied. (default: current engine)
  63641. * @param reusable If the post process can be reused on the same frame. (default: false)
  63642. * @param textureType Type of textures used when performing the post process. (default: 0)
  63643. * @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)
  63644. */
  63645. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63646. }
  63647. }
  63648. declare module "babylonjs/Shaders/highlights.fragment" {
  63649. /** @hidden */
  63650. export var highlightsPixelShader: {
  63651. name: string;
  63652. shader: string;
  63653. };
  63654. }
  63655. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63656. import { Nullable } from "babylonjs/types";
  63657. import { Camera } from "babylonjs/Cameras/camera";
  63658. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63659. import { Engine } from "babylonjs/Engines/engine";
  63660. import "babylonjs/Shaders/highlights.fragment";
  63661. /**
  63662. * Extracts highlights from the image
  63663. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63664. */
  63665. export class HighlightsPostProcess extends PostProcess {
  63666. /**
  63667. * Extracts highlights from the image
  63668. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63669. * @param name The name of the effect.
  63670. * @param options The required width/height ratio to downsize to before computing the render pass.
  63671. * @param camera The camera to apply the render pass to.
  63672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63673. * @param engine The engine which the post process will be applied. (default: current engine)
  63674. * @param reusable If the post process can be reused on the same frame. (default: false)
  63675. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63676. */
  63677. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63678. }
  63679. }
  63680. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63681. /** @hidden */
  63682. export var mrtFragmentDeclaration: {
  63683. name: string;
  63684. shader: string;
  63685. };
  63686. }
  63687. declare module "babylonjs/Shaders/geometry.fragment" {
  63688. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63689. /** @hidden */
  63690. export var geometryPixelShader: {
  63691. name: string;
  63692. shader: string;
  63693. };
  63694. }
  63695. declare module "babylonjs/Shaders/geometry.vertex" {
  63696. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63697. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63698. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63699. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63700. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63701. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63702. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63703. /** @hidden */
  63704. export var geometryVertexShader: {
  63705. name: string;
  63706. shader: string;
  63707. };
  63708. }
  63709. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63710. import { Matrix } from "babylonjs/Maths/math.vector";
  63711. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63712. import { Mesh } from "babylonjs/Meshes/mesh";
  63713. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63714. import { Effect } from "babylonjs/Materials/effect";
  63715. import { Scene } from "babylonjs/scene";
  63716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63717. import "babylonjs/Shaders/geometry.fragment";
  63718. import "babylonjs/Shaders/geometry.vertex";
  63719. /** @hidden */
  63720. interface ISavedTransformationMatrix {
  63721. world: Matrix;
  63722. viewProjection: Matrix;
  63723. }
  63724. /**
  63725. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63726. */
  63727. export class GeometryBufferRenderer {
  63728. /**
  63729. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63730. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63731. */
  63732. static readonly POSITION_TEXTURE_TYPE: number;
  63733. /**
  63734. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63735. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63736. */
  63737. static readonly VELOCITY_TEXTURE_TYPE: number;
  63738. /**
  63739. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63740. * in order to compute objects velocities when enableVelocity is set to "true"
  63741. * @hidden
  63742. */
  63743. _previousTransformationMatrices: {
  63744. [index: number]: ISavedTransformationMatrix;
  63745. };
  63746. /**
  63747. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63748. * in order to compute objects velocities when enableVelocity is set to "true"
  63749. * @hidden
  63750. */
  63751. _previousBonesTransformationMatrices: {
  63752. [index: number]: Float32Array;
  63753. };
  63754. /**
  63755. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63756. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63757. */
  63758. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63759. private _scene;
  63760. private _multiRenderTarget;
  63761. private _ratio;
  63762. private _enablePosition;
  63763. private _enableVelocity;
  63764. private _positionIndex;
  63765. private _velocityIndex;
  63766. protected _effect: Effect;
  63767. protected _cachedDefines: string;
  63768. /**
  63769. * Set the render list (meshes to be rendered) used in the G buffer.
  63770. */
  63771. renderList: Mesh[];
  63772. /**
  63773. * Gets wether or not G buffer are supported by the running hardware.
  63774. * This requires draw buffer supports
  63775. */
  63776. readonly isSupported: boolean;
  63777. /**
  63778. * Returns the index of the given texture type in the G-Buffer textures array
  63779. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63780. * @returns the index of the given texture type in the G-Buffer textures array
  63781. */
  63782. getTextureIndex(textureType: number): number;
  63783. /**
  63784. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63785. */
  63786. /**
  63787. * Sets whether or not objects positions are enabled for the G buffer.
  63788. */
  63789. enablePosition: boolean;
  63790. /**
  63791. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63792. */
  63793. /**
  63794. * Sets wether or not objects velocities are enabled for the G buffer.
  63795. */
  63796. enableVelocity: boolean;
  63797. /**
  63798. * Gets the scene associated with the buffer.
  63799. */
  63800. readonly scene: Scene;
  63801. /**
  63802. * Gets the ratio used by the buffer during its creation.
  63803. * How big is the buffer related to the main canvas.
  63804. */
  63805. readonly ratio: number;
  63806. /** @hidden */
  63807. static _SceneComponentInitialization: (scene: Scene) => void;
  63808. /**
  63809. * Creates a new G Buffer for the scene
  63810. * @param scene The scene the buffer belongs to
  63811. * @param ratio How big is the buffer related to the main canvas.
  63812. */
  63813. constructor(scene: Scene, ratio?: number);
  63814. /**
  63815. * Checks wether everything is ready to render a submesh to the G buffer.
  63816. * @param subMesh the submesh to check readiness for
  63817. * @param useInstances is the mesh drawn using instance or not
  63818. * @returns true if ready otherwise false
  63819. */
  63820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63821. /**
  63822. * Gets the current underlying G Buffer.
  63823. * @returns the buffer
  63824. */
  63825. getGBuffer(): MultiRenderTarget;
  63826. /**
  63827. * Gets the number of samples used to render the buffer (anti aliasing).
  63828. */
  63829. /**
  63830. * Sets the number of samples used to render the buffer (anti aliasing).
  63831. */
  63832. samples: number;
  63833. /**
  63834. * Disposes the renderer and frees up associated resources.
  63835. */
  63836. dispose(): void;
  63837. protected _createRenderTargets(): void;
  63838. private _copyBonesTransformationMatrices;
  63839. }
  63840. }
  63841. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63842. import { Nullable } from "babylonjs/types";
  63843. import { Scene } from "babylonjs/scene";
  63844. import { ISceneComponent } from "babylonjs/sceneComponent";
  63845. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63846. module "babylonjs/scene" {
  63847. interface Scene {
  63848. /** @hidden (Backing field) */
  63849. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63850. /**
  63851. * Gets or Sets the current geometry buffer associated to the scene.
  63852. */
  63853. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63854. /**
  63855. * Enables a GeometryBufferRender and associates it with the scene
  63856. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63857. * @returns the GeometryBufferRenderer
  63858. */
  63859. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63860. /**
  63861. * Disables the GeometryBufferRender associated with the scene
  63862. */
  63863. disableGeometryBufferRenderer(): void;
  63864. }
  63865. }
  63866. /**
  63867. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63868. * in several rendering techniques.
  63869. */
  63870. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63871. /**
  63872. * The component name helpful to identify the component in the list of scene components.
  63873. */
  63874. readonly name: string;
  63875. /**
  63876. * The scene the component belongs to.
  63877. */
  63878. scene: Scene;
  63879. /**
  63880. * Creates a new instance of the component for the given scene
  63881. * @param scene Defines the scene to register the component in
  63882. */
  63883. constructor(scene: Scene);
  63884. /**
  63885. * Registers the component in a given scene
  63886. */
  63887. register(): void;
  63888. /**
  63889. * Rebuilds the elements related to this component in case of
  63890. * context lost for instance.
  63891. */
  63892. rebuild(): void;
  63893. /**
  63894. * Disposes the component and the associated ressources
  63895. */
  63896. dispose(): void;
  63897. private _gatherRenderTargets;
  63898. }
  63899. }
  63900. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63901. /** @hidden */
  63902. export var motionBlurPixelShader: {
  63903. name: string;
  63904. shader: string;
  63905. };
  63906. }
  63907. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63908. import { Nullable } from "babylonjs/types";
  63909. import { Camera } from "babylonjs/Cameras/camera";
  63910. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63911. import { Scene } from "babylonjs/scene";
  63912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63913. import "babylonjs/Animations/animatable";
  63914. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63915. import "babylonjs/Shaders/motionBlur.fragment";
  63916. import { Engine } from "babylonjs/Engines/engine";
  63917. /**
  63918. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63919. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63920. * As an example, all you have to do is to create the post-process:
  63921. * var mb = new BABYLON.MotionBlurPostProcess(
  63922. * 'mb', // The name of the effect.
  63923. * scene, // The scene containing the objects to blur according to their velocity.
  63924. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63925. * camera // The camera to apply the render pass to.
  63926. * );
  63927. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63928. */
  63929. export class MotionBlurPostProcess extends PostProcess {
  63930. /**
  63931. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63932. */
  63933. motionStrength: number;
  63934. /**
  63935. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63936. */
  63937. /**
  63938. * Sets the number of iterations to be used for motion blur quality
  63939. */
  63940. motionBlurSamples: number;
  63941. private _motionBlurSamples;
  63942. private _geometryBufferRenderer;
  63943. /**
  63944. * Creates a new instance MotionBlurPostProcess
  63945. * @param name The name of the effect.
  63946. * @param scene The scene containing the objects to blur according to their velocity.
  63947. * @param options The required width/height ratio to downsize to before computing the render pass.
  63948. * @param camera The camera to apply the render pass to.
  63949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63950. * @param engine The engine which the post process will be applied. (default: current engine)
  63951. * @param reusable If the post process can be reused on the same frame. (default: false)
  63952. * @param textureType Type of textures used when performing the post process. (default: 0)
  63953. * @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)
  63954. */
  63955. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63956. /**
  63957. * Excludes the given skinned mesh from computing bones velocities.
  63958. * 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.
  63959. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63960. */
  63961. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63962. /**
  63963. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63964. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63965. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63966. */
  63967. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63968. /**
  63969. * Disposes the post process.
  63970. * @param camera The camera to dispose the post process on.
  63971. */
  63972. dispose(camera?: Camera): void;
  63973. }
  63974. }
  63975. declare module "babylonjs/Shaders/refraction.fragment" {
  63976. /** @hidden */
  63977. export var refractionPixelShader: {
  63978. name: string;
  63979. shader: string;
  63980. };
  63981. }
  63982. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63983. import { Color3 } from "babylonjs/Maths/math.color";
  63984. import { Camera } from "babylonjs/Cameras/camera";
  63985. import { Texture } from "babylonjs/Materials/Textures/texture";
  63986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63987. import { Engine } from "babylonjs/Engines/engine";
  63988. import "babylonjs/Shaders/refraction.fragment";
  63989. /**
  63990. * Post process which applies a refractin texture
  63991. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63992. */
  63993. export class RefractionPostProcess extends PostProcess {
  63994. /** the base color of the refraction (used to taint the rendering) */
  63995. color: Color3;
  63996. /** simulated refraction depth */
  63997. depth: number;
  63998. /** the coefficient of the base color (0 to remove base color tainting) */
  63999. colorLevel: number;
  64000. private _refTexture;
  64001. private _ownRefractionTexture;
  64002. /**
  64003. * Gets or sets the refraction texture
  64004. * Please note that you are responsible for disposing the texture if you set it manually
  64005. */
  64006. refractionTexture: Texture;
  64007. /**
  64008. * Initializes the RefractionPostProcess
  64009. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64010. * @param name The name of the effect.
  64011. * @param refractionTextureUrl Url of the refraction texture to use
  64012. * @param color the base color of the refraction (used to taint the rendering)
  64013. * @param depth simulated refraction depth
  64014. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64015. * @param camera The camera to apply the render pass to.
  64016. * @param options The required width/height ratio to downsize to before computing the render pass.
  64017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64018. * @param engine The engine which the post process will be applied. (default: current engine)
  64019. * @param reusable If the post process can be reused on the same frame. (default: false)
  64020. */
  64021. constructor(name: string, refractionTextureUrl: string,
  64022. /** the base color of the refraction (used to taint the rendering) */
  64023. color: Color3,
  64024. /** simulated refraction depth */
  64025. depth: number,
  64026. /** the coefficient of the base color (0 to remove base color tainting) */
  64027. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64028. /**
  64029. * Disposes of the post process
  64030. * @param camera Camera to dispose post process on
  64031. */
  64032. dispose(camera: Camera): void;
  64033. }
  64034. }
  64035. declare module "babylonjs/Shaders/sharpen.fragment" {
  64036. /** @hidden */
  64037. export var sharpenPixelShader: {
  64038. name: string;
  64039. shader: string;
  64040. };
  64041. }
  64042. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64043. import { Nullable } from "babylonjs/types";
  64044. import { Camera } from "babylonjs/Cameras/camera";
  64045. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64046. import "babylonjs/Shaders/sharpen.fragment";
  64047. import { Engine } from "babylonjs/Engines/engine";
  64048. /**
  64049. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64050. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64051. */
  64052. export class SharpenPostProcess extends PostProcess {
  64053. /**
  64054. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64055. */
  64056. colorAmount: number;
  64057. /**
  64058. * How much sharpness should be applied (default: 0.3)
  64059. */
  64060. edgeAmount: number;
  64061. /**
  64062. * Creates a new instance ConvolutionPostProcess
  64063. * @param name The name of the effect.
  64064. * @param options The required width/height ratio to downsize to before computing the render pass.
  64065. * @param camera The camera to apply the render pass to.
  64066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64067. * @param engine The engine which the post process will be applied. (default: current engine)
  64068. * @param reusable If the post process can be reused on the same frame. (default: false)
  64069. * @param textureType Type of textures used when performing the post process. (default: 0)
  64070. * @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)
  64071. */
  64072. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64073. }
  64074. }
  64075. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64076. import { Nullable } from "babylonjs/types";
  64077. import { Camera } from "babylonjs/Cameras/camera";
  64078. import { Engine } from "babylonjs/Engines/engine";
  64079. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64080. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64081. /**
  64082. * PostProcessRenderPipeline
  64083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64084. */
  64085. export class PostProcessRenderPipeline {
  64086. private engine;
  64087. private _renderEffects;
  64088. private _renderEffectsForIsolatedPass;
  64089. /**
  64090. * List of inspectable custom properties (used by the Inspector)
  64091. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64092. */
  64093. inspectableCustomProperties: IInspectable[];
  64094. /**
  64095. * @hidden
  64096. */
  64097. protected _cameras: Camera[];
  64098. /** @hidden */
  64099. _name: string;
  64100. /**
  64101. * Gets pipeline name
  64102. */
  64103. readonly name: string;
  64104. /** Gets the list of attached cameras */
  64105. readonly cameras: Camera[];
  64106. /**
  64107. * Initializes a PostProcessRenderPipeline
  64108. * @param engine engine to add the pipeline to
  64109. * @param name name of the pipeline
  64110. */
  64111. constructor(engine: Engine, name: string);
  64112. /**
  64113. * Gets the class name
  64114. * @returns "PostProcessRenderPipeline"
  64115. */
  64116. getClassName(): string;
  64117. /**
  64118. * If all the render effects in the pipeline are supported
  64119. */
  64120. readonly isSupported: boolean;
  64121. /**
  64122. * Adds an effect to the pipeline
  64123. * @param renderEffect the effect to add
  64124. */
  64125. addEffect(renderEffect: PostProcessRenderEffect): void;
  64126. /** @hidden */
  64127. _rebuild(): void;
  64128. /** @hidden */
  64129. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64130. /** @hidden */
  64131. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64132. /** @hidden */
  64133. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64134. /** @hidden */
  64135. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64136. /** @hidden */
  64137. _attachCameras(cameras: Camera, unique: boolean): void;
  64138. /** @hidden */
  64139. _attachCameras(cameras: Camera[], unique: boolean): void;
  64140. /** @hidden */
  64141. _detachCameras(cameras: Camera): void;
  64142. /** @hidden */
  64143. _detachCameras(cameras: Nullable<Camera[]>): void;
  64144. /** @hidden */
  64145. _update(): void;
  64146. /** @hidden */
  64147. _reset(): void;
  64148. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64149. /**
  64150. * Disposes of the pipeline
  64151. */
  64152. dispose(): void;
  64153. }
  64154. }
  64155. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64156. import { Camera } from "babylonjs/Cameras/camera";
  64157. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64158. /**
  64159. * PostProcessRenderPipelineManager class
  64160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64161. */
  64162. export class PostProcessRenderPipelineManager {
  64163. private _renderPipelines;
  64164. /**
  64165. * Initializes a PostProcessRenderPipelineManager
  64166. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64167. */
  64168. constructor();
  64169. /**
  64170. * Gets the list of supported render pipelines
  64171. */
  64172. readonly supportedPipelines: PostProcessRenderPipeline[];
  64173. /**
  64174. * Adds a pipeline to the manager
  64175. * @param renderPipeline The pipeline to add
  64176. */
  64177. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64178. /**
  64179. * Attaches a camera to the pipeline
  64180. * @param renderPipelineName The name of the pipeline to attach to
  64181. * @param cameras the camera to attach
  64182. * @param unique if the camera can be attached multiple times to the pipeline
  64183. */
  64184. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64185. /**
  64186. * Detaches a camera from the pipeline
  64187. * @param renderPipelineName The name of the pipeline to detach from
  64188. * @param cameras the camera to detach
  64189. */
  64190. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64191. /**
  64192. * Enables an effect by name on a pipeline
  64193. * @param renderPipelineName the name of the pipeline to enable the effect in
  64194. * @param renderEffectName the name of the effect to enable
  64195. * @param cameras the cameras that the effect should be enabled on
  64196. */
  64197. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64198. /**
  64199. * Disables an effect by name on a pipeline
  64200. * @param renderPipelineName the name of the pipeline to disable the effect in
  64201. * @param renderEffectName the name of the effect to disable
  64202. * @param cameras the cameras that the effect should be disabled on
  64203. */
  64204. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64205. /**
  64206. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64207. */
  64208. update(): void;
  64209. /** @hidden */
  64210. _rebuild(): void;
  64211. /**
  64212. * Disposes of the manager and pipelines
  64213. */
  64214. dispose(): void;
  64215. }
  64216. }
  64217. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64218. import { ISceneComponent } from "babylonjs/sceneComponent";
  64219. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64220. import { Scene } from "babylonjs/scene";
  64221. module "babylonjs/scene" {
  64222. interface Scene {
  64223. /** @hidden (Backing field) */
  64224. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64225. /**
  64226. * Gets the postprocess render pipeline manager
  64227. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64228. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64229. */
  64230. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64231. }
  64232. }
  64233. /**
  64234. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64235. */
  64236. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64237. /**
  64238. * The component name helpfull to identify the component in the list of scene components.
  64239. */
  64240. readonly name: string;
  64241. /**
  64242. * The scene the component belongs to.
  64243. */
  64244. scene: Scene;
  64245. /**
  64246. * Creates a new instance of the component for the given scene
  64247. * @param scene Defines the scene to register the component in
  64248. */
  64249. constructor(scene: Scene);
  64250. /**
  64251. * Registers the component in a given scene
  64252. */
  64253. register(): void;
  64254. /**
  64255. * Rebuilds the elements related to this component in case of
  64256. * context lost for instance.
  64257. */
  64258. rebuild(): void;
  64259. /**
  64260. * Disposes the component and the associated ressources
  64261. */
  64262. dispose(): void;
  64263. private _gatherRenderTargets;
  64264. }
  64265. }
  64266. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64267. import { Nullable } from "babylonjs/types";
  64268. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64269. import { Camera } from "babylonjs/Cameras/camera";
  64270. import { IDisposable } from "babylonjs/scene";
  64271. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64272. import { Scene } from "babylonjs/scene";
  64273. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64274. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64275. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64276. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64277. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64278. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64279. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64280. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64281. import { Animation } from "babylonjs/Animations/animation";
  64282. /**
  64283. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64284. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64285. */
  64286. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64287. private _scene;
  64288. private _camerasToBeAttached;
  64289. /**
  64290. * ID of the sharpen post process,
  64291. */
  64292. private readonly SharpenPostProcessId;
  64293. /**
  64294. * @ignore
  64295. * ID of the image processing post process;
  64296. */
  64297. readonly ImageProcessingPostProcessId: string;
  64298. /**
  64299. * @ignore
  64300. * ID of the Fast Approximate Anti-Aliasing post process;
  64301. */
  64302. readonly FxaaPostProcessId: string;
  64303. /**
  64304. * ID of the chromatic aberration post process,
  64305. */
  64306. private readonly ChromaticAberrationPostProcessId;
  64307. /**
  64308. * ID of the grain post process
  64309. */
  64310. private readonly GrainPostProcessId;
  64311. /**
  64312. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64313. */
  64314. sharpen: SharpenPostProcess;
  64315. private _sharpenEffect;
  64316. private bloom;
  64317. /**
  64318. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64319. */
  64320. depthOfField: DepthOfFieldEffect;
  64321. /**
  64322. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64323. */
  64324. fxaa: FxaaPostProcess;
  64325. /**
  64326. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64327. */
  64328. imageProcessing: ImageProcessingPostProcess;
  64329. /**
  64330. * Chromatic aberration post process which will shift rgb colors in the image
  64331. */
  64332. chromaticAberration: ChromaticAberrationPostProcess;
  64333. private _chromaticAberrationEffect;
  64334. /**
  64335. * Grain post process which add noise to the image
  64336. */
  64337. grain: GrainPostProcess;
  64338. private _grainEffect;
  64339. /**
  64340. * Glow post process which adds a glow to emissive areas of the image
  64341. */
  64342. private _glowLayer;
  64343. /**
  64344. * Animations which can be used to tweak settings over a period of time
  64345. */
  64346. animations: Animation[];
  64347. private _imageProcessingConfigurationObserver;
  64348. private _sharpenEnabled;
  64349. private _bloomEnabled;
  64350. private _depthOfFieldEnabled;
  64351. private _depthOfFieldBlurLevel;
  64352. private _fxaaEnabled;
  64353. private _imageProcessingEnabled;
  64354. private _defaultPipelineTextureType;
  64355. private _bloomScale;
  64356. private _chromaticAberrationEnabled;
  64357. private _grainEnabled;
  64358. private _buildAllowed;
  64359. /**
  64360. * Gets active scene
  64361. */
  64362. readonly scene: Scene;
  64363. /**
  64364. * Enable or disable the sharpen process from the pipeline
  64365. */
  64366. sharpenEnabled: boolean;
  64367. private _resizeObserver;
  64368. private _hardwareScaleLevel;
  64369. private _bloomKernel;
  64370. /**
  64371. * Specifies the size of the bloom blur kernel, relative to the final output size
  64372. */
  64373. bloomKernel: number;
  64374. /**
  64375. * Specifies the weight of the bloom in the final rendering
  64376. */
  64377. private _bloomWeight;
  64378. /**
  64379. * Specifies the luma threshold for the area that will be blurred by the bloom
  64380. */
  64381. private _bloomThreshold;
  64382. private _hdr;
  64383. /**
  64384. * The strength of the bloom.
  64385. */
  64386. bloomWeight: number;
  64387. /**
  64388. * The strength of the bloom.
  64389. */
  64390. bloomThreshold: number;
  64391. /**
  64392. * The scale of the bloom, lower value will provide better performance.
  64393. */
  64394. bloomScale: number;
  64395. /**
  64396. * Enable or disable the bloom from the pipeline
  64397. */
  64398. bloomEnabled: boolean;
  64399. private _rebuildBloom;
  64400. /**
  64401. * If the depth of field is enabled.
  64402. */
  64403. depthOfFieldEnabled: boolean;
  64404. /**
  64405. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64406. */
  64407. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64408. /**
  64409. * If the anti aliasing is enabled.
  64410. */
  64411. fxaaEnabled: boolean;
  64412. private _samples;
  64413. /**
  64414. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64415. */
  64416. samples: number;
  64417. /**
  64418. * If image processing is enabled.
  64419. */
  64420. imageProcessingEnabled: boolean;
  64421. /**
  64422. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64423. */
  64424. glowLayerEnabled: boolean;
  64425. /**
  64426. * Gets the glow layer (or null if not defined)
  64427. */
  64428. readonly glowLayer: Nullable<GlowLayer>;
  64429. /**
  64430. * Enable or disable the chromaticAberration process from the pipeline
  64431. */
  64432. chromaticAberrationEnabled: boolean;
  64433. /**
  64434. * Enable or disable the grain process from the pipeline
  64435. */
  64436. grainEnabled: boolean;
  64437. /**
  64438. * @constructor
  64439. * @param name - The rendering pipeline name (default: "")
  64440. * @param hdr - If high dynamic range textures should be used (default: true)
  64441. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64442. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64443. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64444. */
  64445. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64446. /**
  64447. * Get the class name
  64448. * @returns "DefaultRenderingPipeline"
  64449. */
  64450. getClassName(): string;
  64451. /**
  64452. * Force the compilation of the entire pipeline.
  64453. */
  64454. prepare(): void;
  64455. private _hasCleared;
  64456. private _prevPostProcess;
  64457. private _prevPrevPostProcess;
  64458. private _setAutoClearAndTextureSharing;
  64459. private _depthOfFieldSceneObserver;
  64460. private _buildPipeline;
  64461. private _disposePostProcesses;
  64462. /**
  64463. * Adds a camera to the pipeline
  64464. * @param camera the camera to be added
  64465. */
  64466. addCamera(camera: Camera): void;
  64467. /**
  64468. * Removes a camera from the pipeline
  64469. * @param camera the camera to remove
  64470. */
  64471. removeCamera(camera: Camera): void;
  64472. /**
  64473. * Dispose of the pipeline and stop all post processes
  64474. */
  64475. dispose(): void;
  64476. /**
  64477. * Serialize the rendering pipeline (Used when exporting)
  64478. * @returns the serialized object
  64479. */
  64480. serialize(): any;
  64481. /**
  64482. * Parse the serialized pipeline
  64483. * @param source Source pipeline.
  64484. * @param scene The scene to load the pipeline to.
  64485. * @param rootUrl The URL of the serialized pipeline.
  64486. * @returns An instantiated pipeline from the serialized object.
  64487. */
  64488. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64489. }
  64490. }
  64491. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64492. /** @hidden */
  64493. export var lensHighlightsPixelShader: {
  64494. name: string;
  64495. shader: string;
  64496. };
  64497. }
  64498. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64499. /** @hidden */
  64500. export var depthOfFieldPixelShader: {
  64501. name: string;
  64502. shader: string;
  64503. };
  64504. }
  64505. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64506. import { Camera } from "babylonjs/Cameras/camera";
  64507. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64508. import { Scene } from "babylonjs/scene";
  64509. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64510. import "babylonjs/Shaders/chromaticAberration.fragment";
  64511. import "babylonjs/Shaders/lensHighlights.fragment";
  64512. import "babylonjs/Shaders/depthOfField.fragment";
  64513. /**
  64514. * BABYLON.JS Chromatic Aberration GLSL Shader
  64515. * Author: Olivier Guyot
  64516. * Separates very slightly R, G and B colors on the edges of the screen
  64517. * Inspired by Francois Tarlier & Martins Upitis
  64518. */
  64519. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64520. /**
  64521. * @ignore
  64522. * The chromatic aberration PostProcess id in the pipeline
  64523. */
  64524. LensChromaticAberrationEffect: string;
  64525. /**
  64526. * @ignore
  64527. * The highlights enhancing PostProcess id in the pipeline
  64528. */
  64529. HighlightsEnhancingEffect: string;
  64530. /**
  64531. * @ignore
  64532. * The depth-of-field PostProcess id in the pipeline
  64533. */
  64534. LensDepthOfFieldEffect: string;
  64535. private _scene;
  64536. private _depthTexture;
  64537. private _grainTexture;
  64538. private _chromaticAberrationPostProcess;
  64539. private _highlightsPostProcess;
  64540. private _depthOfFieldPostProcess;
  64541. private _edgeBlur;
  64542. private _grainAmount;
  64543. private _chromaticAberration;
  64544. private _distortion;
  64545. private _highlightsGain;
  64546. private _highlightsThreshold;
  64547. private _dofDistance;
  64548. private _dofAperture;
  64549. private _dofDarken;
  64550. private _dofPentagon;
  64551. private _blurNoise;
  64552. /**
  64553. * @constructor
  64554. *
  64555. * Effect parameters are as follow:
  64556. * {
  64557. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64558. * edge_blur: number; // from 0 to x (1 for realism)
  64559. * distortion: number; // from 0 to x (1 for realism)
  64560. * grain_amount: number; // from 0 to 1
  64561. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64562. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64563. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64564. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64565. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64566. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64567. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64568. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64569. * }
  64570. * Note: if an effect parameter is unset, effect is disabled
  64571. *
  64572. * @param name The rendering pipeline name
  64573. * @param parameters - An object containing all parameters (see above)
  64574. * @param scene The scene linked to this pipeline
  64575. * @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)
  64576. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64577. */
  64578. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64579. /**
  64580. * Get the class name
  64581. * @returns "LensRenderingPipeline"
  64582. */
  64583. getClassName(): string;
  64584. /**
  64585. * Gets associated scene
  64586. */
  64587. readonly scene: Scene;
  64588. /**
  64589. * Gets or sets the edge blur
  64590. */
  64591. edgeBlur: number;
  64592. /**
  64593. * Gets or sets the grain amount
  64594. */
  64595. grainAmount: number;
  64596. /**
  64597. * Gets or sets the chromatic aberration amount
  64598. */
  64599. chromaticAberration: number;
  64600. /**
  64601. * Gets or sets the depth of field aperture
  64602. */
  64603. dofAperture: number;
  64604. /**
  64605. * Gets or sets the edge distortion
  64606. */
  64607. edgeDistortion: number;
  64608. /**
  64609. * Gets or sets the depth of field distortion
  64610. */
  64611. dofDistortion: number;
  64612. /**
  64613. * Gets or sets the darken out of focus amount
  64614. */
  64615. darkenOutOfFocus: number;
  64616. /**
  64617. * Gets or sets a boolean indicating if blur noise is enabled
  64618. */
  64619. blurNoise: boolean;
  64620. /**
  64621. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64622. */
  64623. pentagonBokeh: boolean;
  64624. /**
  64625. * Gets or sets the highlight grain amount
  64626. */
  64627. highlightsGain: number;
  64628. /**
  64629. * Gets or sets the highlight threshold
  64630. */
  64631. highlightsThreshold: number;
  64632. /**
  64633. * Sets the amount of blur at the edges
  64634. * @param amount blur amount
  64635. */
  64636. setEdgeBlur(amount: number): void;
  64637. /**
  64638. * Sets edge blur to 0
  64639. */
  64640. disableEdgeBlur(): void;
  64641. /**
  64642. * Sets the amout of grain
  64643. * @param amount Amount of grain
  64644. */
  64645. setGrainAmount(amount: number): void;
  64646. /**
  64647. * Set grain amount to 0
  64648. */
  64649. disableGrain(): void;
  64650. /**
  64651. * Sets the chromatic aberration amount
  64652. * @param amount amount of chromatic aberration
  64653. */
  64654. setChromaticAberration(amount: number): void;
  64655. /**
  64656. * Sets chromatic aberration amount to 0
  64657. */
  64658. disableChromaticAberration(): void;
  64659. /**
  64660. * Sets the EdgeDistortion amount
  64661. * @param amount amount of EdgeDistortion
  64662. */
  64663. setEdgeDistortion(amount: number): void;
  64664. /**
  64665. * Sets edge distortion to 0
  64666. */
  64667. disableEdgeDistortion(): void;
  64668. /**
  64669. * Sets the FocusDistance amount
  64670. * @param amount amount of FocusDistance
  64671. */
  64672. setFocusDistance(amount: number): void;
  64673. /**
  64674. * Disables depth of field
  64675. */
  64676. disableDepthOfField(): void;
  64677. /**
  64678. * Sets the Aperture amount
  64679. * @param amount amount of Aperture
  64680. */
  64681. setAperture(amount: number): void;
  64682. /**
  64683. * Sets the DarkenOutOfFocus amount
  64684. * @param amount amount of DarkenOutOfFocus
  64685. */
  64686. setDarkenOutOfFocus(amount: number): void;
  64687. private _pentagonBokehIsEnabled;
  64688. /**
  64689. * Creates a pentagon bokeh effect
  64690. */
  64691. enablePentagonBokeh(): void;
  64692. /**
  64693. * Disables the pentagon bokeh effect
  64694. */
  64695. disablePentagonBokeh(): void;
  64696. /**
  64697. * Enables noise blur
  64698. */
  64699. enableNoiseBlur(): void;
  64700. /**
  64701. * Disables noise blur
  64702. */
  64703. disableNoiseBlur(): void;
  64704. /**
  64705. * Sets the HighlightsGain amount
  64706. * @param amount amount of HighlightsGain
  64707. */
  64708. setHighlightsGain(amount: number): void;
  64709. /**
  64710. * Sets the HighlightsThreshold amount
  64711. * @param amount amount of HighlightsThreshold
  64712. */
  64713. setHighlightsThreshold(amount: number): void;
  64714. /**
  64715. * Disables highlights
  64716. */
  64717. disableHighlights(): void;
  64718. /**
  64719. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64720. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64721. */
  64722. dispose(disableDepthRender?: boolean): void;
  64723. private _createChromaticAberrationPostProcess;
  64724. private _createHighlightsPostProcess;
  64725. private _createDepthOfFieldPostProcess;
  64726. private _createGrainTexture;
  64727. }
  64728. }
  64729. declare module "babylonjs/Shaders/ssao2.fragment" {
  64730. /** @hidden */
  64731. export var ssao2PixelShader: {
  64732. name: string;
  64733. shader: string;
  64734. };
  64735. }
  64736. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64737. /** @hidden */
  64738. export var ssaoCombinePixelShader: {
  64739. name: string;
  64740. shader: string;
  64741. };
  64742. }
  64743. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64744. import { Camera } from "babylonjs/Cameras/camera";
  64745. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64746. import { Scene } from "babylonjs/scene";
  64747. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64748. import "babylonjs/Shaders/ssao2.fragment";
  64749. import "babylonjs/Shaders/ssaoCombine.fragment";
  64750. /**
  64751. * Render pipeline to produce ssao effect
  64752. */
  64753. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64754. /**
  64755. * @ignore
  64756. * The PassPostProcess id in the pipeline that contains the original scene color
  64757. */
  64758. SSAOOriginalSceneColorEffect: string;
  64759. /**
  64760. * @ignore
  64761. * The SSAO PostProcess id in the pipeline
  64762. */
  64763. SSAORenderEffect: string;
  64764. /**
  64765. * @ignore
  64766. * The horizontal blur PostProcess id in the pipeline
  64767. */
  64768. SSAOBlurHRenderEffect: string;
  64769. /**
  64770. * @ignore
  64771. * The vertical blur PostProcess id in the pipeline
  64772. */
  64773. SSAOBlurVRenderEffect: string;
  64774. /**
  64775. * @ignore
  64776. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64777. */
  64778. SSAOCombineRenderEffect: string;
  64779. /**
  64780. * The output strength of the SSAO post-process. Default value is 1.0.
  64781. */
  64782. totalStrength: number;
  64783. /**
  64784. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64785. */
  64786. maxZ: number;
  64787. /**
  64788. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64789. */
  64790. minZAspect: number;
  64791. private _samples;
  64792. /**
  64793. * Number of samples used for the SSAO calculations. Default value is 8
  64794. */
  64795. samples: number;
  64796. private _textureSamples;
  64797. /**
  64798. * Number of samples to use for antialiasing
  64799. */
  64800. textureSamples: number;
  64801. /**
  64802. * Ratio object used for SSAO ratio and blur ratio
  64803. */
  64804. private _ratio;
  64805. /**
  64806. * Dynamically generated sphere sampler.
  64807. */
  64808. private _sampleSphere;
  64809. /**
  64810. * Blur filter offsets
  64811. */
  64812. private _samplerOffsets;
  64813. private _expensiveBlur;
  64814. /**
  64815. * If bilateral blur should be used
  64816. */
  64817. expensiveBlur: boolean;
  64818. /**
  64819. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64820. */
  64821. radius: number;
  64822. /**
  64823. * The base color of the SSAO post-process
  64824. * The final result is "base + ssao" between [0, 1]
  64825. */
  64826. base: number;
  64827. /**
  64828. * Support test.
  64829. */
  64830. static readonly IsSupported: boolean;
  64831. private _scene;
  64832. private _depthTexture;
  64833. private _normalTexture;
  64834. private _randomTexture;
  64835. private _originalColorPostProcess;
  64836. private _ssaoPostProcess;
  64837. private _blurHPostProcess;
  64838. private _blurVPostProcess;
  64839. private _ssaoCombinePostProcess;
  64840. private _firstUpdate;
  64841. /**
  64842. * Gets active scene
  64843. */
  64844. readonly scene: Scene;
  64845. /**
  64846. * @constructor
  64847. * @param name The rendering pipeline name
  64848. * @param scene The scene linked to this pipeline
  64849. * @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 }
  64850. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64851. */
  64852. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64853. /**
  64854. * Get the class name
  64855. * @returns "SSAO2RenderingPipeline"
  64856. */
  64857. getClassName(): string;
  64858. /**
  64859. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64860. */
  64861. dispose(disableGeometryBufferRenderer?: boolean): void;
  64862. private _createBlurPostProcess;
  64863. /** @hidden */
  64864. _rebuild(): void;
  64865. private _bits;
  64866. private _radicalInverse_VdC;
  64867. private _hammersley;
  64868. private _hemisphereSample_uniform;
  64869. private _generateHemisphere;
  64870. private _createSSAOPostProcess;
  64871. private _createSSAOCombinePostProcess;
  64872. private _createRandomTexture;
  64873. /**
  64874. * Serialize the rendering pipeline (Used when exporting)
  64875. * @returns the serialized object
  64876. */
  64877. serialize(): any;
  64878. /**
  64879. * Parse the serialized pipeline
  64880. * @param source Source pipeline.
  64881. * @param scene The scene to load the pipeline to.
  64882. * @param rootUrl The URL of the serialized pipeline.
  64883. * @returns An instantiated pipeline from the serialized object.
  64884. */
  64885. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64886. }
  64887. }
  64888. declare module "babylonjs/Shaders/ssao.fragment" {
  64889. /** @hidden */
  64890. export var ssaoPixelShader: {
  64891. name: string;
  64892. shader: string;
  64893. };
  64894. }
  64895. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64896. import { Camera } from "babylonjs/Cameras/camera";
  64897. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64898. import { Scene } from "babylonjs/scene";
  64899. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64900. import "babylonjs/Shaders/ssao.fragment";
  64901. import "babylonjs/Shaders/ssaoCombine.fragment";
  64902. /**
  64903. * Render pipeline to produce ssao effect
  64904. */
  64905. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64906. /**
  64907. * @ignore
  64908. * The PassPostProcess id in the pipeline that contains the original scene color
  64909. */
  64910. SSAOOriginalSceneColorEffect: string;
  64911. /**
  64912. * @ignore
  64913. * The SSAO PostProcess id in the pipeline
  64914. */
  64915. SSAORenderEffect: string;
  64916. /**
  64917. * @ignore
  64918. * The horizontal blur PostProcess id in the pipeline
  64919. */
  64920. SSAOBlurHRenderEffect: string;
  64921. /**
  64922. * @ignore
  64923. * The vertical blur PostProcess id in the pipeline
  64924. */
  64925. SSAOBlurVRenderEffect: string;
  64926. /**
  64927. * @ignore
  64928. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64929. */
  64930. SSAOCombineRenderEffect: string;
  64931. /**
  64932. * The output strength of the SSAO post-process. Default value is 1.0.
  64933. */
  64934. totalStrength: number;
  64935. /**
  64936. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64937. */
  64938. radius: number;
  64939. /**
  64940. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64941. * Must not be equal to fallOff and superior to fallOff.
  64942. * Default value is 0.0075
  64943. */
  64944. area: number;
  64945. /**
  64946. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64947. * Must not be equal to area and inferior to area.
  64948. * Default value is 0.000001
  64949. */
  64950. fallOff: number;
  64951. /**
  64952. * The base color of the SSAO post-process
  64953. * The final result is "base + ssao" between [0, 1]
  64954. */
  64955. base: number;
  64956. private _scene;
  64957. private _depthTexture;
  64958. private _randomTexture;
  64959. private _originalColorPostProcess;
  64960. private _ssaoPostProcess;
  64961. private _blurHPostProcess;
  64962. private _blurVPostProcess;
  64963. private _ssaoCombinePostProcess;
  64964. private _firstUpdate;
  64965. /**
  64966. * Gets active scene
  64967. */
  64968. readonly scene: Scene;
  64969. /**
  64970. * @constructor
  64971. * @param name - The rendering pipeline name
  64972. * @param scene - The scene linked to this pipeline
  64973. * @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 }
  64974. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64975. */
  64976. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64977. /**
  64978. * Get the class name
  64979. * @returns "SSAORenderingPipeline"
  64980. */
  64981. getClassName(): string;
  64982. /**
  64983. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64984. */
  64985. dispose(disableDepthRender?: boolean): void;
  64986. private _createBlurPostProcess;
  64987. /** @hidden */
  64988. _rebuild(): void;
  64989. private _createSSAOPostProcess;
  64990. private _createSSAOCombinePostProcess;
  64991. private _createRandomTexture;
  64992. }
  64993. }
  64994. declare module "babylonjs/Shaders/standard.fragment" {
  64995. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64996. /** @hidden */
  64997. export var standardPixelShader: {
  64998. name: string;
  64999. shader: string;
  65000. };
  65001. }
  65002. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65003. import { Nullable } from "babylonjs/types";
  65004. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65005. import { Camera } from "babylonjs/Cameras/camera";
  65006. import { Texture } from "babylonjs/Materials/Textures/texture";
  65007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65008. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65009. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65010. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65011. import { IDisposable } from "babylonjs/scene";
  65012. import { SpotLight } from "babylonjs/Lights/spotLight";
  65013. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65014. import { Scene } from "babylonjs/scene";
  65015. import { Animation } from "babylonjs/Animations/animation";
  65016. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65017. import "babylonjs/Shaders/standard.fragment";
  65018. /**
  65019. * Standard rendering pipeline
  65020. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65021. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65022. */
  65023. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65024. /**
  65025. * Public members
  65026. */
  65027. /**
  65028. * Post-process which contains the original scene color before the pipeline applies all the effects
  65029. */
  65030. originalPostProcess: Nullable<PostProcess>;
  65031. /**
  65032. * Post-process used to down scale an image x4
  65033. */
  65034. downSampleX4PostProcess: Nullable<PostProcess>;
  65035. /**
  65036. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65037. */
  65038. brightPassPostProcess: Nullable<PostProcess>;
  65039. /**
  65040. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65041. */
  65042. blurHPostProcesses: PostProcess[];
  65043. /**
  65044. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65045. */
  65046. blurVPostProcesses: PostProcess[];
  65047. /**
  65048. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65049. */
  65050. textureAdderPostProcess: Nullable<PostProcess>;
  65051. /**
  65052. * Post-process used to create volumetric lighting effect
  65053. */
  65054. volumetricLightPostProcess: Nullable<PostProcess>;
  65055. /**
  65056. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65057. */
  65058. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65059. /**
  65060. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65061. */
  65062. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65063. /**
  65064. * Post-process used to merge the volumetric light effect and the real scene color
  65065. */
  65066. volumetricLightMergePostProces: Nullable<PostProcess>;
  65067. /**
  65068. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65069. */
  65070. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65071. /**
  65072. * Base post-process used to calculate the average luminance of the final image for HDR
  65073. */
  65074. luminancePostProcess: Nullable<PostProcess>;
  65075. /**
  65076. * Post-processes used to create down sample post-processes in order to get
  65077. * the average luminance of the final image for HDR
  65078. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65079. */
  65080. luminanceDownSamplePostProcesses: PostProcess[];
  65081. /**
  65082. * Post-process used to create a HDR effect (light adaptation)
  65083. */
  65084. hdrPostProcess: Nullable<PostProcess>;
  65085. /**
  65086. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65087. */
  65088. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65089. /**
  65090. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65091. */
  65092. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65093. /**
  65094. * Post-process used to merge the final HDR post-process and the real scene color
  65095. */
  65096. hdrFinalPostProcess: Nullable<PostProcess>;
  65097. /**
  65098. * Post-process used to create a lens flare effect
  65099. */
  65100. lensFlarePostProcess: Nullable<PostProcess>;
  65101. /**
  65102. * Post-process that merges the result of the lens flare post-process and the real scene color
  65103. */
  65104. lensFlareComposePostProcess: Nullable<PostProcess>;
  65105. /**
  65106. * Post-process used to create a motion blur effect
  65107. */
  65108. motionBlurPostProcess: Nullable<PostProcess>;
  65109. /**
  65110. * Post-process used to create a depth of field effect
  65111. */
  65112. depthOfFieldPostProcess: Nullable<PostProcess>;
  65113. /**
  65114. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65115. */
  65116. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65117. /**
  65118. * Represents the brightness threshold in order to configure the illuminated surfaces
  65119. */
  65120. brightThreshold: number;
  65121. /**
  65122. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65123. */
  65124. blurWidth: number;
  65125. /**
  65126. * Sets if the blur for highlighted surfaces must be only horizontal
  65127. */
  65128. horizontalBlur: boolean;
  65129. /**
  65130. * Gets the overall exposure used by the pipeline
  65131. */
  65132. /**
  65133. * Sets the overall exposure used by the pipeline
  65134. */
  65135. exposure: number;
  65136. /**
  65137. * Texture used typically to simulate "dirty" on camera lens
  65138. */
  65139. lensTexture: Nullable<Texture>;
  65140. /**
  65141. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65142. */
  65143. volumetricLightCoefficient: number;
  65144. /**
  65145. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65146. */
  65147. volumetricLightPower: number;
  65148. /**
  65149. * Used the set the blur intensity to smooth the volumetric lights
  65150. */
  65151. volumetricLightBlurScale: number;
  65152. /**
  65153. * Light (spot or directional) used to generate the volumetric lights rays
  65154. * The source light must have a shadow generate so the pipeline can get its
  65155. * depth map
  65156. */
  65157. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65158. /**
  65159. * For eye adaptation, represents the minimum luminance the eye can see
  65160. */
  65161. hdrMinimumLuminance: number;
  65162. /**
  65163. * For eye adaptation, represents the decrease luminance speed
  65164. */
  65165. hdrDecreaseRate: number;
  65166. /**
  65167. * For eye adaptation, represents the increase luminance speed
  65168. */
  65169. hdrIncreaseRate: number;
  65170. /**
  65171. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65172. */
  65173. /**
  65174. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65175. */
  65176. hdrAutoExposure: boolean;
  65177. /**
  65178. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65179. */
  65180. lensColorTexture: Nullable<Texture>;
  65181. /**
  65182. * The overall strengh for the lens flare effect
  65183. */
  65184. lensFlareStrength: number;
  65185. /**
  65186. * Dispersion coefficient for lens flare ghosts
  65187. */
  65188. lensFlareGhostDispersal: number;
  65189. /**
  65190. * Main lens flare halo width
  65191. */
  65192. lensFlareHaloWidth: number;
  65193. /**
  65194. * Based on the lens distortion effect, defines how much the lens flare result
  65195. * is distorted
  65196. */
  65197. lensFlareDistortionStrength: number;
  65198. /**
  65199. * Configures the blur intensity used for for lens flare (halo)
  65200. */
  65201. lensFlareBlurWidth: number;
  65202. /**
  65203. * Lens star texture must be used to simulate rays on the flares and is available
  65204. * in the documentation
  65205. */
  65206. lensStarTexture: Nullable<Texture>;
  65207. /**
  65208. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65209. * flare effect by taking account of the dirt texture
  65210. */
  65211. lensFlareDirtTexture: Nullable<Texture>;
  65212. /**
  65213. * Represents the focal length for the depth of field effect
  65214. */
  65215. depthOfFieldDistance: number;
  65216. /**
  65217. * Represents the blur intensity for the blurred part of the depth of field effect
  65218. */
  65219. depthOfFieldBlurWidth: number;
  65220. /**
  65221. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65222. */
  65223. /**
  65224. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65225. */
  65226. motionStrength: number;
  65227. /**
  65228. * Gets wether or not the motion blur post-process is object based or screen based.
  65229. */
  65230. /**
  65231. * Sets wether or not the motion blur post-process should be object based or screen based
  65232. */
  65233. objectBasedMotionBlur: boolean;
  65234. /**
  65235. * List of animations for the pipeline (IAnimatable implementation)
  65236. */
  65237. animations: Animation[];
  65238. /**
  65239. * Private members
  65240. */
  65241. private _scene;
  65242. private _currentDepthOfFieldSource;
  65243. private _basePostProcess;
  65244. private _fixedExposure;
  65245. private _currentExposure;
  65246. private _hdrAutoExposure;
  65247. private _hdrCurrentLuminance;
  65248. private _motionStrength;
  65249. private _isObjectBasedMotionBlur;
  65250. private _floatTextureType;
  65251. private _camerasToBeAttached;
  65252. private _ratio;
  65253. private _bloomEnabled;
  65254. private _depthOfFieldEnabled;
  65255. private _vlsEnabled;
  65256. private _lensFlareEnabled;
  65257. private _hdrEnabled;
  65258. private _motionBlurEnabled;
  65259. private _fxaaEnabled;
  65260. private _motionBlurSamples;
  65261. private _volumetricLightStepsCount;
  65262. private _samples;
  65263. /**
  65264. * @ignore
  65265. * Specifies if the bloom pipeline is enabled
  65266. */
  65267. BloomEnabled: boolean;
  65268. /**
  65269. * @ignore
  65270. * Specifies if the depth of field pipeline is enabed
  65271. */
  65272. DepthOfFieldEnabled: boolean;
  65273. /**
  65274. * @ignore
  65275. * Specifies if the lens flare pipeline is enabed
  65276. */
  65277. LensFlareEnabled: boolean;
  65278. /**
  65279. * @ignore
  65280. * Specifies if the HDR pipeline is enabled
  65281. */
  65282. HDREnabled: boolean;
  65283. /**
  65284. * @ignore
  65285. * Specifies if the volumetric lights scattering effect is enabled
  65286. */
  65287. VLSEnabled: boolean;
  65288. /**
  65289. * @ignore
  65290. * Specifies if the motion blur effect is enabled
  65291. */
  65292. MotionBlurEnabled: boolean;
  65293. /**
  65294. * Specifies if anti-aliasing is enabled
  65295. */
  65296. fxaaEnabled: boolean;
  65297. /**
  65298. * Specifies the number of steps used to calculate the volumetric lights
  65299. * Typically in interval [50, 200]
  65300. */
  65301. volumetricLightStepsCount: number;
  65302. /**
  65303. * Specifies the number of samples used for the motion blur effect
  65304. * Typically in interval [16, 64]
  65305. */
  65306. motionBlurSamples: number;
  65307. /**
  65308. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65309. */
  65310. samples: number;
  65311. /**
  65312. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65313. * @constructor
  65314. * @param name The rendering pipeline name
  65315. * @param scene The scene linked to this pipeline
  65316. * @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)
  65317. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65318. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65319. */
  65320. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65321. private _buildPipeline;
  65322. private _createDownSampleX4PostProcess;
  65323. private _createBrightPassPostProcess;
  65324. private _createBlurPostProcesses;
  65325. private _createTextureAdderPostProcess;
  65326. private _createVolumetricLightPostProcess;
  65327. private _createLuminancePostProcesses;
  65328. private _createHdrPostProcess;
  65329. private _createLensFlarePostProcess;
  65330. private _createDepthOfFieldPostProcess;
  65331. private _createMotionBlurPostProcess;
  65332. private _getDepthTexture;
  65333. private _disposePostProcesses;
  65334. /**
  65335. * Dispose of the pipeline and stop all post processes
  65336. */
  65337. dispose(): void;
  65338. /**
  65339. * Serialize the rendering pipeline (Used when exporting)
  65340. * @returns the serialized object
  65341. */
  65342. serialize(): any;
  65343. /**
  65344. * Parse the serialized pipeline
  65345. * @param source Source pipeline.
  65346. * @param scene The scene to load the pipeline to.
  65347. * @param rootUrl The URL of the serialized pipeline.
  65348. * @returns An instantiated pipeline from the serialized object.
  65349. */
  65350. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65351. /**
  65352. * Luminance steps
  65353. */
  65354. static LuminanceSteps: number;
  65355. }
  65356. }
  65357. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65358. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65359. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65360. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65361. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65362. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65363. }
  65364. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65365. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65366. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65367. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65368. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65369. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65370. }
  65371. declare module "babylonjs/Shaders/tonemap.fragment" {
  65372. /** @hidden */
  65373. export var tonemapPixelShader: {
  65374. name: string;
  65375. shader: string;
  65376. };
  65377. }
  65378. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65379. import { Camera } from "babylonjs/Cameras/camera";
  65380. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65381. import "babylonjs/Shaders/tonemap.fragment";
  65382. import { Engine } from "babylonjs/Engines/engine";
  65383. /** Defines operator used for tonemapping */
  65384. export enum TonemappingOperator {
  65385. /** Hable */
  65386. Hable = 0,
  65387. /** Reinhard */
  65388. Reinhard = 1,
  65389. /** HejiDawson */
  65390. HejiDawson = 2,
  65391. /** Photographic */
  65392. Photographic = 3
  65393. }
  65394. /**
  65395. * Defines a post process to apply tone mapping
  65396. */
  65397. export class TonemapPostProcess extends PostProcess {
  65398. private _operator;
  65399. /** Defines the required exposure adjustement */
  65400. exposureAdjustment: number;
  65401. /**
  65402. * Creates a new TonemapPostProcess
  65403. * @param name defines the name of the postprocess
  65404. * @param _operator defines the operator to use
  65405. * @param exposureAdjustment defines the required exposure adjustement
  65406. * @param camera defines the camera to use (can be null)
  65407. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65408. * @param engine defines the hosting engine (can be ignore if camera is set)
  65409. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65410. */
  65411. constructor(name: string, _operator: TonemappingOperator,
  65412. /** Defines the required exposure adjustement */
  65413. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65414. }
  65415. }
  65416. declare module "babylonjs/Shaders/depth.vertex" {
  65417. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65418. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65419. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65420. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65422. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65423. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65424. /** @hidden */
  65425. export var depthVertexShader: {
  65426. name: string;
  65427. shader: string;
  65428. };
  65429. }
  65430. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65431. /** @hidden */
  65432. export var volumetricLightScatteringPixelShader: {
  65433. name: string;
  65434. shader: string;
  65435. };
  65436. }
  65437. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65438. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65439. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65440. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65441. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65442. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65443. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65444. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65445. /** @hidden */
  65446. export var volumetricLightScatteringPassVertexShader: {
  65447. name: string;
  65448. shader: string;
  65449. };
  65450. }
  65451. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65452. /** @hidden */
  65453. export var volumetricLightScatteringPassPixelShader: {
  65454. name: string;
  65455. shader: string;
  65456. };
  65457. }
  65458. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65459. import { Vector3 } from "babylonjs/Maths/math.vector";
  65460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65461. import { Mesh } from "babylonjs/Meshes/mesh";
  65462. import { Camera } from "babylonjs/Cameras/camera";
  65463. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65464. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65465. import { Scene } from "babylonjs/scene";
  65466. import "babylonjs/Meshes/Builders/planeBuilder";
  65467. import "babylonjs/Shaders/depth.vertex";
  65468. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65469. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65470. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65471. import { Engine } from "babylonjs/Engines/engine";
  65472. /**
  65473. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65474. */
  65475. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65476. private _volumetricLightScatteringPass;
  65477. private _volumetricLightScatteringRTT;
  65478. private _viewPort;
  65479. private _screenCoordinates;
  65480. private _cachedDefines;
  65481. /**
  65482. * If not undefined, the mesh position is computed from the attached node position
  65483. */
  65484. attachedNode: {
  65485. position: Vector3;
  65486. };
  65487. /**
  65488. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65489. */
  65490. customMeshPosition: Vector3;
  65491. /**
  65492. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65493. */
  65494. useCustomMeshPosition: boolean;
  65495. /**
  65496. * If the post-process should inverse the light scattering direction
  65497. */
  65498. invert: boolean;
  65499. /**
  65500. * The internal mesh used by the post-process
  65501. */
  65502. mesh: Mesh;
  65503. /**
  65504. * @hidden
  65505. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65506. */
  65507. useDiffuseColor: boolean;
  65508. /**
  65509. * Array containing the excluded meshes not rendered in the internal pass
  65510. */
  65511. excludedMeshes: AbstractMesh[];
  65512. /**
  65513. * Controls the overall intensity of the post-process
  65514. */
  65515. exposure: number;
  65516. /**
  65517. * Dissipates each sample's contribution in range [0, 1]
  65518. */
  65519. decay: number;
  65520. /**
  65521. * Controls the overall intensity of each sample
  65522. */
  65523. weight: number;
  65524. /**
  65525. * Controls the density of each sample
  65526. */
  65527. density: number;
  65528. /**
  65529. * @constructor
  65530. * @param name The post-process name
  65531. * @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)
  65532. * @param camera The camera that the post-process will be attached to
  65533. * @param mesh The mesh used to create the light scattering
  65534. * @param samples The post-process quality, default 100
  65535. * @param samplingModeThe post-process filtering mode
  65536. * @param engine The babylon engine
  65537. * @param reusable If the post-process is reusable
  65538. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65539. */
  65540. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65541. /**
  65542. * Returns the string "VolumetricLightScatteringPostProcess"
  65543. * @returns "VolumetricLightScatteringPostProcess"
  65544. */
  65545. getClassName(): string;
  65546. private _isReady;
  65547. /**
  65548. * Sets the new light position for light scattering effect
  65549. * @param position The new custom light position
  65550. */
  65551. setCustomMeshPosition(position: Vector3): void;
  65552. /**
  65553. * Returns the light position for light scattering effect
  65554. * @return Vector3 The custom light position
  65555. */
  65556. getCustomMeshPosition(): Vector3;
  65557. /**
  65558. * Disposes the internal assets and detaches the post-process from the camera
  65559. */
  65560. dispose(camera: Camera): void;
  65561. /**
  65562. * Returns the render target texture used by the post-process
  65563. * @return the render target texture used by the post-process
  65564. */
  65565. getPass(): RenderTargetTexture;
  65566. private _meshExcluded;
  65567. private _createPass;
  65568. private _updateMeshScreenCoordinates;
  65569. /**
  65570. * Creates a default mesh for the Volumeric Light Scattering post-process
  65571. * @param name The mesh name
  65572. * @param scene The scene where to create the mesh
  65573. * @return the default mesh
  65574. */
  65575. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65576. }
  65577. }
  65578. declare module "babylonjs/PostProcesses/index" {
  65579. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65580. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65581. export * from "babylonjs/PostProcesses/bloomEffect";
  65582. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65583. export * from "babylonjs/PostProcesses/blurPostProcess";
  65584. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65585. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65586. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65587. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65588. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65589. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65590. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65591. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65592. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65593. export * from "babylonjs/PostProcesses/filterPostProcess";
  65594. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65595. export * from "babylonjs/PostProcesses/grainPostProcess";
  65596. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65597. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65598. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65599. export * from "babylonjs/PostProcesses/passPostProcess";
  65600. export * from "babylonjs/PostProcesses/postProcess";
  65601. export * from "babylonjs/PostProcesses/postProcessManager";
  65602. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65603. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65604. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65605. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65606. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65607. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65608. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65609. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65610. }
  65611. declare module "babylonjs/Probes/index" {
  65612. export * from "babylonjs/Probes/reflectionProbe";
  65613. }
  65614. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65615. import { Scene } from "babylonjs/scene";
  65616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65617. import { SmartArray } from "babylonjs/Misc/smartArray";
  65618. import { ISceneComponent } from "babylonjs/sceneComponent";
  65619. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65620. import "babylonjs/Meshes/Builders/boxBuilder";
  65621. import "babylonjs/Shaders/color.fragment";
  65622. import "babylonjs/Shaders/color.vertex";
  65623. import { Color3 } from "babylonjs/Maths/math.color";
  65624. module "babylonjs/scene" {
  65625. interface Scene {
  65626. /** @hidden (Backing field) */
  65627. _boundingBoxRenderer: BoundingBoxRenderer;
  65628. /** @hidden (Backing field) */
  65629. _forceShowBoundingBoxes: boolean;
  65630. /**
  65631. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65632. */
  65633. forceShowBoundingBoxes: boolean;
  65634. /**
  65635. * Gets the bounding box renderer associated with the scene
  65636. * @returns a BoundingBoxRenderer
  65637. */
  65638. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65639. }
  65640. }
  65641. module "babylonjs/Meshes/abstractMesh" {
  65642. interface AbstractMesh {
  65643. /** @hidden (Backing field) */
  65644. _showBoundingBox: boolean;
  65645. /**
  65646. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65647. */
  65648. showBoundingBox: boolean;
  65649. }
  65650. }
  65651. /**
  65652. * Component responsible of rendering the bounding box of the meshes in a scene.
  65653. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65654. */
  65655. export class BoundingBoxRenderer implements ISceneComponent {
  65656. /**
  65657. * The component name helpfull to identify the component in the list of scene components.
  65658. */
  65659. readonly name: string;
  65660. /**
  65661. * The scene the component belongs to.
  65662. */
  65663. scene: Scene;
  65664. /**
  65665. * Color of the bounding box lines placed in front of an object
  65666. */
  65667. frontColor: Color3;
  65668. /**
  65669. * Color of the bounding box lines placed behind an object
  65670. */
  65671. backColor: Color3;
  65672. /**
  65673. * Defines if the renderer should show the back lines or not
  65674. */
  65675. showBackLines: boolean;
  65676. /**
  65677. * @hidden
  65678. */
  65679. renderList: SmartArray<BoundingBox>;
  65680. private _colorShader;
  65681. private _vertexBuffers;
  65682. private _indexBuffer;
  65683. private _fillIndexBuffer;
  65684. private _fillIndexData;
  65685. /**
  65686. * Instantiates a new bounding box renderer in a scene.
  65687. * @param scene the scene the renderer renders in
  65688. */
  65689. constructor(scene: Scene);
  65690. /**
  65691. * Registers the component in a given scene
  65692. */
  65693. register(): void;
  65694. private _evaluateSubMesh;
  65695. private _activeMesh;
  65696. private _prepareRessources;
  65697. private _createIndexBuffer;
  65698. /**
  65699. * Rebuilds the elements related to this component in case of
  65700. * context lost for instance.
  65701. */
  65702. rebuild(): void;
  65703. /**
  65704. * @hidden
  65705. */
  65706. reset(): void;
  65707. /**
  65708. * Render the bounding boxes of a specific rendering group
  65709. * @param renderingGroupId defines the rendering group to render
  65710. */
  65711. render(renderingGroupId: number): void;
  65712. /**
  65713. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65714. * @param mesh Define the mesh to render the occlusion bounding box for
  65715. */
  65716. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65717. /**
  65718. * Dispose and release the resources attached to this renderer.
  65719. */
  65720. dispose(): void;
  65721. }
  65722. }
  65723. declare module "babylonjs/Shaders/depth.fragment" {
  65724. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65725. /** @hidden */
  65726. export var depthPixelShader: {
  65727. name: string;
  65728. shader: string;
  65729. };
  65730. }
  65731. declare module "babylonjs/Rendering/depthRenderer" {
  65732. import { Nullable } from "babylonjs/types";
  65733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65734. import { Scene } from "babylonjs/scene";
  65735. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65736. import { Camera } from "babylonjs/Cameras/camera";
  65737. import "babylonjs/Shaders/depth.fragment";
  65738. import "babylonjs/Shaders/depth.vertex";
  65739. /**
  65740. * This represents a depth renderer in Babylon.
  65741. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65742. */
  65743. export class DepthRenderer {
  65744. private _scene;
  65745. private _depthMap;
  65746. private _effect;
  65747. private readonly _storeNonLinearDepth;
  65748. private readonly _clearColor;
  65749. /** Get if the depth renderer is using packed depth or not */
  65750. readonly isPacked: boolean;
  65751. private _cachedDefines;
  65752. private _camera;
  65753. /**
  65754. * Specifiess that the depth renderer will only be used within
  65755. * the camera it is created for.
  65756. * This can help forcing its rendering during the camera processing.
  65757. */
  65758. useOnlyInActiveCamera: boolean;
  65759. /** @hidden */
  65760. static _SceneComponentInitialization: (scene: Scene) => void;
  65761. /**
  65762. * Instantiates a depth renderer
  65763. * @param scene The scene the renderer belongs to
  65764. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65765. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65766. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65767. */
  65768. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65769. /**
  65770. * Creates the depth rendering effect and checks if the effect is ready.
  65771. * @param subMesh The submesh to be used to render the depth map of
  65772. * @param useInstances If multiple world instances should be used
  65773. * @returns if the depth renderer is ready to render the depth map
  65774. */
  65775. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65776. /**
  65777. * Gets the texture which the depth map will be written to.
  65778. * @returns The depth map texture
  65779. */
  65780. getDepthMap(): RenderTargetTexture;
  65781. /**
  65782. * Disposes of the depth renderer.
  65783. */
  65784. dispose(): void;
  65785. }
  65786. }
  65787. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65788. import { Nullable } from "babylonjs/types";
  65789. import { Scene } from "babylonjs/scene";
  65790. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65791. import { Camera } from "babylonjs/Cameras/camera";
  65792. import { ISceneComponent } from "babylonjs/sceneComponent";
  65793. module "babylonjs/scene" {
  65794. interface Scene {
  65795. /** @hidden (Backing field) */
  65796. _depthRenderer: {
  65797. [id: string]: DepthRenderer;
  65798. };
  65799. /**
  65800. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65801. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65802. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65803. * @returns the created depth renderer
  65804. */
  65805. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65806. /**
  65807. * Disables a depth renderer for a given camera
  65808. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65809. */
  65810. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65811. }
  65812. }
  65813. /**
  65814. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65815. * in several rendering techniques.
  65816. */
  65817. export class DepthRendererSceneComponent implements ISceneComponent {
  65818. /**
  65819. * The component name helpfull to identify the component in the list of scene components.
  65820. */
  65821. readonly name: string;
  65822. /**
  65823. * The scene the component belongs to.
  65824. */
  65825. scene: Scene;
  65826. /**
  65827. * Creates a new instance of the component for the given scene
  65828. * @param scene Defines the scene to register the component in
  65829. */
  65830. constructor(scene: Scene);
  65831. /**
  65832. * Registers the component in a given scene
  65833. */
  65834. register(): void;
  65835. /**
  65836. * Rebuilds the elements related to this component in case of
  65837. * context lost for instance.
  65838. */
  65839. rebuild(): void;
  65840. /**
  65841. * Disposes the component and the associated ressources
  65842. */
  65843. dispose(): void;
  65844. private _gatherRenderTargets;
  65845. private _gatherActiveCameraRenderTargets;
  65846. }
  65847. }
  65848. declare module "babylonjs/Shaders/outline.fragment" {
  65849. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65850. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65851. /** @hidden */
  65852. export var outlinePixelShader: {
  65853. name: string;
  65854. shader: string;
  65855. };
  65856. }
  65857. declare module "babylonjs/Shaders/outline.vertex" {
  65858. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65860. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65861. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65862. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65864. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65865. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65866. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65867. /** @hidden */
  65868. export var outlineVertexShader: {
  65869. name: string;
  65870. shader: string;
  65871. };
  65872. }
  65873. declare module "babylonjs/Rendering/outlineRenderer" {
  65874. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65875. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65876. import { Scene } from "babylonjs/scene";
  65877. import { ISceneComponent } from "babylonjs/sceneComponent";
  65878. import "babylonjs/Shaders/outline.fragment";
  65879. import "babylonjs/Shaders/outline.vertex";
  65880. module "babylonjs/scene" {
  65881. interface Scene {
  65882. /** @hidden */
  65883. _outlineRenderer: OutlineRenderer;
  65884. /**
  65885. * Gets the outline renderer associated with the scene
  65886. * @returns a OutlineRenderer
  65887. */
  65888. getOutlineRenderer(): OutlineRenderer;
  65889. }
  65890. }
  65891. module "babylonjs/Meshes/abstractMesh" {
  65892. interface AbstractMesh {
  65893. /** @hidden (Backing field) */
  65894. _renderOutline: boolean;
  65895. /**
  65896. * Gets or sets a boolean indicating if the outline must be rendered as well
  65897. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65898. */
  65899. renderOutline: boolean;
  65900. /** @hidden (Backing field) */
  65901. _renderOverlay: boolean;
  65902. /**
  65903. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65904. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65905. */
  65906. renderOverlay: boolean;
  65907. }
  65908. }
  65909. /**
  65910. * This class is responsible to draw bothe outline/overlay of meshes.
  65911. * It should not be used directly but through the available method on mesh.
  65912. */
  65913. export class OutlineRenderer implements ISceneComponent {
  65914. /**
  65915. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65916. */
  65917. private static _StencilReference;
  65918. /**
  65919. * The name of the component. Each component must have a unique name.
  65920. */
  65921. name: string;
  65922. /**
  65923. * The scene the component belongs to.
  65924. */
  65925. scene: Scene;
  65926. /**
  65927. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65928. */
  65929. zOffset: number;
  65930. private _engine;
  65931. private _effect;
  65932. private _cachedDefines;
  65933. private _savedDepthWrite;
  65934. /**
  65935. * Instantiates a new outline renderer. (There could be only one per scene).
  65936. * @param scene Defines the scene it belongs to
  65937. */
  65938. constructor(scene: Scene);
  65939. /**
  65940. * Register the component to one instance of a scene.
  65941. */
  65942. register(): void;
  65943. /**
  65944. * Rebuilds the elements related to this component in case of
  65945. * context lost for instance.
  65946. */
  65947. rebuild(): void;
  65948. /**
  65949. * Disposes the component and the associated ressources.
  65950. */
  65951. dispose(): void;
  65952. /**
  65953. * Renders the outline in the canvas.
  65954. * @param subMesh Defines the sumesh to render
  65955. * @param batch Defines the batch of meshes in case of instances
  65956. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65957. */
  65958. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65959. /**
  65960. * Returns whether or not the outline renderer is ready for a given submesh.
  65961. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65962. * @param subMesh Defines the submesh to check readyness for
  65963. * @param useInstances Defines wheter wee are trying to render instances or not
  65964. * @returns true if ready otherwise false
  65965. */
  65966. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65967. private _beforeRenderingMesh;
  65968. private _afterRenderingMesh;
  65969. }
  65970. }
  65971. declare module "babylonjs/Rendering/index" {
  65972. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65973. export * from "babylonjs/Rendering/depthRenderer";
  65974. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65975. export * from "babylonjs/Rendering/edgesRenderer";
  65976. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65977. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65978. export * from "babylonjs/Rendering/outlineRenderer";
  65979. export * from "babylonjs/Rendering/renderingGroup";
  65980. export * from "babylonjs/Rendering/renderingManager";
  65981. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65982. }
  65983. declare module "babylonjs/Sprites/spritePackedManager" {
  65984. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65985. import { Scene } from "babylonjs/scene";
  65986. /**
  65987. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65988. * @see http://doc.babylonjs.com/babylon101/sprites
  65989. */
  65990. export class SpritePackedManager extends SpriteManager {
  65991. /** defines the packed manager's name */
  65992. name: string;
  65993. /**
  65994. * Creates a new sprite manager from a packed sprite sheet
  65995. * @param name defines the manager's name
  65996. * @param imgUrl defines the sprite sheet url
  65997. * @param capacity defines the maximum allowed number of sprites
  65998. * @param scene defines the hosting scene
  65999. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66000. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66001. * @param samplingMode defines the smapling mode to use with spritesheet
  66002. * @param fromPacked set to true; do not alter
  66003. */
  66004. constructor(
  66005. /** defines the packed manager's name */
  66006. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66007. }
  66008. }
  66009. declare module "babylonjs/Sprites/index" {
  66010. export * from "babylonjs/Sprites/sprite";
  66011. export * from "babylonjs/Sprites/spriteManager";
  66012. export * from "babylonjs/Sprites/spritePackedManager";
  66013. export * from "babylonjs/Sprites/spriteSceneComponent";
  66014. }
  66015. declare module "babylonjs/States/index" {
  66016. export * from "babylonjs/States/alphaCullingState";
  66017. export * from "babylonjs/States/depthCullingState";
  66018. export * from "babylonjs/States/stencilState";
  66019. }
  66020. declare module "babylonjs/Misc/assetsManager" {
  66021. import { Scene } from "babylonjs/scene";
  66022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66023. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66024. import { Skeleton } from "babylonjs/Bones/skeleton";
  66025. import { Observable } from "babylonjs/Misc/observable";
  66026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66027. import { Texture } from "babylonjs/Materials/Textures/texture";
  66028. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66029. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66030. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66031. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66032. /**
  66033. * Defines the list of states available for a task inside a AssetsManager
  66034. */
  66035. export enum AssetTaskState {
  66036. /**
  66037. * Initialization
  66038. */
  66039. INIT = 0,
  66040. /**
  66041. * Running
  66042. */
  66043. RUNNING = 1,
  66044. /**
  66045. * Done
  66046. */
  66047. DONE = 2,
  66048. /**
  66049. * Error
  66050. */
  66051. ERROR = 3
  66052. }
  66053. /**
  66054. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66055. */
  66056. export abstract class AbstractAssetTask {
  66057. /**
  66058. * Task name
  66059. */ name: string;
  66060. /**
  66061. * Callback called when the task is successful
  66062. */
  66063. onSuccess: (task: any) => void;
  66064. /**
  66065. * Callback called when the task is not successful
  66066. */
  66067. onError: (task: any, message?: string, exception?: any) => void;
  66068. /**
  66069. * Creates a new AssetsManager
  66070. * @param name defines the name of the task
  66071. */
  66072. constructor(
  66073. /**
  66074. * Task name
  66075. */ name: string);
  66076. private _isCompleted;
  66077. private _taskState;
  66078. private _errorObject;
  66079. /**
  66080. * Get if the task is completed
  66081. */
  66082. readonly isCompleted: boolean;
  66083. /**
  66084. * Gets the current state of the task
  66085. */
  66086. readonly taskState: AssetTaskState;
  66087. /**
  66088. * Gets the current error object (if task is in error)
  66089. */
  66090. readonly errorObject: {
  66091. message?: string;
  66092. exception?: any;
  66093. };
  66094. /**
  66095. * Internal only
  66096. * @hidden
  66097. */
  66098. _setErrorObject(message?: string, exception?: any): void;
  66099. /**
  66100. * Execute the current task
  66101. * @param scene defines the scene where you want your assets to be loaded
  66102. * @param onSuccess is a callback called when the task is successfully executed
  66103. * @param onError is a callback called if an error occurs
  66104. */
  66105. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66106. /**
  66107. * Execute the current task
  66108. * @param scene defines the scene where you want your assets to be loaded
  66109. * @param onSuccess is a callback called when the task is successfully executed
  66110. * @param onError is a callback called if an error occurs
  66111. */
  66112. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66113. /**
  66114. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66115. * This can be used with failed tasks that have the reason for failure fixed.
  66116. */
  66117. reset(): void;
  66118. private onErrorCallback;
  66119. private onDoneCallback;
  66120. }
  66121. /**
  66122. * Define the interface used by progress events raised during assets loading
  66123. */
  66124. export interface IAssetsProgressEvent {
  66125. /**
  66126. * Defines the number of remaining tasks to process
  66127. */
  66128. remainingCount: number;
  66129. /**
  66130. * Defines the total number of tasks
  66131. */
  66132. totalCount: number;
  66133. /**
  66134. * Defines the task that was just processed
  66135. */
  66136. task: AbstractAssetTask;
  66137. }
  66138. /**
  66139. * Class used to share progress information about assets loading
  66140. */
  66141. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66142. /**
  66143. * Defines the number of remaining tasks to process
  66144. */
  66145. remainingCount: number;
  66146. /**
  66147. * Defines the total number of tasks
  66148. */
  66149. totalCount: number;
  66150. /**
  66151. * Defines the task that was just processed
  66152. */
  66153. task: AbstractAssetTask;
  66154. /**
  66155. * Creates a AssetsProgressEvent
  66156. * @param remainingCount defines the number of remaining tasks to process
  66157. * @param totalCount defines the total number of tasks
  66158. * @param task defines the task that was just processed
  66159. */
  66160. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66161. }
  66162. /**
  66163. * Define a task used by AssetsManager to load meshes
  66164. */
  66165. export class MeshAssetTask extends AbstractAssetTask {
  66166. /**
  66167. * Defines the name of the task
  66168. */
  66169. name: string;
  66170. /**
  66171. * Defines the list of mesh's names you want to load
  66172. */
  66173. meshesNames: any;
  66174. /**
  66175. * Defines the root url to use as a base to load your meshes and associated resources
  66176. */
  66177. rootUrl: string;
  66178. /**
  66179. * Defines the filename of the scene to load from
  66180. */
  66181. sceneFilename: string;
  66182. /**
  66183. * Gets the list of loaded meshes
  66184. */
  66185. loadedMeshes: Array<AbstractMesh>;
  66186. /**
  66187. * Gets the list of loaded particle systems
  66188. */
  66189. loadedParticleSystems: Array<IParticleSystem>;
  66190. /**
  66191. * Gets the list of loaded skeletons
  66192. */
  66193. loadedSkeletons: Array<Skeleton>;
  66194. /**
  66195. * Gets the list of loaded animation groups
  66196. */
  66197. loadedAnimationGroups: Array<AnimationGroup>;
  66198. /**
  66199. * Callback called when the task is successful
  66200. */
  66201. onSuccess: (task: MeshAssetTask) => void;
  66202. /**
  66203. * Callback called when the task is successful
  66204. */
  66205. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66206. /**
  66207. * Creates a new MeshAssetTask
  66208. * @param name defines the name of the task
  66209. * @param meshesNames defines the list of mesh's names you want to load
  66210. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66211. * @param sceneFilename defines the filename of the scene to load from
  66212. */
  66213. constructor(
  66214. /**
  66215. * Defines the name of the task
  66216. */
  66217. name: string,
  66218. /**
  66219. * Defines the list of mesh's names you want to load
  66220. */
  66221. meshesNames: any,
  66222. /**
  66223. * Defines the root url to use as a base to load your meshes and associated resources
  66224. */
  66225. rootUrl: string,
  66226. /**
  66227. * Defines the filename of the scene to load from
  66228. */
  66229. sceneFilename: string);
  66230. /**
  66231. * Execute the current task
  66232. * @param scene defines the scene where you want your assets to be loaded
  66233. * @param onSuccess is a callback called when the task is successfully executed
  66234. * @param onError is a callback called if an error occurs
  66235. */
  66236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66237. }
  66238. /**
  66239. * Define a task used by AssetsManager to load text content
  66240. */
  66241. export class TextFileAssetTask extends AbstractAssetTask {
  66242. /**
  66243. * Defines the name of the task
  66244. */
  66245. name: string;
  66246. /**
  66247. * Defines the location of the file to load
  66248. */
  66249. url: string;
  66250. /**
  66251. * Gets the loaded text string
  66252. */
  66253. text: string;
  66254. /**
  66255. * Callback called when the task is successful
  66256. */
  66257. onSuccess: (task: TextFileAssetTask) => void;
  66258. /**
  66259. * Callback called when the task is successful
  66260. */
  66261. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66262. /**
  66263. * Creates a new TextFileAssetTask object
  66264. * @param name defines the name of the task
  66265. * @param url defines the location of the file to load
  66266. */
  66267. constructor(
  66268. /**
  66269. * Defines the name of the task
  66270. */
  66271. name: string,
  66272. /**
  66273. * Defines the location of the file to load
  66274. */
  66275. url: string);
  66276. /**
  66277. * Execute the current task
  66278. * @param scene defines the scene where you want your assets to be loaded
  66279. * @param onSuccess is a callback called when the task is successfully executed
  66280. * @param onError is a callback called if an error occurs
  66281. */
  66282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66283. }
  66284. /**
  66285. * Define a task used by AssetsManager to load binary data
  66286. */
  66287. export class BinaryFileAssetTask extends AbstractAssetTask {
  66288. /**
  66289. * Defines the name of the task
  66290. */
  66291. name: string;
  66292. /**
  66293. * Defines the location of the file to load
  66294. */
  66295. url: string;
  66296. /**
  66297. * Gets the lodaded data (as an array buffer)
  66298. */
  66299. data: ArrayBuffer;
  66300. /**
  66301. * Callback called when the task is successful
  66302. */
  66303. onSuccess: (task: BinaryFileAssetTask) => void;
  66304. /**
  66305. * Callback called when the task is successful
  66306. */
  66307. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66308. /**
  66309. * Creates a new BinaryFileAssetTask object
  66310. * @param name defines the name of the new task
  66311. * @param url defines the location of the file to load
  66312. */
  66313. constructor(
  66314. /**
  66315. * Defines the name of the task
  66316. */
  66317. name: string,
  66318. /**
  66319. * Defines the location of the file to load
  66320. */
  66321. url: string);
  66322. /**
  66323. * Execute the current task
  66324. * @param scene defines the scene where you want your assets to be loaded
  66325. * @param onSuccess is a callback called when the task is successfully executed
  66326. * @param onError is a callback called if an error occurs
  66327. */
  66328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66329. }
  66330. /**
  66331. * Define a task used by AssetsManager to load images
  66332. */
  66333. export class ImageAssetTask extends AbstractAssetTask {
  66334. /**
  66335. * Defines the name of the task
  66336. */
  66337. name: string;
  66338. /**
  66339. * Defines the location of the image to load
  66340. */
  66341. url: string;
  66342. /**
  66343. * Gets the loaded images
  66344. */
  66345. image: HTMLImageElement;
  66346. /**
  66347. * Callback called when the task is successful
  66348. */
  66349. onSuccess: (task: ImageAssetTask) => void;
  66350. /**
  66351. * Callback called when the task is successful
  66352. */
  66353. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66354. /**
  66355. * Creates a new ImageAssetTask
  66356. * @param name defines the name of the task
  66357. * @param url defines the location of the image to load
  66358. */
  66359. constructor(
  66360. /**
  66361. * Defines the name of the task
  66362. */
  66363. name: string,
  66364. /**
  66365. * Defines the location of the image to load
  66366. */
  66367. url: string);
  66368. /**
  66369. * Execute the current task
  66370. * @param scene defines the scene where you want your assets to be loaded
  66371. * @param onSuccess is a callback called when the task is successfully executed
  66372. * @param onError is a callback called if an error occurs
  66373. */
  66374. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66375. }
  66376. /**
  66377. * Defines the interface used by texture loading tasks
  66378. */
  66379. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66380. /**
  66381. * Gets the loaded texture
  66382. */
  66383. texture: TEX;
  66384. }
  66385. /**
  66386. * Define a task used by AssetsManager to load 2D textures
  66387. */
  66388. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66389. /**
  66390. * Defines the name of the task
  66391. */
  66392. name: string;
  66393. /**
  66394. * Defines the location of the file to load
  66395. */
  66396. url: string;
  66397. /**
  66398. * Defines if mipmap should not be generated (default is false)
  66399. */
  66400. noMipmap?: boolean | undefined;
  66401. /**
  66402. * Defines if texture must be inverted on Y axis (default is false)
  66403. */
  66404. invertY?: boolean | undefined;
  66405. /**
  66406. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66407. */
  66408. samplingMode: number;
  66409. /**
  66410. * Gets the loaded texture
  66411. */
  66412. texture: Texture;
  66413. /**
  66414. * Callback called when the task is successful
  66415. */
  66416. onSuccess: (task: TextureAssetTask) => void;
  66417. /**
  66418. * Callback called when the task is successful
  66419. */
  66420. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66421. /**
  66422. * Creates a new TextureAssetTask object
  66423. * @param name defines the name of the task
  66424. * @param url defines the location of the file to load
  66425. * @param noMipmap defines if mipmap should not be generated (default is false)
  66426. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66427. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66428. */
  66429. constructor(
  66430. /**
  66431. * Defines the name of the task
  66432. */
  66433. name: string,
  66434. /**
  66435. * Defines the location of the file to load
  66436. */
  66437. url: string,
  66438. /**
  66439. * Defines if mipmap should not be generated (default is false)
  66440. */
  66441. noMipmap?: boolean | undefined,
  66442. /**
  66443. * Defines if texture must be inverted on Y axis (default is false)
  66444. */
  66445. invertY?: boolean | undefined,
  66446. /**
  66447. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66448. */
  66449. samplingMode?: number);
  66450. /**
  66451. * Execute the current task
  66452. * @param scene defines the scene where you want your assets to be loaded
  66453. * @param onSuccess is a callback called when the task is successfully executed
  66454. * @param onError is a callback called if an error occurs
  66455. */
  66456. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66457. }
  66458. /**
  66459. * Define a task used by AssetsManager to load cube textures
  66460. */
  66461. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66462. /**
  66463. * Defines the name of the task
  66464. */
  66465. name: string;
  66466. /**
  66467. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66468. */
  66469. url: string;
  66470. /**
  66471. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66472. */
  66473. extensions?: string[] | undefined;
  66474. /**
  66475. * Defines if mipmaps should not be generated (default is false)
  66476. */
  66477. noMipmap?: boolean | undefined;
  66478. /**
  66479. * Defines the explicit list of files (undefined by default)
  66480. */
  66481. files?: string[] | undefined;
  66482. /**
  66483. * Gets the loaded texture
  66484. */
  66485. texture: CubeTexture;
  66486. /**
  66487. * Callback called when the task is successful
  66488. */
  66489. onSuccess: (task: CubeTextureAssetTask) => void;
  66490. /**
  66491. * Callback called when the task is successful
  66492. */
  66493. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66494. /**
  66495. * Creates a new CubeTextureAssetTask
  66496. * @param name defines the name of the task
  66497. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66498. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66499. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66500. * @param files defines the explicit list of files (undefined by default)
  66501. */
  66502. constructor(
  66503. /**
  66504. * Defines the name of the task
  66505. */
  66506. name: string,
  66507. /**
  66508. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66509. */
  66510. url: string,
  66511. /**
  66512. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66513. */
  66514. extensions?: string[] | undefined,
  66515. /**
  66516. * Defines if mipmaps should not be generated (default is false)
  66517. */
  66518. noMipmap?: boolean | undefined,
  66519. /**
  66520. * Defines the explicit list of files (undefined by default)
  66521. */
  66522. files?: string[] | undefined);
  66523. /**
  66524. * Execute the current task
  66525. * @param scene defines the scene where you want your assets to be loaded
  66526. * @param onSuccess is a callback called when the task is successfully executed
  66527. * @param onError is a callback called if an error occurs
  66528. */
  66529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66530. }
  66531. /**
  66532. * Define a task used by AssetsManager to load HDR cube textures
  66533. */
  66534. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66535. /**
  66536. * Defines the name of the task
  66537. */
  66538. name: string;
  66539. /**
  66540. * Defines the location of the file to load
  66541. */
  66542. url: string;
  66543. /**
  66544. * Defines the desired size (the more it increases the longer the generation will be)
  66545. */
  66546. size: number;
  66547. /**
  66548. * Defines if mipmaps should not be generated (default is false)
  66549. */
  66550. noMipmap: boolean;
  66551. /**
  66552. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66553. */
  66554. generateHarmonics: boolean;
  66555. /**
  66556. * 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)
  66557. */
  66558. gammaSpace: boolean;
  66559. /**
  66560. * Internal Use Only
  66561. */
  66562. reserved: boolean;
  66563. /**
  66564. * Gets the loaded texture
  66565. */
  66566. texture: HDRCubeTexture;
  66567. /**
  66568. * Callback called when the task is successful
  66569. */
  66570. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66571. /**
  66572. * Callback called when the task is successful
  66573. */
  66574. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66575. /**
  66576. * Creates a new HDRCubeTextureAssetTask object
  66577. * @param name defines the name of the task
  66578. * @param url defines the location of the file to load
  66579. * @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.
  66580. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66581. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66582. * @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)
  66583. * @param reserved Internal use only
  66584. */
  66585. constructor(
  66586. /**
  66587. * Defines the name of the task
  66588. */
  66589. name: string,
  66590. /**
  66591. * Defines the location of the file to load
  66592. */
  66593. url: string,
  66594. /**
  66595. * Defines the desired size (the more it increases the longer the generation will be)
  66596. */
  66597. size: number,
  66598. /**
  66599. * Defines if mipmaps should not be generated (default is false)
  66600. */
  66601. noMipmap?: boolean,
  66602. /**
  66603. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66604. */
  66605. generateHarmonics?: boolean,
  66606. /**
  66607. * 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)
  66608. */
  66609. gammaSpace?: boolean,
  66610. /**
  66611. * Internal Use Only
  66612. */
  66613. reserved?: boolean);
  66614. /**
  66615. * Execute the current task
  66616. * @param scene defines the scene where you want your assets to be loaded
  66617. * @param onSuccess is a callback called when the task is successfully executed
  66618. * @param onError is a callback called if an error occurs
  66619. */
  66620. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66621. }
  66622. /**
  66623. * Define a task used by AssetsManager to load Equirectangular cube textures
  66624. */
  66625. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66626. /**
  66627. * Defines the name of the task
  66628. */
  66629. name: string;
  66630. /**
  66631. * Defines the location of the file to load
  66632. */
  66633. url: string;
  66634. /**
  66635. * Defines the desired size (the more it increases the longer the generation will be)
  66636. */
  66637. size: number;
  66638. /**
  66639. * Defines if mipmaps should not be generated (default is false)
  66640. */
  66641. noMipmap: boolean;
  66642. /**
  66643. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66644. * but the standard material would require them in Gamma space) (default is true)
  66645. */
  66646. gammaSpace: boolean;
  66647. /**
  66648. * Gets the loaded texture
  66649. */
  66650. texture: EquiRectangularCubeTexture;
  66651. /**
  66652. * Callback called when the task is successful
  66653. */
  66654. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66655. /**
  66656. * Callback called when the task is successful
  66657. */
  66658. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66659. /**
  66660. * Creates a new EquiRectangularCubeTextureAssetTask object
  66661. * @param name defines the name of the task
  66662. * @param url defines the location of the file to load
  66663. * @param size defines the desired size (the more it increases the longer the generation will be)
  66664. * If the size is omitted this implies you are using a preprocessed cubemap.
  66665. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66666. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66667. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66668. * (default is true)
  66669. */
  66670. constructor(
  66671. /**
  66672. * Defines the name of the task
  66673. */
  66674. name: string,
  66675. /**
  66676. * Defines the location of the file to load
  66677. */
  66678. url: string,
  66679. /**
  66680. * Defines the desired size (the more it increases the longer the generation will be)
  66681. */
  66682. size: number,
  66683. /**
  66684. * Defines if mipmaps should not be generated (default is false)
  66685. */
  66686. noMipmap?: boolean,
  66687. /**
  66688. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66689. * but the standard material would require them in Gamma space) (default is true)
  66690. */
  66691. gammaSpace?: boolean);
  66692. /**
  66693. * Execute the current task
  66694. * @param scene defines the scene where you want your assets to be loaded
  66695. * @param onSuccess is a callback called when the task is successfully executed
  66696. * @param onError is a callback called if an error occurs
  66697. */
  66698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66699. }
  66700. /**
  66701. * This class can be used to easily import assets into a scene
  66702. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66703. */
  66704. export class AssetsManager {
  66705. private _scene;
  66706. private _isLoading;
  66707. protected _tasks: AbstractAssetTask[];
  66708. protected _waitingTasksCount: number;
  66709. protected _totalTasksCount: number;
  66710. /**
  66711. * Callback called when all tasks are processed
  66712. */
  66713. onFinish: (tasks: AbstractAssetTask[]) => void;
  66714. /**
  66715. * Callback called when a task is successful
  66716. */
  66717. onTaskSuccess: (task: AbstractAssetTask) => void;
  66718. /**
  66719. * Callback called when a task had an error
  66720. */
  66721. onTaskError: (task: AbstractAssetTask) => void;
  66722. /**
  66723. * Callback called when a task is done (whatever the result is)
  66724. */
  66725. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66726. /**
  66727. * Observable called when all tasks are processed
  66728. */
  66729. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66730. /**
  66731. * Observable called when a task had an error
  66732. */
  66733. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66734. /**
  66735. * Observable called when all tasks were executed
  66736. */
  66737. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66738. /**
  66739. * Observable called when a task is done (whatever the result is)
  66740. */
  66741. onProgressObservable: Observable<IAssetsProgressEvent>;
  66742. /**
  66743. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66744. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66745. */
  66746. useDefaultLoadingScreen: boolean;
  66747. /**
  66748. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66749. * when all assets have been downloaded.
  66750. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66751. */
  66752. autoHideLoadingUI: boolean;
  66753. /**
  66754. * Creates a new AssetsManager
  66755. * @param scene defines the scene to work on
  66756. */
  66757. constructor(scene: Scene);
  66758. /**
  66759. * Add a MeshAssetTask to the list of active tasks
  66760. * @param taskName defines the name of the new task
  66761. * @param meshesNames defines the name of meshes to load
  66762. * @param rootUrl defines the root url to use to locate files
  66763. * @param sceneFilename defines the filename of the scene file
  66764. * @returns a new MeshAssetTask object
  66765. */
  66766. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66767. /**
  66768. * Add a TextFileAssetTask to the list of active tasks
  66769. * @param taskName defines the name of the new task
  66770. * @param url defines the url of the file to load
  66771. * @returns a new TextFileAssetTask object
  66772. */
  66773. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66774. /**
  66775. * Add a BinaryFileAssetTask to the list of active tasks
  66776. * @param taskName defines the name of the new task
  66777. * @param url defines the url of the file to load
  66778. * @returns a new BinaryFileAssetTask object
  66779. */
  66780. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66781. /**
  66782. * Add a ImageAssetTask to the list of active tasks
  66783. * @param taskName defines the name of the new task
  66784. * @param url defines the url of the file to load
  66785. * @returns a new ImageAssetTask object
  66786. */
  66787. addImageTask(taskName: string, url: string): ImageAssetTask;
  66788. /**
  66789. * Add a TextureAssetTask to the list of active tasks
  66790. * @param taskName defines the name of the new task
  66791. * @param url defines the url of the file to load
  66792. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66793. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66794. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66795. * @returns a new TextureAssetTask object
  66796. */
  66797. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66798. /**
  66799. * Add a CubeTextureAssetTask to the list of active tasks
  66800. * @param taskName defines the name of the new task
  66801. * @param url defines the url of the file to load
  66802. * @param extensions defines the extension to use to load the cube map (can be null)
  66803. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66804. * @param files defines the list of files to load (can be null)
  66805. * @returns a new CubeTextureAssetTask object
  66806. */
  66807. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66808. /**
  66809. *
  66810. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66811. * @param taskName defines the name of the new task
  66812. * @param url defines the url of the file to load
  66813. * @param size defines the size you want for the cubemap (can be null)
  66814. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66815. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66816. * @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)
  66817. * @param reserved Internal use only
  66818. * @returns a new HDRCubeTextureAssetTask object
  66819. */
  66820. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66821. /**
  66822. *
  66823. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66824. * @param taskName defines the name of the new task
  66825. * @param url defines the url of the file to load
  66826. * @param size defines the size you want for the cubemap (can be null)
  66827. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66828. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66829. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66830. * @returns a new EquiRectangularCubeTextureAssetTask object
  66831. */
  66832. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66833. /**
  66834. * Remove a task from the assets manager.
  66835. * @param task the task to remove
  66836. */
  66837. removeTask(task: AbstractAssetTask): void;
  66838. private _decreaseWaitingTasksCount;
  66839. private _runTask;
  66840. /**
  66841. * Reset the AssetsManager and remove all tasks
  66842. * @return the current instance of the AssetsManager
  66843. */
  66844. reset(): AssetsManager;
  66845. /**
  66846. * Start the loading process
  66847. * @return the current instance of the AssetsManager
  66848. */
  66849. load(): AssetsManager;
  66850. /**
  66851. * Start the loading process as an async operation
  66852. * @return a promise returning the list of failed tasks
  66853. */
  66854. loadAsync(): Promise<void>;
  66855. }
  66856. }
  66857. declare module "babylonjs/Misc/deferred" {
  66858. /**
  66859. * Wrapper class for promise with external resolve and reject.
  66860. */
  66861. export class Deferred<T> {
  66862. /**
  66863. * The promise associated with this deferred object.
  66864. */
  66865. readonly promise: Promise<T>;
  66866. private _resolve;
  66867. private _reject;
  66868. /**
  66869. * The resolve method of the promise associated with this deferred object.
  66870. */
  66871. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66872. /**
  66873. * The reject method of the promise associated with this deferred object.
  66874. */
  66875. readonly reject: (reason?: any) => void;
  66876. /**
  66877. * Constructor for this deferred object.
  66878. */
  66879. constructor();
  66880. }
  66881. }
  66882. declare module "babylonjs/Misc/meshExploder" {
  66883. import { Mesh } from "babylonjs/Meshes/mesh";
  66884. /**
  66885. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66886. */
  66887. export class MeshExploder {
  66888. private _centerMesh;
  66889. private _meshes;
  66890. private _meshesOrigins;
  66891. private _toCenterVectors;
  66892. private _scaledDirection;
  66893. private _newPosition;
  66894. private _centerPosition;
  66895. /**
  66896. * Explodes meshes from a center mesh.
  66897. * @param meshes The meshes to explode.
  66898. * @param centerMesh The mesh to be center of explosion.
  66899. */
  66900. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66901. private _setCenterMesh;
  66902. /**
  66903. * Get class name
  66904. * @returns "MeshExploder"
  66905. */
  66906. getClassName(): string;
  66907. /**
  66908. * "Exploded meshes"
  66909. * @returns Array of meshes with the centerMesh at index 0.
  66910. */
  66911. getMeshes(): Array<Mesh>;
  66912. /**
  66913. * Explodes meshes giving a specific direction
  66914. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66915. */
  66916. explode(direction?: number): void;
  66917. }
  66918. }
  66919. declare module "babylonjs/Misc/filesInput" {
  66920. import { Engine } from "babylonjs/Engines/engine";
  66921. import { Scene } from "babylonjs/scene";
  66922. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66923. /**
  66924. * Class used to help managing file picking and drag'n'drop
  66925. */
  66926. export class FilesInput {
  66927. /**
  66928. * List of files ready to be loaded
  66929. */
  66930. static readonly FilesToLoad: {
  66931. [key: string]: File;
  66932. };
  66933. /**
  66934. * Callback called when a file is processed
  66935. */
  66936. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66937. private _engine;
  66938. private _currentScene;
  66939. private _sceneLoadedCallback;
  66940. private _progressCallback;
  66941. private _additionalRenderLoopLogicCallback;
  66942. private _textureLoadingCallback;
  66943. private _startingProcessingFilesCallback;
  66944. private _onReloadCallback;
  66945. private _errorCallback;
  66946. private _elementToMonitor;
  66947. private _sceneFileToLoad;
  66948. private _filesToLoad;
  66949. /**
  66950. * Creates a new FilesInput
  66951. * @param engine defines the rendering engine
  66952. * @param scene defines the hosting scene
  66953. * @param sceneLoadedCallback callback called when scene is loaded
  66954. * @param progressCallback callback called to track progress
  66955. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66956. * @param textureLoadingCallback callback called when a texture is loading
  66957. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66958. * @param onReloadCallback callback called when a reload is requested
  66959. * @param errorCallback callback call if an error occurs
  66960. */
  66961. 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);
  66962. private _dragEnterHandler;
  66963. private _dragOverHandler;
  66964. private _dropHandler;
  66965. /**
  66966. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66967. * @param elementToMonitor defines the DOM element to track
  66968. */
  66969. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66970. /**
  66971. * Release all associated resources
  66972. */
  66973. dispose(): void;
  66974. private renderFunction;
  66975. private drag;
  66976. private drop;
  66977. private _traverseFolder;
  66978. private _processFiles;
  66979. /**
  66980. * Load files from a drop event
  66981. * @param event defines the drop event to use as source
  66982. */
  66983. loadFiles(event: any): void;
  66984. private _processReload;
  66985. /**
  66986. * Reload the current scene from the loaded files
  66987. */
  66988. reload(): void;
  66989. }
  66990. }
  66991. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66992. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66993. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66994. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66995. }
  66996. declare module "babylonjs/Misc/sceneOptimizer" {
  66997. import { Scene, IDisposable } from "babylonjs/scene";
  66998. import { Observable } from "babylonjs/Misc/observable";
  66999. /**
  67000. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67001. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67002. */
  67003. export class SceneOptimization {
  67004. /**
  67005. * Defines the priority of this optimization (0 by default which means first in the list)
  67006. */
  67007. priority: number;
  67008. /**
  67009. * Gets a string describing the action executed by the current optimization
  67010. * @returns description string
  67011. */
  67012. getDescription(): string;
  67013. /**
  67014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67015. * @param scene defines the current scene where to apply this optimization
  67016. * @param optimizer defines the current optimizer
  67017. * @returns true if everything that can be done was applied
  67018. */
  67019. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67020. /**
  67021. * Creates the SceneOptimization object
  67022. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67023. * @param desc defines the description associated with the optimization
  67024. */
  67025. constructor(
  67026. /**
  67027. * Defines the priority of this optimization (0 by default which means first in the list)
  67028. */
  67029. priority?: number);
  67030. }
  67031. /**
  67032. * Defines an optimization used to reduce the size of render target textures
  67033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67034. */
  67035. export class TextureOptimization extends SceneOptimization {
  67036. /**
  67037. * Defines the priority of this optimization (0 by default which means first in the list)
  67038. */
  67039. priority: number;
  67040. /**
  67041. * 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
  67042. */
  67043. maximumSize: number;
  67044. /**
  67045. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67046. */
  67047. step: number;
  67048. /**
  67049. * Gets a string describing the action executed by the current optimization
  67050. * @returns description string
  67051. */
  67052. getDescription(): string;
  67053. /**
  67054. * Creates the TextureOptimization object
  67055. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67056. * @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
  67057. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67058. */
  67059. constructor(
  67060. /**
  67061. * Defines the priority of this optimization (0 by default which means first in the list)
  67062. */
  67063. priority?: number,
  67064. /**
  67065. * 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
  67066. */
  67067. maximumSize?: number,
  67068. /**
  67069. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67070. */
  67071. step?: number);
  67072. /**
  67073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67074. * @param scene defines the current scene where to apply this optimization
  67075. * @param optimizer defines the current optimizer
  67076. * @returns true if everything that can be done was applied
  67077. */
  67078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67079. }
  67080. /**
  67081. * Defines an optimization used to increase or decrease the rendering resolution
  67082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67083. */
  67084. export class HardwareScalingOptimization extends SceneOptimization {
  67085. /**
  67086. * Defines the priority of this optimization (0 by default which means first in the list)
  67087. */
  67088. priority: number;
  67089. /**
  67090. * Defines the maximum scale to use (2 by default)
  67091. */
  67092. maximumScale: number;
  67093. /**
  67094. * Defines the step to use between two passes (0.5 by default)
  67095. */
  67096. step: number;
  67097. private _currentScale;
  67098. private _directionOffset;
  67099. /**
  67100. * Gets a string describing the action executed by the current optimization
  67101. * @return description string
  67102. */
  67103. getDescription(): string;
  67104. /**
  67105. * Creates the HardwareScalingOptimization object
  67106. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67107. * @param maximumScale defines the maximum scale to use (2 by default)
  67108. * @param step defines the step to use between two passes (0.5 by default)
  67109. */
  67110. constructor(
  67111. /**
  67112. * Defines the priority of this optimization (0 by default which means first in the list)
  67113. */
  67114. priority?: number,
  67115. /**
  67116. * Defines the maximum scale to use (2 by default)
  67117. */
  67118. maximumScale?: number,
  67119. /**
  67120. * Defines the step to use between two passes (0.5 by default)
  67121. */
  67122. step?: number);
  67123. /**
  67124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67125. * @param scene defines the current scene where to apply this optimization
  67126. * @param optimizer defines the current optimizer
  67127. * @returns true if everything that can be done was applied
  67128. */
  67129. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67130. }
  67131. /**
  67132. * Defines an optimization used to remove shadows
  67133. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67134. */
  67135. export class ShadowsOptimization extends SceneOptimization {
  67136. /**
  67137. * Gets a string describing the action executed by the current optimization
  67138. * @return description string
  67139. */
  67140. getDescription(): string;
  67141. /**
  67142. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67143. * @param scene defines the current scene where to apply this optimization
  67144. * @param optimizer defines the current optimizer
  67145. * @returns true if everything that can be done was applied
  67146. */
  67147. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67148. }
  67149. /**
  67150. * Defines an optimization used to turn post-processes off
  67151. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67152. */
  67153. export class PostProcessesOptimization extends SceneOptimization {
  67154. /**
  67155. * Gets a string describing the action executed by the current optimization
  67156. * @return description string
  67157. */
  67158. getDescription(): string;
  67159. /**
  67160. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67161. * @param scene defines the current scene where to apply this optimization
  67162. * @param optimizer defines the current optimizer
  67163. * @returns true if everything that can be done was applied
  67164. */
  67165. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67166. }
  67167. /**
  67168. * Defines an optimization used to turn lens flares off
  67169. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67170. */
  67171. export class LensFlaresOptimization extends SceneOptimization {
  67172. /**
  67173. * Gets a string describing the action executed by the current optimization
  67174. * @return description string
  67175. */
  67176. getDescription(): string;
  67177. /**
  67178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67179. * @param scene defines the current scene where to apply this optimization
  67180. * @param optimizer defines the current optimizer
  67181. * @returns true if everything that can be done was applied
  67182. */
  67183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67184. }
  67185. /**
  67186. * Defines an optimization based on user defined callback.
  67187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67188. */
  67189. export class CustomOptimization extends SceneOptimization {
  67190. /**
  67191. * Callback called to apply the custom optimization.
  67192. */
  67193. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67194. /**
  67195. * Callback called to get custom description
  67196. */
  67197. onGetDescription: () => string;
  67198. /**
  67199. * Gets a string describing the action executed by the current optimization
  67200. * @returns description string
  67201. */
  67202. getDescription(): string;
  67203. /**
  67204. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67205. * @param scene defines the current scene where to apply this optimization
  67206. * @param optimizer defines the current optimizer
  67207. * @returns true if everything that can be done was applied
  67208. */
  67209. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67210. }
  67211. /**
  67212. * Defines an optimization used to turn particles off
  67213. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67214. */
  67215. export class ParticlesOptimization extends SceneOptimization {
  67216. /**
  67217. * Gets a string describing the action executed by the current optimization
  67218. * @return description string
  67219. */
  67220. getDescription(): string;
  67221. /**
  67222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67223. * @param scene defines the current scene where to apply this optimization
  67224. * @param optimizer defines the current optimizer
  67225. * @returns true if everything that can be done was applied
  67226. */
  67227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67228. }
  67229. /**
  67230. * Defines an optimization used to turn render targets off
  67231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67232. */
  67233. export class RenderTargetsOptimization extends SceneOptimization {
  67234. /**
  67235. * Gets a string describing the action executed by the current optimization
  67236. * @return description string
  67237. */
  67238. getDescription(): string;
  67239. /**
  67240. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67241. * @param scene defines the current scene where to apply this optimization
  67242. * @param optimizer defines the current optimizer
  67243. * @returns true if everything that can be done was applied
  67244. */
  67245. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67246. }
  67247. /**
  67248. * Defines an optimization used to merge meshes with compatible materials
  67249. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67250. */
  67251. export class MergeMeshesOptimization extends SceneOptimization {
  67252. private static _UpdateSelectionTree;
  67253. /**
  67254. * Gets or sets a boolean which defines if optimization octree has to be updated
  67255. */
  67256. /**
  67257. * Gets or sets a boolean which defines if optimization octree has to be updated
  67258. */
  67259. static UpdateSelectionTree: boolean;
  67260. /**
  67261. * Gets a string describing the action executed by the current optimization
  67262. * @return description string
  67263. */
  67264. getDescription(): string;
  67265. private _canBeMerged;
  67266. /**
  67267. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67268. * @param scene defines the current scene where to apply this optimization
  67269. * @param optimizer defines the current optimizer
  67270. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67271. * @returns true if everything that can be done was applied
  67272. */
  67273. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67274. }
  67275. /**
  67276. * Defines a list of options used by SceneOptimizer
  67277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67278. */
  67279. export class SceneOptimizerOptions {
  67280. /**
  67281. * Defines the target frame rate to reach (60 by default)
  67282. */
  67283. targetFrameRate: number;
  67284. /**
  67285. * Defines the interval between two checkes (2000ms by default)
  67286. */
  67287. trackerDuration: number;
  67288. /**
  67289. * Gets the list of optimizations to apply
  67290. */
  67291. optimizations: SceneOptimization[];
  67292. /**
  67293. * Creates a new list of options used by SceneOptimizer
  67294. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67295. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67296. */
  67297. constructor(
  67298. /**
  67299. * Defines the target frame rate to reach (60 by default)
  67300. */
  67301. targetFrameRate?: number,
  67302. /**
  67303. * Defines the interval between two checkes (2000ms by default)
  67304. */
  67305. trackerDuration?: number);
  67306. /**
  67307. * Add a new optimization
  67308. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67309. * @returns the current SceneOptimizerOptions
  67310. */
  67311. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67312. /**
  67313. * Add a new custom optimization
  67314. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67315. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67316. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67317. * @returns the current SceneOptimizerOptions
  67318. */
  67319. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67320. /**
  67321. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67322. * @param targetFrameRate defines the target frame rate (60 by default)
  67323. * @returns a SceneOptimizerOptions object
  67324. */
  67325. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67326. /**
  67327. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67328. * @param targetFrameRate defines the target frame rate (60 by default)
  67329. * @returns a SceneOptimizerOptions object
  67330. */
  67331. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67332. /**
  67333. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67334. * @param targetFrameRate defines the target frame rate (60 by default)
  67335. * @returns a SceneOptimizerOptions object
  67336. */
  67337. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67338. }
  67339. /**
  67340. * Class used to run optimizations in order to reach a target frame rate
  67341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67342. */
  67343. export class SceneOptimizer implements IDisposable {
  67344. private _isRunning;
  67345. private _options;
  67346. private _scene;
  67347. private _currentPriorityLevel;
  67348. private _targetFrameRate;
  67349. private _trackerDuration;
  67350. private _currentFrameRate;
  67351. private _sceneDisposeObserver;
  67352. private _improvementMode;
  67353. /**
  67354. * Defines an observable called when the optimizer reaches the target frame rate
  67355. */
  67356. onSuccessObservable: Observable<SceneOptimizer>;
  67357. /**
  67358. * Defines an observable called when the optimizer enables an optimization
  67359. */
  67360. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67361. /**
  67362. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67363. */
  67364. onFailureObservable: Observable<SceneOptimizer>;
  67365. /**
  67366. * Gets a boolean indicating if the optimizer is in improvement mode
  67367. */
  67368. readonly isInImprovementMode: boolean;
  67369. /**
  67370. * Gets the current priority level (0 at start)
  67371. */
  67372. readonly currentPriorityLevel: number;
  67373. /**
  67374. * Gets the current frame rate checked by the SceneOptimizer
  67375. */
  67376. readonly currentFrameRate: number;
  67377. /**
  67378. * Gets or sets the current target frame rate (60 by default)
  67379. */
  67380. /**
  67381. * Gets or sets the current target frame rate (60 by default)
  67382. */
  67383. targetFrameRate: number;
  67384. /**
  67385. * Gets or sets the current interval between two checks (every 2000ms by default)
  67386. */
  67387. /**
  67388. * Gets or sets the current interval between two checks (every 2000ms by default)
  67389. */
  67390. trackerDuration: number;
  67391. /**
  67392. * Gets the list of active optimizations
  67393. */
  67394. readonly optimizations: SceneOptimization[];
  67395. /**
  67396. * Creates a new SceneOptimizer
  67397. * @param scene defines the scene to work on
  67398. * @param options defines the options to use with the SceneOptimizer
  67399. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67400. * @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)
  67401. */
  67402. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67403. /**
  67404. * Stops the current optimizer
  67405. */
  67406. stop(): void;
  67407. /**
  67408. * Reset the optimizer to initial step (current priority level = 0)
  67409. */
  67410. reset(): void;
  67411. /**
  67412. * Start the optimizer. By default it will try to reach a specific framerate
  67413. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67414. */
  67415. start(): void;
  67416. private _checkCurrentState;
  67417. /**
  67418. * Release all resources
  67419. */
  67420. dispose(): void;
  67421. /**
  67422. * Helper function to create a SceneOptimizer with one single line of code
  67423. * @param scene defines the scene to work on
  67424. * @param options defines the options to use with the SceneOptimizer
  67425. * @param onSuccess defines a callback to call on success
  67426. * @param onFailure defines a callback to call on failure
  67427. * @returns the new SceneOptimizer object
  67428. */
  67429. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67430. }
  67431. }
  67432. declare module "babylonjs/Misc/sceneSerializer" {
  67433. import { Scene } from "babylonjs/scene";
  67434. /**
  67435. * Class used to serialize a scene into a string
  67436. */
  67437. export class SceneSerializer {
  67438. /**
  67439. * Clear cache used by a previous serialization
  67440. */
  67441. static ClearCache(): void;
  67442. /**
  67443. * Serialize a scene into a JSON compatible object
  67444. * @param scene defines the scene to serialize
  67445. * @returns a JSON compatible object
  67446. */
  67447. static Serialize(scene: Scene): any;
  67448. /**
  67449. * Serialize a mesh into a JSON compatible object
  67450. * @param toSerialize defines the mesh to serialize
  67451. * @param withParents defines if parents must be serialized as well
  67452. * @param withChildren defines if children must be serialized as well
  67453. * @returns a JSON compatible object
  67454. */
  67455. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67456. }
  67457. }
  67458. declare module "babylonjs/Misc/textureTools" {
  67459. import { Texture } from "babylonjs/Materials/Textures/texture";
  67460. /**
  67461. * Class used to host texture specific utilities
  67462. */
  67463. export class TextureTools {
  67464. /**
  67465. * Uses the GPU to create a copy texture rescaled at a given size
  67466. * @param texture Texture to copy from
  67467. * @param width defines the desired width
  67468. * @param height defines the desired height
  67469. * @param useBilinearMode defines if bilinear mode has to be used
  67470. * @return the generated texture
  67471. */
  67472. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67473. }
  67474. }
  67475. declare module "babylonjs/Misc/videoRecorder" {
  67476. import { Nullable } from "babylonjs/types";
  67477. import { Engine } from "babylonjs/Engines/engine";
  67478. /**
  67479. * This represents the different options available for the video capture.
  67480. */
  67481. export interface VideoRecorderOptions {
  67482. /** Defines the mime type of the video. */
  67483. mimeType: string;
  67484. /** Defines the FPS the video should be recorded at. */
  67485. fps: number;
  67486. /** Defines the chunk size for the recording data. */
  67487. recordChunckSize: number;
  67488. /** The audio tracks to attach to the recording. */
  67489. audioTracks?: MediaStreamTrack[];
  67490. }
  67491. /**
  67492. * This can help with recording videos from BabylonJS.
  67493. * This is based on the available WebRTC functionalities of the browser.
  67494. *
  67495. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67496. */
  67497. export class VideoRecorder {
  67498. private static readonly _defaultOptions;
  67499. /**
  67500. * Returns whether or not the VideoRecorder is available in your browser.
  67501. * @param engine Defines the Babylon Engine.
  67502. * @returns true if supported otherwise false.
  67503. */
  67504. static IsSupported(engine: Engine): boolean;
  67505. private readonly _options;
  67506. private _canvas;
  67507. private _mediaRecorder;
  67508. private _recordedChunks;
  67509. private _fileName;
  67510. private _resolve;
  67511. private _reject;
  67512. /**
  67513. * True when a recording is already in progress.
  67514. */
  67515. readonly isRecording: boolean;
  67516. /**
  67517. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67518. * @param engine Defines the BabylonJS Engine you wish to record.
  67519. * @param options Defines options that can be used to customize the capture.
  67520. */
  67521. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67522. /**
  67523. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67524. */
  67525. stopRecording(): void;
  67526. /**
  67527. * Starts recording the canvas for a max duration specified in parameters.
  67528. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67529. * If null no automatic download will start and you can rely on the promise to get the data back.
  67530. * @param maxDuration Defines the maximum recording time in seconds.
  67531. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67532. * @return A promise callback at the end of the recording with the video data in Blob.
  67533. */
  67534. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67535. /**
  67536. * Releases internal resources used during the recording.
  67537. */
  67538. dispose(): void;
  67539. private _handleDataAvailable;
  67540. private _handleError;
  67541. private _handleStop;
  67542. }
  67543. }
  67544. declare module "babylonjs/Misc/screenshotTools" {
  67545. import { Camera } from "babylonjs/Cameras/camera";
  67546. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67547. import { Engine } from "babylonjs/Engines/engine";
  67548. /**
  67549. * Class containing a set of static utilities functions for screenshots
  67550. */
  67551. export class ScreenshotTools {
  67552. /**
  67553. * Captures a screenshot of the current rendering
  67554. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67555. * @param engine defines the rendering engine
  67556. * @param camera defines the source camera
  67557. * @param size This parameter can be set to a single number or to an object with the
  67558. * following (optional) properties: precision, width, height. If a single number is passed,
  67559. * it will be used for both width and height. If an object is passed, the screenshot size
  67560. * will be derived from the parameters. The precision property is a multiplier allowing
  67561. * rendering at a higher or lower resolution
  67562. * @param successCallback defines the callback receives a single parameter which contains the
  67563. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67564. * src parameter of an <img> to display it
  67565. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67566. * Check your browser for supported MIME types
  67567. */
  67568. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67569. /**
  67570. * Captures a screenshot of the current rendering
  67571. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67572. * @param engine defines the rendering engine
  67573. * @param camera defines the source camera
  67574. * @param size This parameter can be set to a single number or to an object with the
  67575. * following (optional) properties: precision, width, height. If a single number is passed,
  67576. * it will be used for both width and height. If an object is passed, the screenshot size
  67577. * will be derived from the parameters. The precision property is a multiplier allowing
  67578. * rendering at a higher or lower resolution
  67579. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67580. * Check your browser for supported MIME types
  67581. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67582. * to the src parameter of an <img> to display it
  67583. */
  67584. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67585. /**
  67586. * Generates an image screenshot from the specified camera.
  67587. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67588. * @param engine The engine to use for rendering
  67589. * @param camera The camera to use for rendering
  67590. * @param size This parameter can be set to a single number or to an object with the
  67591. * following (optional) properties: precision, width, height. If a single number is passed,
  67592. * it will be used for both width and height. If an object is passed, the screenshot size
  67593. * will be derived from the parameters. The precision property is a multiplier allowing
  67594. * rendering at a higher or lower resolution
  67595. * @param successCallback The callback receives a single parameter which contains the
  67596. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67597. * src parameter of an <img> to display it
  67598. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67599. * Check your browser for supported MIME types
  67600. * @param samples Texture samples (default: 1)
  67601. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67602. * @param fileName A name for for the downloaded file.
  67603. */
  67604. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67605. /**
  67606. * Generates an image screenshot from the specified camera.
  67607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67608. * @param engine The engine to use for rendering
  67609. * @param camera The camera to use for rendering
  67610. * @param size This parameter can be set to a single number or to an object with the
  67611. * following (optional) properties: precision, width, height. If a single number is passed,
  67612. * it will be used for both width and height. If an object is passed, the screenshot size
  67613. * will be derived from the parameters. The precision property is a multiplier allowing
  67614. * rendering at a higher or lower resolution
  67615. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67616. * Check your browser for supported MIME types
  67617. * @param samples Texture samples (default: 1)
  67618. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67619. * @param fileName A name for for the downloaded file.
  67620. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67621. * to the src parameter of an <img> to display it
  67622. */
  67623. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67624. /**
  67625. * Gets height and width for screenshot size
  67626. * @private
  67627. */
  67628. private static _getScreenshotSize;
  67629. }
  67630. }
  67631. declare module "babylonjs/Misc/dataReader" {
  67632. /**
  67633. * Interface for a data buffer
  67634. */
  67635. export interface IDataBuffer {
  67636. /**
  67637. * Reads bytes from the data buffer.
  67638. * @param byteOffset The byte offset to read
  67639. * @param byteLength The byte length to read
  67640. * @returns A promise that resolves when the bytes are read
  67641. */
  67642. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67643. /**
  67644. * The byte length of the buffer.
  67645. */
  67646. readonly byteLength: number;
  67647. }
  67648. /**
  67649. * Utility class for reading from a data buffer
  67650. */
  67651. export class DataReader {
  67652. /**
  67653. * The data buffer associated with this data reader.
  67654. */
  67655. readonly buffer: IDataBuffer;
  67656. /**
  67657. * The current byte offset from the beginning of the data buffer.
  67658. */
  67659. byteOffset: number;
  67660. private _dataView;
  67661. private _dataByteOffset;
  67662. /**
  67663. * Constructor
  67664. * @param buffer The buffer to read
  67665. */
  67666. constructor(buffer: IDataBuffer);
  67667. /**
  67668. * Loads the given byte length.
  67669. * @param byteLength The byte length to load
  67670. * @returns A promise that resolves when the load is complete
  67671. */
  67672. loadAsync(byteLength: number): Promise<void>;
  67673. /**
  67674. * Read a unsigned 32-bit integer from the currently loaded data range.
  67675. * @returns The 32-bit integer read
  67676. */
  67677. readUint32(): number;
  67678. /**
  67679. * Read a byte array from the currently loaded data range.
  67680. * @param byteLength The byte length to read
  67681. * @returns The byte array read
  67682. */
  67683. readUint8Array(byteLength: number): Uint8Array;
  67684. /**
  67685. * Read a string from the currently loaded data range.
  67686. * @param byteLength The byte length to read
  67687. * @returns The string read
  67688. */
  67689. readString(byteLength: number): string;
  67690. /**
  67691. * Skips the given byte length the currently loaded data range.
  67692. * @param byteLength The byte length to skip
  67693. */
  67694. skipBytes(byteLength: number): void;
  67695. }
  67696. }
  67697. declare module "babylonjs/Misc/index" {
  67698. export * from "babylonjs/Misc/andOrNotEvaluator";
  67699. export * from "babylonjs/Misc/assetsManager";
  67700. export * from "babylonjs/Misc/dds";
  67701. export * from "babylonjs/Misc/decorators";
  67702. export * from "babylonjs/Misc/deferred";
  67703. export * from "babylonjs/Misc/environmentTextureTools";
  67704. export * from "babylonjs/Misc/meshExploder";
  67705. export * from "babylonjs/Misc/filesInput";
  67706. export * from "babylonjs/Misc/HighDynamicRange/index";
  67707. export * from "babylonjs/Misc/khronosTextureContainer";
  67708. export * from "babylonjs/Misc/observable";
  67709. export * from "babylonjs/Misc/performanceMonitor";
  67710. export * from "babylonjs/Misc/promise";
  67711. export * from "babylonjs/Misc/sceneOptimizer";
  67712. export * from "babylonjs/Misc/sceneSerializer";
  67713. export * from "babylonjs/Misc/smartArray";
  67714. export * from "babylonjs/Misc/stringDictionary";
  67715. export * from "babylonjs/Misc/tags";
  67716. export * from "babylonjs/Misc/textureTools";
  67717. export * from "babylonjs/Misc/tga";
  67718. export * from "babylonjs/Misc/tools";
  67719. export * from "babylonjs/Misc/videoRecorder";
  67720. export * from "babylonjs/Misc/virtualJoystick";
  67721. export * from "babylonjs/Misc/workerPool";
  67722. export * from "babylonjs/Misc/logger";
  67723. export * from "babylonjs/Misc/typeStore";
  67724. export * from "babylonjs/Misc/filesInputStore";
  67725. export * from "babylonjs/Misc/deepCopier";
  67726. export * from "babylonjs/Misc/pivotTools";
  67727. export * from "babylonjs/Misc/precisionDate";
  67728. export * from "babylonjs/Misc/screenshotTools";
  67729. export * from "babylonjs/Misc/typeStore";
  67730. export * from "babylonjs/Misc/webRequest";
  67731. export * from "babylonjs/Misc/iInspectable";
  67732. export * from "babylonjs/Misc/brdfTextureTools";
  67733. export * from "babylonjs/Misc/rgbdTextureTools";
  67734. export * from "babylonjs/Misc/gradients";
  67735. export * from "babylonjs/Misc/perfCounter";
  67736. export * from "babylonjs/Misc/fileRequest";
  67737. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67738. export * from "babylonjs/Misc/retryStrategy";
  67739. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67740. export * from "babylonjs/Misc/canvasGenerator";
  67741. export * from "babylonjs/Misc/fileTools";
  67742. export * from "babylonjs/Misc/stringTools";
  67743. export * from "babylonjs/Misc/dataReader";
  67744. }
  67745. declare module "babylonjs/index" {
  67746. export * from "babylonjs/abstractScene";
  67747. export * from "babylonjs/Actions/index";
  67748. export * from "babylonjs/Animations/index";
  67749. export * from "babylonjs/assetContainer";
  67750. export * from "babylonjs/Audio/index";
  67751. export * from "babylonjs/Behaviors/index";
  67752. export * from "babylonjs/Bones/index";
  67753. export * from "babylonjs/Cameras/index";
  67754. export * from "babylonjs/Collisions/index";
  67755. export * from "babylonjs/Culling/index";
  67756. export * from "babylonjs/Debug/index";
  67757. export * from "babylonjs/Engines/index";
  67758. export * from "babylonjs/Events/index";
  67759. export * from "babylonjs/Gamepads/index";
  67760. export * from "babylonjs/Gizmos/index";
  67761. export * from "babylonjs/Helpers/index";
  67762. export * from "babylonjs/Instrumentation/index";
  67763. export * from "babylonjs/Layers/index";
  67764. export * from "babylonjs/LensFlares/index";
  67765. export * from "babylonjs/Lights/index";
  67766. export * from "babylonjs/Loading/index";
  67767. export * from "babylonjs/Materials/index";
  67768. export * from "babylonjs/Maths/index";
  67769. export * from "babylonjs/Meshes/index";
  67770. export * from "babylonjs/Morph/index";
  67771. export * from "babylonjs/Navigation/index";
  67772. export * from "babylonjs/node";
  67773. export * from "babylonjs/Offline/index";
  67774. export * from "babylonjs/Particles/index";
  67775. export * from "babylonjs/Physics/index";
  67776. export * from "babylonjs/PostProcesses/index";
  67777. export * from "babylonjs/Probes/index";
  67778. export * from "babylonjs/Rendering/index";
  67779. export * from "babylonjs/scene";
  67780. export * from "babylonjs/sceneComponent";
  67781. export * from "babylonjs/Sprites/index";
  67782. export * from "babylonjs/States/index";
  67783. export * from "babylonjs/Misc/index";
  67784. export * from "babylonjs/types";
  67785. }
  67786. declare module "babylonjs/Animations/pathCursor" {
  67787. import { Vector3 } from "babylonjs/Maths/math.vector";
  67788. import { Path2 } from "babylonjs/Maths/math.path";
  67789. /**
  67790. * A cursor which tracks a point on a path
  67791. */
  67792. export class PathCursor {
  67793. private path;
  67794. /**
  67795. * Stores path cursor callbacks for when an onchange event is triggered
  67796. */
  67797. private _onchange;
  67798. /**
  67799. * The value of the path cursor
  67800. */
  67801. value: number;
  67802. /**
  67803. * The animation array of the path cursor
  67804. */
  67805. animations: Animation[];
  67806. /**
  67807. * Initializes the path cursor
  67808. * @param path The path to track
  67809. */
  67810. constructor(path: Path2);
  67811. /**
  67812. * Gets the cursor point on the path
  67813. * @returns A point on the path cursor at the cursor location
  67814. */
  67815. getPoint(): Vector3;
  67816. /**
  67817. * Moves the cursor ahead by the step amount
  67818. * @param step The amount to move the cursor forward
  67819. * @returns This path cursor
  67820. */
  67821. moveAhead(step?: number): PathCursor;
  67822. /**
  67823. * Moves the cursor behind by the step amount
  67824. * @param step The amount to move the cursor back
  67825. * @returns This path cursor
  67826. */
  67827. moveBack(step?: number): PathCursor;
  67828. /**
  67829. * Moves the cursor by the step amount
  67830. * If the step amount is greater than one, an exception is thrown
  67831. * @param step The amount to move the cursor
  67832. * @returns This path cursor
  67833. */
  67834. move(step: number): PathCursor;
  67835. /**
  67836. * Ensures that the value is limited between zero and one
  67837. * @returns This path cursor
  67838. */
  67839. private ensureLimits;
  67840. /**
  67841. * Runs onchange callbacks on change (used by the animation engine)
  67842. * @returns This path cursor
  67843. */
  67844. private raiseOnChange;
  67845. /**
  67846. * Executes a function on change
  67847. * @param f A path cursor onchange callback
  67848. * @returns This path cursor
  67849. */
  67850. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67851. }
  67852. }
  67853. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67854. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67855. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67856. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67857. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67858. }
  67859. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67860. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67861. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67862. }
  67863. declare module "babylonjs/Engines/Processors/index" {
  67864. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67865. export * from "babylonjs/Engines/Processors/Expressions/index";
  67866. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67867. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67868. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67869. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67870. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67871. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67872. }
  67873. declare module "babylonjs/Legacy/legacy" {
  67874. import * as Babylon from "babylonjs/index";
  67875. export * from "babylonjs/index";
  67876. }
  67877. declare module "babylonjs/Shaders/blur.fragment" {
  67878. /** @hidden */
  67879. export var blurPixelShader: {
  67880. name: string;
  67881. shader: string;
  67882. };
  67883. }
  67884. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67885. /** @hidden */
  67886. export var pointCloudVertexDeclaration: {
  67887. name: string;
  67888. shader: string;
  67889. };
  67890. }
  67891. declare module "babylonjs" {
  67892. export * from "babylonjs/Legacy/legacy";
  67893. }
  67894. declare module BABYLON {
  67895. /** Alias type for value that can be null */
  67896. export type Nullable<T> = T | null;
  67897. /**
  67898. * Alias type for number that are floats
  67899. * @ignorenaming
  67900. */
  67901. export type float = number;
  67902. /**
  67903. * Alias type for number that are doubles.
  67904. * @ignorenaming
  67905. */
  67906. export type double = number;
  67907. /**
  67908. * Alias type for number that are integer
  67909. * @ignorenaming
  67910. */
  67911. export type int = number;
  67912. /** Alias type for number array or Float32Array */
  67913. export type FloatArray = number[] | Float32Array;
  67914. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67915. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67916. /**
  67917. * Alias for types that can be used by a Buffer or VertexBuffer.
  67918. */
  67919. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67920. /**
  67921. * Alias type for primitive types
  67922. * @ignorenaming
  67923. */
  67924. type Primitive = undefined | null | boolean | string | number | Function;
  67925. /**
  67926. * Type modifier to make all the properties of an object Readonly
  67927. */
  67928. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67929. /**
  67930. * Type modifier to make all the properties of an object Readonly recursively
  67931. */
  67932. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67933. /**
  67934. * Type modifier to make object properties readonly.
  67935. */
  67936. export type DeepImmutableObject<T> = {
  67937. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67938. };
  67939. /** @hidden */
  67940. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67941. }
  67942. }
  67943. declare module BABYLON {
  67944. /**
  67945. * A class serves as a medium between the observable and its observers
  67946. */
  67947. export class EventState {
  67948. /**
  67949. * Create a new EventState
  67950. * @param mask defines the mask associated with this state
  67951. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67952. * @param target defines the original target of the state
  67953. * @param currentTarget defines the current target of the state
  67954. */
  67955. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67956. /**
  67957. * Initialize the current event state
  67958. * @param mask defines the mask associated with this state
  67959. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67960. * @param target defines the original target of the state
  67961. * @param currentTarget defines the current target of the state
  67962. * @returns the current event state
  67963. */
  67964. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67965. /**
  67966. * An Observer can set this property to true to prevent subsequent observers of being notified
  67967. */
  67968. skipNextObservers: boolean;
  67969. /**
  67970. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67971. */
  67972. mask: number;
  67973. /**
  67974. * The object that originally notified the event
  67975. */
  67976. target?: any;
  67977. /**
  67978. * The current object in the bubbling phase
  67979. */
  67980. currentTarget?: any;
  67981. /**
  67982. * This will be populated with the return value of the last function that was executed.
  67983. * If it is the first function in the callback chain it will be the event data.
  67984. */
  67985. lastReturnValue?: any;
  67986. }
  67987. /**
  67988. * Represent an Observer registered to a given Observable object.
  67989. */
  67990. export class Observer<T> {
  67991. /**
  67992. * Defines the callback to call when the observer is notified
  67993. */
  67994. callback: (eventData: T, eventState: EventState) => void;
  67995. /**
  67996. * Defines the mask of the observer (used to filter notifications)
  67997. */
  67998. mask: number;
  67999. /**
  68000. * Defines the current scope used to restore the JS context
  68001. */
  68002. scope: any;
  68003. /** @hidden */
  68004. _willBeUnregistered: boolean;
  68005. /**
  68006. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68007. */
  68008. unregisterOnNextCall: boolean;
  68009. /**
  68010. * Creates a new observer
  68011. * @param callback defines the callback to call when the observer is notified
  68012. * @param mask defines the mask of the observer (used to filter notifications)
  68013. * @param scope defines the current scope used to restore the JS context
  68014. */
  68015. constructor(
  68016. /**
  68017. * Defines the callback to call when the observer is notified
  68018. */
  68019. callback: (eventData: T, eventState: EventState) => void,
  68020. /**
  68021. * Defines the mask of the observer (used to filter notifications)
  68022. */
  68023. mask: number,
  68024. /**
  68025. * Defines the current scope used to restore the JS context
  68026. */
  68027. scope?: any);
  68028. }
  68029. /**
  68030. * Represent a list of observers registered to multiple Observables object.
  68031. */
  68032. export class MultiObserver<T> {
  68033. private _observers;
  68034. private _observables;
  68035. /**
  68036. * Release associated resources
  68037. */
  68038. dispose(): void;
  68039. /**
  68040. * Raise a callback when one of the observable will notify
  68041. * @param observables defines a list of observables to watch
  68042. * @param callback defines the callback to call on notification
  68043. * @param mask defines the mask used to filter notifications
  68044. * @param scope defines the current scope used to restore the JS context
  68045. * @returns the new MultiObserver
  68046. */
  68047. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68048. }
  68049. /**
  68050. * The Observable class is a simple implementation of the Observable pattern.
  68051. *
  68052. * 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.
  68053. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68054. * 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).
  68055. * 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.
  68056. */
  68057. export class Observable<T> {
  68058. private _observers;
  68059. private _eventState;
  68060. private _onObserverAdded;
  68061. /**
  68062. * Gets the list of observers
  68063. */
  68064. readonly observers: Array<Observer<T>>;
  68065. /**
  68066. * Creates a new observable
  68067. * @param onObserverAdded defines a callback to call when a new observer is added
  68068. */
  68069. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68070. /**
  68071. * Create a new Observer with the specified callback
  68072. * @param callback the callback that will be executed for that Observer
  68073. * @param mask the mask used to filter observers
  68074. * @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.
  68075. * @param scope optional scope for the callback to be called from
  68076. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68077. * @returns the new observer created for the callback
  68078. */
  68079. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68080. /**
  68081. * Create a new Observer with the specified callback and unregisters after the next notification
  68082. * @param callback the callback that will be executed for that Observer
  68083. * @returns the new observer created for the callback
  68084. */
  68085. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68086. /**
  68087. * Remove an Observer from the Observable object
  68088. * @param observer the instance of the Observer to remove
  68089. * @returns false if it doesn't belong to this Observable
  68090. */
  68091. remove(observer: Nullable<Observer<T>>): boolean;
  68092. /**
  68093. * Remove a callback from the Observable object
  68094. * @param callback the callback to remove
  68095. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68096. * @returns false if it doesn't belong to this Observable
  68097. */
  68098. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68099. private _deferUnregister;
  68100. private _remove;
  68101. /**
  68102. * Moves the observable to the top of the observer list making it get called first when notified
  68103. * @param observer the observer to move
  68104. */
  68105. makeObserverTopPriority(observer: Observer<T>): void;
  68106. /**
  68107. * Moves the observable to the bottom of the observer list making it get called last when notified
  68108. * @param observer the observer to move
  68109. */
  68110. makeObserverBottomPriority(observer: Observer<T>): void;
  68111. /**
  68112. * Notify all Observers by calling their respective callback with the given data
  68113. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68114. * @param eventData defines the data to send to all observers
  68115. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68116. * @param target defines the original target of the state
  68117. * @param currentTarget defines the current target of the state
  68118. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68119. */
  68120. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68121. /**
  68122. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68123. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68124. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68125. * and it is crucial that all callbacks will be executed.
  68126. * The order of the callbacks is kept, callbacks are not executed parallel.
  68127. *
  68128. * @param eventData The data to be sent to each callback
  68129. * @param mask is used to filter observers defaults to -1
  68130. * @param target defines the callback target (see EventState)
  68131. * @param currentTarget defines he current object in the bubbling phase
  68132. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68133. */
  68134. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68135. /**
  68136. * Notify a specific observer
  68137. * @param observer defines the observer to notify
  68138. * @param eventData defines the data to be sent to each callback
  68139. * @param mask is used to filter observers defaults to -1
  68140. */
  68141. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68142. /**
  68143. * Gets a boolean indicating if the observable has at least one observer
  68144. * @returns true is the Observable has at least one Observer registered
  68145. */
  68146. hasObservers(): boolean;
  68147. /**
  68148. * Clear the list of observers
  68149. */
  68150. clear(): void;
  68151. /**
  68152. * Clone the current observable
  68153. * @returns a new observable
  68154. */
  68155. clone(): Observable<T>;
  68156. /**
  68157. * Does this observable handles observer registered with a given mask
  68158. * @param mask defines the mask to be tested
  68159. * @return whether or not one observer registered with the given mask is handeled
  68160. **/
  68161. hasSpecificMask(mask?: number): boolean;
  68162. }
  68163. }
  68164. declare module BABYLON {
  68165. /**
  68166. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68167. * Babylon.js
  68168. */
  68169. export class DomManagement {
  68170. /**
  68171. * Checks if the window object exists
  68172. * @returns true if the window object exists
  68173. */
  68174. static IsWindowObjectExist(): boolean;
  68175. /**
  68176. * Checks if the navigator object exists
  68177. * @returns true if the navigator object exists
  68178. */
  68179. static IsNavigatorAvailable(): boolean;
  68180. /**
  68181. * Extracts text content from a DOM element hierarchy
  68182. * @param element defines the root element
  68183. * @returns a string
  68184. */
  68185. static GetDOMTextContent(element: HTMLElement): string;
  68186. }
  68187. }
  68188. declare module BABYLON {
  68189. /**
  68190. * Logger used througouht the application to allow configuration of
  68191. * the log level required for the messages.
  68192. */
  68193. export class Logger {
  68194. /**
  68195. * No log
  68196. */
  68197. static readonly NoneLogLevel: number;
  68198. /**
  68199. * Only message logs
  68200. */
  68201. static readonly MessageLogLevel: number;
  68202. /**
  68203. * Only warning logs
  68204. */
  68205. static readonly WarningLogLevel: number;
  68206. /**
  68207. * Only error logs
  68208. */
  68209. static readonly ErrorLogLevel: number;
  68210. /**
  68211. * All logs
  68212. */
  68213. static readonly AllLogLevel: number;
  68214. private static _LogCache;
  68215. /**
  68216. * Gets a value indicating the number of loading errors
  68217. * @ignorenaming
  68218. */
  68219. static errorsCount: number;
  68220. /**
  68221. * Callback called when a new log is added
  68222. */
  68223. static OnNewCacheEntry: (entry: string) => void;
  68224. private static _AddLogEntry;
  68225. private static _FormatMessage;
  68226. private static _LogDisabled;
  68227. private static _LogEnabled;
  68228. private static _WarnDisabled;
  68229. private static _WarnEnabled;
  68230. private static _ErrorDisabled;
  68231. private static _ErrorEnabled;
  68232. /**
  68233. * Log a message to the console
  68234. */
  68235. static Log: (message: string) => void;
  68236. /**
  68237. * Write a warning message to the console
  68238. */
  68239. static Warn: (message: string) => void;
  68240. /**
  68241. * Write an error message to the console
  68242. */
  68243. static Error: (message: string) => void;
  68244. /**
  68245. * Gets current log cache (list of logs)
  68246. */
  68247. static readonly LogCache: string;
  68248. /**
  68249. * Clears the log cache
  68250. */
  68251. static ClearLogCache(): void;
  68252. /**
  68253. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68254. */
  68255. static LogLevels: number;
  68256. }
  68257. }
  68258. declare module BABYLON {
  68259. /** @hidden */
  68260. export class _TypeStore {
  68261. /** @hidden */
  68262. static RegisteredTypes: {
  68263. [key: string]: Object;
  68264. };
  68265. /** @hidden */
  68266. static GetClass(fqdn: string): any;
  68267. }
  68268. }
  68269. declare module BABYLON {
  68270. /**
  68271. * Helper to manipulate strings
  68272. */
  68273. export class StringTools {
  68274. /**
  68275. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68276. * @param str Source string
  68277. * @param suffix Suffix to search for in the source string
  68278. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68279. */
  68280. static EndsWith(str: string, suffix: string): boolean;
  68281. /**
  68282. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68283. * @param str Source string
  68284. * @param suffix Suffix to search for in the source string
  68285. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68286. */
  68287. static StartsWith(str: string, suffix: string): boolean;
  68288. /**
  68289. * Decodes a buffer into a string
  68290. * @param buffer The buffer to decode
  68291. * @returns The decoded string
  68292. */
  68293. static Decode(buffer: Uint8Array | Uint16Array): string;
  68294. /**
  68295. * Encode a buffer to a base64 string
  68296. * @param buffer defines the buffer to encode
  68297. * @returns the encoded string
  68298. */
  68299. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68300. }
  68301. }
  68302. declare module BABYLON {
  68303. /**
  68304. * Class containing a set of static utilities functions for deep copy.
  68305. */
  68306. export class DeepCopier {
  68307. /**
  68308. * Tries to copy an object by duplicating every property
  68309. * @param source defines the source object
  68310. * @param destination defines the target object
  68311. * @param doNotCopyList defines a list of properties to avoid
  68312. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68313. */
  68314. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68315. }
  68316. }
  68317. declare module BABYLON {
  68318. /**
  68319. * Class containing a set of static utilities functions for precision date
  68320. */
  68321. export class PrecisionDate {
  68322. /**
  68323. * Gets either window.performance.now() if supported or Date.now() else
  68324. */
  68325. static readonly Now: number;
  68326. }
  68327. }
  68328. declare module BABYLON {
  68329. /** @hidden */
  68330. export class _DevTools {
  68331. static WarnImport(name: string): string;
  68332. }
  68333. }
  68334. declare module BABYLON {
  68335. /**
  68336. * Interface used to define the mechanism to get data from the network
  68337. */
  68338. export interface IWebRequest {
  68339. /**
  68340. * Returns client's response url
  68341. */
  68342. responseURL: string;
  68343. /**
  68344. * Returns client's status
  68345. */
  68346. status: number;
  68347. /**
  68348. * Returns client's status as a text
  68349. */
  68350. statusText: string;
  68351. }
  68352. }
  68353. declare module BABYLON {
  68354. /**
  68355. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68356. */
  68357. export class WebRequest implements IWebRequest {
  68358. private _xhr;
  68359. /**
  68360. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68361. * i.e. when loading files, where the server/service expects an Authorization header
  68362. */
  68363. static CustomRequestHeaders: {
  68364. [key: string]: string;
  68365. };
  68366. /**
  68367. * Add callback functions in this array to update all the requests before they get sent to the network
  68368. */
  68369. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68370. private _injectCustomRequestHeaders;
  68371. /**
  68372. * Gets or sets a function to be called when loading progress changes
  68373. */
  68374. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68375. /**
  68376. * Returns client's state
  68377. */
  68378. readonly readyState: number;
  68379. /**
  68380. * Returns client's status
  68381. */
  68382. readonly status: number;
  68383. /**
  68384. * Returns client's status as a text
  68385. */
  68386. readonly statusText: string;
  68387. /**
  68388. * Returns client's response
  68389. */
  68390. readonly response: any;
  68391. /**
  68392. * Returns client's response url
  68393. */
  68394. readonly responseURL: string;
  68395. /**
  68396. * Returns client's response as text
  68397. */
  68398. readonly responseText: string;
  68399. /**
  68400. * Gets or sets the expected response type
  68401. */
  68402. responseType: XMLHttpRequestResponseType;
  68403. /** @hidden */
  68404. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68405. /** @hidden */
  68406. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68407. /**
  68408. * Cancels any network activity
  68409. */
  68410. abort(): void;
  68411. /**
  68412. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68413. * @param body defines an optional request body
  68414. */
  68415. send(body?: Document | BodyInit | null): void;
  68416. /**
  68417. * Sets the request method, request URL
  68418. * @param method defines the method to use (GET, POST, etc..)
  68419. * @param url defines the url to connect with
  68420. */
  68421. open(method: string, url: string): void;
  68422. /**
  68423. * Sets the value of a request header.
  68424. * @param name The name of the header whose value is to be set
  68425. * @param value The value to set as the body of the header
  68426. */
  68427. setRequestHeader(name: string, value: string): void;
  68428. /**
  68429. * Get the string containing the text of a particular header's value.
  68430. * @param name The name of the header
  68431. * @returns The string containing the text of the given header name
  68432. */
  68433. getResponseHeader(name: string): Nullable<string>;
  68434. }
  68435. }
  68436. declare module BABYLON {
  68437. /**
  68438. * File request interface
  68439. */
  68440. export interface IFileRequest {
  68441. /**
  68442. * Raised when the request is complete (success or error).
  68443. */
  68444. onCompleteObservable: Observable<IFileRequest>;
  68445. /**
  68446. * Aborts the request for a file.
  68447. */
  68448. abort: () => void;
  68449. }
  68450. }
  68451. declare module BABYLON {
  68452. /**
  68453. * Define options used to create a render target texture
  68454. */
  68455. export class RenderTargetCreationOptions {
  68456. /**
  68457. * Specifies is mipmaps must be generated
  68458. */
  68459. generateMipMaps?: boolean;
  68460. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68461. generateDepthBuffer?: boolean;
  68462. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68463. generateStencilBuffer?: boolean;
  68464. /** Defines texture type (int by default) */
  68465. type?: number;
  68466. /** Defines sampling mode (trilinear by default) */
  68467. samplingMode?: number;
  68468. /** Defines format (RGBA by default) */
  68469. format?: number;
  68470. }
  68471. }
  68472. declare module BABYLON {
  68473. /**
  68474. * @hidden
  68475. **/
  68476. export class _TimeToken {
  68477. _startTimeQuery: Nullable<WebGLQuery>;
  68478. _endTimeQuery: Nullable<WebGLQuery>;
  68479. _timeElapsedQuery: Nullable<WebGLQuery>;
  68480. _timeElapsedQueryEnded: boolean;
  68481. }
  68482. }
  68483. declare module BABYLON {
  68484. /** Defines the cross module used constants to avoid circular dependncies */
  68485. export class Constants {
  68486. /** Defines that alpha blending is disabled */
  68487. static readonly ALPHA_DISABLE: number;
  68488. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68489. static readonly ALPHA_ADD: number;
  68490. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68491. static readonly ALPHA_COMBINE: number;
  68492. /** Defines that alpha blending to DEST - SRC * DEST */
  68493. static readonly ALPHA_SUBTRACT: number;
  68494. /** Defines that alpha blending to SRC * DEST */
  68495. static readonly ALPHA_MULTIPLY: number;
  68496. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68497. static readonly ALPHA_MAXIMIZED: number;
  68498. /** Defines that alpha blending to SRC + DEST */
  68499. static readonly ALPHA_ONEONE: number;
  68500. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68501. static readonly ALPHA_PREMULTIPLIED: number;
  68502. /**
  68503. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68504. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68505. */
  68506. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68507. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68508. static readonly ALPHA_INTERPOLATE: number;
  68509. /**
  68510. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68511. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68512. */
  68513. static readonly ALPHA_SCREENMODE: number;
  68514. /**
  68515. * Defines that alpha blending to SRC + DST
  68516. * Alpha will be set to SRC ALPHA + DST ALPHA
  68517. */
  68518. static readonly ALPHA_ONEONE_ONEONE: number;
  68519. /**
  68520. * Defines that alpha blending to SRC * DST ALPHA + DST
  68521. * Alpha will be set to 0
  68522. */
  68523. static readonly ALPHA_ALPHATOCOLOR: number;
  68524. /**
  68525. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68526. */
  68527. static readonly ALPHA_REVERSEONEMINUS: number;
  68528. /**
  68529. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68530. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68531. */
  68532. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68533. /**
  68534. * Defines that alpha blending to SRC + DST
  68535. * Alpha will be set to SRC ALPHA
  68536. */
  68537. static readonly ALPHA_ONEONE_ONEZERO: number;
  68538. /** Defines that alpha blending equation a SUM */
  68539. static readonly ALPHA_EQUATION_ADD: number;
  68540. /** Defines that alpha blending equation a SUBSTRACTION */
  68541. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68542. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68543. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68544. /** Defines that alpha blending equation a MAX operation */
  68545. static readonly ALPHA_EQUATION_MAX: number;
  68546. /** Defines that alpha blending equation a MIN operation */
  68547. static readonly ALPHA_EQUATION_MIN: number;
  68548. /**
  68549. * Defines that alpha blending equation a DARKEN operation:
  68550. * It takes the min of the src and sums the alpha channels.
  68551. */
  68552. static readonly ALPHA_EQUATION_DARKEN: number;
  68553. /** Defines that the ressource is not delayed*/
  68554. static readonly DELAYLOADSTATE_NONE: number;
  68555. /** Defines that the ressource was successfully delay loaded */
  68556. static readonly DELAYLOADSTATE_LOADED: number;
  68557. /** Defines that the ressource is currently delay loading */
  68558. static readonly DELAYLOADSTATE_LOADING: number;
  68559. /** Defines that the ressource is delayed and has not started loading */
  68560. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68561. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68562. static readonly NEVER: number;
  68563. /** 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 */
  68564. static readonly ALWAYS: number;
  68565. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68566. static readonly LESS: number;
  68567. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68568. static readonly EQUAL: number;
  68569. /** 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 */
  68570. static readonly LEQUAL: number;
  68571. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68572. static readonly GREATER: number;
  68573. /** 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 */
  68574. static readonly GEQUAL: number;
  68575. /** 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 */
  68576. static readonly NOTEQUAL: number;
  68577. /** Passed to stencilOperation to specify that stencil value must be kept */
  68578. static readonly KEEP: number;
  68579. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68580. static readonly REPLACE: number;
  68581. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68582. static readonly INCR: number;
  68583. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68584. static readonly DECR: number;
  68585. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68586. static readonly INVERT: number;
  68587. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68588. static readonly INCR_WRAP: number;
  68589. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68590. static readonly DECR_WRAP: number;
  68591. /** Texture is not repeating outside of 0..1 UVs */
  68592. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68593. /** Texture is repeating outside of 0..1 UVs */
  68594. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68595. /** Texture is repeating and mirrored */
  68596. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68597. /** ALPHA */
  68598. static readonly TEXTUREFORMAT_ALPHA: number;
  68599. /** LUMINANCE */
  68600. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68601. /** LUMINANCE_ALPHA */
  68602. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68603. /** RGB */
  68604. static readonly TEXTUREFORMAT_RGB: number;
  68605. /** RGBA */
  68606. static readonly TEXTUREFORMAT_RGBA: number;
  68607. /** RED */
  68608. static readonly TEXTUREFORMAT_RED: number;
  68609. /** RED (2nd reference) */
  68610. static readonly TEXTUREFORMAT_R: number;
  68611. /** RG */
  68612. static readonly TEXTUREFORMAT_RG: number;
  68613. /** RED_INTEGER */
  68614. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68615. /** RED_INTEGER (2nd reference) */
  68616. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68617. /** RG_INTEGER */
  68618. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68619. /** RGB_INTEGER */
  68620. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68621. /** RGBA_INTEGER */
  68622. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68623. /** UNSIGNED_BYTE */
  68624. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68625. /** UNSIGNED_BYTE (2nd reference) */
  68626. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68627. /** FLOAT */
  68628. static readonly TEXTURETYPE_FLOAT: number;
  68629. /** HALF_FLOAT */
  68630. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68631. /** BYTE */
  68632. static readonly TEXTURETYPE_BYTE: number;
  68633. /** SHORT */
  68634. static readonly TEXTURETYPE_SHORT: number;
  68635. /** UNSIGNED_SHORT */
  68636. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68637. /** INT */
  68638. static readonly TEXTURETYPE_INT: number;
  68639. /** UNSIGNED_INT */
  68640. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68641. /** UNSIGNED_SHORT_4_4_4_4 */
  68642. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68643. /** UNSIGNED_SHORT_5_5_5_1 */
  68644. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68645. /** UNSIGNED_SHORT_5_6_5 */
  68646. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68647. /** UNSIGNED_INT_2_10_10_10_REV */
  68648. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68649. /** UNSIGNED_INT_24_8 */
  68650. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68651. /** UNSIGNED_INT_10F_11F_11F_REV */
  68652. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68653. /** UNSIGNED_INT_5_9_9_9_REV */
  68654. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68655. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68656. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68657. /** nearest is mag = nearest and min = nearest and mip = linear */
  68658. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68659. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68660. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68661. /** Trilinear is mag = linear and min = linear and mip = linear */
  68662. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68663. /** nearest is mag = nearest and min = nearest and mip = linear */
  68664. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68665. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68666. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68667. /** Trilinear is mag = linear and min = linear and mip = linear */
  68668. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68669. /** mag = nearest and min = nearest and mip = nearest */
  68670. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68671. /** mag = nearest and min = linear and mip = nearest */
  68672. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68673. /** mag = nearest and min = linear and mip = linear */
  68674. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68675. /** mag = nearest and min = linear and mip = none */
  68676. static readonly TEXTURE_NEAREST_LINEAR: number;
  68677. /** mag = nearest and min = nearest and mip = none */
  68678. static readonly TEXTURE_NEAREST_NEAREST: number;
  68679. /** mag = linear and min = nearest and mip = nearest */
  68680. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68681. /** mag = linear and min = nearest and mip = linear */
  68682. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68683. /** mag = linear and min = linear and mip = none */
  68684. static readonly TEXTURE_LINEAR_LINEAR: number;
  68685. /** mag = linear and min = nearest and mip = none */
  68686. static readonly TEXTURE_LINEAR_NEAREST: number;
  68687. /** Explicit coordinates mode */
  68688. static readonly TEXTURE_EXPLICIT_MODE: number;
  68689. /** Spherical coordinates mode */
  68690. static readonly TEXTURE_SPHERICAL_MODE: number;
  68691. /** Planar coordinates mode */
  68692. static readonly TEXTURE_PLANAR_MODE: number;
  68693. /** Cubic coordinates mode */
  68694. static readonly TEXTURE_CUBIC_MODE: number;
  68695. /** Projection coordinates mode */
  68696. static readonly TEXTURE_PROJECTION_MODE: number;
  68697. /** Skybox coordinates mode */
  68698. static readonly TEXTURE_SKYBOX_MODE: number;
  68699. /** Inverse Cubic coordinates mode */
  68700. static readonly TEXTURE_INVCUBIC_MODE: number;
  68701. /** Equirectangular coordinates mode */
  68702. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68703. /** Equirectangular Fixed coordinates mode */
  68704. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68705. /** Equirectangular Fixed Mirrored coordinates mode */
  68706. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68707. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68708. static readonly SCALEMODE_FLOOR: number;
  68709. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68710. static readonly SCALEMODE_NEAREST: number;
  68711. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68712. static readonly SCALEMODE_CEILING: number;
  68713. /**
  68714. * The dirty texture flag value
  68715. */
  68716. static readonly MATERIAL_TextureDirtyFlag: number;
  68717. /**
  68718. * The dirty light flag value
  68719. */
  68720. static readonly MATERIAL_LightDirtyFlag: number;
  68721. /**
  68722. * The dirty fresnel flag value
  68723. */
  68724. static readonly MATERIAL_FresnelDirtyFlag: number;
  68725. /**
  68726. * The dirty attribute flag value
  68727. */
  68728. static readonly MATERIAL_AttributesDirtyFlag: number;
  68729. /**
  68730. * The dirty misc flag value
  68731. */
  68732. static readonly MATERIAL_MiscDirtyFlag: number;
  68733. /**
  68734. * The all dirty flag value
  68735. */
  68736. static readonly MATERIAL_AllDirtyFlag: number;
  68737. /**
  68738. * Returns the triangle fill mode
  68739. */
  68740. static readonly MATERIAL_TriangleFillMode: number;
  68741. /**
  68742. * Returns the wireframe mode
  68743. */
  68744. static readonly MATERIAL_WireFrameFillMode: number;
  68745. /**
  68746. * Returns the point fill mode
  68747. */
  68748. static readonly MATERIAL_PointFillMode: number;
  68749. /**
  68750. * Returns the point list draw mode
  68751. */
  68752. static readonly MATERIAL_PointListDrawMode: number;
  68753. /**
  68754. * Returns the line list draw mode
  68755. */
  68756. static readonly MATERIAL_LineListDrawMode: number;
  68757. /**
  68758. * Returns the line loop draw mode
  68759. */
  68760. static readonly MATERIAL_LineLoopDrawMode: number;
  68761. /**
  68762. * Returns the line strip draw mode
  68763. */
  68764. static readonly MATERIAL_LineStripDrawMode: number;
  68765. /**
  68766. * Returns the triangle strip draw mode
  68767. */
  68768. static readonly MATERIAL_TriangleStripDrawMode: number;
  68769. /**
  68770. * Returns the triangle fan draw mode
  68771. */
  68772. static readonly MATERIAL_TriangleFanDrawMode: number;
  68773. /**
  68774. * Stores the clock-wise side orientation
  68775. */
  68776. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68777. /**
  68778. * Stores the counter clock-wise side orientation
  68779. */
  68780. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68781. /**
  68782. * Nothing
  68783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68784. */
  68785. static readonly ACTION_NothingTrigger: number;
  68786. /**
  68787. * On pick
  68788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68789. */
  68790. static readonly ACTION_OnPickTrigger: number;
  68791. /**
  68792. * On left pick
  68793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68794. */
  68795. static readonly ACTION_OnLeftPickTrigger: number;
  68796. /**
  68797. * On right pick
  68798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68799. */
  68800. static readonly ACTION_OnRightPickTrigger: number;
  68801. /**
  68802. * On center pick
  68803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68804. */
  68805. static readonly ACTION_OnCenterPickTrigger: number;
  68806. /**
  68807. * On pick down
  68808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68809. */
  68810. static readonly ACTION_OnPickDownTrigger: number;
  68811. /**
  68812. * On double pick
  68813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68814. */
  68815. static readonly ACTION_OnDoublePickTrigger: number;
  68816. /**
  68817. * On pick up
  68818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68819. */
  68820. static readonly ACTION_OnPickUpTrigger: number;
  68821. /**
  68822. * On pick out.
  68823. * This trigger will only be raised if you also declared a OnPickDown
  68824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68825. */
  68826. static readonly ACTION_OnPickOutTrigger: number;
  68827. /**
  68828. * On long press
  68829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68830. */
  68831. static readonly ACTION_OnLongPressTrigger: number;
  68832. /**
  68833. * On pointer over
  68834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68835. */
  68836. static readonly ACTION_OnPointerOverTrigger: number;
  68837. /**
  68838. * On pointer out
  68839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68840. */
  68841. static readonly ACTION_OnPointerOutTrigger: number;
  68842. /**
  68843. * On every frame
  68844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68845. */
  68846. static readonly ACTION_OnEveryFrameTrigger: number;
  68847. /**
  68848. * On intersection enter
  68849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68850. */
  68851. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68852. /**
  68853. * On intersection exit
  68854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68855. */
  68856. static readonly ACTION_OnIntersectionExitTrigger: number;
  68857. /**
  68858. * On key down
  68859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68860. */
  68861. static readonly ACTION_OnKeyDownTrigger: number;
  68862. /**
  68863. * On key up
  68864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68865. */
  68866. static readonly ACTION_OnKeyUpTrigger: number;
  68867. /**
  68868. * Billboard mode will only apply to Y axis
  68869. */
  68870. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68871. /**
  68872. * Billboard mode will apply to all axes
  68873. */
  68874. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68875. /**
  68876. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68877. */
  68878. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68879. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68880. * Test order :
  68881. * Is the bounding sphere outside the frustum ?
  68882. * If not, are the bounding box vertices outside the frustum ?
  68883. * It not, then the cullable object is in the frustum.
  68884. */
  68885. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68886. /** Culling strategy : Bounding Sphere Only.
  68887. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68888. * It's also less accurate than the standard because some not visible objects can still be selected.
  68889. * Test : is the bounding sphere outside the frustum ?
  68890. * If not, then the cullable object is in the frustum.
  68891. */
  68892. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68893. /** Culling strategy : Optimistic Inclusion.
  68894. * This in an inclusion test first, then the standard exclusion test.
  68895. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68896. * 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.
  68897. * Anyway, it's as accurate as the standard strategy.
  68898. * Test :
  68899. * Is the cullable object bounding sphere center in the frustum ?
  68900. * If not, apply the default culling strategy.
  68901. */
  68902. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68903. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68904. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68905. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68906. * 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.
  68907. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68908. * Test :
  68909. * Is the cullable object bounding sphere center in the frustum ?
  68910. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68911. */
  68912. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68913. /**
  68914. * No logging while loading
  68915. */
  68916. static readonly SCENELOADER_NO_LOGGING: number;
  68917. /**
  68918. * Minimal logging while loading
  68919. */
  68920. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68921. /**
  68922. * Summary logging while loading
  68923. */
  68924. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68925. /**
  68926. * Detailled logging while loading
  68927. */
  68928. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68929. }
  68930. }
  68931. declare module BABYLON {
  68932. /**
  68933. * This represents the required contract to create a new type of texture loader.
  68934. */
  68935. export interface IInternalTextureLoader {
  68936. /**
  68937. * Defines wether the loader supports cascade loading the different faces.
  68938. */
  68939. supportCascades: boolean;
  68940. /**
  68941. * This returns if the loader support the current file information.
  68942. * @param extension defines the file extension of the file being loaded
  68943. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68944. * @param fallback defines the fallback internal texture if any
  68945. * @param isBase64 defines whether the texture is encoded as a base64
  68946. * @param isBuffer defines whether the texture data are stored as a buffer
  68947. * @returns true if the loader can load the specified file
  68948. */
  68949. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68950. /**
  68951. * Transform the url before loading if required.
  68952. * @param rootUrl the url of the texture
  68953. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68954. * @returns the transformed texture
  68955. */
  68956. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68957. /**
  68958. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68959. * @param rootUrl the url of the texture
  68960. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68961. * @returns the fallback texture
  68962. */
  68963. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68964. /**
  68965. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68966. * @param data contains the texture data
  68967. * @param texture defines the BabylonJS internal texture
  68968. * @param createPolynomials will be true if polynomials have been requested
  68969. * @param onLoad defines the callback to trigger once the texture is ready
  68970. * @param onError defines the callback to trigger in case of error
  68971. */
  68972. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68973. /**
  68974. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68975. * @param data contains the texture data
  68976. * @param texture defines the BabylonJS internal texture
  68977. * @param callback defines the method to call once ready to upload
  68978. */
  68979. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68980. }
  68981. }
  68982. declare module BABYLON {
  68983. /**
  68984. * Class used to store and describe the pipeline context associated with an effect
  68985. */
  68986. export interface IPipelineContext {
  68987. /**
  68988. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68989. */
  68990. isAsync: boolean;
  68991. /**
  68992. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68993. */
  68994. isReady: boolean;
  68995. /** @hidden */
  68996. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68997. }
  68998. }
  68999. declare module BABYLON {
  69000. /**
  69001. * Class used to store gfx data (like WebGLBuffer)
  69002. */
  69003. export class DataBuffer {
  69004. /**
  69005. * Gets or sets the number of objects referencing this buffer
  69006. */
  69007. references: number;
  69008. /** Gets or sets the size of the underlying buffer */
  69009. capacity: number;
  69010. /**
  69011. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69012. */
  69013. is32Bits: boolean;
  69014. /**
  69015. * Gets the underlying buffer
  69016. */
  69017. readonly underlyingResource: any;
  69018. }
  69019. }
  69020. declare module BABYLON {
  69021. /** @hidden */
  69022. export interface IShaderProcessor {
  69023. attributeProcessor?: (attribute: string) => string;
  69024. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69025. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69026. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69027. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69028. lineProcessor?: (line: string, isFragment: boolean) => string;
  69029. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69030. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69031. }
  69032. }
  69033. declare module BABYLON {
  69034. /** @hidden */
  69035. export interface ProcessingOptions {
  69036. defines: string[];
  69037. indexParameters: any;
  69038. isFragment: boolean;
  69039. shouldUseHighPrecisionShader: boolean;
  69040. supportsUniformBuffers: boolean;
  69041. shadersRepository: string;
  69042. includesShadersStore: {
  69043. [key: string]: string;
  69044. };
  69045. processor?: IShaderProcessor;
  69046. version: string;
  69047. platformName: string;
  69048. lookForClosingBracketForUniformBuffer?: boolean;
  69049. }
  69050. }
  69051. declare module BABYLON {
  69052. /** @hidden */
  69053. export class ShaderCodeNode {
  69054. line: string;
  69055. children: ShaderCodeNode[];
  69056. additionalDefineKey?: string;
  69057. additionalDefineValue?: string;
  69058. isValid(preprocessors: {
  69059. [key: string]: string;
  69060. }): boolean;
  69061. process(preprocessors: {
  69062. [key: string]: string;
  69063. }, options: ProcessingOptions): string;
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. /** @hidden */
  69068. export class ShaderCodeCursor {
  69069. private _lines;
  69070. lineIndex: number;
  69071. readonly currentLine: string;
  69072. readonly canRead: boolean;
  69073. lines: string[];
  69074. }
  69075. }
  69076. declare module BABYLON {
  69077. /** @hidden */
  69078. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69079. process(preprocessors: {
  69080. [key: string]: string;
  69081. }, options: ProcessingOptions): string;
  69082. }
  69083. }
  69084. declare module BABYLON {
  69085. /** @hidden */
  69086. export class ShaderDefineExpression {
  69087. isTrue(preprocessors: {
  69088. [key: string]: string;
  69089. }): boolean;
  69090. }
  69091. }
  69092. declare module BABYLON {
  69093. /** @hidden */
  69094. export class ShaderCodeTestNode extends ShaderCodeNode {
  69095. testExpression: ShaderDefineExpression;
  69096. isValid(preprocessors: {
  69097. [key: string]: string;
  69098. }): boolean;
  69099. }
  69100. }
  69101. declare module BABYLON {
  69102. /** @hidden */
  69103. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69104. define: string;
  69105. not: boolean;
  69106. constructor(define: string, not?: boolean);
  69107. isTrue(preprocessors: {
  69108. [key: string]: string;
  69109. }): boolean;
  69110. }
  69111. }
  69112. declare module BABYLON {
  69113. /** @hidden */
  69114. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69115. leftOperand: ShaderDefineExpression;
  69116. rightOperand: ShaderDefineExpression;
  69117. isTrue(preprocessors: {
  69118. [key: string]: string;
  69119. }): boolean;
  69120. }
  69121. }
  69122. declare module BABYLON {
  69123. /** @hidden */
  69124. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69125. leftOperand: ShaderDefineExpression;
  69126. rightOperand: ShaderDefineExpression;
  69127. isTrue(preprocessors: {
  69128. [key: string]: string;
  69129. }): boolean;
  69130. }
  69131. }
  69132. declare module BABYLON {
  69133. /** @hidden */
  69134. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69135. define: string;
  69136. operand: string;
  69137. testValue: string;
  69138. constructor(define: string, operand: string, testValue: string);
  69139. isTrue(preprocessors: {
  69140. [key: string]: string;
  69141. }): boolean;
  69142. }
  69143. }
  69144. declare module BABYLON {
  69145. /**
  69146. * Class used to enable access to offline support
  69147. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69148. */
  69149. export interface IOfflineProvider {
  69150. /**
  69151. * Gets a boolean indicating if scene must be saved in the database
  69152. */
  69153. enableSceneOffline: boolean;
  69154. /**
  69155. * Gets a boolean indicating if textures must be saved in the database
  69156. */
  69157. enableTexturesOffline: boolean;
  69158. /**
  69159. * Open the offline support and make it available
  69160. * @param successCallback defines the callback to call on success
  69161. * @param errorCallback defines the callback to call on error
  69162. */
  69163. open(successCallback: () => void, errorCallback: () => void): void;
  69164. /**
  69165. * Loads an image from the offline support
  69166. * @param url defines the url to load from
  69167. * @param image defines the target DOM image
  69168. */
  69169. loadImage(url: string, image: HTMLImageElement): void;
  69170. /**
  69171. * Loads a file from offline support
  69172. * @param url defines the URL to load from
  69173. * @param sceneLoaded defines a callback to call on success
  69174. * @param progressCallBack defines a callback to call when progress changed
  69175. * @param errorCallback defines a callback to call on error
  69176. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69177. */
  69178. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69179. }
  69180. }
  69181. declare module BABYLON {
  69182. /**
  69183. * Class used to help managing file picking and drag'n'drop
  69184. * File Storage
  69185. */
  69186. export class FilesInputStore {
  69187. /**
  69188. * List of files ready to be loaded
  69189. */
  69190. static FilesToLoad: {
  69191. [key: string]: File;
  69192. };
  69193. }
  69194. }
  69195. declare module BABYLON {
  69196. /**
  69197. * Class used to define a retry strategy when error happens while loading assets
  69198. */
  69199. export class RetryStrategy {
  69200. /**
  69201. * Function used to defines an exponential back off strategy
  69202. * @param maxRetries defines the maximum number of retries (3 by default)
  69203. * @param baseInterval defines the interval between retries
  69204. * @returns the strategy function to use
  69205. */
  69206. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69207. }
  69208. }
  69209. declare module BABYLON {
  69210. /**
  69211. * @ignore
  69212. * Application error to support additional information when loading a file
  69213. */
  69214. export abstract class BaseError extends Error {
  69215. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69216. }
  69217. }
  69218. declare module BABYLON {
  69219. /** @ignore */
  69220. export class LoadFileError extends BaseError {
  69221. request?: WebRequest;
  69222. file?: File;
  69223. /**
  69224. * Creates a new LoadFileError
  69225. * @param message defines the message of the error
  69226. * @param request defines the optional web request
  69227. * @param file defines the optional file
  69228. */
  69229. constructor(message: string, object?: WebRequest | File);
  69230. }
  69231. /** @ignore */
  69232. export class RequestFileError extends BaseError {
  69233. request: WebRequest;
  69234. /**
  69235. * Creates a new LoadFileError
  69236. * @param message defines the message of the error
  69237. * @param request defines the optional web request
  69238. */
  69239. constructor(message: string, request: WebRequest);
  69240. }
  69241. /** @ignore */
  69242. export class ReadFileError extends BaseError {
  69243. file: File;
  69244. /**
  69245. * Creates a new ReadFileError
  69246. * @param message defines the message of the error
  69247. * @param file defines the optional file
  69248. */
  69249. constructor(message: string, file: File);
  69250. }
  69251. /**
  69252. * @hidden
  69253. */
  69254. export class FileTools {
  69255. /**
  69256. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69257. */
  69258. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69259. /**
  69260. * Gets or sets the base URL to use to load assets
  69261. */
  69262. static BaseUrl: string;
  69263. /**
  69264. * Default behaviour for cors in the application.
  69265. * It can be a string if the expected behavior is identical in the entire app.
  69266. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69267. */
  69268. static CorsBehavior: string | ((url: string | string[]) => string);
  69269. /**
  69270. * Gets or sets a function used to pre-process url before using them to load assets
  69271. */
  69272. static PreprocessUrl: (url: string) => string;
  69273. /**
  69274. * Removes unwanted characters from an url
  69275. * @param url defines the url to clean
  69276. * @returns the cleaned url
  69277. */
  69278. private static _CleanUrl;
  69279. /**
  69280. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69281. * @param url define the url we are trying
  69282. * @param element define the dom element where to configure the cors policy
  69283. */
  69284. static SetCorsBehavior(url: string | string[], element: {
  69285. crossOrigin: string | null;
  69286. }): void;
  69287. /**
  69288. * Loads an image as an HTMLImageElement.
  69289. * @param input url string, ArrayBuffer, or Blob to load
  69290. * @param onLoad callback called when the image successfully loads
  69291. * @param onError callback called when the image fails to load
  69292. * @param offlineProvider offline provider for caching
  69293. * @param mimeType optional mime type
  69294. * @returns the HTMLImageElement of the loaded image
  69295. */
  69296. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  69297. /**
  69298. * Reads a file from a File object
  69299. * @param file defines the file to load
  69300. * @param onSuccess defines the callback to call when data is loaded
  69301. * @param onProgress defines the callback to call during loading process
  69302. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69303. * @param onError defines the callback to call when an error occurs
  69304. * @returns a file request object
  69305. */
  69306. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69307. /**
  69308. * Loads a file from a url
  69309. * @param url url to load
  69310. * @param onSuccess callback called when the file successfully loads
  69311. * @param onProgress callback called while file is loading (if the server supports this mode)
  69312. * @param offlineProvider defines the offline provider for caching
  69313. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69314. * @param onError callback called when the file fails to load
  69315. * @returns a file request object
  69316. */
  69317. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  69318. /**
  69319. * Loads a file
  69320. * @param url url to load
  69321. * @param onSuccess callback called when the file successfully loads
  69322. * @param onProgress callback called while file is loading (if the server supports this mode)
  69323. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69324. * @param onError callback called when the file fails to load
  69325. * @param onOpened callback called when the web request is opened
  69326. * @returns a file request object
  69327. */
  69328. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  69329. /**
  69330. * Checks if the loaded document was accessed via `file:`-Protocol.
  69331. * @returns boolean
  69332. */
  69333. static IsFileURL(): boolean;
  69334. }
  69335. }
  69336. declare module BABYLON {
  69337. /** @hidden */
  69338. export class ShaderProcessor {
  69339. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69340. private static _ProcessPrecision;
  69341. private static _ExtractOperation;
  69342. private static _BuildSubExpression;
  69343. private static _BuildExpression;
  69344. private static _MoveCursorWithinIf;
  69345. private static _MoveCursor;
  69346. private static _EvaluatePreProcessors;
  69347. private static _PreparePreProcessors;
  69348. private static _ProcessShaderConversion;
  69349. private static _ProcessIncludes;
  69350. }
  69351. }
  69352. declare module BABYLON {
  69353. /**
  69354. * @hidden
  69355. */
  69356. export interface IColor4Like {
  69357. r: float;
  69358. g: float;
  69359. b: float;
  69360. a: float;
  69361. }
  69362. /**
  69363. * @hidden
  69364. */
  69365. export interface IColor3Like {
  69366. r: float;
  69367. g: float;
  69368. b: float;
  69369. }
  69370. /**
  69371. * @hidden
  69372. */
  69373. export interface IVector4Like {
  69374. x: float;
  69375. y: float;
  69376. z: float;
  69377. w: float;
  69378. }
  69379. /**
  69380. * @hidden
  69381. */
  69382. export interface IVector3Like {
  69383. x: float;
  69384. y: float;
  69385. z: float;
  69386. }
  69387. /**
  69388. * @hidden
  69389. */
  69390. export interface IVector2Like {
  69391. x: float;
  69392. y: float;
  69393. }
  69394. /**
  69395. * @hidden
  69396. */
  69397. export interface IMatrixLike {
  69398. toArray(): DeepImmutable<Float32Array>;
  69399. updateFlag: int;
  69400. }
  69401. /**
  69402. * @hidden
  69403. */
  69404. export interface IViewportLike {
  69405. x: float;
  69406. y: float;
  69407. width: float;
  69408. height: float;
  69409. }
  69410. /**
  69411. * @hidden
  69412. */
  69413. export interface IPlaneLike {
  69414. normal: IVector3Like;
  69415. d: float;
  69416. normalize(): void;
  69417. }
  69418. }
  69419. declare module BABYLON {
  69420. /**
  69421. * Interface used to define common properties for effect fallbacks
  69422. */
  69423. export interface IEffectFallbacks {
  69424. /**
  69425. * Removes the defines that should be removed when falling back.
  69426. * @param currentDefines defines the current define statements for the shader.
  69427. * @param effect defines the current effect we try to compile
  69428. * @returns The resulting defines with defines of the current rank removed.
  69429. */
  69430. reduce(currentDefines: string, effect: Effect): string;
  69431. /**
  69432. * Removes the fallback from the bound mesh.
  69433. */
  69434. unBindMesh(): void;
  69435. /**
  69436. * Checks to see if more fallbacks are still availible.
  69437. */
  69438. hasMoreFallbacks: boolean;
  69439. }
  69440. }
  69441. declare module BABYLON {
  69442. /**
  69443. * Class used to evalaute queries containing `and` and `or` operators
  69444. */
  69445. export class AndOrNotEvaluator {
  69446. /**
  69447. * Evaluate a query
  69448. * @param query defines the query to evaluate
  69449. * @param evaluateCallback defines the callback used to filter result
  69450. * @returns true if the query matches
  69451. */
  69452. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69453. private static _HandleParenthesisContent;
  69454. private static _SimplifyNegation;
  69455. }
  69456. }
  69457. declare module BABYLON {
  69458. /**
  69459. * Class used to store custom tags
  69460. */
  69461. export class Tags {
  69462. /**
  69463. * Adds support for tags on the given object
  69464. * @param obj defines the object to use
  69465. */
  69466. static EnableFor(obj: any): void;
  69467. /**
  69468. * Removes tags support
  69469. * @param obj defines the object to use
  69470. */
  69471. static DisableFor(obj: any): void;
  69472. /**
  69473. * Gets a boolean indicating if the given object has tags
  69474. * @param obj defines the object to use
  69475. * @returns a boolean
  69476. */
  69477. static HasTags(obj: any): boolean;
  69478. /**
  69479. * Gets the tags available on a given object
  69480. * @param obj defines the object to use
  69481. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69482. * @returns the tags
  69483. */
  69484. static GetTags(obj: any, asString?: boolean): any;
  69485. /**
  69486. * Adds tags to an object
  69487. * @param obj defines the object to use
  69488. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69489. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69490. */
  69491. static AddTagsTo(obj: any, tagsString: string): void;
  69492. /**
  69493. * @hidden
  69494. */
  69495. static _AddTagTo(obj: any, tag: string): void;
  69496. /**
  69497. * Removes specific tags from a specific object
  69498. * @param obj defines the object to use
  69499. * @param tagsString defines the tags to remove
  69500. */
  69501. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69502. /**
  69503. * @hidden
  69504. */
  69505. static _RemoveTagFrom(obj: any, tag: string): void;
  69506. /**
  69507. * Defines if tags hosted on an object match a given query
  69508. * @param obj defines the object to use
  69509. * @param tagsQuery defines the tag query
  69510. * @returns a boolean
  69511. */
  69512. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69513. }
  69514. }
  69515. declare module BABYLON {
  69516. /**
  69517. * Scalar computation library
  69518. */
  69519. export class Scalar {
  69520. /**
  69521. * Two pi constants convenient for computation.
  69522. */
  69523. static TwoPi: number;
  69524. /**
  69525. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69526. * @param a number
  69527. * @param b number
  69528. * @param epsilon (default = 1.401298E-45)
  69529. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69530. */
  69531. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69532. /**
  69533. * Returns a string : the upper case translation of the number i to hexadecimal.
  69534. * @param i number
  69535. * @returns the upper case translation of the number i to hexadecimal.
  69536. */
  69537. static ToHex(i: number): string;
  69538. /**
  69539. * Returns -1 if value is negative and +1 is value is positive.
  69540. * @param value the value
  69541. * @returns the value itself if it's equal to zero.
  69542. */
  69543. static Sign(value: number): number;
  69544. /**
  69545. * Returns the value itself if it's between min and max.
  69546. * Returns min if the value is lower than min.
  69547. * Returns max if the value is greater than max.
  69548. * @param value the value to clmap
  69549. * @param min the min value to clamp to (default: 0)
  69550. * @param max the max value to clamp to (default: 1)
  69551. * @returns the clamped value
  69552. */
  69553. static Clamp(value: number, min?: number, max?: number): number;
  69554. /**
  69555. * the log2 of value.
  69556. * @param value the value to compute log2 of
  69557. * @returns the log2 of value.
  69558. */
  69559. static Log2(value: number): number;
  69560. /**
  69561. * Loops the value, so that it is never larger than length and never smaller than 0.
  69562. *
  69563. * This is similar to the modulo operator but it works with floating point numbers.
  69564. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69565. * With t = 5 and length = 2.5, the result would be 0.0.
  69566. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69567. * @param value the value
  69568. * @param length the length
  69569. * @returns the looped value
  69570. */
  69571. static Repeat(value: number, length: number): number;
  69572. /**
  69573. * Normalize the value between 0.0 and 1.0 using min and max values
  69574. * @param value value to normalize
  69575. * @param min max to normalize between
  69576. * @param max min to normalize between
  69577. * @returns the normalized value
  69578. */
  69579. static Normalize(value: number, min: number, max: number): number;
  69580. /**
  69581. * Denormalize the value from 0.0 and 1.0 using min and max values
  69582. * @param normalized value to denormalize
  69583. * @param min max to denormalize between
  69584. * @param max min to denormalize between
  69585. * @returns the denormalized value
  69586. */
  69587. static Denormalize(normalized: number, min: number, max: number): number;
  69588. /**
  69589. * Calculates the shortest difference between two given angles given in degrees.
  69590. * @param current current angle in degrees
  69591. * @param target target angle in degrees
  69592. * @returns the delta
  69593. */
  69594. static DeltaAngle(current: number, target: number): number;
  69595. /**
  69596. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69597. * @param tx value
  69598. * @param length length
  69599. * @returns The returned value will move back and forth between 0 and length
  69600. */
  69601. static PingPong(tx: number, length: number): number;
  69602. /**
  69603. * Interpolates between min and max with smoothing at the limits.
  69604. *
  69605. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69606. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69607. * @param from from
  69608. * @param to to
  69609. * @param tx value
  69610. * @returns the smooth stepped value
  69611. */
  69612. static SmoothStep(from: number, to: number, tx: number): number;
  69613. /**
  69614. * Moves a value current towards target.
  69615. *
  69616. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69617. * Negative values of maxDelta pushes the value away from target.
  69618. * @param current current value
  69619. * @param target target value
  69620. * @param maxDelta max distance to move
  69621. * @returns resulting value
  69622. */
  69623. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69624. /**
  69625. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69626. *
  69627. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69628. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69629. * @param current current value
  69630. * @param target target value
  69631. * @param maxDelta max distance to move
  69632. * @returns resulting angle
  69633. */
  69634. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69635. /**
  69636. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69637. * @param start start value
  69638. * @param end target value
  69639. * @param amount amount to lerp between
  69640. * @returns the lerped value
  69641. */
  69642. static Lerp(start: number, end: number, amount: number): number;
  69643. /**
  69644. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69645. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69646. * @param start start value
  69647. * @param end target value
  69648. * @param amount amount to lerp between
  69649. * @returns the lerped value
  69650. */
  69651. static LerpAngle(start: number, end: number, amount: number): number;
  69652. /**
  69653. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69654. * @param a start value
  69655. * @param b target value
  69656. * @param value value between a and b
  69657. * @returns the inverseLerp value
  69658. */
  69659. static InverseLerp(a: number, b: number, value: number): number;
  69660. /**
  69661. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69662. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69663. * @param value1 spline value
  69664. * @param tangent1 spline value
  69665. * @param value2 spline value
  69666. * @param tangent2 spline value
  69667. * @param amount input value
  69668. * @returns hermite result
  69669. */
  69670. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69671. /**
  69672. * Returns a random float number between and min and max values
  69673. * @param min min value of random
  69674. * @param max max value of random
  69675. * @returns random value
  69676. */
  69677. static RandomRange(min: number, max: number): number;
  69678. /**
  69679. * This function returns percentage of a number in a given range.
  69680. *
  69681. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69682. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69683. * @param number to convert to percentage
  69684. * @param min min range
  69685. * @param max max range
  69686. * @returns the percentage
  69687. */
  69688. static RangeToPercent(number: number, min: number, max: number): number;
  69689. /**
  69690. * This function returns number that corresponds to the percentage in a given range.
  69691. *
  69692. * PercentToRange(0.34,0,100) will return 34.
  69693. * @param percent to convert to number
  69694. * @param min min range
  69695. * @param max max range
  69696. * @returns the number
  69697. */
  69698. static PercentToRange(percent: number, min: number, max: number): number;
  69699. /**
  69700. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69701. * @param angle The angle to normalize in radian.
  69702. * @return The converted angle.
  69703. */
  69704. static NormalizeRadians(angle: number): number;
  69705. }
  69706. }
  69707. declare module BABYLON {
  69708. /**
  69709. * Constant used to convert a value to gamma space
  69710. * @ignorenaming
  69711. */
  69712. export const ToGammaSpace: number;
  69713. /**
  69714. * Constant used to convert a value to linear space
  69715. * @ignorenaming
  69716. */
  69717. export const ToLinearSpace = 2.2;
  69718. /**
  69719. * Constant used to define the minimal number value in Babylon.js
  69720. * @ignorenaming
  69721. */
  69722. let Epsilon: number;
  69723. }
  69724. declare module BABYLON {
  69725. /**
  69726. * Class used to represent a viewport on screen
  69727. */
  69728. export class Viewport {
  69729. /** viewport left coordinate */
  69730. x: number;
  69731. /** viewport top coordinate */
  69732. y: number;
  69733. /**viewport width */
  69734. width: number;
  69735. /** viewport height */
  69736. height: number;
  69737. /**
  69738. * Creates a Viewport object located at (x, y) and sized (width, height)
  69739. * @param x defines viewport left coordinate
  69740. * @param y defines viewport top coordinate
  69741. * @param width defines the viewport width
  69742. * @param height defines the viewport height
  69743. */
  69744. constructor(
  69745. /** viewport left coordinate */
  69746. x: number,
  69747. /** viewport top coordinate */
  69748. y: number,
  69749. /**viewport width */
  69750. width: number,
  69751. /** viewport height */
  69752. height: number);
  69753. /**
  69754. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69755. * @param renderWidth defines the rendering width
  69756. * @param renderHeight defines the rendering height
  69757. * @returns a new Viewport
  69758. */
  69759. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69760. /**
  69761. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69762. * @param renderWidth defines the rendering width
  69763. * @param renderHeight defines the rendering height
  69764. * @param ref defines the target viewport
  69765. * @returns the current viewport
  69766. */
  69767. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69768. /**
  69769. * Returns a new Viewport copied from the current one
  69770. * @returns a new Viewport
  69771. */
  69772. clone(): Viewport;
  69773. }
  69774. }
  69775. declare module BABYLON {
  69776. /**
  69777. * Class containing a set of static utilities functions for arrays.
  69778. */
  69779. export class ArrayTools {
  69780. /**
  69781. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69782. * @param size the number of element to construct and put in the array
  69783. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69784. * @returns a new array filled with new objects
  69785. */
  69786. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69787. }
  69788. }
  69789. declare module BABYLON {
  69790. /**
  69791. * Class representing a vector containing 2 coordinates
  69792. */
  69793. export class Vector2 {
  69794. /** defines the first coordinate */
  69795. x: number;
  69796. /** defines the second coordinate */
  69797. y: number;
  69798. /**
  69799. * Creates a new Vector2 from the given x and y coordinates
  69800. * @param x defines the first coordinate
  69801. * @param y defines the second coordinate
  69802. */
  69803. constructor(
  69804. /** defines the first coordinate */
  69805. x?: number,
  69806. /** defines the second coordinate */
  69807. y?: number);
  69808. /**
  69809. * Gets a string with the Vector2 coordinates
  69810. * @returns a string with the Vector2 coordinates
  69811. */
  69812. toString(): string;
  69813. /**
  69814. * Gets class name
  69815. * @returns the string "Vector2"
  69816. */
  69817. getClassName(): string;
  69818. /**
  69819. * Gets current vector hash code
  69820. * @returns the Vector2 hash code as a number
  69821. */
  69822. getHashCode(): number;
  69823. /**
  69824. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69825. * @param array defines the source array
  69826. * @param index defines the offset in source array
  69827. * @returns the current Vector2
  69828. */
  69829. toArray(array: FloatArray, index?: number): Vector2;
  69830. /**
  69831. * Copy the current vector to an array
  69832. * @returns a new array with 2 elements: the Vector2 coordinates.
  69833. */
  69834. asArray(): number[];
  69835. /**
  69836. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69837. * @param source defines the source Vector2
  69838. * @returns the current updated Vector2
  69839. */
  69840. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69841. /**
  69842. * Sets the Vector2 coordinates with the given floats
  69843. * @param x defines the first coordinate
  69844. * @param y defines the second coordinate
  69845. * @returns the current updated Vector2
  69846. */
  69847. copyFromFloats(x: number, y: number): Vector2;
  69848. /**
  69849. * Sets the Vector2 coordinates with the given floats
  69850. * @param x defines the first coordinate
  69851. * @param y defines the second coordinate
  69852. * @returns the current updated Vector2
  69853. */
  69854. set(x: number, y: number): Vector2;
  69855. /**
  69856. * Add another vector with the current one
  69857. * @param otherVector defines the other vector
  69858. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69859. */
  69860. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69861. /**
  69862. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69863. * @param otherVector defines the other vector
  69864. * @param result defines the target vector
  69865. * @returns the unmodified current Vector2
  69866. */
  69867. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69868. /**
  69869. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69870. * @param otherVector defines the other vector
  69871. * @returns the current updated Vector2
  69872. */
  69873. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69874. /**
  69875. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69876. * @param otherVector defines the other vector
  69877. * @returns a new Vector2
  69878. */
  69879. addVector3(otherVector: Vector3): Vector2;
  69880. /**
  69881. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69882. * @param otherVector defines the other vector
  69883. * @returns a new Vector2
  69884. */
  69885. subtract(otherVector: Vector2): Vector2;
  69886. /**
  69887. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69888. * @param otherVector defines the other vector
  69889. * @param result defines the target vector
  69890. * @returns the unmodified current Vector2
  69891. */
  69892. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69893. /**
  69894. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69895. * @param otherVector defines the other vector
  69896. * @returns the current updated Vector2
  69897. */
  69898. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69899. /**
  69900. * Multiplies in place the current Vector2 coordinates by the given ones
  69901. * @param otherVector defines the other vector
  69902. * @returns the current updated Vector2
  69903. */
  69904. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69905. /**
  69906. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69907. * @param otherVector defines the other vector
  69908. * @returns a new Vector2
  69909. */
  69910. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69911. /**
  69912. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69913. * @param otherVector defines the other vector
  69914. * @param result defines the target vector
  69915. * @returns the unmodified current Vector2
  69916. */
  69917. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69918. /**
  69919. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69920. * @param x defines the first coordinate
  69921. * @param y defines the second coordinate
  69922. * @returns a new Vector2
  69923. */
  69924. multiplyByFloats(x: number, y: number): Vector2;
  69925. /**
  69926. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69927. * @param otherVector defines the other vector
  69928. * @returns a new Vector2
  69929. */
  69930. divide(otherVector: Vector2): Vector2;
  69931. /**
  69932. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69933. * @param otherVector defines the other vector
  69934. * @param result defines the target vector
  69935. * @returns the unmodified current Vector2
  69936. */
  69937. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69938. /**
  69939. * Divides the current Vector2 coordinates by the given ones
  69940. * @param otherVector defines the other vector
  69941. * @returns the current updated Vector2
  69942. */
  69943. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69944. /**
  69945. * Gets a new Vector2 with current Vector2 negated coordinates
  69946. * @returns a new Vector2
  69947. */
  69948. negate(): Vector2;
  69949. /**
  69950. * Multiply the Vector2 coordinates by scale
  69951. * @param scale defines the scaling factor
  69952. * @returns the current updated Vector2
  69953. */
  69954. scaleInPlace(scale: number): Vector2;
  69955. /**
  69956. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69957. * @param scale defines the scaling factor
  69958. * @returns a new Vector2
  69959. */
  69960. scale(scale: number): Vector2;
  69961. /**
  69962. * Scale the current Vector2 values by a factor to a given Vector2
  69963. * @param scale defines the scale factor
  69964. * @param result defines the Vector2 object where to store the result
  69965. * @returns the unmodified current Vector2
  69966. */
  69967. scaleToRef(scale: number, result: Vector2): Vector2;
  69968. /**
  69969. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69970. * @param scale defines the scale factor
  69971. * @param result defines the Vector2 object where to store the result
  69972. * @returns the unmodified current Vector2
  69973. */
  69974. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69975. /**
  69976. * Gets a boolean if two vectors are equals
  69977. * @param otherVector defines the other vector
  69978. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69979. */
  69980. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69981. /**
  69982. * Gets a boolean if two vectors are equals (using an epsilon value)
  69983. * @param otherVector defines the other vector
  69984. * @param epsilon defines the minimal distance to consider equality
  69985. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69986. */
  69987. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69988. /**
  69989. * Gets a new Vector2 from current Vector2 floored values
  69990. * @returns a new Vector2
  69991. */
  69992. floor(): Vector2;
  69993. /**
  69994. * Gets a new Vector2 from current Vector2 floored values
  69995. * @returns a new Vector2
  69996. */
  69997. fract(): Vector2;
  69998. /**
  69999. * Gets the length of the vector
  70000. * @returns the vector length (float)
  70001. */
  70002. length(): number;
  70003. /**
  70004. * Gets the vector squared length
  70005. * @returns the vector squared length (float)
  70006. */
  70007. lengthSquared(): number;
  70008. /**
  70009. * Normalize the vector
  70010. * @returns the current updated Vector2
  70011. */
  70012. normalize(): Vector2;
  70013. /**
  70014. * Gets a new Vector2 copied from the Vector2
  70015. * @returns a new Vector2
  70016. */
  70017. clone(): Vector2;
  70018. /**
  70019. * Gets a new Vector2(0, 0)
  70020. * @returns a new Vector2
  70021. */
  70022. static Zero(): Vector2;
  70023. /**
  70024. * Gets a new Vector2(1, 1)
  70025. * @returns a new Vector2
  70026. */
  70027. static One(): Vector2;
  70028. /**
  70029. * Gets a new Vector2 set from the given index element of the given array
  70030. * @param array defines the data source
  70031. * @param offset defines the offset in the data source
  70032. * @returns a new Vector2
  70033. */
  70034. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70035. /**
  70036. * Sets "result" from the given index element of the given array
  70037. * @param array defines the data source
  70038. * @param offset defines the offset in the data source
  70039. * @param result defines the target vector
  70040. */
  70041. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70042. /**
  70043. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70044. * @param value1 defines 1st point of control
  70045. * @param value2 defines 2nd point of control
  70046. * @param value3 defines 3rd point of control
  70047. * @param value4 defines 4th point of control
  70048. * @param amount defines the interpolation factor
  70049. * @returns a new Vector2
  70050. */
  70051. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70052. /**
  70053. * 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".
  70054. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70055. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70056. * @param value defines the value to clamp
  70057. * @param min defines the lower limit
  70058. * @param max defines the upper limit
  70059. * @returns a new Vector2
  70060. */
  70061. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70062. /**
  70063. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70064. * @param value1 defines the 1st control point
  70065. * @param tangent1 defines the outgoing tangent
  70066. * @param value2 defines the 2nd control point
  70067. * @param tangent2 defines the incoming tangent
  70068. * @param amount defines the interpolation factor
  70069. * @returns a new Vector2
  70070. */
  70071. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70072. /**
  70073. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70074. * @param start defines the start vector
  70075. * @param end defines the end vector
  70076. * @param amount defines the interpolation factor
  70077. * @returns a new Vector2
  70078. */
  70079. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70080. /**
  70081. * Gets the dot product of the vector "left" and the vector "right"
  70082. * @param left defines first vector
  70083. * @param right defines second vector
  70084. * @returns the dot product (float)
  70085. */
  70086. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70087. /**
  70088. * Returns a new Vector2 equal to the normalized given vector
  70089. * @param vector defines the vector to normalize
  70090. * @returns a new Vector2
  70091. */
  70092. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70093. /**
  70094. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70095. * @param left defines 1st vector
  70096. * @param right defines 2nd vector
  70097. * @returns a new Vector2
  70098. */
  70099. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70100. /**
  70101. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70102. * @param left defines 1st vector
  70103. * @param right defines 2nd vector
  70104. * @returns a new Vector2
  70105. */
  70106. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70107. /**
  70108. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70109. * @param vector defines the vector to transform
  70110. * @param transformation defines the matrix to apply
  70111. * @returns a new Vector2
  70112. */
  70113. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70114. /**
  70115. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70116. * @param vector defines the vector to transform
  70117. * @param transformation defines the matrix to apply
  70118. * @param result defines the target vector
  70119. */
  70120. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70121. /**
  70122. * Determines if a given vector is included in a triangle
  70123. * @param p defines the vector to test
  70124. * @param p0 defines 1st triangle point
  70125. * @param p1 defines 2nd triangle point
  70126. * @param p2 defines 3rd triangle point
  70127. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70128. */
  70129. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70130. /**
  70131. * Gets the distance between the vectors "value1" and "value2"
  70132. * @param value1 defines first vector
  70133. * @param value2 defines second vector
  70134. * @returns the distance between vectors
  70135. */
  70136. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70137. /**
  70138. * Returns the squared distance between the vectors "value1" and "value2"
  70139. * @param value1 defines first vector
  70140. * @param value2 defines second vector
  70141. * @returns the squared distance between vectors
  70142. */
  70143. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70144. /**
  70145. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70146. * @param value1 defines first vector
  70147. * @param value2 defines second vector
  70148. * @returns a new Vector2
  70149. */
  70150. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70151. /**
  70152. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70153. * @param p defines the middle point
  70154. * @param segA defines one point of the segment
  70155. * @param segB defines the other point of the segment
  70156. * @returns the shortest distance
  70157. */
  70158. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70159. }
  70160. /**
  70161. * Classed used to store (x,y,z) vector representation
  70162. * A Vector3 is the main object used in 3D geometry
  70163. * It can represent etiher the coordinates of a point the space, either a direction
  70164. * Reminder: js uses a left handed forward facing system
  70165. */
  70166. export class Vector3 {
  70167. /**
  70168. * Defines the first coordinates (on X axis)
  70169. */
  70170. x: number;
  70171. /**
  70172. * Defines the second coordinates (on Y axis)
  70173. */
  70174. y: number;
  70175. /**
  70176. * Defines the third coordinates (on Z axis)
  70177. */
  70178. z: number;
  70179. private static _UpReadOnly;
  70180. private static _ZeroReadOnly;
  70181. /**
  70182. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70183. * @param x defines the first coordinates (on X axis)
  70184. * @param y defines the second coordinates (on Y axis)
  70185. * @param z defines the third coordinates (on Z axis)
  70186. */
  70187. constructor(
  70188. /**
  70189. * Defines the first coordinates (on X axis)
  70190. */
  70191. x?: number,
  70192. /**
  70193. * Defines the second coordinates (on Y axis)
  70194. */
  70195. y?: number,
  70196. /**
  70197. * Defines the third coordinates (on Z axis)
  70198. */
  70199. z?: number);
  70200. /**
  70201. * Creates a string representation of the Vector3
  70202. * @returns a string with the Vector3 coordinates.
  70203. */
  70204. toString(): string;
  70205. /**
  70206. * Gets the class name
  70207. * @returns the string "Vector3"
  70208. */
  70209. getClassName(): string;
  70210. /**
  70211. * Creates the Vector3 hash code
  70212. * @returns a number which tends to be unique between Vector3 instances
  70213. */
  70214. getHashCode(): number;
  70215. /**
  70216. * Creates an array containing three elements : the coordinates of the Vector3
  70217. * @returns a new array of numbers
  70218. */
  70219. asArray(): number[];
  70220. /**
  70221. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70222. * @param array defines the destination array
  70223. * @param index defines the offset in the destination array
  70224. * @returns the current Vector3
  70225. */
  70226. toArray(array: FloatArray, index?: number): Vector3;
  70227. /**
  70228. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70229. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70230. */
  70231. toQuaternion(): Quaternion;
  70232. /**
  70233. * Adds the given vector to the current Vector3
  70234. * @param otherVector defines the second operand
  70235. * @returns the current updated Vector3
  70236. */
  70237. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70238. /**
  70239. * Adds the given coordinates to the current Vector3
  70240. * @param x defines the x coordinate of the operand
  70241. * @param y defines the y coordinate of the operand
  70242. * @param z defines the z coordinate of the operand
  70243. * @returns the current updated Vector3
  70244. */
  70245. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70246. /**
  70247. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70248. * @param otherVector defines the second operand
  70249. * @returns the resulting Vector3
  70250. */
  70251. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70252. /**
  70253. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70254. * @param otherVector defines the second operand
  70255. * @param result defines the Vector3 object where to store the result
  70256. * @returns the current Vector3
  70257. */
  70258. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70259. /**
  70260. * Subtract the given vector from the current Vector3
  70261. * @param otherVector defines the second operand
  70262. * @returns the current updated Vector3
  70263. */
  70264. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70265. /**
  70266. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70267. * @param otherVector defines the second operand
  70268. * @returns the resulting Vector3
  70269. */
  70270. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70271. /**
  70272. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70273. * @param otherVector defines the second operand
  70274. * @param result defines the Vector3 object where to store the result
  70275. * @returns the current Vector3
  70276. */
  70277. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70278. /**
  70279. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70280. * @param x defines the x coordinate of the operand
  70281. * @param y defines the y coordinate of the operand
  70282. * @param z defines the z coordinate of the operand
  70283. * @returns the resulting Vector3
  70284. */
  70285. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70286. /**
  70287. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70288. * @param x defines the x coordinate of the operand
  70289. * @param y defines the y coordinate of the operand
  70290. * @param z defines the z coordinate of the operand
  70291. * @param result defines the Vector3 object where to store the result
  70292. * @returns the current Vector3
  70293. */
  70294. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70295. /**
  70296. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70297. * @returns a new Vector3
  70298. */
  70299. negate(): Vector3;
  70300. /**
  70301. * Multiplies the Vector3 coordinates by the float "scale"
  70302. * @param scale defines the multiplier factor
  70303. * @returns the current updated Vector3
  70304. */
  70305. scaleInPlace(scale: number): Vector3;
  70306. /**
  70307. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70308. * @param scale defines the multiplier factor
  70309. * @returns a new Vector3
  70310. */
  70311. scale(scale: number): Vector3;
  70312. /**
  70313. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70314. * @param scale defines the multiplier factor
  70315. * @param result defines the Vector3 object where to store the result
  70316. * @returns the current Vector3
  70317. */
  70318. scaleToRef(scale: number, result: Vector3): Vector3;
  70319. /**
  70320. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70321. * @param scale defines the scale factor
  70322. * @param result defines the Vector3 object where to store the result
  70323. * @returns the unmodified current Vector3
  70324. */
  70325. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70326. /**
  70327. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70328. * @param otherVector defines the second operand
  70329. * @returns true if both vectors are equals
  70330. */
  70331. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70332. /**
  70333. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70334. * @param otherVector defines the second operand
  70335. * @param epsilon defines the minimal distance to define values as equals
  70336. * @returns true if both vectors are distant less than epsilon
  70337. */
  70338. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70339. /**
  70340. * Returns true if the current Vector3 coordinates equals the given floats
  70341. * @param x defines the x coordinate of the operand
  70342. * @param y defines the y coordinate of the operand
  70343. * @param z defines the z coordinate of the operand
  70344. * @returns true if both vectors are equals
  70345. */
  70346. equalsToFloats(x: number, y: number, z: number): boolean;
  70347. /**
  70348. * Multiplies the current Vector3 coordinates by the given ones
  70349. * @param otherVector defines the second operand
  70350. * @returns the current updated Vector3
  70351. */
  70352. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70353. /**
  70354. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70355. * @param otherVector defines the second operand
  70356. * @returns the new Vector3
  70357. */
  70358. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70359. /**
  70360. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70361. * @param otherVector defines the second operand
  70362. * @param result defines the Vector3 object where to store the result
  70363. * @returns the current Vector3
  70364. */
  70365. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70366. /**
  70367. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70368. * @param x defines the x coordinate of the operand
  70369. * @param y defines the y coordinate of the operand
  70370. * @param z defines the z coordinate of the operand
  70371. * @returns the new Vector3
  70372. */
  70373. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70374. /**
  70375. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70376. * @param otherVector defines the second operand
  70377. * @returns the new Vector3
  70378. */
  70379. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70380. /**
  70381. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70382. * @param otherVector defines the second operand
  70383. * @param result defines the Vector3 object where to store the result
  70384. * @returns the current Vector3
  70385. */
  70386. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70387. /**
  70388. * Divides the current Vector3 coordinates by the given ones.
  70389. * @param otherVector defines the second operand
  70390. * @returns the current updated Vector3
  70391. */
  70392. divideInPlace(otherVector: Vector3): Vector3;
  70393. /**
  70394. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70395. * @param other defines the second operand
  70396. * @returns the current updated Vector3
  70397. */
  70398. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70399. /**
  70400. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70401. * @param other defines the second operand
  70402. * @returns the current updated Vector3
  70403. */
  70404. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70405. /**
  70406. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70407. * @param x defines the x coordinate of the operand
  70408. * @param y defines the y coordinate of the operand
  70409. * @param z defines the z coordinate of the operand
  70410. * @returns the current updated Vector3
  70411. */
  70412. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70413. /**
  70414. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70415. * @param x defines the x coordinate of the operand
  70416. * @param y defines the y coordinate of the operand
  70417. * @param z defines the z coordinate of the operand
  70418. * @returns the current updated Vector3
  70419. */
  70420. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70421. /**
  70422. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70423. * Check if is non uniform within a certain amount of decimal places to account for this
  70424. * @param epsilon the amount the values can differ
  70425. * @returns if the the vector is non uniform to a certain number of decimal places
  70426. */
  70427. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70428. /**
  70429. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70430. */
  70431. readonly isNonUniform: boolean;
  70432. /**
  70433. * Gets a new Vector3 from current Vector3 floored values
  70434. * @returns a new Vector3
  70435. */
  70436. floor(): Vector3;
  70437. /**
  70438. * Gets a new Vector3 from current Vector3 floored values
  70439. * @returns a new Vector3
  70440. */
  70441. fract(): Vector3;
  70442. /**
  70443. * Gets the length of the Vector3
  70444. * @returns the length of the Vector3
  70445. */
  70446. length(): number;
  70447. /**
  70448. * Gets the squared length of the Vector3
  70449. * @returns squared length of the Vector3
  70450. */
  70451. lengthSquared(): number;
  70452. /**
  70453. * Normalize the current Vector3.
  70454. * Please note that this is an in place operation.
  70455. * @returns the current updated Vector3
  70456. */
  70457. normalize(): Vector3;
  70458. /**
  70459. * Reorders the x y z properties of the vector in place
  70460. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70461. * @returns the current updated vector
  70462. */
  70463. reorderInPlace(order: string): this;
  70464. /**
  70465. * Rotates the vector around 0,0,0 by a quaternion
  70466. * @param quaternion the rotation quaternion
  70467. * @param result vector to store the result
  70468. * @returns the resulting vector
  70469. */
  70470. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70471. /**
  70472. * Rotates a vector around a given point
  70473. * @param quaternion the rotation quaternion
  70474. * @param point the point to rotate around
  70475. * @param result vector to store the result
  70476. * @returns the resulting vector
  70477. */
  70478. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70479. /**
  70480. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70481. * The cross product is then orthogonal to both current and "other"
  70482. * @param other defines the right operand
  70483. * @returns the cross product
  70484. */
  70485. cross(other: Vector3): Vector3;
  70486. /**
  70487. * Normalize the current Vector3 with the given input length.
  70488. * Please note that this is an in place operation.
  70489. * @param len the length of the vector
  70490. * @returns the current updated Vector3
  70491. */
  70492. normalizeFromLength(len: number): Vector3;
  70493. /**
  70494. * Normalize the current Vector3 to a new vector
  70495. * @returns the new Vector3
  70496. */
  70497. normalizeToNew(): Vector3;
  70498. /**
  70499. * Normalize the current Vector3 to the reference
  70500. * @param reference define the Vector3 to update
  70501. * @returns the updated Vector3
  70502. */
  70503. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70504. /**
  70505. * Creates a new Vector3 copied from the current Vector3
  70506. * @returns the new Vector3
  70507. */
  70508. clone(): Vector3;
  70509. /**
  70510. * Copies the given vector coordinates to the current Vector3 ones
  70511. * @param source defines the source Vector3
  70512. * @returns the current updated Vector3
  70513. */
  70514. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70515. /**
  70516. * Copies the given floats to the current Vector3 coordinates
  70517. * @param x defines the x coordinate of the operand
  70518. * @param y defines the y coordinate of the operand
  70519. * @param z defines the z coordinate of the operand
  70520. * @returns the current updated Vector3
  70521. */
  70522. copyFromFloats(x: number, y: number, z: number): Vector3;
  70523. /**
  70524. * Copies the given floats to the current Vector3 coordinates
  70525. * @param x defines the x coordinate of the operand
  70526. * @param y defines the y coordinate of the operand
  70527. * @param z defines the z coordinate of the operand
  70528. * @returns the current updated Vector3
  70529. */
  70530. set(x: number, y: number, z: number): Vector3;
  70531. /**
  70532. * Copies the given float to the current Vector3 coordinates
  70533. * @param v defines the x, y and z coordinates of the operand
  70534. * @returns the current updated Vector3
  70535. */
  70536. setAll(v: number): Vector3;
  70537. /**
  70538. * Get the clip factor between two vectors
  70539. * @param vector0 defines the first operand
  70540. * @param vector1 defines the second operand
  70541. * @param axis defines the axis to use
  70542. * @param size defines the size along the axis
  70543. * @returns the clip factor
  70544. */
  70545. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70546. /**
  70547. * Get angle between two vectors
  70548. * @param vector0 angle between vector0 and vector1
  70549. * @param vector1 angle between vector0 and vector1
  70550. * @param normal direction of the normal
  70551. * @return the angle between vector0 and vector1
  70552. */
  70553. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70554. /**
  70555. * Returns a new Vector3 set from the index "offset" of the given array
  70556. * @param array defines the source array
  70557. * @param offset defines the offset in the source array
  70558. * @returns the new Vector3
  70559. */
  70560. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70561. /**
  70562. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70563. * This function is deprecated. Use FromArray instead
  70564. * @param array defines the source array
  70565. * @param offset defines the offset in the source array
  70566. * @returns the new Vector3
  70567. */
  70568. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70569. /**
  70570. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70571. * @param array defines the source array
  70572. * @param offset defines the offset in the source array
  70573. * @param result defines the Vector3 where to store the result
  70574. */
  70575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70576. /**
  70577. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70578. * This function is deprecated. Use FromArrayToRef instead.
  70579. * @param array defines the source array
  70580. * @param offset defines the offset in the source array
  70581. * @param result defines the Vector3 where to store the result
  70582. */
  70583. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70584. /**
  70585. * Sets the given vector "result" with the given floats.
  70586. * @param x defines the x coordinate of the source
  70587. * @param y defines the y coordinate of the source
  70588. * @param z defines the z coordinate of the source
  70589. * @param result defines the Vector3 where to store the result
  70590. */
  70591. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70592. /**
  70593. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70594. * @returns a new empty Vector3
  70595. */
  70596. static Zero(): Vector3;
  70597. /**
  70598. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70599. * @returns a new unit Vector3
  70600. */
  70601. static One(): Vector3;
  70602. /**
  70603. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70604. * @returns a new up Vector3
  70605. */
  70606. static Up(): Vector3;
  70607. /**
  70608. * Gets a up Vector3 that must not be updated
  70609. */
  70610. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70611. /**
  70612. * Gets a zero Vector3 that must not be updated
  70613. */
  70614. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70615. /**
  70616. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70617. * @returns a new down Vector3
  70618. */
  70619. static Down(): Vector3;
  70620. /**
  70621. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70622. * @returns a new forward Vector3
  70623. */
  70624. static Forward(): Vector3;
  70625. /**
  70626. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70627. * @returns a new forward Vector3
  70628. */
  70629. static Backward(): Vector3;
  70630. /**
  70631. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70632. * @returns a new right Vector3
  70633. */
  70634. static Right(): Vector3;
  70635. /**
  70636. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70637. * @returns a new left Vector3
  70638. */
  70639. static Left(): Vector3;
  70640. /**
  70641. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70642. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70643. * @param vector defines the Vector3 to transform
  70644. * @param transformation defines the transformation matrix
  70645. * @returns the transformed Vector3
  70646. */
  70647. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70648. /**
  70649. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70650. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70651. * @param vector defines the Vector3 to transform
  70652. * @param transformation defines the transformation matrix
  70653. * @param result defines the Vector3 where to store the result
  70654. */
  70655. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70656. /**
  70657. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70658. * This method computes tranformed coordinates only, not transformed direction vectors
  70659. * @param x define the x coordinate of the source vector
  70660. * @param y define the y coordinate of the source vector
  70661. * @param z define the z coordinate of the source vector
  70662. * @param transformation defines the transformation matrix
  70663. * @param result defines the Vector3 where to store the result
  70664. */
  70665. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70666. /**
  70667. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70668. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70669. * @param vector defines the Vector3 to transform
  70670. * @param transformation defines the transformation matrix
  70671. * @returns the new Vector3
  70672. */
  70673. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70674. /**
  70675. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70676. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70677. * @param vector defines the Vector3 to transform
  70678. * @param transformation defines the transformation matrix
  70679. * @param result defines the Vector3 where to store the result
  70680. */
  70681. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70682. /**
  70683. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70684. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70685. * @param x define the x coordinate of the source vector
  70686. * @param y define the y coordinate of the source vector
  70687. * @param z define the z coordinate of the source vector
  70688. * @param transformation defines the transformation matrix
  70689. * @param result defines the Vector3 where to store the result
  70690. */
  70691. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70692. /**
  70693. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70694. * @param value1 defines the first control point
  70695. * @param value2 defines the second control point
  70696. * @param value3 defines the third control point
  70697. * @param value4 defines the fourth control point
  70698. * @param amount defines the amount on the spline to use
  70699. * @returns the new Vector3
  70700. */
  70701. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70702. /**
  70703. * 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"
  70704. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70705. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70706. * @param value defines the current value
  70707. * @param min defines the lower range value
  70708. * @param max defines the upper range value
  70709. * @returns the new Vector3
  70710. */
  70711. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70712. /**
  70713. * 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"
  70714. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70715. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70716. * @param value defines the current value
  70717. * @param min defines the lower range value
  70718. * @param max defines the upper range value
  70719. * @param result defines the Vector3 where to store the result
  70720. */
  70721. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70722. /**
  70723. * Checks if a given vector is inside a specific range
  70724. * @param v defines the vector to test
  70725. * @param min defines the minimum range
  70726. * @param max defines the maximum range
  70727. */
  70728. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70729. /**
  70730. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70731. * @param value1 defines the first control point
  70732. * @param tangent1 defines the first tangent vector
  70733. * @param value2 defines the second control point
  70734. * @param tangent2 defines the second tangent vector
  70735. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70736. * @returns the new Vector3
  70737. */
  70738. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70739. /**
  70740. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70741. * @param start defines the start value
  70742. * @param end defines the end value
  70743. * @param amount max defines amount between both (between 0 and 1)
  70744. * @returns the new Vector3
  70745. */
  70746. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70747. /**
  70748. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70749. * @param start defines the start value
  70750. * @param end defines the end value
  70751. * @param amount max defines amount between both (between 0 and 1)
  70752. * @param result defines the Vector3 where to store the result
  70753. */
  70754. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70755. /**
  70756. * Returns the dot product (float) between the vectors "left" and "right"
  70757. * @param left defines the left operand
  70758. * @param right defines the right operand
  70759. * @returns the dot product
  70760. */
  70761. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70762. /**
  70763. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70764. * The cross product is then orthogonal to both "left" and "right"
  70765. * @param left defines the left operand
  70766. * @param right defines the right operand
  70767. * @returns the cross product
  70768. */
  70769. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70770. /**
  70771. * Sets the given vector "result" with the cross product of "left" and "right"
  70772. * The cross product is then orthogonal to both "left" and "right"
  70773. * @param left defines the left operand
  70774. * @param right defines the right operand
  70775. * @param result defines the Vector3 where to store the result
  70776. */
  70777. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70778. /**
  70779. * Returns a new Vector3 as the normalization of the given vector
  70780. * @param vector defines the Vector3 to normalize
  70781. * @returns the new Vector3
  70782. */
  70783. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70784. /**
  70785. * Sets the given vector "result" with the normalization of the given first vector
  70786. * @param vector defines the Vector3 to normalize
  70787. * @param result defines the Vector3 where to store the result
  70788. */
  70789. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70790. /**
  70791. * Project a Vector3 onto screen space
  70792. * @param vector defines the Vector3 to project
  70793. * @param world defines the world matrix to use
  70794. * @param transform defines the transform (view x projection) matrix to use
  70795. * @param viewport defines the screen viewport to use
  70796. * @returns the new Vector3
  70797. */
  70798. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70799. /** @hidden */
  70800. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70801. /**
  70802. * Unproject from screen space to object space
  70803. * @param source defines the screen space Vector3 to use
  70804. * @param viewportWidth defines the current width of the viewport
  70805. * @param viewportHeight defines the current height of the viewport
  70806. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70807. * @param transform defines the transform (view x projection) matrix to use
  70808. * @returns the new Vector3
  70809. */
  70810. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70811. /**
  70812. * Unproject from screen space to object space
  70813. * @param source defines the screen space Vector3 to use
  70814. * @param viewportWidth defines the current width of the viewport
  70815. * @param viewportHeight defines the current height of the viewport
  70816. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70817. * @param view defines the view matrix to use
  70818. * @param projection defines the projection matrix to use
  70819. * @returns the new Vector3
  70820. */
  70821. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70822. /**
  70823. * Unproject from screen space to object space
  70824. * @param source defines the screen space Vector3 to use
  70825. * @param viewportWidth defines the current width of the viewport
  70826. * @param viewportHeight defines the current height of the viewport
  70827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70828. * @param view defines the view matrix to use
  70829. * @param projection defines the projection matrix to use
  70830. * @param result defines the Vector3 where to store the result
  70831. */
  70832. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70833. /**
  70834. * Unproject from screen space to object space
  70835. * @param sourceX defines the screen space x coordinate to use
  70836. * @param sourceY defines the screen space y coordinate to use
  70837. * @param sourceZ defines the screen space z coordinate to use
  70838. * @param viewportWidth defines the current width of the viewport
  70839. * @param viewportHeight defines the current height of the viewport
  70840. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70841. * @param view defines the view matrix to use
  70842. * @param projection defines the projection matrix to use
  70843. * @param result defines the Vector3 where to store the result
  70844. */
  70845. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70846. /**
  70847. * Gets the minimal coordinate values between two Vector3
  70848. * @param left defines the first operand
  70849. * @param right defines the second operand
  70850. * @returns the new Vector3
  70851. */
  70852. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70853. /**
  70854. * Gets the maximal coordinate values between two Vector3
  70855. * @param left defines the first operand
  70856. * @param right defines the second operand
  70857. * @returns the new Vector3
  70858. */
  70859. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70860. /**
  70861. * Returns the distance between the vectors "value1" and "value2"
  70862. * @param value1 defines the first operand
  70863. * @param value2 defines the second operand
  70864. * @returns the distance
  70865. */
  70866. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70867. /**
  70868. * Returns the squared distance between the vectors "value1" and "value2"
  70869. * @param value1 defines the first operand
  70870. * @param value2 defines the second operand
  70871. * @returns the squared distance
  70872. */
  70873. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70874. /**
  70875. * Returns a new Vector3 located at the center between "value1" and "value2"
  70876. * @param value1 defines the first operand
  70877. * @param value2 defines the second operand
  70878. * @returns the new Vector3
  70879. */
  70880. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70881. /**
  70882. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70883. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70884. * to something in order to rotate it from its local system to the given target system
  70885. * Note: axis1, axis2 and axis3 are normalized during this operation
  70886. * @param axis1 defines the first axis
  70887. * @param axis2 defines the second axis
  70888. * @param axis3 defines the third axis
  70889. * @returns a new Vector3
  70890. */
  70891. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70892. /**
  70893. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70894. * @param axis1 defines the first axis
  70895. * @param axis2 defines the second axis
  70896. * @param axis3 defines the third axis
  70897. * @param ref defines the Vector3 where to store the result
  70898. */
  70899. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70900. }
  70901. /**
  70902. * Vector4 class created for EulerAngle class conversion to Quaternion
  70903. */
  70904. export class Vector4 {
  70905. /** x value of the vector */
  70906. x: number;
  70907. /** y value of the vector */
  70908. y: number;
  70909. /** z value of the vector */
  70910. z: number;
  70911. /** w value of the vector */
  70912. w: number;
  70913. /**
  70914. * Creates a Vector4 object from the given floats.
  70915. * @param x x value of the vector
  70916. * @param y y value of the vector
  70917. * @param z z value of the vector
  70918. * @param w w value of the vector
  70919. */
  70920. constructor(
  70921. /** x value of the vector */
  70922. x: number,
  70923. /** y value of the vector */
  70924. y: number,
  70925. /** z value of the vector */
  70926. z: number,
  70927. /** w value of the vector */
  70928. w: number);
  70929. /**
  70930. * Returns the string with the Vector4 coordinates.
  70931. * @returns a string containing all the vector values
  70932. */
  70933. toString(): string;
  70934. /**
  70935. * Returns the string "Vector4".
  70936. * @returns "Vector4"
  70937. */
  70938. getClassName(): string;
  70939. /**
  70940. * Returns the Vector4 hash code.
  70941. * @returns a unique hash code
  70942. */
  70943. getHashCode(): number;
  70944. /**
  70945. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70946. * @returns the resulting array
  70947. */
  70948. asArray(): number[];
  70949. /**
  70950. * Populates the given array from the given index with the Vector4 coordinates.
  70951. * @param array array to populate
  70952. * @param index index of the array to start at (default: 0)
  70953. * @returns the Vector4.
  70954. */
  70955. toArray(array: FloatArray, index?: number): Vector4;
  70956. /**
  70957. * Adds the given vector to the current Vector4.
  70958. * @param otherVector the vector to add
  70959. * @returns the updated Vector4.
  70960. */
  70961. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70962. /**
  70963. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70964. * @param otherVector the vector to add
  70965. * @returns the resulting vector
  70966. */
  70967. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70968. /**
  70969. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70970. * @param otherVector the vector to add
  70971. * @param result the vector to store the result
  70972. * @returns the current Vector4.
  70973. */
  70974. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70975. /**
  70976. * Subtract in place the given vector from the current Vector4.
  70977. * @param otherVector the vector to subtract
  70978. * @returns the updated Vector4.
  70979. */
  70980. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70981. /**
  70982. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70983. * @param otherVector the vector to add
  70984. * @returns the new vector with the result
  70985. */
  70986. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70987. /**
  70988. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70989. * @param otherVector the vector to subtract
  70990. * @param result the vector to store the result
  70991. * @returns the current Vector4.
  70992. */
  70993. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70994. /**
  70995. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70996. */
  70997. /**
  70998. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70999. * @param x value to subtract
  71000. * @param y value to subtract
  71001. * @param z value to subtract
  71002. * @param w value to subtract
  71003. * @returns new vector containing the result
  71004. */
  71005. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71006. /**
  71007. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71008. * @param x value to subtract
  71009. * @param y value to subtract
  71010. * @param z value to subtract
  71011. * @param w value to subtract
  71012. * @param result the vector to store the result in
  71013. * @returns the current Vector4.
  71014. */
  71015. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71016. /**
  71017. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71018. * @returns a new vector with the negated values
  71019. */
  71020. negate(): Vector4;
  71021. /**
  71022. * Multiplies the current Vector4 coordinates by scale (float).
  71023. * @param scale the number to scale with
  71024. * @returns the updated Vector4.
  71025. */
  71026. scaleInPlace(scale: number): Vector4;
  71027. /**
  71028. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71029. * @param scale the number to scale with
  71030. * @returns a new vector with the result
  71031. */
  71032. scale(scale: number): Vector4;
  71033. /**
  71034. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71035. * @param scale the number to scale with
  71036. * @param result a vector to store the result in
  71037. * @returns the current Vector4.
  71038. */
  71039. scaleToRef(scale: number, result: Vector4): Vector4;
  71040. /**
  71041. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71042. * @param scale defines the scale factor
  71043. * @param result defines the Vector4 object where to store the result
  71044. * @returns the unmodified current Vector4
  71045. */
  71046. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71047. /**
  71048. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71049. * @param otherVector the vector to compare against
  71050. * @returns true if they are equal
  71051. */
  71052. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71053. /**
  71054. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71055. * @param otherVector vector to compare against
  71056. * @param epsilon (Default: very small number)
  71057. * @returns true if they are equal
  71058. */
  71059. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71060. /**
  71061. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71062. * @param x x value to compare against
  71063. * @param y y value to compare against
  71064. * @param z z value to compare against
  71065. * @param w w value to compare against
  71066. * @returns true if equal
  71067. */
  71068. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71069. /**
  71070. * Multiplies in place the current Vector4 by the given one.
  71071. * @param otherVector vector to multiple with
  71072. * @returns the updated Vector4.
  71073. */
  71074. multiplyInPlace(otherVector: Vector4): Vector4;
  71075. /**
  71076. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71077. * @param otherVector vector to multiple with
  71078. * @returns resulting new vector
  71079. */
  71080. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71081. /**
  71082. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71083. * @param otherVector vector to multiple with
  71084. * @param result vector to store the result
  71085. * @returns the current Vector4.
  71086. */
  71087. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71088. /**
  71089. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71090. * @param x x value multiply with
  71091. * @param y y value multiply with
  71092. * @param z z value multiply with
  71093. * @param w w value multiply with
  71094. * @returns resulting new vector
  71095. */
  71096. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71097. /**
  71098. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71099. * @param otherVector vector to devide with
  71100. * @returns resulting new vector
  71101. */
  71102. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71103. /**
  71104. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71105. * @param otherVector vector to devide with
  71106. * @param result vector to store the result
  71107. * @returns the current Vector4.
  71108. */
  71109. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71110. /**
  71111. * Divides the current Vector3 coordinates by the given ones.
  71112. * @param otherVector vector to devide with
  71113. * @returns the updated Vector3.
  71114. */
  71115. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71116. /**
  71117. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71118. * @param other defines the second operand
  71119. * @returns the current updated Vector4
  71120. */
  71121. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71122. /**
  71123. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71124. * @param other defines the second operand
  71125. * @returns the current updated Vector4
  71126. */
  71127. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71128. /**
  71129. * Gets a new Vector4 from current Vector4 floored values
  71130. * @returns a new Vector4
  71131. */
  71132. floor(): Vector4;
  71133. /**
  71134. * Gets a new Vector4 from current Vector3 floored values
  71135. * @returns a new Vector4
  71136. */
  71137. fract(): Vector4;
  71138. /**
  71139. * Returns the Vector4 length (float).
  71140. * @returns the length
  71141. */
  71142. length(): number;
  71143. /**
  71144. * Returns the Vector4 squared length (float).
  71145. * @returns the length squared
  71146. */
  71147. lengthSquared(): number;
  71148. /**
  71149. * Normalizes in place the Vector4.
  71150. * @returns the updated Vector4.
  71151. */
  71152. normalize(): Vector4;
  71153. /**
  71154. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71155. * @returns this converted to a new vector3
  71156. */
  71157. toVector3(): Vector3;
  71158. /**
  71159. * Returns a new Vector4 copied from the current one.
  71160. * @returns the new cloned vector
  71161. */
  71162. clone(): Vector4;
  71163. /**
  71164. * Updates the current Vector4 with the given one coordinates.
  71165. * @param source the source vector to copy from
  71166. * @returns the updated Vector4.
  71167. */
  71168. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71169. /**
  71170. * Updates the current Vector4 coordinates with the given floats.
  71171. * @param x float to copy from
  71172. * @param y float to copy from
  71173. * @param z float to copy from
  71174. * @param w float to copy from
  71175. * @returns the updated Vector4.
  71176. */
  71177. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71178. /**
  71179. * Updates the current Vector4 coordinates with the given floats.
  71180. * @param x float to set from
  71181. * @param y float to set from
  71182. * @param z float to set from
  71183. * @param w float to set from
  71184. * @returns the updated Vector4.
  71185. */
  71186. set(x: number, y: number, z: number, w: number): Vector4;
  71187. /**
  71188. * Copies the given float to the current Vector3 coordinates
  71189. * @param v defines the x, y, z and w coordinates of the operand
  71190. * @returns the current updated Vector3
  71191. */
  71192. setAll(v: number): Vector4;
  71193. /**
  71194. * Returns a new Vector4 set from the starting index of the given array.
  71195. * @param array the array to pull values from
  71196. * @param offset the offset into the array to start at
  71197. * @returns the new vector
  71198. */
  71199. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71200. /**
  71201. * Updates the given vector "result" from the starting index of the given array.
  71202. * @param array the array to pull values from
  71203. * @param offset the offset into the array to start at
  71204. * @param result the vector to store the result in
  71205. */
  71206. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71207. /**
  71208. * Updates the given vector "result" from the starting index of the given Float32Array.
  71209. * @param array the array to pull values from
  71210. * @param offset the offset into the array to start at
  71211. * @param result the vector to store the result in
  71212. */
  71213. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71214. /**
  71215. * Updates the given vector "result" coordinates from the given floats.
  71216. * @param x float to set from
  71217. * @param y float to set from
  71218. * @param z float to set from
  71219. * @param w float to set from
  71220. * @param result the vector to the floats in
  71221. */
  71222. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71223. /**
  71224. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71225. * @returns the new vector
  71226. */
  71227. static Zero(): Vector4;
  71228. /**
  71229. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71230. * @returns the new vector
  71231. */
  71232. static One(): Vector4;
  71233. /**
  71234. * Returns a new normalized Vector4 from the given one.
  71235. * @param vector the vector to normalize
  71236. * @returns the vector
  71237. */
  71238. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71239. /**
  71240. * Updates the given vector "result" from the normalization of the given one.
  71241. * @param vector the vector to normalize
  71242. * @param result the vector to store the result in
  71243. */
  71244. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71245. /**
  71246. * Returns a vector with the minimum values from the left and right vectors
  71247. * @param left left vector to minimize
  71248. * @param right right vector to minimize
  71249. * @returns a new vector with the minimum of the left and right vector values
  71250. */
  71251. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71252. /**
  71253. * Returns a vector with the maximum values from the left and right vectors
  71254. * @param left left vector to maximize
  71255. * @param right right vector to maximize
  71256. * @returns a new vector with the maximum of the left and right vector values
  71257. */
  71258. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71259. /**
  71260. * Returns the distance (float) between the vectors "value1" and "value2".
  71261. * @param value1 value to calulate the distance between
  71262. * @param value2 value to calulate the distance between
  71263. * @return the distance between the two vectors
  71264. */
  71265. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71266. /**
  71267. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71268. * @param value1 value to calulate the distance between
  71269. * @param value2 value to calulate the distance between
  71270. * @return the distance between the two vectors squared
  71271. */
  71272. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71273. /**
  71274. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71275. * @param value1 value to calulate the center between
  71276. * @param value2 value to calulate the center between
  71277. * @return the center between the two vectors
  71278. */
  71279. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71280. /**
  71281. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71282. * This methods computes transformed normalized direction vectors only.
  71283. * @param vector the vector to transform
  71284. * @param transformation the transformation matrix to apply
  71285. * @returns the new vector
  71286. */
  71287. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71288. /**
  71289. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71290. * This methods computes transformed normalized direction vectors only.
  71291. * @param vector the vector to transform
  71292. * @param transformation the transformation matrix to apply
  71293. * @param result the vector to store the result in
  71294. */
  71295. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71296. /**
  71297. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71298. * This methods computes transformed normalized direction vectors only.
  71299. * @param x value to transform
  71300. * @param y value to transform
  71301. * @param z value to transform
  71302. * @param w value to transform
  71303. * @param transformation the transformation matrix to apply
  71304. * @param result the vector to store the results in
  71305. */
  71306. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71307. /**
  71308. * Creates a new Vector4 from a Vector3
  71309. * @param source defines the source data
  71310. * @param w defines the 4th component (default is 0)
  71311. * @returns a new Vector4
  71312. */
  71313. static FromVector3(source: Vector3, w?: number): Vector4;
  71314. }
  71315. /**
  71316. * Class used to store quaternion data
  71317. * @see https://en.wikipedia.org/wiki/Quaternion
  71318. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71319. */
  71320. export class Quaternion {
  71321. /** defines the first component (0 by default) */
  71322. x: number;
  71323. /** defines the second component (0 by default) */
  71324. y: number;
  71325. /** defines the third component (0 by default) */
  71326. z: number;
  71327. /** defines the fourth component (1.0 by default) */
  71328. w: number;
  71329. /**
  71330. * Creates a new Quaternion from the given floats
  71331. * @param x defines the first component (0 by default)
  71332. * @param y defines the second component (0 by default)
  71333. * @param z defines the third component (0 by default)
  71334. * @param w defines the fourth component (1.0 by default)
  71335. */
  71336. constructor(
  71337. /** defines the first component (0 by default) */
  71338. x?: number,
  71339. /** defines the second component (0 by default) */
  71340. y?: number,
  71341. /** defines the third component (0 by default) */
  71342. z?: number,
  71343. /** defines the fourth component (1.0 by default) */
  71344. w?: number);
  71345. /**
  71346. * Gets a string representation for the current quaternion
  71347. * @returns a string with the Quaternion coordinates
  71348. */
  71349. toString(): string;
  71350. /**
  71351. * Gets the class name of the quaternion
  71352. * @returns the string "Quaternion"
  71353. */
  71354. getClassName(): string;
  71355. /**
  71356. * Gets a hash code for this quaternion
  71357. * @returns the quaternion hash code
  71358. */
  71359. getHashCode(): number;
  71360. /**
  71361. * Copy the quaternion to an array
  71362. * @returns a new array populated with 4 elements from the quaternion coordinates
  71363. */
  71364. asArray(): number[];
  71365. /**
  71366. * Check if two quaternions are equals
  71367. * @param otherQuaternion defines the second operand
  71368. * @return true if the current quaternion and the given one coordinates are strictly equals
  71369. */
  71370. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71371. /**
  71372. * Clone the current quaternion
  71373. * @returns a new quaternion copied from the current one
  71374. */
  71375. clone(): Quaternion;
  71376. /**
  71377. * Copy a quaternion to the current one
  71378. * @param other defines the other quaternion
  71379. * @returns the updated current quaternion
  71380. */
  71381. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71382. /**
  71383. * Updates the current quaternion with the given float coordinates
  71384. * @param x defines the x coordinate
  71385. * @param y defines the y coordinate
  71386. * @param z defines the z coordinate
  71387. * @param w defines the w coordinate
  71388. * @returns the updated current quaternion
  71389. */
  71390. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71391. /**
  71392. * Updates the current quaternion from the given float coordinates
  71393. * @param x defines the x coordinate
  71394. * @param y defines the y coordinate
  71395. * @param z defines the z coordinate
  71396. * @param w defines the w coordinate
  71397. * @returns the updated current quaternion
  71398. */
  71399. set(x: number, y: number, z: number, w: number): Quaternion;
  71400. /**
  71401. * Adds two quaternions
  71402. * @param other defines the second operand
  71403. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71404. */
  71405. add(other: DeepImmutable<Quaternion>): Quaternion;
  71406. /**
  71407. * Add a quaternion to the current one
  71408. * @param other defines the quaternion to add
  71409. * @returns the current quaternion
  71410. */
  71411. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71412. /**
  71413. * Subtract two quaternions
  71414. * @param other defines the second operand
  71415. * @returns a new quaternion as the subtraction result of the given one from the current one
  71416. */
  71417. subtract(other: Quaternion): Quaternion;
  71418. /**
  71419. * Multiplies the current quaternion by a scale factor
  71420. * @param value defines the scale factor
  71421. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71422. */
  71423. scale(value: number): Quaternion;
  71424. /**
  71425. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71426. * @param scale defines the scale factor
  71427. * @param result defines the Quaternion object where to store the result
  71428. * @returns the unmodified current quaternion
  71429. */
  71430. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71431. /**
  71432. * Multiplies in place the current quaternion by a scale factor
  71433. * @param value defines the scale factor
  71434. * @returns the current modified quaternion
  71435. */
  71436. scaleInPlace(value: number): Quaternion;
  71437. /**
  71438. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71439. * @param scale defines the scale factor
  71440. * @param result defines the Quaternion object where to store the result
  71441. * @returns the unmodified current quaternion
  71442. */
  71443. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71444. /**
  71445. * Multiplies two quaternions
  71446. * @param q1 defines the second operand
  71447. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71448. */
  71449. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71450. /**
  71451. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71452. * @param q1 defines the second operand
  71453. * @param result defines the target quaternion
  71454. * @returns the current quaternion
  71455. */
  71456. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71457. /**
  71458. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71459. * @param q1 defines the second operand
  71460. * @returns the currentupdated quaternion
  71461. */
  71462. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71463. /**
  71464. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71465. * @param ref defines the target quaternion
  71466. * @returns the current quaternion
  71467. */
  71468. conjugateToRef(ref: Quaternion): Quaternion;
  71469. /**
  71470. * Conjugates in place (1-q) the current quaternion
  71471. * @returns the current updated quaternion
  71472. */
  71473. conjugateInPlace(): Quaternion;
  71474. /**
  71475. * Conjugates in place (1-q) the current quaternion
  71476. * @returns a new quaternion
  71477. */
  71478. conjugate(): Quaternion;
  71479. /**
  71480. * Gets length of current quaternion
  71481. * @returns the quaternion length (float)
  71482. */
  71483. length(): number;
  71484. /**
  71485. * Normalize in place the current quaternion
  71486. * @returns the current updated quaternion
  71487. */
  71488. normalize(): Quaternion;
  71489. /**
  71490. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71491. * @param order is a reserved parameter and is ignore for now
  71492. * @returns a new Vector3 containing the Euler angles
  71493. */
  71494. toEulerAngles(order?: string): Vector3;
  71495. /**
  71496. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71497. * @param result defines the vector which will be filled with the Euler angles
  71498. * @param order is a reserved parameter and is ignore for now
  71499. * @returns the current unchanged quaternion
  71500. */
  71501. toEulerAnglesToRef(result: Vector3): Quaternion;
  71502. /**
  71503. * Updates the given rotation matrix with the current quaternion values
  71504. * @param result defines the target matrix
  71505. * @returns the current unchanged quaternion
  71506. */
  71507. toRotationMatrix(result: Matrix): Quaternion;
  71508. /**
  71509. * Updates the current quaternion from the given rotation matrix values
  71510. * @param matrix defines the source matrix
  71511. * @returns the current updated quaternion
  71512. */
  71513. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71514. /**
  71515. * Creates a new quaternion from a rotation matrix
  71516. * @param matrix defines the source matrix
  71517. * @returns a new quaternion created from the given rotation matrix values
  71518. */
  71519. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71520. /**
  71521. * Updates the given quaternion with the given rotation matrix values
  71522. * @param matrix defines the source matrix
  71523. * @param result defines the target quaternion
  71524. */
  71525. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71526. /**
  71527. * Returns the dot product (float) between the quaternions "left" and "right"
  71528. * @param left defines the left operand
  71529. * @param right defines the right operand
  71530. * @returns the dot product
  71531. */
  71532. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71533. /**
  71534. * Checks if the two quaternions are close to each other
  71535. * @param quat0 defines the first quaternion to check
  71536. * @param quat1 defines the second quaternion to check
  71537. * @returns true if the two quaternions are close to each other
  71538. */
  71539. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71540. /**
  71541. * Creates an empty quaternion
  71542. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71543. */
  71544. static Zero(): Quaternion;
  71545. /**
  71546. * Inverse a given quaternion
  71547. * @param q defines the source quaternion
  71548. * @returns a new quaternion as the inverted current quaternion
  71549. */
  71550. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71551. /**
  71552. * Inverse a given quaternion
  71553. * @param q defines the source quaternion
  71554. * @param result the quaternion the result will be stored in
  71555. * @returns the result quaternion
  71556. */
  71557. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71558. /**
  71559. * Creates an identity quaternion
  71560. * @returns the identity quaternion
  71561. */
  71562. static Identity(): Quaternion;
  71563. /**
  71564. * Gets a boolean indicating if the given quaternion is identity
  71565. * @param quaternion defines the quaternion to check
  71566. * @returns true if the quaternion is identity
  71567. */
  71568. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71569. /**
  71570. * Creates a quaternion from a rotation around an axis
  71571. * @param axis defines the axis to use
  71572. * @param angle defines the angle to use
  71573. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71574. */
  71575. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71576. /**
  71577. * Creates a rotation around an axis and stores it into the given quaternion
  71578. * @param axis defines the axis to use
  71579. * @param angle defines the angle to use
  71580. * @param result defines the target quaternion
  71581. * @returns the target quaternion
  71582. */
  71583. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71584. /**
  71585. * Creates a new quaternion from data stored into an array
  71586. * @param array defines the data source
  71587. * @param offset defines the offset in the source array where the data starts
  71588. * @returns a new quaternion
  71589. */
  71590. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71591. /**
  71592. * Create a quaternion from Euler rotation angles
  71593. * @param x Pitch
  71594. * @param y Yaw
  71595. * @param z Roll
  71596. * @returns the new Quaternion
  71597. */
  71598. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71599. /**
  71600. * Updates a quaternion from Euler rotation angles
  71601. * @param x Pitch
  71602. * @param y Yaw
  71603. * @param z Roll
  71604. * @param result the quaternion to store the result
  71605. * @returns the updated quaternion
  71606. */
  71607. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71608. /**
  71609. * Create a quaternion from Euler rotation vector
  71610. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71611. * @returns the new Quaternion
  71612. */
  71613. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71614. /**
  71615. * Updates a quaternion from Euler rotation vector
  71616. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71617. * @param result the quaternion to store the result
  71618. * @returns the updated quaternion
  71619. */
  71620. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71621. /**
  71622. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71623. * @param yaw defines the rotation around Y axis
  71624. * @param pitch defines the rotation around X axis
  71625. * @param roll defines the rotation around Z axis
  71626. * @returns the new quaternion
  71627. */
  71628. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71629. /**
  71630. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71631. * @param yaw defines the rotation around Y axis
  71632. * @param pitch defines the rotation around X axis
  71633. * @param roll defines the rotation around Z axis
  71634. * @param result defines the target quaternion
  71635. */
  71636. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71637. /**
  71638. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71639. * @param alpha defines the rotation around first axis
  71640. * @param beta defines the rotation around second axis
  71641. * @param gamma defines the rotation around third axis
  71642. * @returns the new quaternion
  71643. */
  71644. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71645. /**
  71646. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71647. * @param alpha defines the rotation around first axis
  71648. * @param beta defines the rotation around second axis
  71649. * @param gamma defines the rotation around third axis
  71650. * @param result defines the target quaternion
  71651. */
  71652. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71653. /**
  71654. * 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)
  71655. * @param axis1 defines the first axis
  71656. * @param axis2 defines the second axis
  71657. * @param axis3 defines the third axis
  71658. * @returns the new quaternion
  71659. */
  71660. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71661. /**
  71662. * 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
  71663. * @param axis1 defines the first axis
  71664. * @param axis2 defines the second axis
  71665. * @param axis3 defines the third axis
  71666. * @param ref defines the target quaternion
  71667. */
  71668. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71669. /**
  71670. * Interpolates between two quaternions
  71671. * @param left defines first quaternion
  71672. * @param right defines second quaternion
  71673. * @param amount defines the gradient to use
  71674. * @returns the new interpolated quaternion
  71675. */
  71676. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71677. /**
  71678. * Interpolates between two quaternions and stores it into a target quaternion
  71679. * @param left defines first quaternion
  71680. * @param right defines second quaternion
  71681. * @param amount defines the gradient to use
  71682. * @param result defines the target quaternion
  71683. */
  71684. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71685. /**
  71686. * Interpolate between two quaternions using Hermite interpolation
  71687. * @param value1 defines first quaternion
  71688. * @param tangent1 defines the incoming tangent
  71689. * @param value2 defines second quaternion
  71690. * @param tangent2 defines the outgoing tangent
  71691. * @param amount defines the target quaternion
  71692. * @returns the new interpolated quaternion
  71693. */
  71694. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71695. }
  71696. /**
  71697. * Class used to store matrix data (4x4)
  71698. */
  71699. export class Matrix {
  71700. private static _updateFlagSeed;
  71701. private static _identityReadOnly;
  71702. private _isIdentity;
  71703. private _isIdentityDirty;
  71704. private _isIdentity3x2;
  71705. private _isIdentity3x2Dirty;
  71706. /**
  71707. * Gets the update flag of the matrix which is an unique number for the matrix.
  71708. * It will be incremented every time the matrix data change.
  71709. * You can use it to speed the comparison between two versions of the same matrix.
  71710. */
  71711. updateFlag: number;
  71712. private readonly _m;
  71713. /**
  71714. * Gets the internal data of the matrix
  71715. */
  71716. readonly m: DeepImmutable<Float32Array>;
  71717. /** @hidden */
  71718. _markAsUpdated(): void;
  71719. /** @hidden */
  71720. private _updateIdentityStatus;
  71721. /**
  71722. * Creates an empty matrix (filled with zeros)
  71723. */
  71724. constructor();
  71725. /**
  71726. * Check if the current matrix is identity
  71727. * @returns true is the matrix is the identity matrix
  71728. */
  71729. isIdentity(): boolean;
  71730. /**
  71731. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71732. * @returns true is the matrix is the identity matrix
  71733. */
  71734. isIdentityAs3x2(): boolean;
  71735. /**
  71736. * Gets the determinant of the matrix
  71737. * @returns the matrix determinant
  71738. */
  71739. determinant(): number;
  71740. /**
  71741. * Returns the matrix as a Float32Array
  71742. * @returns the matrix underlying array
  71743. */
  71744. toArray(): DeepImmutable<Float32Array>;
  71745. /**
  71746. * Returns the matrix as a Float32Array
  71747. * @returns the matrix underlying array.
  71748. */
  71749. asArray(): DeepImmutable<Float32Array>;
  71750. /**
  71751. * Inverts the current matrix in place
  71752. * @returns the current inverted matrix
  71753. */
  71754. invert(): Matrix;
  71755. /**
  71756. * Sets all the matrix elements to zero
  71757. * @returns the current matrix
  71758. */
  71759. reset(): Matrix;
  71760. /**
  71761. * Adds the current matrix with a second one
  71762. * @param other defines the matrix to add
  71763. * @returns a new matrix as the addition of the current matrix and the given one
  71764. */
  71765. add(other: DeepImmutable<Matrix>): Matrix;
  71766. /**
  71767. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71768. * @param other defines the matrix to add
  71769. * @param result defines the target matrix
  71770. * @returns the current matrix
  71771. */
  71772. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71773. /**
  71774. * Adds in place the given matrix to the current matrix
  71775. * @param other defines the second operand
  71776. * @returns the current updated matrix
  71777. */
  71778. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71779. /**
  71780. * Sets the given matrix to the current inverted Matrix
  71781. * @param other defines the target matrix
  71782. * @returns the unmodified current matrix
  71783. */
  71784. invertToRef(other: Matrix): Matrix;
  71785. /**
  71786. * add a value at the specified position in the current Matrix
  71787. * @param index the index of the value within the matrix. between 0 and 15.
  71788. * @param value the value to be added
  71789. * @returns the current updated matrix
  71790. */
  71791. addAtIndex(index: number, value: number): Matrix;
  71792. /**
  71793. * mutiply the specified position in the current Matrix by a value
  71794. * @param index the index of the value within the matrix. between 0 and 15.
  71795. * @param value the value to be added
  71796. * @returns the current updated matrix
  71797. */
  71798. multiplyAtIndex(index: number, value: number): Matrix;
  71799. /**
  71800. * Inserts the translation vector (using 3 floats) in the current matrix
  71801. * @param x defines the 1st component of the translation
  71802. * @param y defines the 2nd component of the translation
  71803. * @param z defines the 3rd component of the translation
  71804. * @returns the current updated matrix
  71805. */
  71806. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71807. /**
  71808. * Adds the translation vector (using 3 floats) in the current matrix
  71809. * @param x defines the 1st component of the translation
  71810. * @param y defines the 2nd component of the translation
  71811. * @param z defines the 3rd component of the translation
  71812. * @returns the current updated matrix
  71813. */
  71814. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71815. /**
  71816. * Inserts the translation vector in the current matrix
  71817. * @param vector3 defines the translation to insert
  71818. * @returns the current updated matrix
  71819. */
  71820. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71821. /**
  71822. * Gets the translation value of the current matrix
  71823. * @returns a new Vector3 as the extracted translation from the matrix
  71824. */
  71825. getTranslation(): Vector3;
  71826. /**
  71827. * Fill a Vector3 with the extracted translation from the matrix
  71828. * @param result defines the Vector3 where to store the translation
  71829. * @returns the current matrix
  71830. */
  71831. getTranslationToRef(result: Vector3): Matrix;
  71832. /**
  71833. * Remove rotation and scaling part from the matrix
  71834. * @returns the updated matrix
  71835. */
  71836. removeRotationAndScaling(): Matrix;
  71837. /**
  71838. * Multiply two matrices
  71839. * @param other defines the second operand
  71840. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71841. */
  71842. multiply(other: DeepImmutable<Matrix>): Matrix;
  71843. /**
  71844. * Copy the current matrix from the given one
  71845. * @param other defines the source matrix
  71846. * @returns the current updated matrix
  71847. */
  71848. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71849. /**
  71850. * Populates the given array from the starting index with the current matrix values
  71851. * @param array defines the target array
  71852. * @param offset defines the offset in the target array where to start storing values
  71853. * @returns the current matrix
  71854. */
  71855. copyToArray(array: Float32Array, offset?: number): Matrix;
  71856. /**
  71857. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71858. * @param other defines the second operand
  71859. * @param result defines the matrix where to store the multiplication
  71860. * @returns the current matrix
  71861. */
  71862. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71863. /**
  71864. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71865. * @param other defines the second operand
  71866. * @param result defines the array where to store the multiplication
  71867. * @param offset defines the offset in the target array where to start storing values
  71868. * @returns the current matrix
  71869. */
  71870. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71871. /**
  71872. * Check equality between this matrix and a second one
  71873. * @param value defines the second matrix to compare
  71874. * @returns true is the current matrix and the given one values are strictly equal
  71875. */
  71876. equals(value: DeepImmutable<Matrix>): boolean;
  71877. /**
  71878. * Clone the current matrix
  71879. * @returns a new matrix from the current matrix
  71880. */
  71881. clone(): Matrix;
  71882. /**
  71883. * Returns the name of the current matrix class
  71884. * @returns the string "Matrix"
  71885. */
  71886. getClassName(): string;
  71887. /**
  71888. * Gets the hash code of the current matrix
  71889. * @returns the hash code
  71890. */
  71891. getHashCode(): number;
  71892. /**
  71893. * Decomposes the current Matrix into a translation, rotation and scaling components
  71894. * @param scale defines the scale vector3 given as a reference to update
  71895. * @param rotation defines the rotation quaternion given as a reference to update
  71896. * @param translation defines the translation vector3 given as a reference to update
  71897. * @returns true if operation was successful
  71898. */
  71899. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71900. /**
  71901. * Gets specific row of the matrix
  71902. * @param index defines the number of the row to get
  71903. * @returns the index-th row of the current matrix as a new Vector4
  71904. */
  71905. getRow(index: number): Nullable<Vector4>;
  71906. /**
  71907. * Sets the index-th row of the current matrix to the vector4 values
  71908. * @param index defines the number of the row to set
  71909. * @param row defines the target vector4
  71910. * @returns the updated current matrix
  71911. */
  71912. setRow(index: number, row: Vector4): Matrix;
  71913. /**
  71914. * Compute the transpose of the matrix
  71915. * @returns the new transposed matrix
  71916. */
  71917. transpose(): Matrix;
  71918. /**
  71919. * Compute the transpose of the matrix and store it in a given matrix
  71920. * @param result defines the target matrix
  71921. * @returns the current matrix
  71922. */
  71923. transposeToRef(result: Matrix): Matrix;
  71924. /**
  71925. * Sets the index-th row of the current matrix with the given 4 x float values
  71926. * @param index defines the row index
  71927. * @param x defines the x component to set
  71928. * @param y defines the y component to set
  71929. * @param z defines the z component to set
  71930. * @param w defines the w component to set
  71931. * @returns the updated current matrix
  71932. */
  71933. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71934. /**
  71935. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71936. * @param scale defines the scale factor
  71937. * @returns a new matrix
  71938. */
  71939. scale(scale: number): Matrix;
  71940. /**
  71941. * Scale the current matrix values by a factor to a given result matrix
  71942. * @param scale defines the scale factor
  71943. * @param result defines the matrix to store the result
  71944. * @returns the current matrix
  71945. */
  71946. scaleToRef(scale: number, result: Matrix): Matrix;
  71947. /**
  71948. * Scale the current matrix values by a factor and add the result to a given matrix
  71949. * @param scale defines the scale factor
  71950. * @param result defines the Matrix to store the result
  71951. * @returns the current matrix
  71952. */
  71953. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71954. /**
  71955. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71956. * @param ref matrix to store the result
  71957. */
  71958. toNormalMatrix(ref: Matrix): void;
  71959. /**
  71960. * Gets only rotation part of the current matrix
  71961. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71962. */
  71963. getRotationMatrix(): Matrix;
  71964. /**
  71965. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71966. * @param result defines the target matrix to store data to
  71967. * @returns the current matrix
  71968. */
  71969. getRotationMatrixToRef(result: Matrix): Matrix;
  71970. /**
  71971. * Toggles model matrix from being right handed to left handed in place and vice versa
  71972. */
  71973. toggleModelMatrixHandInPlace(): void;
  71974. /**
  71975. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71976. */
  71977. toggleProjectionMatrixHandInPlace(): void;
  71978. /**
  71979. * Creates a matrix from an array
  71980. * @param array defines the source array
  71981. * @param offset defines an offset in the source array
  71982. * @returns a new Matrix set from the starting index of the given array
  71983. */
  71984. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71985. /**
  71986. * Copy the content of an array into a given matrix
  71987. * @param array defines the source array
  71988. * @param offset defines an offset in the source array
  71989. * @param result defines the target matrix
  71990. */
  71991. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71992. /**
  71993. * Stores an array into a matrix after having multiplied each component by a given factor
  71994. * @param array defines the source array
  71995. * @param offset defines the offset in the source array
  71996. * @param scale defines the scaling factor
  71997. * @param result defines the target matrix
  71998. */
  71999. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72000. /**
  72001. * Gets an identity matrix that must not be updated
  72002. */
  72003. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72004. /**
  72005. * Stores a list of values (16) inside a given matrix
  72006. * @param initialM11 defines 1st value of 1st row
  72007. * @param initialM12 defines 2nd value of 1st row
  72008. * @param initialM13 defines 3rd value of 1st row
  72009. * @param initialM14 defines 4th value of 1st row
  72010. * @param initialM21 defines 1st value of 2nd row
  72011. * @param initialM22 defines 2nd value of 2nd row
  72012. * @param initialM23 defines 3rd value of 2nd row
  72013. * @param initialM24 defines 4th value of 2nd row
  72014. * @param initialM31 defines 1st value of 3rd row
  72015. * @param initialM32 defines 2nd value of 3rd row
  72016. * @param initialM33 defines 3rd value of 3rd row
  72017. * @param initialM34 defines 4th value of 3rd row
  72018. * @param initialM41 defines 1st value of 4th row
  72019. * @param initialM42 defines 2nd value of 4th row
  72020. * @param initialM43 defines 3rd value of 4th row
  72021. * @param initialM44 defines 4th value of 4th row
  72022. * @param result defines the target matrix
  72023. */
  72024. 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;
  72025. /**
  72026. * Creates new matrix from a list of values (16)
  72027. * @param initialM11 defines 1st value of 1st row
  72028. * @param initialM12 defines 2nd value of 1st row
  72029. * @param initialM13 defines 3rd value of 1st row
  72030. * @param initialM14 defines 4th value of 1st row
  72031. * @param initialM21 defines 1st value of 2nd row
  72032. * @param initialM22 defines 2nd value of 2nd row
  72033. * @param initialM23 defines 3rd value of 2nd row
  72034. * @param initialM24 defines 4th value of 2nd row
  72035. * @param initialM31 defines 1st value of 3rd row
  72036. * @param initialM32 defines 2nd value of 3rd row
  72037. * @param initialM33 defines 3rd value of 3rd row
  72038. * @param initialM34 defines 4th value of 3rd row
  72039. * @param initialM41 defines 1st value of 4th row
  72040. * @param initialM42 defines 2nd value of 4th row
  72041. * @param initialM43 defines 3rd value of 4th row
  72042. * @param initialM44 defines 4th value of 4th row
  72043. * @returns the new matrix
  72044. */
  72045. 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;
  72046. /**
  72047. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72048. * @param scale defines the scale vector3
  72049. * @param rotation defines the rotation quaternion
  72050. * @param translation defines the translation vector3
  72051. * @returns a new matrix
  72052. */
  72053. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72054. /**
  72055. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72056. * @param scale defines the scale vector3
  72057. * @param rotation defines the rotation quaternion
  72058. * @param translation defines the translation vector3
  72059. * @param result defines the target matrix
  72060. */
  72061. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72062. /**
  72063. * Creates a new identity matrix
  72064. * @returns a new identity matrix
  72065. */
  72066. static Identity(): Matrix;
  72067. /**
  72068. * Creates a new identity matrix and stores the result in a given matrix
  72069. * @param result defines the target matrix
  72070. */
  72071. static IdentityToRef(result: Matrix): void;
  72072. /**
  72073. * Creates a new zero matrix
  72074. * @returns a new zero matrix
  72075. */
  72076. static Zero(): Matrix;
  72077. /**
  72078. * Creates a new rotation matrix for "angle" radians around the X axis
  72079. * @param angle defines the angle (in radians) to use
  72080. * @return the new matrix
  72081. */
  72082. static RotationX(angle: number): Matrix;
  72083. /**
  72084. * Creates a new matrix as the invert of a given matrix
  72085. * @param source defines the source matrix
  72086. * @returns the new matrix
  72087. */
  72088. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72089. /**
  72090. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72091. * @param angle defines the angle (in radians) to use
  72092. * @param result defines the target matrix
  72093. */
  72094. static RotationXToRef(angle: number, result: Matrix): void;
  72095. /**
  72096. * Creates a new rotation matrix for "angle" radians around the Y axis
  72097. * @param angle defines the angle (in radians) to use
  72098. * @return the new matrix
  72099. */
  72100. static RotationY(angle: number): Matrix;
  72101. /**
  72102. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72103. * @param angle defines the angle (in radians) to use
  72104. * @param result defines the target matrix
  72105. */
  72106. static RotationYToRef(angle: number, result: Matrix): void;
  72107. /**
  72108. * Creates a new rotation matrix for "angle" radians around the Z axis
  72109. * @param angle defines the angle (in radians) to use
  72110. * @return the new matrix
  72111. */
  72112. static RotationZ(angle: number): Matrix;
  72113. /**
  72114. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72115. * @param angle defines the angle (in radians) to use
  72116. * @param result defines the target matrix
  72117. */
  72118. static RotationZToRef(angle: number, result: Matrix): void;
  72119. /**
  72120. * Creates a new rotation matrix for "angle" radians around the given axis
  72121. * @param axis defines the axis to use
  72122. * @param angle defines the angle (in radians) to use
  72123. * @return the new matrix
  72124. */
  72125. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72126. /**
  72127. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72128. * @param axis defines the axis to use
  72129. * @param angle defines the angle (in radians) to use
  72130. * @param result defines the target matrix
  72131. */
  72132. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72133. /**
  72134. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72135. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72136. * @param from defines the vector to align
  72137. * @param to defines the vector to align to
  72138. * @param result defines the target matrix
  72139. */
  72140. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72141. /**
  72142. * Creates a rotation matrix
  72143. * @param yaw defines the yaw angle in radians (Y axis)
  72144. * @param pitch defines the pitch angle in radians (X axis)
  72145. * @param roll defines the roll angle in radians (X axis)
  72146. * @returns the new rotation matrix
  72147. */
  72148. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72149. /**
  72150. * Creates a rotation matrix and stores it in a given matrix
  72151. * @param yaw defines the yaw angle in radians (Y axis)
  72152. * @param pitch defines the pitch angle in radians (X axis)
  72153. * @param roll defines the roll angle in radians (X axis)
  72154. * @param result defines the target matrix
  72155. */
  72156. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72157. /**
  72158. * Creates a scaling matrix
  72159. * @param x defines the scale factor on X axis
  72160. * @param y defines the scale factor on Y axis
  72161. * @param z defines the scale factor on Z axis
  72162. * @returns the new matrix
  72163. */
  72164. static Scaling(x: number, y: number, z: number): Matrix;
  72165. /**
  72166. * Creates a scaling matrix and stores it in a given matrix
  72167. * @param x defines the scale factor on X axis
  72168. * @param y defines the scale factor on Y axis
  72169. * @param z defines the scale factor on Z axis
  72170. * @param result defines the target matrix
  72171. */
  72172. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72173. /**
  72174. * Creates a translation matrix
  72175. * @param x defines the translation on X axis
  72176. * @param y defines the translation on Y axis
  72177. * @param z defines the translationon Z axis
  72178. * @returns the new matrix
  72179. */
  72180. static Translation(x: number, y: number, z: number): Matrix;
  72181. /**
  72182. * Creates a translation matrix and stores it in a given matrix
  72183. * @param x defines the translation on X axis
  72184. * @param y defines the translation on Y axis
  72185. * @param z defines the translationon Z axis
  72186. * @param result defines the target matrix
  72187. */
  72188. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72189. /**
  72190. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72191. * @param startValue defines the start value
  72192. * @param endValue defines the end value
  72193. * @param gradient defines the gradient factor
  72194. * @returns the new matrix
  72195. */
  72196. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72197. /**
  72198. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72199. * @param startValue defines the start value
  72200. * @param endValue defines the end value
  72201. * @param gradient defines the gradient factor
  72202. * @param result defines the Matrix object where to store data
  72203. */
  72204. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72205. /**
  72206. * Builds a new matrix whose values are computed by:
  72207. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72208. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72209. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72210. * @param startValue defines the first matrix
  72211. * @param endValue defines the second matrix
  72212. * @param gradient defines the gradient between the two matrices
  72213. * @returns the new matrix
  72214. */
  72215. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72216. /**
  72217. * Update a matrix to values which are computed by:
  72218. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72219. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72220. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72221. * @param startValue defines the first matrix
  72222. * @param endValue defines the second matrix
  72223. * @param gradient defines the gradient between the two matrices
  72224. * @param result defines the target matrix
  72225. */
  72226. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72227. /**
  72228. * 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"
  72229. * This function works in left handed mode
  72230. * @param eye defines the final position of the entity
  72231. * @param target defines where the entity should look at
  72232. * @param up defines the up vector for the entity
  72233. * @returns the new matrix
  72234. */
  72235. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72236. /**
  72237. * 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".
  72238. * This function works in left handed mode
  72239. * @param eye defines the final position of the entity
  72240. * @param target defines where the entity should look at
  72241. * @param up defines the up vector for the entity
  72242. * @param result defines the target matrix
  72243. */
  72244. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72245. /**
  72246. * 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"
  72247. * This function works in right handed mode
  72248. * @param eye defines the final position of the entity
  72249. * @param target defines where the entity should look at
  72250. * @param up defines the up vector for the entity
  72251. * @returns the new matrix
  72252. */
  72253. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72254. /**
  72255. * 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".
  72256. * This function works in right handed mode
  72257. * @param eye defines the final position of the entity
  72258. * @param target defines where the entity should look at
  72259. * @param up defines the up vector for the entity
  72260. * @param result defines the target matrix
  72261. */
  72262. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72263. /**
  72264. * Create a left-handed orthographic projection matrix
  72265. * @param width defines the viewport width
  72266. * @param height defines the viewport height
  72267. * @param znear defines the near clip plane
  72268. * @param zfar defines the far clip plane
  72269. * @returns a new matrix as a left-handed orthographic projection matrix
  72270. */
  72271. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72272. /**
  72273. * Store a left-handed orthographic projection to a given matrix
  72274. * @param width defines the viewport width
  72275. * @param height defines the viewport height
  72276. * @param znear defines the near clip plane
  72277. * @param zfar defines the far clip plane
  72278. * @param result defines the target matrix
  72279. */
  72280. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72281. /**
  72282. * Create a left-handed orthographic projection matrix
  72283. * @param left defines the viewport left coordinate
  72284. * @param right defines the viewport right coordinate
  72285. * @param bottom defines the viewport bottom coordinate
  72286. * @param top defines the viewport top coordinate
  72287. * @param znear defines the near clip plane
  72288. * @param zfar defines the far clip plane
  72289. * @returns a new matrix as a left-handed orthographic projection matrix
  72290. */
  72291. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72292. /**
  72293. * Stores a left-handed orthographic projection into a given matrix
  72294. * @param left defines the viewport left coordinate
  72295. * @param right defines the viewport right coordinate
  72296. * @param bottom defines the viewport bottom coordinate
  72297. * @param top defines the viewport top coordinate
  72298. * @param znear defines the near clip plane
  72299. * @param zfar defines the far clip plane
  72300. * @param result defines the target matrix
  72301. */
  72302. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72303. /**
  72304. * Creates a right-handed orthographic projection matrix
  72305. * @param left defines the viewport left coordinate
  72306. * @param right defines the viewport right coordinate
  72307. * @param bottom defines the viewport bottom coordinate
  72308. * @param top defines the viewport top coordinate
  72309. * @param znear defines the near clip plane
  72310. * @param zfar defines the far clip plane
  72311. * @returns a new matrix as a right-handed orthographic projection matrix
  72312. */
  72313. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72314. /**
  72315. * Stores a right-handed orthographic projection into a given matrix
  72316. * @param left defines the viewport left coordinate
  72317. * @param right defines the viewport right coordinate
  72318. * @param bottom defines the viewport bottom coordinate
  72319. * @param top defines the viewport top coordinate
  72320. * @param znear defines the near clip plane
  72321. * @param zfar defines the far clip plane
  72322. * @param result defines the target matrix
  72323. */
  72324. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72325. /**
  72326. * Creates a left-handed perspective projection matrix
  72327. * @param width defines the viewport width
  72328. * @param height defines the viewport height
  72329. * @param znear defines the near clip plane
  72330. * @param zfar defines the far clip plane
  72331. * @returns a new matrix as a left-handed perspective projection matrix
  72332. */
  72333. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72334. /**
  72335. * Creates a left-handed perspective projection matrix
  72336. * @param fov defines the horizontal field of view
  72337. * @param aspect defines the aspect ratio
  72338. * @param znear defines the near clip plane
  72339. * @param zfar defines the far clip plane
  72340. * @returns a new matrix as a left-handed perspective projection matrix
  72341. */
  72342. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72343. /**
  72344. * Stores a left-handed perspective projection into a given matrix
  72345. * @param fov defines the horizontal field of view
  72346. * @param aspect defines the aspect ratio
  72347. * @param znear defines the near clip plane
  72348. * @param zfar defines the far clip plane
  72349. * @param result defines the target matrix
  72350. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72351. */
  72352. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72353. /**
  72354. * Creates a right-handed perspective projection matrix
  72355. * @param fov defines the horizontal field of view
  72356. * @param aspect defines the aspect ratio
  72357. * @param znear defines the near clip plane
  72358. * @param zfar defines the far clip plane
  72359. * @returns a new matrix as a right-handed perspective projection matrix
  72360. */
  72361. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72362. /**
  72363. * Stores a right-handed perspective projection into a given matrix
  72364. * @param fov defines the horizontal field of view
  72365. * @param aspect defines the aspect ratio
  72366. * @param znear defines the near clip plane
  72367. * @param zfar defines the far clip plane
  72368. * @param result defines the target matrix
  72369. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72370. */
  72371. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72372. /**
  72373. * Stores a perspective projection for WebVR info a given matrix
  72374. * @param fov defines the field of view
  72375. * @param znear defines the near clip plane
  72376. * @param zfar defines the far clip plane
  72377. * @param result defines the target matrix
  72378. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72379. */
  72380. static PerspectiveFovWebVRToRef(fov: {
  72381. upDegrees: number;
  72382. downDegrees: number;
  72383. leftDegrees: number;
  72384. rightDegrees: number;
  72385. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72386. /**
  72387. * Computes a complete transformation matrix
  72388. * @param viewport defines the viewport to use
  72389. * @param world defines the world matrix
  72390. * @param view defines the view matrix
  72391. * @param projection defines the projection matrix
  72392. * @param zmin defines the near clip plane
  72393. * @param zmax defines the far clip plane
  72394. * @returns the transformation matrix
  72395. */
  72396. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72397. /**
  72398. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72399. * @param matrix defines the matrix to use
  72400. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72401. */
  72402. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72403. /**
  72404. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72405. * @param matrix defines the matrix to use
  72406. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72407. */
  72408. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72409. /**
  72410. * Compute the transpose of a given matrix
  72411. * @param matrix defines the matrix to transpose
  72412. * @returns the new matrix
  72413. */
  72414. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72415. /**
  72416. * Compute the transpose of a matrix and store it in a target matrix
  72417. * @param matrix defines the matrix to transpose
  72418. * @param result defines the target matrix
  72419. */
  72420. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72421. /**
  72422. * Computes a reflection matrix from a plane
  72423. * @param plane defines the reflection plane
  72424. * @returns a new matrix
  72425. */
  72426. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72427. /**
  72428. * Computes a reflection matrix from a plane
  72429. * @param plane defines the reflection plane
  72430. * @param result defines the target matrix
  72431. */
  72432. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72433. /**
  72434. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72435. * @param xaxis defines the value of the 1st axis
  72436. * @param yaxis defines the value of the 2nd axis
  72437. * @param zaxis defines the value of the 3rd axis
  72438. * @param result defines the target matrix
  72439. */
  72440. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72441. /**
  72442. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72443. * @param quat defines the quaternion to use
  72444. * @param result defines the target matrix
  72445. */
  72446. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72447. }
  72448. /**
  72449. * @hidden
  72450. */
  72451. export class TmpVectors {
  72452. static Vector2: Vector2[];
  72453. static Vector3: Vector3[];
  72454. static Vector4: Vector4[];
  72455. static Quaternion: Quaternion[];
  72456. static Matrix: Matrix[];
  72457. }
  72458. }
  72459. declare module BABYLON {
  72460. /**
  72461. * Defines potential orientation for back face culling
  72462. */
  72463. export enum Orientation {
  72464. /**
  72465. * Clockwise
  72466. */
  72467. CW = 0,
  72468. /** Counter clockwise */
  72469. CCW = 1
  72470. }
  72471. /** Class used to represent a Bezier curve */
  72472. export class BezierCurve {
  72473. /**
  72474. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72475. * @param t defines the time
  72476. * @param x1 defines the left coordinate on X axis
  72477. * @param y1 defines the left coordinate on Y axis
  72478. * @param x2 defines the right coordinate on X axis
  72479. * @param y2 defines the right coordinate on Y axis
  72480. * @returns the interpolated value
  72481. */
  72482. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72483. }
  72484. /**
  72485. * Defines angle representation
  72486. */
  72487. export class Angle {
  72488. private _radians;
  72489. /**
  72490. * Creates an Angle object of "radians" radians (float).
  72491. * @param radians the angle in radians
  72492. */
  72493. constructor(radians: number);
  72494. /**
  72495. * Get value in degrees
  72496. * @returns the Angle value in degrees (float)
  72497. */
  72498. degrees(): number;
  72499. /**
  72500. * Get value in radians
  72501. * @returns the Angle value in radians (float)
  72502. */
  72503. radians(): number;
  72504. /**
  72505. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72506. * @param a defines first vector
  72507. * @param b defines second vector
  72508. * @returns a new Angle
  72509. */
  72510. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72511. /**
  72512. * Gets a new Angle object from the given float in radians
  72513. * @param radians defines the angle value in radians
  72514. * @returns a new Angle
  72515. */
  72516. static FromRadians(radians: number): Angle;
  72517. /**
  72518. * Gets a new Angle object from the given float in degrees
  72519. * @param degrees defines the angle value in degrees
  72520. * @returns a new Angle
  72521. */
  72522. static FromDegrees(degrees: number): Angle;
  72523. }
  72524. /**
  72525. * This represents an arc in a 2d space.
  72526. */
  72527. export class Arc2 {
  72528. /** Defines the start point of the arc */
  72529. startPoint: Vector2;
  72530. /** Defines the mid point of the arc */
  72531. midPoint: Vector2;
  72532. /** Defines the end point of the arc */
  72533. endPoint: Vector2;
  72534. /**
  72535. * Defines the center point of the arc.
  72536. */
  72537. centerPoint: Vector2;
  72538. /**
  72539. * Defines the radius of the arc.
  72540. */
  72541. radius: number;
  72542. /**
  72543. * Defines the angle of the arc (from mid point to end point).
  72544. */
  72545. angle: Angle;
  72546. /**
  72547. * Defines the start angle of the arc (from start point to middle point).
  72548. */
  72549. startAngle: Angle;
  72550. /**
  72551. * Defines the orientation of the arc (clock wise/counter clock wise).
  72552. */
  72553. orientation: Orientation;
  72554. /**
  72555. * Creates an Arc object from the three given points : start, middle and end.
  72556. * @param startPoint Defines the start point of the arc
  72557. * @param midPoint Defines the midlle point of the arc
  72558. * @param endPoint Defines the end point of the arc
  72559. */
  72560. constructor(
  72561. /** Defines the start point of the arc */
  72562. startPoint: Vector2,
  72563. /** Defines the mid point of the arc */
  72564. midPoint: Vector2,
  72565. /** Defines the end point of the arc */
  72566. endPoint: Vector2);
  72567. }
  72568. /**
  72569. * Represents a 2D path made up of multiple 2D points
  72570. */
  72571. export class Path2 {
  72572. private _points;
  72573. private _length;
  72574. /**
  72575. * If the path start and end point are the same
  72576. */
  72577. closed: boolean;
  72578. /**
  72579. * Creates a Path2 object from the starting 2D coordinates x and y.
  72580. * @param x the starting points x value
  72581. * @param y the starting points y value
  72582. */
  72583. constructor(x: number, y: number);
  72584. /**
  72585. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72586. * @param x the added points x value
  72587. * @param y the added points y value
  72588. * @returns the updated Path2.
  72589. */
  72590. addLineTo(x: number, y: number): Path2;
  72591. /**
  72592. * 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.
  72593. * @param midX middle point x value
  72594. * @param midY middle point y value
  72595. * @param endX end point x value
  72596. * @param endY end point y value
  72597. * @param numberOfSegments (default: 36)
  72598. * @returns the updated Path2.
  72599. */
  72600. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72601. /**
  72602. * Closes the Path2.
  72603. * @returns the Path2.
  72604. */
  72605. close(): Path2;
  72606. /**
  72607. * Gets the sum of the distance between each sequential point in the path
  72608. * @returns the Path2 total length (float).
  72609. */
  72610. length(): number;
  72611. /**
  72612. * Gets the points which construct the path
  72613. * @returns the Path2 internal array of points.
  72614. */
  72615. getPoints(): Vector2[];
  72616. /**
  72617. * Retreives the point at the distance aways from the starting point
  72618. * @param normalizedLengthPosition the length along the path to retreive the point from
  72619. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72620. */
  72621. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72622. /**
  72623. * Creates a new path starting from an x and y position
  72624. * @param x starting x value
  72625. * @param y starting y value
  72626. * @returns a new Path2 starting at the coordinates (x, y).
  72627. */
  72628. static StartingAt(x: number, y: number): Path2;
  72629. }
  72630. /**
  72631. * Represents a 3D path made up of multiple 3D points
  72632. */
  72633. export class Path3D {
  72634. /**
  72635. * an array of Vector3, the curve axis of the Path3D
  72636. */
  72637. path: Vector3[];
  72638. private _curve;
  72639. private _distances;
  72640. private _tangents;
  72641. private _normals;
  72642. private _binormals;
  72643. private _raw;
  72644. /**
  72645. * new Path3D(path, normal, raw)
  72646. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72647. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72648. * @param path an array of Vector3, the curve axis of the Path3D
  72649. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72650. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72651. */
  72652. constructor(
  72653. /**
  72654. * an array of Vector3, the curve axis of the Path3D
  72655. */
  72656. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72657. /**
  72658. * Returns the Path3D array of successive Vector3 designing its curve.
  72659. * @returns the Path3D array of successive Vector3 designing its curve.
  72660. */
  72661. getCurve(): Vector3[];
  72662. /**
  72663. * Returns an array populated with tangent vectors on each Path3D curve point.
  72664. * @returns an array populated with tangent vectors on each Path3D curve point.
  72665. */
  72666. getTangents(): Vector3[];
  72667. /**
  72668. * Returns an array populated with normal vectors on each Path3D curve point.
  72669. * @returns an array populated with normal vectors on each Path3D curve point.
  72670. */
  72671. getNormals(): Vector3[];
  72672. /**
  72673. * Returns an array populated with binormal vectors on each Path3D curve point.
  72674. * @returns an array populated with binormal vectors on each Path3D curve point.
  72675. */
  72676. getBinormals(): Vector3[];
  72677. /**
  72678. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72679. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72680. */
  72681. getDistances(): number[];
  72682. /**
  72683. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72684. * @param path path which all values are copied into the curves points
  72685. * @param firstNormal which should be projected onto the curve
  72686. * @returns the same object updated.
  72687. */
  72688. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72689. private _compute;
  72690. private _getFirstNonNullVector;
  72691. private _getLastNonNullVector;
  72692. private _normalVector;
  72693. }
  72694. /**
  72695. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72696. * A Curve3 is designed from a series of successive Vector3.
  72697. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72698. */
  72699. export class Curve3 {
  72700. private _points;
  72701. private _length;
  72702. /**
  72703. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72704. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72705. * @param v1 (Vector3) the control point
  72706. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72707. * @param nbPoints (integer) the wanted number of points in the curve
  72708. * @returns the created Curve3
  72709. */
  72710. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72711. /**
  72712. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72713. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72714. * @param v1 (Vector3) the first control point
  72715. * @param v2 (Vector3) the second control point
  72716. * @param v3 (Vector3) the end point of the Cubic Bezier
  72717. * @param nbPoints (integer) the wanted number of points in the curve
  72718. * @returns the created Curve3
  72719. */
  72720. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72721. /**
  72722. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72723. * @param p1 (Vector3) the origin point of the Hermite Spline
  72724. * @param t1 (Vector3) the tangent vector at the origin point
  72725. * @param p2 (Vector3) the end point of the Hermite Spline
  72726. * @param t2 (Vector3) the tangent vector at the end point
  72727. * @param nbPoints (integer) the wanted number of points in the curve
  72728. * @returns the created Curve3
  72729. */
  72730. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72731. /**
  72732. * Returns a Curve3 object along a CatmullRom Spline curve :
  72733. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72734. * @param nbPoints (integer) the wanted number of points between each curve control points
  72735. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72736. * @returns the created Curve3
  72737. */
  72738. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72739. /**
  72740. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72741. * A Curve3 is designed from a series of successive Vector3.
  72742. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72743. * @param points points which make up the curve
  72744. */
  72745. constructor(points: Vector3[]);
  72746. /**
  72747. * @returns the Curve3 stored array of successive Vector3
  72748. */
  72749. getPoints(): Vector3[];
  72750. /**
  72751. * @returns the computed length (float) of the curve.
  72752. */
  72753. length(): number;
  72754. /**
  72755. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72756. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72757. * curveA and curveB keep unchanged.
  72758. * @param curve the curve to continue from this curve
  72759. * @returns the newly constructed curve
  72760. */
  72761. continue(curve: DeepImmutable<Curve3>): Curve3;
  72762. private _computeLength;
  72763. }
  72764. }
  72765. declare module BABYLON {
  72766. /**
  72767. * This represents the main contract an easing function should follow.
  72768. * Easing functions are used throughout the animation system.
  72769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72770. */
  72771. export interface IEasingFunction {
  72772. /**
  72773. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72774. * of the easing function.
  72775. * The link below provides some of the most common examples of easing functions.
  72776. * @see https://easings.net/
  72777. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72778. * @returns the corresponding value on the curve defined by the easing function
  72779. */
  72780. ease(gradient: number): number;
  72781. }
  72782. /**
  72783. * Base class used for every default easing function.
  72784. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72785. */
  72786. export class EasingFunction implements IEasingFunction {
  72787. /**
  72788. * Interpolation follows the mathematical formula associated with the easing function.
  72789. */
  72790. static readonly EASINGMODE_EASEIN: number;
  72791. /**
  72792. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72793. */
  72794. static readonly EASINGMODE_EASEOUT: number;
  72795. /**
  72796. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72797. */
  72798. static readonly EASINGMODE_EASEINOUT: number;
  72799. private _easingMode;
  72800. /**
  72801. * Sets the easing mode of the current function.
  72802. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72803. */
  72804. setEasingMode(easingMode: number): void;
  72805. /**
  72806. * Gets the current easing mode.
  72807. * @returns the easing mode
  72808. */
  72809. getEasingMode(): number;
  72810. /**
  72811. * @hidden
  72812. */
  72813. easeInCore(gradient: number): number;
  72814. /**
  72815. * Given an input gradient between 0 and 1, this returns the corresponding value
  72816. * of the easing function.
  72817. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72818. * @returns the corresponding value on the curve defined by the easing function
  72819. */
  72820. ease(gradient: number): number;
  72821. }
  72822. /**
  72823. * Easing function with a circle shape (see link below).
  72824. * @see https://easings.net/#easeInCirc
  72825. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72826. */
  72827. export class CircleEase extends EasingFunction implements IEasingFunction {
  72828. /** @hidden */
  72829. easeInCore(gradient: number): number;
  72830. }
  72831. /**
  72832. * Easing function with a ease back shape (see link below).
  72833. * @see https://easings.net/#easeInBack
  72834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72835. */
  72836. export class BackEase extends EasingFunction implements IEasingFunction {
  72837. /** Defines the amplitude of the function */
  72838. amplitude: number;
  72839. /**
  72840. * Instantiates a back ease easing
  72841. * @see https://easings.net/#easeInBack
  72842. * @param amplitude Defines the amplitude of the function
  72843. */
  72844. constructor(
  72845. /** Defines the amplitude of the function */
  72846. amplitude?: number);
  72847. /** @hidden */
  72848. easeInCore(gradient: number): number;
  72849. }
  72850. /**
  72851. * Easing function with a bouncing shape (see link below).
  72852. * @see https://easings.net/#easeInBounce
  72853. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72854. */
  72855. export class BounceEase extends EasingFunction implements IEasingFunction {
  72856. /** Defines the number of bounces */
  72857. bounces: number;
  72858. /** Defines the amplitude of the bounce */
  72859. bounciness: number;
  72860. /**
  72861. * Instantiates a bounce easing
  72862. * @see https://easings.net/#easeInBounce
  72863. * @param bounces Defines the number of bounces
  72864. * @param bounciness Defines the amplitude of the bounce
  72865. */
  72866. constructor(
  72867. /** Defines the number of bounces */
  72868. bounces?: number,
  72869. /** Defines the amplitude of the bounce */
  72870. bounciness?: number);
  72871. /** @hidden */
  72872. easeInCore(gradient: number): number;
  72873. }
  72874. /**
  72875. * Easing function with a power of 3 shape (see link below).
  72876. * @see https://easings.net/#easeInCubic
  72877. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72878. */
  72879. export class CubicEase extends EasingFunction implements IEasingFunction {
  72880. /** @hidden */
  72881. easeInCore(gradient: number): number;
  72882. }
  72883. /**
  72884. * Easing function with an elastic shape (see link below).
  72885. * @see https://easings.net/#easeInElastic
  72886. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72887. */
  72888. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72889. /** Defines the number of oscillations*/
  72890. oscillations: number;
  72891. /** Defines the amplitude of the oscillations*/
  72892. springiness: number;
  72893. /**
  72894. * Instantiates an elastic easing function
  72895. * @see https://easings.net/#easeInElastic
  72896. * @param oscillations Defines the number of oscillations
  72897. * @param springiness Defines the amplitude of the oscillations
  72898. */
  72899. constructor(
  72900. /** Defines the number of oscillations*/
  72901. oscillations?: number,
  72902. /** Defines the amplitude of the oscillations*/
  72903. springiness?: number);
  72904. /** @hidden */
  72905. easeInCore(gradient: number): number;
  72906. }
  72907. /**
  72908. * Easing function with an exponential shape (see link below).
  72909. * @see https://easings.net/#easeInExpo
  72910. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72911. */
  72912. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72913. /** Defines the exponent of the function */
  72914. exponent: number;
  72915. /**
  72916. * Instantiates an exponential easing function
  72917. * @see https://easings.net/#easeInExpo
  72918. * @param exponent Defines the exponent of the function
  72919. */
  72920. constructor(
  72921. /** Defines the exponent of the function */
  72922. exponent?: number);
  72923. /** @hidden */
  72924. easeInCore(gradient: number): number;
  72925. }
  72926. /**
  72927. * Easing function with a power shape (see link below).
  72928. * @see https://easings.net/#easeInQuad
  72929. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72930. */
  72931. export class PowerEase extends EasingFunction implements IEasingFunction {
  72932. /** Defines the power of the function */
  72933. power: number;
  72934. /**
  72935. * Instantiates an power base easing function
  72936. * @see https://easings.net/#easeInQuad
  72937. * @param power Defines the power of the function
  72938. */
  72939. constructor(
  72940. /** Defines the power of the function */
  72941. power?: number);
  72942. /** @hidden */
  72943. easeInCore(gradient: number): number;
  72944. }
  72945. /**
  72946. * Easing function with a power of 2 shape (see link below).
  72947. * @see https://easings.net/#easeInQuad
  72948. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72949. */
  72950. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72951. /** @hidden */
  72952. easeInCore(gradient: number): number;
  72953. }
  72954. /**
  72955. * Easing function with a power of 4 shape (see link below).
  72956. * @see https://easings.net/#easeInQuart
  72957. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72958. */
  72959. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72960. /** @hidden */
  72961. easeInCore(gradient: number): number;
  72962. }
  72963. /**
  72964. * Easing function with a power of 5 shape (see link below).
  72965. * @see https://easings.net/#easeInQuint
  72966. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72967. */
  72968. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72969. /** @hidden */
  72970. easeInCore(gradient: number): number;
  72971. }
  72972. /**
  72973. * Easing function with a sin shape (see link below).
  72974. * @see https://easings.net/#easeInSine
  72975. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72976. */
  72977. export class SineEase extends EasingFunction implements IEasingFunction {
  72978. /** @hidden */
  72979. easeInCore(gradient: number): number;
  72980. }
  72981. /**
  72982. * Easing function with a bezier shape (see link below).
  72983. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72985. */
  72986. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72987. /** Defines the x component of the start tangent in the bezier curve */
  72988. x1: number;
  72989. /** Defines the y component of the start tangent in the bezier curve */
  72990. y1: number;
  72991. /** Defines the x component of the end tangent in the bezier curve */
  72992. x2: number;
  72993. /** Defines the y component of the end tangent in the bezier curve */
  72994. y2: number;
  72995. /**
  72996. * Instantiates a bezier function
  72997. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72998. * @param x1 Defines the x component of the start tangent in the bezier curve
  72999. * @param y1 Defines the y component of the start tangent in the bezier curve
  73000. * @param x2 Defines the x component of the end tangent in the bezier curve
  73001. * @param y2 Defines the y component of the end tangent in the bezier curve
  73002. */
  73003. constructor(
  73004. /** Defines the x component of the start tangent in the bezier curve */
  73005. x1?: number,
  73006. /** Defines the y component of the start tangent in the bezier curve */
  73007. y1?: number,
  73008. /** Defines the x component of the end tangent in the bezier curve */
  73009. x2?: number,
  73010. /** Defines the y component of the end tangent in the bezier curve */
  73011. y2?: number);
  73012. /** @hidden */
  73013. easeInCore(gradient: number): number;
  73014. }
  73015. }
  73016. declare module BABYLON {
  73017. /**
  73018. * Class used to hold a RBG color
  73019. */
  73020. export class Color3 {
  73021. /**
  73022. * Defines the red component (between 0 and 1, default is 0)
  73023. */
  73024. r: number;
  73025. /**
  73026. * Defines the green component (between 0 and 1, default is 0)
  73027. */
  73028. g: number;
  73029. /**
  73030. * Defines the blue component (between 0 and 1, default is 0)
  73031. */
  73032. b: number;
  73033. /**
  73034. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73035. * @param r defines the red component (between 0 and 1, default is 0)
  73036. * @param g defines the green component (between 0 and 1, default is 0)
  73037. * @param b defines the blue component (between 0 and 1, default is 0)
  73038. */
  73039. constructor(
  73040. /**
  73041. * Defines the red component (between 0 and 1, default is 0)
  73042. */
  73043. r?: number,
  73044. /**
  73045. * Defines the green component (between 0 and 1, default is 0)
  73046. */
  73047. g?: number,
  73048. /**
  73049. * Defines the blue component (between 0 and 1, default is 0)
  73050. */
  73051. b?: number);
  73052. /**
  73053. * Creates a string with the Color3 current values
  73054. * @returns the string representation of the Color3 object
  73055. */
  73056. toString(): string;
  73057. /**
  73058. * Returns the string "Color3"
  73059. * @returns "Color3"
  73060. */
  73061. getClassName(): string;
  73062. /**
  73063. * Compute the Color3 hash code
  73064. * @returns an unique number that can be used to hash Color3 objects
  73065. */
  73066. getHashCode(): number;
  73067. /**
  73068. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73069. * @param array defines the array where to store the r,g,b components
  73070. * @param index defines an optional index in the target array to define where to start storing values
  73071. * @returns the current Color3 object
  73072. */
  73073. toArray(array: FloatArray, index?: number): Color3;
  73074. /**
  73075. * Returns a new Color4 object from the current Color3 and the given alpha
  73076. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73077. * @returns a new Color4 object
  73078. */
  73079. toColor4(alpha?: number): Color4;
  73080. /**
  73081. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73082. * @returns the new array
  73083. */
  73084. asArray(): number[];
  73085. /**
  73086. * Returns the luminance value
  73087. * @returns a float value
  73088. */
  73089. toLuminance(): number;
  73090. /**
  73091. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73092. * @param otherColor defines the second operand
  73093. * @returns the new Color3 object
  73094. */
  73095. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73096. /**
  73097. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73098. * @param otherColor defines the second operand
  73099. * @param result defines the Color3 object where to store the result
  73100. * @returns the current Color3
  73101. */
  73102. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73103. /**
  73104. * Determines equality between Color3 objects
  73105. * @param otherColor defines the second operand
  73106. * @returns true if the rgb values are equal to the given ones
  73107. */
  73108. equals(otherColor: DeepImmutable<Color3>): boolean;
  73109. /**
  73110. * Determines equality between the current Color3 object and a set of r,b,g values
  73111. * @param r defines the red component to check
  73112. * @param g defines the green component to check
  73113. * @param b defines the blue component to check
  73114. * @returns true if the rgb values are equal to the given ones
  73115. */
  73116. equalsFloats(r: number, g: number, b: number): boolean;
  73117. /**
  73118. * Multiplies in place each rgb value by scale
  73119. * @param scale defines the scaling factor
  73120. * @returns the updated Color3
  73121. */
  73122. scale(scale: number): Color3;
  73123. /**
  73124. * Multiplies the rgb values by scale and stores the result into "result"
  73125. * @param scale defines the scaling factor
  73126. * @param result defines the Color3 object where to store the result
  73127. * @returns the unmodified current Color3
  73128. */
  73129. scaleToRef(scale: number, result: Color3): Color3;
  73130. /**
  73131. * Scale the current Color3 values by a factor and add the result to a given Color3
  73132. * @param scale defines the scale factor
  73133. * @param result defines color to store the result into
  73134. * @returns the unmodified current Color3
  73135. */
  73136. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73137. /**
  73138. * Clamps the rgb values by the min and max values and stores the result into "result"
  73139. * @param min defines minimum clamping value (default is 0)
  73140. * @param max defines maximum clamping value (default is 1)
  73141. * @param result defines color to store the result into
  73142. * @returns the original Color3
  73143. */
  73144. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73145. /**
  73146. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73147. * @param otherColor defines the second operand
  73148. * @returns the new Color3
  73149. */
  73150. add(otherColor: DeepImmutable<Color3>): Color3;
  73151. /**
  73152. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73153. * @param otherColor defines the second operand
  73154. * @param result defines Color3 object to store the result into
  73155. * @returns the unmodified current Color3
  73156. */
  73157. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73158. /**
  73159. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73160. * @param otherColor defines the second operand
  73161. * @returns the new Color3
  73162. */
  73163. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73164. /**
  73165. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73166. * @param otherColor defines the second operand
  73167. * @param result defines Color3 object to store the result into
  73168. * @returns the unmodified current Color3
  73169. */
  73170. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73171. /**
  73172. * Copy the current object
  73173. * @returns a new Color3 copied the current one
  73174. */
  73175. clone(): Color3;
  73176. /**
  73177. * Copies the rgb values from the source in the current Color3
  73178. * @param source defines the source Color3 object
  73179. * @returns the updated Color3 object
  73180. */
  73181. copyFrom(source: DeepImmutable<Color3>): Color3;
  73182. /**
  73183. * Updates the Color3 rgb values from the given floats
  73184. * @param r defines the red component to read from
  73185. * @param g defines the green component to read from
  73186. * @param b defines the blue component to read from
  73187. * @returns the current Color3 object
  73188. */
  73189. copyFromFloats(r: number, g: number, b: number): Color3;
  73190. /**
  73191. * Updates the Color3 rgb values from the given floats
  73192. * @param r defines the red component to read from
  73193. * @param g defines the green component to read from
  73194. * @param b defines the blue component to read from
  73195. * @returns the current Color3 object
  73196. */
  73197. set(r: number, g: number, b: number): Color3;
  73198. /**
  73199. * Compute the Color3 hexadecimal code as a string
  73200. * @returns a string containing the hexadecimal representation of the Color3 object
  73201. */
  73202. toHexString(): string;
  73203. /**
  73204. * Computes a new Color3 converted from the current one to linear space
  73205. * @returns a new Color3 object
  73206. */
  73207. toLinearSpace(): Color3;
  73208. /**
  73209. * Converts current color in rgb space to HSV values
  73210. * @returns a new color3 representing the HSV values
  73211. */
  73212. toHSV(): Color3;
  73213. /**
  73214. * Converts current color in rgb space to HSV values
  73215. * @param result defines the Color3 where to store the HSV values
  73216. */
  73217. toHSVToRef(result: Color3): void;
  73218. /**
  73219. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73220. * @param convertedColor defines the Color3 object where to store the linear space version
  73221. * @returns the unmodified Color3
  73222. */
  73223. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73224. /**
  73225. * Computes a new Color3 converted from the current one to gamma space
  73226. * @returns a new Color3 object
  73227. */
  73228. toGammaSpace(): Color3;
  73229. /**
  73230. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73231. * @param convertedColor defines the Color3 object where to store the gamma space version
  73232. * @returns the unmodified Color3
  73233. */
  73234. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73235. private static _BlackReadOnly;
  73236. /**
  73237. * Convert Hue, saturation and value to a Color3 (RGB)
  73238. * @param hue defines the hue
  73239. * @param saturation defines the saturation
  73240. * @param value defines the value
  73241. * @param result defines the Color3 where to store the RGB values
  73242. */
  73243. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73244. /**
  73245. * Creates a new Color3 from the string containing valid hexadecimal values
  73246. * @param hex defines a string containing valid hexadecimal values
  73247. * @returns a new Color3 object
  73248. */
  73249. static FromHexString(hex: string): Color3;
  73250. /**
  73251. * Creates a new Color3 from the starting index of the given array
  73252. * @param array defines the source array
  73253. * @param offset defines an offset in the source array
  73254. * @returns a new Color3 object
  73255. */
  73256. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73257. /**
  73258. * Creates a new Color3 from integer values (< 256)
  73259. * @param r defines the red component to read from (value between 0 and 255)
  73260. * @param g defines the green component to read from (value between 0 and 255)
  73261. * @param b defines the blue component to read from (value between 0 and 255)
  73262. * @returns a new Color3 object
  73263. */
  73264. static FromInts(r: number, g: number, b: number): Color3;
  73265. /**
  73266. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73267. * @param start defines the start Color3 value
  73268. * @param end defines the end Color3 value
  73269. * @param amount defines the gradient value between start and end
  73270. * @returns a new Color3 object
  73271. */
  73272. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73273. /**
  73274. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73275. * @param left defines the start value
  73276. * @param right defines the end value
  73277. * @param amount defines the gradient factor
  73278. * @param result defines the Color3 object where to store the result
  73279. */
  73280. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73281. /**
  73282. * Returns a Color3 value containing a red color
  73283. * @returns a new Color3 object
  73284. */
  73285. static Red(): Color3;
  73286. /**
  73287. * Returns a Color3 value containing a green color
  73288. * @returns a new Color3 object
  73289. */
  73290. static Green(): Color3;
  73291. /**
  73292. * Returns a Color3 value containing a blue color
  73293. * @returns a new Color3 object
  73294. */
  73295. static Blue(): Color3;
  73296. /**
  73297. * Returns a Color3 value containing a black color
  73298. * @returns a new Color3 object
  73299. */
  73300. static Black(): Color3;
  73301. /**
  73302. * Gets a Color3 value containing a black color that must not be updated
  73303. */
  73304. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73305. /**
  73306. * Returns a Color3 value containing a white color
  73307. * @returns a new Color3 object
  73308. */
  73309. static White(): Color3;
  73310. /**
  73311. * Returns a Color3 value containing a purple color
  73312. * @returns a new Color3 object
  73313. */
  73314. static Purple(): Color3;
  73315. /**
  73316. * Returns a Color3 value containing a magenta color
  73317. * @returns a new Color3 object
  73318. */
  73319. static Magenta(): Color3;
  73320. /**
  73321. * Returns a Color3 value containing a yellow color
  73322. * @returns a new Color3 object
  73323. */
  73324. static Yellow(): Color3;
  73325. /**
  73326. * Returns a Color3 value containing a gray color
  73327. * @returns a new Color3 object
  73328. */
  73329. static Gray(): Color3;
  73330. /**
  73331. * Returns a Color3 value containing a teal color
  73332. * @returns a new Color3 object
  73333. */
  73334. static Teal(): Color3;
  73335. /**
  73336. * Returns a Color3 value containing a random color
  73337. * @returns a new Color3 object
  73338. */
  73339. static Random(): Color3;
  73340. }
  73341. /**
  73342. * Class used to hold a RBGA color
  73343. */
  73344. export class Color4 {
  73345. /**
  73346. * Defines the red component (between 0 and 1, default is 0)
  73347. */
  73348. r: number;
  73349. /**
  73350. * Defines the green component (between 0 and 1, default is 0)
  73351. */
  73352. g: number;
  73353. /**
  73354. * Defines the blue component (between 0 and 1, default is 0)
  73355. */
  73356. b: number;
  73357. /**
  73358. * Defines the alpha component (between 0 and 1, default is 1)
  73359. */
  73360. a: number;
  73361. /**
  73362. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73363. * @param r defines the red component (between 0 and 1, default is 0)
  73364. * @param g defines the green component (between 0 and 1, default is 0)
  73365. * @param b defines the blue component (between 0 and 1, default is 0)
  73366. * @param a defines the alpha component (between 0 and 1, default is 1)
  73367. */
  73368. constructor(
  73369. /**
  73370. * Defines the red component (between 0 and 1, default is 0)
  73371. */
  73372. r?: number,
  73373. /**
  73374. * Defines the green component (between 0 and 1, default is 0)
  73375. */
  73376. g?: number,
  73377. /**
  73378. * Defines the blue component (between 0 and 1, default is 0)
  73379. */
  73380. b?: number,
  73381. /**
  73382. * Defines the alpha component (between 0 and 1, default is 1)
  73383. */
  73384. a?: number);
  73385. /**
  73386. * Adds in place the given Color4 values to the current Color4 object
  73387. * @param right defines the second operand
  73388. * @returns the current updated Color4 object
  73389. */
  73390. addInPlace(right: DeepImmutable<Color4>): Color4;
  73391. /**
  73392. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73393. * @returns the new array
  73394. */
  73395. asArray(): number[];
  73396. /**
  73397. * Stores from the starting index in the given array the Color4 successive values
  73398. * @param array defines the array where to store the r,g,b components
  73399. * @param index defines an optional index in the target array to define where to start storing values
  73400. * @returns the current Color4 object
  73401. */
  73402. toArray(array: number[], index?: number): Color4;
  73403. /**
  73404. * Determines equality between Color4 objects
  73405. * @param otherColor defines the second operand
  73406. * @returns true if the rgba values are equal to the given ones
  73407. */
  73408. equals(otherColor: DeepImmutable<Color4>): boolean;
  73409. /**
  73410. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73411. * @param right defines the second operand
  73412. * @returns a new Color4 object
  73413. */
  73414. add(right: DeepImmutable<Color4>): Color4;
  73415. /**
  73416. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73417. * @param right defines the second operand
  73418. * @returns a new Color4 object
  73419. */
  73420. subtract(right: DeepImmutable<Color4>): Color4;
  73421. /**
  73422. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73423. * @param right defines the second operand
  73424. * @param result defines the Color4 object where to store the result
  73425. * @returns the current Color4 object
  73426. */
  73427. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73428. /**
  73429. * Creates a new Color4 with the current Color4 values multiplied by scale
  73430. * @param scale defines the scaling factor to apply
  73431. * @returns a new Color4 object
  73432. */
  73433. scale(scale: number): Color4;
  73434. /**
  73435. * Multiplies the current Color4 values by scale and stores the result in "result"
  73436. * @param scale defines the scaling factor to apply
  73437. * @param result defines the Color4 object where to store the result
  73438. * @returns the current unmodified Color4
  73439. */
  73440. scaleToRef(scale: number, result: Color4): Color4;
  73441. /**
  73442. * Scale the current Color4 values by a factor and add the result to a given Color4
  73443. * @param scale defines the scale factor
  73444. * @param result defines the Color4 object where to store the result
  73445. * @returns the unmodified current Color4
  73446. */
  73447. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73448. /**
  73449. * Clamps the rgb values by the min and max values and stores the result into "result"
  73450. * @param min defines minimum clamping value (default is 0)
  73451. * @param max defines maximum clamping value (default is 1)
  73452. * @param result defines color to store the result into.
  73453. * @returns the cuurent Color4
  73454. */
  73455. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73456. /**
  73457. * Multipy an Color4 value by another and return a new Color4 object
  73458. * @param color defines the Color4 value to multiply by
  73459. * @returns a new Color4 object
  73460. */
  73461. multiply(color: Color4): Color4;
  73462. /**
  73463. * Multipy a Color4 value by another and push the result in a reference value
  73464. * @param color defines the Color4 value to multiply by
  73465. * @param result defines the Color4 to fill the result in
  73466. * @returns the result Color4
  73467. */
  73468. multiplyToRef(color: Color4, result: Color4): Color4;
  73469. /**
  73470. * Creates a string with the Color4 current values
  73471. * @returns the string representation of the Color4 object
  73472. */
  73473. toString(): string;
  73474. /**
  73475. * Returns the string "Color4"
  73476. * @returns "Color4"
  73477. */
  73478. getClassName(): string;
  73479. /**
  73480. * Compute the Color4 hash code
  73481. * @returns an unique number that can be used to hash Color4 objects
  73482. */
  73483. getHashCode(): number;
  73484. /**
  73485. * Creates a new Color4 copied from the current one
  73486. * @returns a new Color4 object
  73487. */
  73488. clone(): Color4;
  73489. /**
  73490. * Copies the given Color4 values into the current one
  73491. * @param source defines the source Color4 object
  73492. * @returns the current updated Color4 object
  73493. */
  73494. copyFrom(source: Color4): Color4;
  73495. /**
  73496. * Copies the given float values into the current one
  73497. * @param r defines the red component to read from
  73498. * @param g defines the green component to read from
  73499. * @param b defines the blue component to read from
  73500. * @param a defines the alpha component to read from
  73501. * @returns the current updated Color4 object
  73502. */
  73503. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73504. /**
  73505. * Copies the given float values into the current one
  73506. * @param r defines the red component to read from
  73507. * @param g defines the green component to read from
  73508. * @param b defines the blue component to read from
  73509. * @param a defines the alpha component to read from
  73510. * @returns the current updated Color4 object
  73511. */
  73512. set(r: number, g: number, b: number, a: number): Color4;
  73513. /**
  73514. * Compute the Color4 hexadecimal code as a string
  73515. * @returns a string containing the hexadecimal representation of the Color4 object
  73516. */
  73517. toHexString(): string;
  73518. /**
  73519. * Computes a new Color4 converted from the current one to linear space
  73520. * @returns a new Color4 object
  73521. */
  73522. toLinearSpace(): Color4;
  73523. /**
  73524. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73525. * @param convertedColor defines the Color4 object where to store the linear space version
  73526. * @returns the unmodified Color4
  73527. */
  73528. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73529. /**
  73530. * Computes a new Color4 converted from the current one to gamma space
  73531. * @returns a new Color4 object
  73532. */
  73533. toGammaSpace(): Color4;
  73534. /**
  73535. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73536. * @param convertedColor defines the Color4 object where to store the gamma space version
  73537. * @returns the unmodified Color4
  73538. */
  73539. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73540. /**
  73541. * Creates a new Color4 from the string containing valid hexadecimal values
  73542. * @param hex defines a string containing valid hexadecimal values
  73543. * @returns a new Color4 object
  73544. */
  73545. static FromHexString(hex: string): Color4;
  73546. /**
  73547. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73548. * @param left defines the start value
  73549. * @param right defines the end value
  73550. * @param amount defines the gradient factor
  73551. * @returns a new Color4 object
  73552. */
  73553. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73554. /**
  73555. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73556. * @param left defines the start value
  73557. * @param right defines the end value
  73558. * @param amount defines the gradient factor
  73559. * @param result defines the Color4 object where to store data
  73560. */
  73561. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73562. /**
  73563. * Creates a new Color4 from a Color3 and an alpha value
  73564. * @param color3 defines the source Color3 to read from
  73565. * @param alpha defines the alpha component (1.0 by default)
  73566. * @returns a new Color4 object
  73567. */
  73568. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73569. /**
  73570. * Creates a new Color4 from the starting index element of the given array
  73571. * @param array defines the source array to read from
  73572. * @param offset defines the offset in the source array
  73573. * @returns a new Color4 object
  73574. */
  73575. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73576. /**
  73577. * Creates a new Color3 from integer values (< 256)
  73578. * @param r defines the red component to read from (value between 0 and 255)
  73579. * @param g defines the green component to read from (value between 0 and 255)
  73580. * @param b defines the blue component to read from (value between 0 and 255)
  73581. * @param a defines the alpha component to read from (value between 0 and 255)
  73582. * @returns a new Color3 object
  73583. */
  73584. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73585. /**
  73586. * Check the content of a given array and convert it to an array containing RGBA data
  73587. * If the original array was already containing count * 4 values then it is returned directly
  73588. * @param colors defines the array to check
  73589. * @param count defines the number of RGBA data to expect
  73590. * @returns an array containing count * 4 values (RGBA)
  73591. */
  73592. static CheckColors4(colors: number[], count: number): number[];
  73593. }
  73594. /**
  73595. * @hidden
  73596. */
  73597. export class TmpColors {
  73598. static Color3: Color3[];
  73599. static Color4: Color4[];
  73600. }
  73601. }
  73602. declare module BABYLON {
  73603. /**
  73604. * Defines an interface which represents an animation key frame
  73605. */
  73606. export interface IAnimationKey {
  73607. /**
  73608. * Frame of the key frame
  73609. */
  73610. frame: number;
  73611. /**
  73612. * Value at the specifies key frame
  73613. */
  73614. value: any;
  73615. /**
  73616. * The input tangent for the cubic hermite spline
  73617. */
  73618. inTangent?: any;
  73619. /**
  73620. * The output tangent for the cubic hermite spline
  73621. */
  73622. outTangent?: any;
  73623. /**
  73624. * The animation interpolation type
  73625. */
  73626. interpolation?: AnimationKeyInterpolation;
  73627. }
  73628. /**
  73629. * Enum for the animation key frame interpolation type
  73630. */
  73631. export enum AnimationKeyInterpolation {
  73632. /**
  73633. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73634. */
  73635. STEP = 1
  73636. }
  73637. }
  73638. declare module BABYLON {
  73639. /**
  73640. * Represents the range of an animation
  73641. */
  73642. export class AnimationRange {
  73643. /**The name of the animation range**/
  73644. name: string;
  73645. /**The starting frame of the animation */
  73646. from: number;
  73647. /**The ending frame of the animation*/
  73648. to: number;
  73649. /**
  73650. * Initializes the range of an animation
  73651. * @param name The name of the animation range
  73652. * @param from The starting frame of the animation
  73653. * @param to The ending frame of the animation
  73654. */
  73655. constructor(
  73656. /**The name of the animation range**/
  73657. name: string,
  73658. /**The starting frame of the animation */
  73659. from: number,
  73660. /**The ending frame of the animation*/
  73661. to: number);
  73662. /**
  73663. * Makes a copy of the animation range
  73664. * @returns A copy of the animation range
  73665. */
  73666. clone(): AnimationRange;
  73667. }
  73668. }
  73669. declare module BABYLON {
  73670. /**
  73671. * Composed of a frame, and an action function
  73672. */
  73673. export class AnimationEvent {
  73674. /** The frame for which the event is triggered **/
  73675. frame: number;
  73676. /** The event to perform when triggered **/
  73677. action: (currentFrame: number) => void;
  73678. /** Specifies if the event should be triggered only once**/
  73679. onlyOnce?: boolean | undefined;
  73680. /**
  73681. * Specifies if the animation event is done
  73682. */
  73683. isDone: boolean;
  73684. /**
  73685. * Initializes the animation event
  73686. * @param frame The frame for which the event is triggered
  73687. * @param action The event to perform when triggered
  73688. * @param onlyOnce Specifies if the event should be triggered only once
  73689. */
  73690. constructor(
  73691. /** The frame for which the event is triggered **/
  73692. frame: number,
  73693. /** The event to perform when triggered **/
  73694. action: (currentFrame: number) => void,
  73695. /** Specifies if the event should be triggered only once**/
  73696. onlyOnce?: boolean | undefined);
  73697. /** @hidden */
  73698. _clone(): AnimationEvent;
  73699. }
  73700. }
  73701. declare module BABYLON {
  73702. /**
  73703. * Interface used to define a behavior
  73704. */
  73705. export interface Behavior<T> {
  73706. /** gets or sets behavior's name */
  73707. name: string;
  73708. /**
  73709. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73710. */
  73711. init(): void;
  73712. /**
  73713. * Called when the behavior is attached to a target
  73714. * @param target defines the target where the behavior is attached to
  73715. */
  73716. attach(target: T): void;
  73717. /**
  73718. * Called when the behavior is detached from its target
  73719. */
  73720. detach(): void;
  73721. }
  73722. /**
  73723. * Interface implemented by classes supporting behaviors
  73724. */
  73725. export interface IBehaviorAware<T> {
  73726. /**
  73727. * Attach a behavior
  73728. * @param behavior defines the behavior to attach
  73729. * @returns the current host
  73730. */
  73731. addBehavior(behavior: Behavior<T>): T;
  73732. /**
  73733. * Remove a behavior from the current object
  73734. * @param behavior defines the behavior to detach
  73735. * @returns the current host
  73736. */
  73737. removeBehavior(behavior: Behavior<T>): T;
  73738. /**
  73739. * Gets a behavior using its name to search
  73740. * @param name defines the name to search
  73741. * @returns the behavior or null if not found
  73742. */
  73743. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73744. }
  73745. }
  73746. declare module BABYLON {
  73747. /**
  73748. * Defines an array and its length.
  73749. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73750. */
  73751. export interface ISmartArrayLike<T> {
  73752. /**
  73753. * The data of the array.
  73754. */
  73755. data: Array<T>;
  73756. /**
  73757. * The active length of the array.
  73758. */
  73759. length: number;
  73760. }
  73761. /**
  73762. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73763. */
  73764. export class SmartArray<T> implements ISmartArrayLike<T> {
  73765. /**
  73766. * The full set of data from the array.
  73767. */
  73768. data: Array<T>;
  73769. /**
  73770. * The active length of the array.
  73771. */
  73772. length: number;
  73773. protected _id: number;
  73774. /**
  73775. * Instantiates a Smart Array.
  73776. * @param capacity defines the default capacity of the array.
  73777. */
  73778. constructor(capacity: number);
  73779. /**
  73780. * Pushes a value at the end of the active data.
  73781. * @param value defines the object to push in the array.
  73782. */
  73783. push(value: T): void;
  73784. /**
  73785. * Iterates over the active data and apply the lambda to them.
  73786. * @param func defines the action to apply on each value.
  73787. */
  73788. forEach(func: (content: T) => void): void;
  73789. /**
  73790. * Sorts the full sets of data.
  73791. * @param compareFn defines the comparison function to apply.
  73792. */
  73793. sort(compareFn: (a: T, b: T) => number): void;
  73794. /**
  73795. * Resets the active data to an empty array.
  73796. */
  73797. reset(): void;
  73798. /**
  73799. * Releases all the data from the array as well as the array.
  73800. */
  73801. dispose(): void;
  73802. /**
  73803. * Concats the active data with a given array.
  73804. * @param array defines the data to concatenate with.
  73805. */
  73806. concat(array: any): void;
  73807. /**
  73808. * Returns the position of a value in the active data.
  73809. * @param value defines the value to find the index for
  73810. * @returns the index if found in the active data otherwise -1
  73811. */
  73812. indexOf(value: T): number;
  73813. /**
  73814. * Returns whether an element is part of the active data.
  73815. * @param value defines the value to look for
  73816. * @returns true if found in the active data otherwise false
  73817. */
  73818. contains(value: T): boolean;
  73819. private static _GlobalId;
  73820. }
  73821. /**
  73822. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73823. * The data in this array can only be present once
  73824. */
  73825. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73826. private _duplicateId;
  73827. /**
  73828. * Pushes a value at the end of the active data.
  73829. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73830. * @param value defines the object to push in the array.
  73831. */
  73832. push(value: T): void;
  73833. /**
  73834. * Pushes a value at the end of the active data.
  73835. * If the data is already present, it won t be added again
  73836. * @param value defines the object to push in the array.
  73837. * @returns true if added false if it was already present
  73838. */
  73839. pushNoDuplicate(value: T): boolean;
  73840. /**
  73841. * Resets the active data to an empty array.
  73842. */
  73843. reset(): void;
  73844. /**
  73845. * Concats the active data with a given array.
  73846. * This ensures no dupplicate will be present in the result.
  73847. * @param array defines the data to concatenate with.
  73848. */
  73849. concatWithNoDuplicate(array: any): void;
  73850. }
  73851. }
  73852. declare module BABYLON {
  73853. /**
  73854. * @ignore
  73855. * This is a list of all the different input types that are available in the application.
  73856. * Fo instance: ArcRotateCameraGamepadInput...
  73857. */
  73858. export var CameraInputTypes: {};
  73859. /**
  73860. * This is the contract to implement in order to create a new input class.
  73861. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73862. */
  73863. export interface ICameraInput<TCamera extends Camera> {
  73864. /**
  73865. * Defines the camera the input is attached to.
  73866. */
  73867. camera: Nullable<TCamera>;
  73868. /**
  73869. * Gets the class name of the current intput.
  73870. * @returns the class name
  73871. */
  73872. getClassName(): string;
  73873. /**
  73874. * Get the friendly name associated with the input class.
  73875. * @returns the input friendly name
  73876. */
  73877. getSimpleName(): string;
  73878. /**
  73879. * Attach the input controls to a specific dom element to get the input from.
  73880. * @param element Defines the element the controls should be listened from
  73881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73882. */
  73883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73884. /**
  73885. * Detach the current controls from the specified dom element.
  73886. * @param element Defines the element to stop listening the inputs from
  73887. */
  73888. detachControl(element: Nullable<HTMLElement>): void;
  73889. /**
  73890. * Update the current camera state depending on the inputs that have been used this frame.
  73891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73892. */
  73893. checkInputs?: () => void;
  73894. }
  73895. /**
  73896. * Represents a map of input types to input instance or input index to input instance.
  73897. */
  73898. export interface CameraInputsMap<TCamera extends Camera> {
  73899. /**
  73900. * Accessor to the input by input type.
  73901. */
  73902. [name: string]: ICameraInput<TCamera>;
  73903. /**
  73904. * Accessor to the input by input index.
  73905. */
  73906. [idx: number]: ICameraInput<TCamera>;
  73907. }
  73908. /**
  73909. * This represents the input manager used within a camera.
  73910. * It helps dealing with all the different kind of input attached to a camera.
  73911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73912. */
  73913. export class CameraInputsManager<TCamera extends Camera> {
  73914. /**
  73915. * Defines the list of inputs attahed to the camera.
  73916. */
  73917. attached: CameraInputsMap<TCamera>;
  73918. /**
  73919. * Defines the dom element the camera is collecting inputs from.
  73920. * This is null if the controls have not been attached.
  73921. */
  73922. attachedElement: Nullable<HTMLElement>;
  73923. /**
  73924. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73925. */
  73926. noPreventDefault: boolean;
  73927. /**
  73928. * Defined the camera the input manager belongs to.
  73929. */
  73930. camera: TCamera;
  73931. /**
  73932. * Update the current camera state depending on the inputs that have been used this frame.
  73933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73934. */
  73935. checkInputs: () => void;
  73936. /**
  73937. * Instantiate a new Camera Input Manager.
  73938. * @param camera Defines the camera the input manager blongs to
  73939. */
  73940. constructor(camera: TCamera);
  73941. /**
  73942. * Add an input method to a camera
  73943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73944. * @param input camera input method
  73945. */
  73946. add(input: ICameraInput<TCamera>): void;
  73947. /**
  73948. * Remove a specific input method from a camera
  73949. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73950. * @param inputToRemove camera input method
  73951. */
  73952. remove(inputToRemove: ICameraInput<TCamera>): void;
  73953. /**
  73954. * Remove a specific input type from a camera
  73955. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73956. * @param inputType the type of the input to remove
  73957. */
  73958. removeByType(inputType: string): void;
  73959. private _addCheckInputs;
  73960. /**
  73961. * Attach the input controls to the currently attached dom element to listen the events from.
  73962. * @param input Defines the input to attach
  73963. */
  73964. attachInput(input: ICameraInput<TCamera>): void;
  73965. /**
  73966. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73967. * @param element Defines the dom element to collect the events from
  73968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73969. */
  73970. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73971. /**
  73972. * Detach the current manager inputs controls from a specific dom element.
  73973. * @param element Defines the dom element to collect the events from
  73974. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73975. */
  73976. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73977. /**
  73978. * Rebuild the dynamic inputCheck function from the current list of
  73979. * defined inputs in the manager.
  73980. */
  73981. rebuildInputCheck(): void;
  73982. /**
  73983. * Remove all attached input methods from a camera
  73984. */
  73985. clear(): void;
  73986. /**
  73987. * Serialize the current input manager attached to a camera.
  73988. * This ensures than once parsed,
  73989. * the input associated to the camera will be identical to the current ones
  73990. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73991. */
  73992. serialize(serializedCamera: any): void;
  73993. /**
  73994. * Parses an input manager serialized JSON to restore the previous list of inputs
  73995. * and states associated to a camera.
  73996. * @param parsedCamera Defines the JSON to parse
  73997. */
  73998. parse(parsedCamera: any): void;
  73999. }
  74000. }
  74001. declare module BABYLON {
  74002. /**
  74003. * Class used to store data that will be store in GPU memory
  74004. */
  74005. export class Buffer {
  74006. private _engine;
  74007. private _buffer;
  74008. /** @hidden */
  74009. _data: Nullable<DataArray>;
  74010. private _updatable;
  74011. private _instanced;
  74012. private _divisor;
  74013. /**
  74014. * Gets the byte stride.
  74015. */
  74016. readonly byteStride: number;
  74017. /**
  74018. * Constructor
  74019. * @param engine the engine
  74020. * @param data the data to use for this buffer
  74021. * @param updatable whether the data is updatable
  74022. * @param stride the stride (optional)
  74023. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74024. * @param instanced whether the buffer is instanced (optional)
  74025. * @param useBytes set to true if the stride in in bytes (optional)
  74026. * @param divisor sets an optional divisor for instances (1 by default)
  74027. */
  74028. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74029. /**
  74030. * Create a new VertexBuffer based on the current buffer
  74031. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74032. * @param offset defines offset in the buffer (0 by default)
  74033. * @param size defines the size in floats of attributes (position is 3 for instance)
  74034. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74035. * @param instanced defines if the vertex buffer contains indexed data
  74036. * @param useBytes defines if the offset and stride are in bytes *
  74037. * @param divisor sets an optional divisor for instances (1 by default)
  74038. * @returns the new vertex buffer
  74039. */
  74040. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74041. /**
  74042. * Gets a boolean indicating if the Buffer is updatable?
  74043. * @returns true if the buffer is updatable
  74044. */
  74045. isUpdatable(): boolean;
  74046. /**
  74047. * Gets current buffer's data
  74048. * @returns a DataArray or null
  74049. */
  74050. getData(): Nullable<DataArray>;
  74051. /**
  74052. * Gets underlying native buffer
  74053. * @returns underlying native buffer
  74054. */
  74055. getBuffer(): Nullable<DataBuffer>;
  74056. /**
  74057. * Gets the stride in float32 units (i.e. byte stride / 4).
  74058. * May not be an integer if the byte stride is not divisible by 4.
  74059. * DEPRECATED. Use byteStride instead.
  74060. * @returns the stride in float32 units
  74061. */
  74062. getStrideSize(): number;
  74063. /**
  74064. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74065. * @param data defines the data to store
  74066. */
  74067. create(data?: Nullable<DataArray>): void;
  74068. /** @hidden */
  74069. _rebuild(): void;
  74070. /**
  74071. * Update current buffer data
  74072. * @param data defines the data to store
  74073. */
  74074. update(data: DataArray): void;
  74075. /**
  74076. * Updates the data directly.
  74077. * @param data the new data
  74078. * @param offset the new offset
  74079. * @param vertexCount the vertex count (optional)
  74080. * @param useBytes set to true if the offset is in bytes
  74081. */
  74082. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74083. /**
  74084. * Release all resources
  74085. */
  74086. dispose(): void;
  74087. }
  74088. /**
  74089. * Specialized buffer used to store vertex data
  74090. */
  74091. export class VertexBuffer {
  74092. /** @hidden */
  74093. _buffer: Buffer;
  74094. private _kind;
  74095. private _size;
  74096. private _ownsBuffer;
  74097. private _instanced;
  74098. private _instanceDivisor;
  74099. /**
  74100. * The byte type.
  74101. */
  74102. static readonly BYTE: number;
  74103. /**
  74104. * The unsigned byte type.
  74105. */
  74106. static readonly UNSIGNED_BYTE: number;
  74107. /**
  74108. * The short type.
  74109. */
  74110. static readonly SHORT: number;
  74111. /**
  74112. * The unsigned short type.
  74113. */
  74114. static readonly UNSIGNED_SHORT: number;
  74115. /**
  74116. * The integer type.
  74117. */
  74118. static readonly INT: number;
  74119. /**
  74120. * The unsigned integer type.
  74121. */
  74122. static readonly UNSIGNED_INT: number;
  74123. /**
  74124. * The float type.
  74125. */
  74126. static readonly FLOAT: number;
  74127. /**
  74128. * Gets or sets the instance divisor when in instanced mode
  74129. */
  74130. instanceDivisor: number;
  74131. /**
  74132. * Gets the byte stride.
  74133. */
  74134. readonly byteStride: number;
  74135. /**
  74136. * Gets the byte offset.
  74137. */
  74138. readonly byteOffset: number;
  74139. /**
  74140. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74141. */
  74142. readonly normalized: boolean;
  74143. /**
  74144. * Gets the data type of each component in the array.
  74145. */
  74146. readonly type: number;
  74147. /**
  74148. * Constructor
  74149. * @param engine the engine
  74150. * @param data the data to use for this vertex buffer
  74151. * @param kind the vertex buffer kind
  74152. * @param updatable whether the data is updatable
  74153. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74154. * @param stride the stride (optional)
  74155. * @param instanced whether the buffer is instanced (optional)
  74156. * @param offset the offset of the data (optional)
  74157. * @param size the number of components (optional)
  74158. * @param type the type of the component (optional)
  74159. * @param normalized whether the data contains normalized data (optional)
  74160. * @param useBytes set to true if stride and offset are in bytes (optional)
  74161. * @param divisor defines the instance divisor to use (1 by default)
  74162. */
  74163. 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, divisor?: number);
  74164. /** @hidden */
  74165. _rebuild(): void;
  74166. /**
  74167. * Returns the kind of the VertexBuffer (string)
  74168. * @returns a string
  74169. */
  74170. getKind(): string;
  74171. /**
  74172. * Gets a boolean indicating if the VertexBuffer is updatable?
  74173. * @returns true if the buffer is updatable
  74174. */
  74175. isUpdatable(): boolean;
  74176. /**
  74177. * Gets current buffer's data
  74178. * @returns a DataArray or null
  74179. */
  74180. getData(): Nullable<DataArray>;
  74181. /**
  74182. * Gets underlying native buffer
  74183. * @returns underlying native buffer
  74184. */
  74185. getBuffer(): Nullable<DataBuffer>;
  74186. /**
  74187. * Gets the stride in float32 units (i.e. byte stride / 4).
  74188. * May not be an integer if the byte stride is not divisible by 4.
  74189. * DEPRECATED. Use byteStride instead.
  74190. * @returns the stride in float32 units
  74191. */
  74192. getStrideSize(): number;
  74193. /**
  74194. * Returns the offset as a multiple of the type byte length.
  74195. * DEPRECATED. Use byteOffset instead.
  74196. * @returns the offset in bytes
  74197. */
  74198. getOffset(): number;
  74199. /**
  74200. * Returns the number of components per vertex attribute (integer)
  74201. * @returns the size in float
  74202. */
  74203. getSize(): number;
  74204. /**
  74205. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74206. * @returns true if this buffer is instanced
  74207. */
  74208. getIsInstanced(): boolean;
  74209. /**
  74210. * Returns the instancing divisor, zero for non-instanced (integer).
  74211. * @returns a number
  74212. */
  74213. getInstanceDivisor(): number;
  74214. /**
  74215. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74216. * @param data defines the data to store
  74217. */
  74218. create(data?: DataArray): void;
  74219. /**
  74220. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74221. * This function will create a new buffer if the current one is not updatable
  74222. * @param data defines the data to store
  74223. */
  74224. update(data: DataArray): void;
  74225. /**
  74226. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74227. * Returns the directly updated WebGLBuffer.
  74228. * @param data the new data
  74229. * @param offset the new offset
  74230. * @param useBytes set to true if the offset is in bytes
  74231. */
  74232. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74233. /**
  74234. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74235. */
  74236. dispose(): void;
  74237. /**
  74238. * Enumerates each value of this vertex buffer as numbers.
  74239. * @param count the number of values to enumerate
  74240. * @param callback the callback function called for each value
  74241. */
  74242. forEach(count: number, callback: (value: number, index: number) => void): void;
  74243. /**
  74244. * Positions
  74245. */
  74246. static readonly PositionKind: string;
  74247. /**
  74248. * Normals
  74249. */
  74250. static readonly NormalKind: string;
  74251. /**
  74252. * Tangents
  74253. */
  74254. static readonly TangentKind: string;
  74255. /**
  74256. * Texture coordinates
  74257. */
  74258. static readonly UVKind: string;
  74259. /**
  74260. * Texture coordinates 2
  74261. */
  74262. static readonly UV2Kind: string;
  74263. /**
  74264. * Texture coordinates 3
  74265. */
  74266. static readonly UV3Kind: string;
  74267. /**
  74268. * Texture coordinates 4
  74269. */
  74270. static readonly UV4Kind: string;
  74271. /**
  74272. * Texture coordinates 5
  74273. */
  74274. static readonly UV5Kind: string;
  74275. /**
  74276. * Texture coordinates 6
  74277. */
  74278. static readonly UV6Kind: string;
  74279. /**
  74280. * Colors
  74281. */
  74282. static readonly ColorKind: string;
  74283. /**
  74284. * Matrix indices (for bones)
  74285. */
  74286. static readonly MatricesIndicesKind: string;
  74287. /**
  74288. * Matrix weights (for bones)
  74289. */
  74290. static readonly MatricesWeightsKind: string;
  74291. /**
  74292. * Additional matrix indices (for bones)
  74293. */
  74294. static readonly MatricesIndicesExtraKind: string;
  74295. /**
  74296. * Additional matrix weights (for bones)
  74297. */
  74298. static readonly MatricesWeightsExtraKind: string;
  74299. /**
  74300. * Deduces the stride given a kind.
  74301. * @param kind The kind string to deduce
  74302. * @returns The deduced stride
  74303. */
  74304. static DeduceStride(kind: string): number;
  74305. /**
  74306. * Gets the byte length of the given type.
  74307. * @param type the type
  74308. * @returns the number of bytes
  74309. */
  74310. static GetTypeByteLength(type: number): number;
  74311. /**
  74312. * Enumerates each value of the given parameters as numbers.
  74313. * @param data the data to enumerate
  74314. * @param byteOffset the byte offset of the data
  74315. * @param byteStride the byte stride of the data
  74316. * @param componentCount the number of components per element
  74317. * @param componentType the type of the component
  74318. * @param count the number of values to enumerate
  74319. * @param normalized whether the data is normalized
  74320. * @param callback the callback function called for each value
  74321. */
  74322. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74323. private static _GetFloatValue;
  74324. }
  74325. }
  74326. declare module BABYLON {
  74327. /**
  74328. * @hidden
  74329. */
  74330. export class IntersectionInfo {
  74331. bu: Nullable<number>;
  74332. bv: Nullable<number>;
  74333. distance: number;
  74334. faceId: number;
  74335. subMeshId: number;
  74336. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74337. }
  74338. }
  74339. declare module BABYLON {
  74340. /**
  74341. * Represens a plane by the equation ax + by + cz + d = 0
  74342. */
  74343. export class Plane {
  74344. private static _TmpMatrix;
  74345. /**
  74346. * Normal of the plane (a,b,c)
  74347. */
  74348. normal: Vector3;
  74349. /**
  74350. * d component of the plane
  74351. */
  74352. d: number;
  74353. /**
  74354. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74355. * @param a a component of the plane
  74356. * @param b b component of the plane
  74357. * @param c c component of the plane
  74358. * @param d d component of the plane
  74359. */
  74360. constructor(a: number, b: number, c: number, d: number);
  74361. /**
  74362. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74363. */
  74364. asArray(): number[];
  74365. /**
  74366. * @returns a new plane copied from the current Plane.
  74367. */
  74368. clone(): Plane;
  74369. /**
  74370. * @returns the string "Plane".
  74371. */
  74372. getClassName(): string;
  74373. /**
  74374. * @returns the Plane hash code.
  74375. */
  74376. getHashCode(): number;
  74377. /**
  74378. * Normalize the current Plane in place.
  74379. * @returns the updated Plane.
  74380. */
  74381. normalize(): Plane;
  74382. /**
  74383. * Applies a transformation the plane and returns the result
  74384. * @param transformation the transformation matrix to be applied to the plane
  74385. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74386. */
  74387. transform(transformation: DeepImmutable<Matrix>): Plane;
  74388. /**
  74389. * Calcualtte the dot product between the point and the plane normal
  74390. * @param point point to calculate the dot product with
  74391. * @returns the dot product (float) of the point coordinates and the plane normal.
  74392. */
  74393. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74394. /**
  74395. * Updates the current Plane from the plane defined by the three given points.
  74396. * @param point1 one of the points used to contruct the plane
  74397. * @param point2 one of the points used to contruct the plane
  74398. * @param point3 one of the points used to contruct the plane
  74399. * @returns the updated Plane.
  74400. */
  74401. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74402. /**
  74403. * Checks if the plane is facing a given direction
  74404. * @param direction the direction to check if the plane is facing
  74405. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74406. * @returns True is the vector "direction" is the same side than the plane normal.
  74407. */
  74408. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74409. /**
  74410. * Calculates the distance to a point
  74411. * @param point point to calculate distance to
  74412. * @returns the signed distance (float) from the given point to the Plane.
  74413. */
  74414. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74415. /**
  74416. * Creates a plane from an array
  74417. * @param array the array to create a plane from
  74418. * @returns a new Plane from the given array.
  74419. */
  74420. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74421. /**
  74422. * Creates a plane from three points
  74423. * @param point1 point used to create the plane
  74424. * @param point2 point used to create the plane
  74425. * @param point3 point used to create the plane
  74426. * @returns a new Plane defined by the three given points.
  74427. */
  74428. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74429. /**
  74430. * Creates a plane from an origin point and a normal
  74431. * @param origin origin of the plane to be constructed
  74432. * @param normal normal of the plane to be constructed
  74433. * @returns a new Plane the normal vector to this plane at the given origin point.
  74434. * Note : the vector "normal" is updated because normalized.
  74435. */
  74436. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74437. /**
  74438. * Calculates the distance from a plane and a point
  74439. * @param origin origin of the plane to be constructed
  74440. * @param normal normal of the plane to be constructed
  74441. * @param point point to calculate distance to
  74442. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74443. */
  74444. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74445. }
  74446. }
  74447. declare module BABYLON {
  74448. /**
  74449. * Class used to store bounding sphere information
  74450. */
  74451. export class BoundingSphere {
  74452. /**
  74453. * Gets the center of the bounding sphere in local space
  74454. */
  74455. readonly center: Vector3;
  74456. /**
  74457. * Radius of the bounding sphere in local space
  74458. */
  74459. radius: number;
  74460. /**
  74461. * Gets the center of the bounding sphere in world space
  74462. */
  74463. readonly centerWorld: Vector3;
  74464. /**
  74465. * Radius of the bounding sphere in world space
  74466. */
  74467. radiusWorld: number;
  74468. /**
  74469. * Gets the minimum vector in local space
  74470. */
  74471. readonly minimum: Vector3;
  74472. /**
  74473. * Gets the maximum vector in local space
  74474. */
  74475. readonly maximum: Vector3;
  74476. private _worldMatrix;
  74477. private static readonly TmpVector3;
  74478. /**
  74479. * Creates a new bounding sphere
  74480. * @param min defines the minimum vector (in local space)
  74481. * @param max defines the maximum vector (in local space)
  74482. * @param worldMatrix defines the new world matrix
  74483. */
  74484. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74485. /**
  74486. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74487. * @param min defines the new minimum vector (in local space)
  74488. * @param max defines the new maximum vector (in local space)
  74489. * @param worldMatrix defines the new world matrix
  74490. */
  74491. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74492. /**
  74493. * Scale the current bounding sphere by applying a scale factor
  74494. * @param factor defines the scale factor to apply
  74495. * @returns the current bounding box
  74496. */
  74497. scale(factor: number): BoundingSphere;
  74498. /**
  74499. * Gets the world matrix of the bounding box
  74500. * @returns a matrix
  74501. */
  74502. getWorldMatrix(): DeepImmutable<Matrix>;
  74503. /** @hidden */
  74504. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74505. /**
  74506. * Tests if the bounding sphere is intersecting the frustum planes
  74507. * @param frustumPlanes defines the frustum planes to test
  74508. * @returns true if there is an intersection
  74509. */
  74510. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74511. /**
  74512. * Tests if the bounding sphere center is in between the frustum planes.
  74513. * Used for optimistic fast inclusion.
  74514. * @param frustumPlanes defines the frustum planes to test
  74515. * @returns true if the sphere center is in between the frustum planes
  74516. */
  74517. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74518. /**
  74519. * Tests if a point is inside the bounding sphere
  74520. * @param point defines the point to test
  74521. * @returns true if the point is inside the bounding sphere
  74522. */
  74523. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74524. /**
  74525. * Checks if two sphere intersct
  74526. * @param sphere0 sphere 0
  74527. * @param sphere1 sphere 1
  74528. * @returns true if the speres intersect
  74529. */
  74530. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74531. }
  74532. }
  74533. declare module BABYLON {
  74534. /**
  74535. * Class used to store bounding box information
  74536. */
  74537. export class BoundingBox implements ICullable {
  74538. /**
  74539. * Gets the 8 vectors representing the bounding box in local space
  74540. */
  74541. readonly vectors: Vector3[];
  74542. /**
  74543. * Gets the center of the bounding box in local space
  74544. */
  74545. readonly center: Vector3;
  74546. /**
  74547. * Gets the center of the bounding box in world space
  74548. */
  74549. readonly centerWorld: Vector3;
  74550. /**
  74551. * Gets the extend size in local space
  74552. */
  74553. readonly extendSize: Vector3;
  74554. /**
  74555. * Gets the extend size in world space
  74556. */
  74557. readonly extendSizeWorld: Vector3;
  74558. /**
  74559. * Gets the OBB (object bounding box) directions
  74560. */
  74561. readonly directions: Vector3[];
  74562. /**
  74563. * Gets the 8 vectors representing the bounding box in world space
  74564. */
  74565. readonly vectorsWorld: Vector3[];
  74566. /**
  74567. * Gets the minimum vector in world space
  74568. */
  74569. readonly minimumWorld: Vector3;
  74570. /**
  74571. * Gets the maximum vector in world space
  74572. */
  74573. readonly maximumWorld: Vector3;
  74574. /**
  74575. * Gets the minimum vector in local space
  74576. */
  74577. readonly minimum: Vector3;
  74578. /**
  74579. * Gets the maximum vector in local space
  74580. */
  74581. readonly maximum: Vector3;
  74582. private _worldMatrix;
  74583. private static readonly TmpVector3;
  74584. /**
  74585. * @hidden
  74586. */
  74587. _tag: number;
  74588. /**
  74589. * Creates a new bounding box
  74590. * @param min defines the minimum vector (in local space)
  74591. * @param max defines the maximum vector (in local space)
  74592. * @param worldMatrix defines the new world matrix
  74593. */
  74594. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74595. /**
  74596. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74597. * @param min defines the new minimum vector (in local space)
  74598. * @param max defines the new maximum vector (in local space)
  74599. * @param worldMatrix defines the new world matrix
  74600. */
  74601. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74602. /**
  74603. * Scale the current bounding box by applying a scale factor
  74604. * @param factor defines the scale factor to apply
  74605. * @returns the current bounding box
  74606. */
  74607. scale(factor: number): BoundingBox;
  74608. /**
  74609. * Gets the world matrix of the bounding box
  74610. * @returns a matrix
  74611. */
  74612. getWorldMatrix(): DeepImmutable<Matrix>;
  74613. /** @hidden */
  74614. _update(world: DeepImmutable<Matrix>): void;
  74615. /**
  74616. * Tests if the bounding box is intersecting the frustum planes
  74617. * @param frustumPlanes defines the frustum planes to test
  74618. * @returns true if there is an intersection
  74619. */
  74620. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74621. /**
  74622. * Tests if the bounding box is entirely inside the frustum planes
  74623. * @param frustumPlanes defines the frustum planes to test
  74624. * @returns true if there is an inclusion
  74625. */
  74626. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74627. /**
  74628. * Tests if a point is inside the bounding box
  74629. * @param point defines the point to test
  74630. * @returns true if the point is inside the bounding box
  74631. */
  74632. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74633. /**
  74634. * Tests if the bounding box intersects with a bounding sphere
  74635. * @param sphere defines the sphere to test
  74636. * @returns true if there is an intersection
  74637. */
  74638. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74639. /**
  74640. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74641. * @param min defines the min vector to use
  74642. * @param max defines the max vector to use
  74643. * @returns true if there is an intersection
  74644. */
  74645. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74646. /**
  74647. * Tests if two bounding boxes are intersections
  74648. * @param box0 defines the first box to test
  74649. * @param box1 defines the second box to test
  74650. * @returns true if there is an intersection
  74651. */
  74652. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74653. /**
  74654. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74655. * @param minPoint defines the minimum vector of the bounding box
  74656. * @param maxPoint defines the maximum vector of the bounding box
  74657. * @param sphereCenter defines the sphere center
  74658. * @param sphereRadius defines the sphere radius
  74659. * @returns true if there is an intersection
  74660. */
  74661. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74662. /**
  74663. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74664. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74665. * @param frustumPlanes defines the frustum planes to test
  74666. * @return true if there is an inclusion
  74667. */
  74668. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74669. /**
  74670. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74671. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74672. * @param frustumPlanes defines the frustum planes to test
  74673. * @return true if there is an intersection
  74674. */
  74675. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74676. }
  74677. }
  74678. declare module BABYLON {
  74679. /** @hidden */
  74680. export class Collider {
  74681. /** Define if a collision was found */
  74682. collisionFound: boolean;
  74683. /**
  74684. * Define last intersection point in local space
  74685. */
  74686. intersectionPoint: Vector3;
  74687. /**
  74688. * Define last collided mesh
  74689. */
  74690. collidedMesh: Nullable<AbstractMesh>;
  74691. private _collisionPoint;
  74692. private _planeIntersectionPoint;
  74693. private _tempVector;
  74694. private _tempVector2;
  74695. private _tempVector3;
  74696. private _tempVector4;
  74697. private _edge;
  74698. private _baseToVertex;
  74699. private _destinationPoint;
  74700. private _slidePlaneNormal;
  74701. private _displacementVector;
  74702. /** @hidden */
  74703. _radius: Vector3;
  74704. /** @hidden */
  74705. _retry: number;
  74706. private _velocity;
  74707. private _basePoint;
  74708. private _epsilon;
  74709. /** @hidden */
  74710. _velocityWorldLength: number;
  74711. /** @hidden */
  74712. _basePointWorld: Vector3;
  74713. private _velocityWorld;
  74714. private _normalizedVelocity;
  74715. /** @hidden */
  74716. _initialVelocity: Vector3;
  74717. /** @hidden */
  74718. _initialPosition: Vector3;
  74719. private _nearestDistance;
  74720. private _collisionMask;
  74721. collisionMask: number;
  74722. /**
  74723. * Gets the plane normal used to compute the sliding response (in local space)
  74724. */
  74725. readonly slidePlaneNormal: Vector3;
  74726. /** @hidden */
  74727. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74728. /** @hidden */
  74729. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74730. /** @hidden */
  74731. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74732. /** @hidden */
  74733. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74734. /** @hidden */
  74735. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74736. /** @hidden */
  74737. _getResponse(pos: Vector3, vel: Vector3): void;
  74738. }
  74739. }
  74740. declare module BABYLON {
  74741. /**
  74742. * Interface for cullable objects
  74743. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74744. */
  74745. export interface ICullable {
  74746. /**
  74747. * Checks if the object or part of the object is in the frustum
  74748. * @param frustumPlanes Camera near/planes
  74749. * @returns true if the object is in frustum otherwise false
  74750. */
  74751. isInFrustum(frustumPlanes: Plane[]): boolean;
  74752. /**
  74753. * Checks if a cullable object (mesh...) is in the camera frustum
  74754. * Unlike isInFrustum this cheks the full bounding box
  74755. * @param frustumPlanes Camera near/planes
  74756. * @returns true if the object is in frustum otherwise false
  74757. */
  74758. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74759. }
  74760. /**
  74761. * Info for a bounding data of a mesh
  74762. */
  74763. export class BoundingInfo implements ICullable {
  74764. /**
  74765. * Bounding box for the mesh
  74766. */
  74767. readonly boundingBox: BoundingBox;
  74768. /**
  74769. * Bounding sphere for the mesh
  74770. */
  74771. readonly boundingSphere: BoundingSphere;
  74772. private _isLocked;
  74773. private static readonly TmpVector3;
  74774. /**
  74775. * Constructs bounding info
  74776. * @param minimum min vector of the bounding box/sphere
  74777. * @param maximum max vector of the bounding box/sphere
  74778. * @param worldMatrix defines the new world matrix
  74779. */
  74780. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74781. /**
  74782. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74783. * @param min defines the new minimum vector (in local space)
  74784. * @param max defines the new maximum vector (in local space)
  74785. * @param worldMatrix defines the new world matrix
  74786. */
  74787. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74788. /**
  74789. * min vector of the bounding box/sphere
  74790. */
  74791. readonly minimum: Vector3;
  74792. /**
  74793. * max vector of the bounding box/sphere
  74794. */
  74795. readonly maximum: Vector3;
  74796. /**
  74797. * If the info is locked and won't be updated to avoid perf overhead
  74798. */
  74799. isLocked: boolean;
  74800. /**
  74801. * Updates the bounding sphere and box
  74802. * @param world world matrix to be used to update
  74803. */
  74804. update(world: DeepImmutable<Matrix>): void;
  74805. /**
  74806. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74807. * @param center New center of the bounding info
  74808. * @param extend New extend of the bounding info
  74809. * @returns the current bounding info
  74810. */
  74811. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74812. /**
  74813. * Scale the current bounding info by applying a scale factor
  74814. * @param factor defines the scale factor to apply
  74815. * @returns the current bounding info
  74816. */
  74817. scale(factor: number): BoundingInfo;
  74818. /**
  74819. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74820. * @param frustumPlanes defines the frustum to test
  74821. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74822. * @returns true if the bounding info is in the frustum planes
  74823. */
  74824. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74825. /**
  74826. * Gets the world distance between the min and max points of the bounding box
  74827. */
  74828. readonly diagonalLength: number;
  74829. /**
  74830. * Checks if a cullable object (mesh...) is in the camera frustum
  74831. * Unlike isInFrustum this cheks the full bounding box
  74832. * @param frustumPlanes Camera near/planes
  74833. * @returns true if the object is in frustum otherwise false
  74834. */
  74835. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74836. /** @hidden */
  74837. _checkCollision(collider: Collider): boolean;
  74838. /**
  74839. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74840. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74841. * @param point the point to check intersection with
  74842. * @returns if the point intersects
  74843. */
  74844. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74845. /**
  74846. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74847. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74848. * @param boundingInfo the bounding info to check intersection with
  74849. * @param precise if the intersection should be done using OBB
  74850. * @returns if the bounding info intersects
  74851. */
  74852. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74853. }
  74854. }
  74855. declare module BABYLON {
  74856. /**
  74857. * Extracts minimum and maximum values from a list of indexed positions
  74858. * @param positions defines the positions to use
  74859. * @param indices defines the indices to the positions
  74860. * @param indexStart defines the start index
  74861. * @param indexCount defines the end index
  74862. * @param bias defines bias value to add to the result
  74863. * @return minimum and maximum values
  74864. */
  74865. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74866. minimum: Vector3;
  74867. maximum: Vector3;
  74868. };
  74869. /**
  74870. * Extracts minimum and maximum values from a list of positions
  74871. * @param positions defines the positions to use
  74872. * @param start defines the start index in the positions array
  74873. * @param count defines the number of positions to handle
  74874. * @param bias defines bias value to add to the result
  74875. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74876. * @return minimum and maximum values
  74877. */
  74878. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74879. minimum: Vector3;
  74880. maximum: Vector3;
  74881. };
  74882. }
  74883. declare module BABYLON {
  74884. /** @hidden */
  74885. export class WebGLDataBuffer extends DataBuffer {
  74886. private _buffer;
  74887. constructor(resource: WebGLBuffer);
  74888. readonly underlyingResource: any;
  74889. }
  74890. }
  74891. declare module BABYLON {
  74892. /** @hidden */
  74893. export class WebGLPipelineContext implements IPipelineContext {
  74894. engine: ThinEngine;
  74895. program: Nullable<WebGLProgram>;
  74896. context?: WebGLRenderingContext;
  74897. vertexShader?: WebGLShader;
  74898. fragmentShader?: WebGLShader;
  74899. isParallelCompiled: boolean;
  74900. onCompiled?: () => void;
  74901. transformFeedback?: WebGLTransformFeedback | null;
  74902. readonly isAsync: boolean;
  74903. readonly isReady: boolean;
  74904. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74905. }
  74906. }
  74907. declare module BABYLON {
  74908. interface ThinEngine {
  74909. /**
  74910. * Create an uniform buffer
  74911. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74912. * @param elements defines the content of the uniform buffer
  74913. * @returns the webGL uniform buffer
  74914. */
  74915. createUniformBuffer(elements: FloatArray): DataBuffer;
  74916. /**
  74917. * Create a dynamic uniform buffer
  74918. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74919. * @param elements defines the content of the uniform buffer
  74920. * @returns the webGL uniform buffer
  74921. */
  74922. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74923. /**
  74924. * Update an existing uniform buffer
  74925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74926. * @param uniformBuffer defines the target uniform buffer
  74927. * @param elements defines the content to update
  74928. * @param offset defines the offset in the uniform buffer where update should start
  74929. * @param count defines the size of the data to update
  74930. */
  74931. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74932. /**
  74933. * Bind an uniform buffer to the current webGL context
  74934. * @param buffer defines the buffer to bind
  74935. */
  74936. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74937. /**
  74938. * Bind a buffer to the current webGL context at a given location
  74939. * @param buffer defines the buffer to bind
  74940. * @param location defines the index where to bind the buffer
  74941. */
  74942. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74943. /**
  74944. * Bind a specific block at a given index in a specific shader program
  74945. * @param pipelineContext defines the pipeline context to use
  74946. * @param blockName defines the block name
  74947. * @param index defines the index where to bind the block
  74948. */
  74949. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74950. }
  74951. }
  74952. declare module BABYLON {
  74953. /**
  74954. * Uniform buffer objects.
  74955. *
  74956. * Handles blocks of uniform on the GPU.
  74957. *
  74958. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74959. *
  74960. * For more information, please refer to :
  74961. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74962. */
  74963. export class UniformBuffer {
  74964. private _engine;
  74965. private _buffer;
  74966. private _data;
  74967. private _bufferData;
  74968. private _dynamic?;
  74969. private _uniformLocations;
  74970. private _uniformSizes;
  74971. private _uniformLocationPointer;
  74972. private _needSync;
  74973. private _noUBO;
  74974. private _currentEffect;
  74975. /** @hidden */
  74976. _alreadyBound: boolean;
  74977. private static _MAX_UNIFORM_SIZE;
  74978. private static _tempBuffer;
  74979. /**
  74980. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74981. * This is dynamic to allow compat with webgl 1 and 2.
  74982. * You will need to pass the name of the uniform as well as the value.
  74983. */
  74984. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74985. /**
  74986. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74987. * This is dynamic to allow compat with webgl 1 and 2.
  74988. * You will need to pass the name of the uniform as well as the value.
  74989. */
  74990. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74991. /**
  74992. * Lambda to Update a single float in a uniform buffer.
  74993. * This is dynamic to allow compat with webgl 1 and 2.
  74994. * You will need to pass the name of the uniform as well as the value.
  74995. */
  74996. updateFloat: (name: string, x: number) => void;
  74997. /**
  74998. * Lambda to Update a vec2 of float in a uniform buffer.
  74999. * This is dynamic to allow compat with webgl 1 and 2.
  75000. * You will need to pass the name of the uniform as well as the value.
  75001. */
  75002. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75003. /**
  75004. * Lambda to Update a vec3 of float in a uniform buffer.
  75005. * This is dynamic to allow compat with webgl 1 and 2.
  75006. * You will need to pass the name of the uniform as well as the value.
  75007. */
  75008. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75009. /**
  75010. * Lambda to Update a vec4 of float in a uniform buffer.
  75011. * This is dynamic to allow compat with webgl 1 and 2.
  75012. * You will need to pass the name of the uniform as well as the value.
  75013. */
  75014. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75015. /**
  75016. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75017. * This is dynamic to allow compat with webgl 1 and 2.
  75018. * You will need to pass the name of the uniform as well as the value.
  75019. */
  75020. updateMatrix: (name: string, mat: Matrix) => void;
  75021. /**
  75022. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75023. * This is dynamic to allow compat with webgl 1 and 2.
  75024. * You will need to pass the name of the uniform as well as the value.
  75025. */
  75026. updateVector3: (name: string, vector: Vector3) => void;
  75027. /**
  75028. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75029. * This is dynamic to allow compat with webgl 1 and 2.
  75030. * You will need to pass the name of the uniform as well as the value.
  75031. */
  75032. updateVector4: (name: string, vector: Vector4) => void;
  75033. /**
  75034. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75035. * This is dynamic to allow compat with webgl 1 and 2.
  75036. * You will need to pass the name of the uniform as well as the value.
  75037. */
  75038. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75039. /**
  75040. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75041. * This is dynamic to allow compat with webgl 1 and 2.
  75042. * You will need to pass the name of the uniform as well as the value.
  75043. */
  75044. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75045. /**
  75046. * Instantiates a new Uniform buffer objects.
  75047. *
  75048. * Handles blocks of uniform on the GPU.
  75049. *
  75050. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75051. *
  75052. * For more information, please refer to :
  75053. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75054. * @param engine Define the engine the buffer is associated with
  75055. * @param data Define the data contained in the buffer
  75056. * @param dynamic Define if the buffer is updatable
  75057. */
  75058. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75059. /**
  75060. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75061. * or just falling back on setUniformXXX calls.
  75062. */
  75063. readonly useUbo: boolean;
  75064. /**
  75065. * Indicates if the WebGL underlying uniform buffer is in sync
  75066. * with the javascript cache data.
  75067. */
  75068. readonly isSync: boolean;
  75069. /**
  75070. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75071. * Also, a dynamic UniformBuffer will disable cache verification and always
  75072. * update the underlying WebGL uniform buffer to the GPU.
  75073. * @returns if Dynamic, otherwise false
  75074. */
  75075. isDynamic(): boolean;
  75076. /**
  75077. * The data cache on JS side.
  75078. * @returns the underlying data as a float array
  75079. */
  75080. getData(): Float32Array;
  75081. /**
  75082. * The underlying WebGL Uniform buffer.
  75083. * @returns the webgl buffer
  75084. */
  75085. getBuffer(): Nullable<DataBuffer>;
  75086. /**
  75087. * std140 layout specifies how to align data within an UBO structure.
  75088. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75089. * for specs.
  75090. */
  75091. private _fillAlignment;
  75092. /**
  75093. * Adds an uniform in the buffer.
  75094. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75095. * for the layout to be correct !
  75096. * @param name Name of the uniform, as used in the uniform block in the shader.
  75097. * @param size Data size, or data directly.
  75098. */
  75099. addUniform(name: string, size: number | number[]): void;
  75100. /**
  75101. * Adds a Matrix 4x4 to the uniform buffer.
  75102. * @param name Name of the uniform, as used in the uniform block in the shader.
  75103. * @param mat A 4x4 matrix.
  75104. */
  75105. addMatrix(name: string, mat: Matrix): void;
  75106. /**
  75107. * Adds a vec2 to the uniform buffer.
  75108. * @param name Name of the uniform, as used in the uniform block in the shader.
  75109. * @param x Define the x component value of the vec2
  75110. * @param y Define the y component value of the vec2
  75111. */
  75112. addFloat2(name: string, x: number, y: number): void;
  75113. /**
  75114. * Adds a vec3 to the uniform buffer.
  75115. * @param name Name of the uniform, as used in the uniform block in the shader.
  75116. * @param x Define the x component value of the vec3
  75117. * @param y Define the y component value of the vec3
  75118. * @param z Define the z component value of the vec3
  75119. */
  75120. addFloat3(name: string, x: number, y: number, z: number): void;
  75121. /**
  75122. * Adds a vec3 to the uniform buffer.
  75123. * @param name Name of the uniform, as used in the uniform block in the shader.
  75124. * @param color Define the vec3 from a Color
  75125. */
  75126. addColor3(name: string, color: Color3): void;
  75127. /**
  75128. * Adds a vec4 to the uniform buffer.
  75129. * @param name Name of the uniform, as used in the uniform block in the shader.
  75130. * @param color Define the rgb components from a Color
  75131. * @param alpha Define the a component of the vec4
  75132. */
  75133. addColor4(name: string, color: Color3, alpha: number): void;
  75134. /**
  75135. * Adds a vec3 to the uniform buffer.
  75136. * @param name Name of the uniform, as used in the uniform block in the shader.
  75137. * @param vector Define the vec3 components from a Vector
  75138. */
  75139. addVector3(name: string, vector: Vector3): void;
  75140. /**
  75141. * Adds a Matrix 3x3 to the uniform buffer.
  75142. * @param name Name of the uniform, as used in the uniform block in the shader.
  75143. */
  75144. addMatrix3x3(name: string): void;
  75145. /**
  75146. * Adds a Matrix 2x2 to the uniform buffer.
  75147. * @param name Name of the uniform, as used in the uniform block in the shader.
  75148. */
  75149. addMatrix2x2(name: string): void;
  75150. /**
  75151. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75152. */
  75153. create(): void;
  75154. /** @hidden */
  75155. _rebuild(): void;
  75156. /**
  75157. * Updates the WebGL Uniform Buffer on the GPU.
  75158. * If the `dynamic` flag is set to true, no cache comparison is done.
  75159. * Otherwise, the buffer will be updated only if the cache differs.
  75160. */
  75161. update(): void;
  75162. /**
  75163. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75164. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75165. * @param data Define the flattened data
  75166. * @param size Define the size of the data.
  75167. */
  75168. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75169. private _valueCache;
  75170. private _cacheMatrix;
  75171. private _updateMatrix3x3ForUniform;
  75172. private _updateMatrix3x3ForEffect;
  75173. private _updateMatrix2x2ForEffect;
  75174. private _updateMatrix2x2ForUniform;
  75175. private _updateFloatForEffect;
  75176. private _updateFloatForUniform;
  75177. private _updateFloat2ForEffect;
  75178. private _updateFloat2ForUniform;
  75179. private _updateFloat3ForEffect;
  75180. private _updateFloat3ForUniform;
  75181. private _updateFloat4ForEffect;
  75182. private _updateFloat4ForUniform;
  75183. private _updateMatrixForEffect;
  75184. private _updateMatrixForUniform;
  75185. private _updateVector3ForEffect;
  75186. private _updateVector3ForUniform;
  75187. private _updateVector4ForEffect;
  75188. private _updateVector4ForUniform;
  75189. private _updateColor3ForEffect;
  75190. private _updateColor3ForUniform;
  75191. private _updateColor4ForEffect;
  75192. private _updateColor4ForUniform;
  75193. /**
  75194. * Sets a sampler uniform on the effect.
  75195. * @param name Define the name of the sampler.
  75196. * @param texture Define the texture to set in the sampler
  75197. */
  75198. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75199. /**
  75200. * Directly updates the value of the uniform in the cache AND on the GPU.
  75201. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75202. * @param data Define the flattened data
  75203. */
  75204. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75205. /**
  75206. * Binds this uniform buffer to an effect.
  75207. * @param effect Define the effect to bind the buffer to
  75208. * @param name Name of the uniform block in the shader.
  75209. */
  75210. bindToEffect(effect: Effect, name: string): void;
  75211. /**
  75212. * Disposes the uniform buffer.
  75213. */
  75214. dispose(): void;
  75215. }
  75216. }
  75217. declare module BABYLON {
  75218. /**
  75219. * Enum that determines the text-wrapping mode to use.
  75220. */
  75221. export enum InspectableType {
  75222. /**
  75223. * Checkbox for booleans
  75224. */
  75225. Checkbox = 0,
  75226. /**
  75227. * Sliders for numbers
  75228. */
  75229. Slider = 1,
  75230. /**
  75231. * Vector3
  75232. */
  75233. Vector3 = 2,
  75234. /**
  75235. * Quaternions
  75236. */
  75237. Quaternion = 3,
  75238. /**
  75239. * Color3
  75240. */
  75241. Color3 = 4,
  75242. /**
  75243. * String
  75244. */
  75245. String = 5
  75246. }
  75247. /**
  75248. * Interface used to define custom inspectable properties.
  75249. * This interface is used by the inspector to display custom property grids
  75250. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75251. */
  75252. export interface IInspectable {
  75253. /**
  75254. * Gets the label to display
  75255. */
  75256. label: string;
  75257. /**
  75258. * Gets the name of the property to edit
  75259. */
  75260. propertyName: string;
  75261. /**
  75262. * Gets the type of the editor to use
  75263. */
  75264. type: InspectableType;
  75265. /**
  75266. * Gets the minimum value of the property when using in "slider" mode
  75267. */
  75268. min?: number;
  75269. /**
  75270. * Gets the maximum value of the property when using in "slider" mode
  75271. */
  75272. max?: number;
  75273. /**
  75274. * Gets the setp to use when using in "slider" mode
  75275. */
  75276. step?: number;
  75277. }
  75278. }
  75279. declare module BABYLON {
  75280. /**
  75281. * Class used to provide helper for timing
  75282. */
  75283. export class TimingTools {
  75284. /**
  75285. * Polyfill for setImmediate
  75286. * @param action defines the action to execute after the current execution block
  75287. */
  75288. static SetImmediate(action: () => void): void;
  75289. }
  75290. }
  75291. declare module BABYLON {
  75292. /**
  75293. * Class used to enable instatition of objects by class name
  75294. */
  75295. export class InstantiationTools {
  75296. /**
  75297. * Use this object to register external classes like custom textures or material
  75298. * to allow the laoders to instantiate them
  75299. */
  75300. static RegisteredExternalClasses: {
  75301. [key: string]: Object;
  75302. };
  75303. /**
  75304. * Tries to instantiate a new object from a given class name
  75305. * @param className defines the class name to instantiate
  75306. * @returns the new object or null if the system was not able to do the instantiation
  75307. */
  75308. static Instantiate(className: string): any;
  75309. }
  75310. }
  75311. declare module BABYLON {
  75312. /**
  75313. * Define options used to create a depth texture
  75314. */
  75315. export class DepthTextureCreationOptions {
  75316. /** Specifies whether or not a stencil should be allocated in the texture */
  75317. generateStencil?: boolean;
  75318. /** Specifies whether or not bilinear filtering is enable on the texture */
  75319. bilinearFiltering?: boolean;
  75320. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75321. comparisonFunction?: number;
  75322. /** Specifies if the created texture is a cube texture */
  75323. isCube?: boolean;
  75324. }
  75325. }
  75326. declare module BABYLON {
  75327. interface ThinEngine {
  75328. /**
  75329. * Creates a depth stencil cube texture.
  75330. * This is only available in WebGL 2.
  75331. * @param size The size of face edge in the cube texture.
  75332. * @param options The options defining the cube texture.
  75333. * @returns The cube texture
  75334. */
  75335. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75336. /**
  75337. * Creates a cube texture
  75338. * @param rootUrl defines the url where the files to load is located
  75339. * @param scene defines the current scene
  75340. * @param files defines the list of files to load (1 per face)
  75341. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75342. * @param onLoad defines an optional callback raised when the texture is loaded
  75343. * @param onError defines an optional callback raised if there is an issue to load the texture
  75344. * @param format defines the format of the data
  75345. * @param forcedExtension defines the extension to use to pick the right loader
  75346. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75347. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75348. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75349. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75350. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75351. * @returns the cube texture as an InternalTexture
  75352. */
  75353. 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;
  75354. /**
  75355. * Creates a cube texture
  75356. * @param rootUrl defines the url where the files to load is located
  75357. * @param scene defines the current scene
  75358. * @param files defines the list of files to load (1 per face)
  75359. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75360. * @param onLoad defines an optional callback raised when the texture is loaded
  75361. * @param onError defines an optional callback raised if there is an issue to load the texture
  75362. * @param format defines the format of the data
  75363. * @param forcedExtension defines the extension to use to pick the right loader
  75364. * @returns the cube texture as an InternalTexture
  75365. */
  75366. 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;
  75367. /**
  75368. * Creates a cube texture
  75369. * @param rootUrl defines the url where the files to load is located
  75370. * @param scene defines the current scene
  75371. * @param files defines the list of files to load (1 per face)
  75372. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75373. * @param onLoad defines an optional callback raised when the texture is loaded
  75374. * @param onError defines an optional callback raised if there is an issue to load the texture
  75375. * @param format defines the format of the data
  75376. * @param forcedExtension defines the extension to use to pick the right loader
  75377. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75378. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75379. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75380. * @returns the cube texture as an InternalTexture
  75381. */
  75382. 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;
  75383. /** @hidden */
  75384. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75385. /** @hidden */
  75386. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75387. /** @hidden */
  75388. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75389. /** @hidden */
  75390. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75391. /**
  75392. * @hidden
  75393. */
  75394. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75395. }
  75396. }
  75397. declare module BABYLON {
  75398. /**
  75399. * Class for creating a cube texture
  75400. */
  75401. export class CubeTexture extends BaseTexture {
  75402. private _delayedOnLoad;
  75403. /**
  75404. * The url of the texture
  75405. */
  75406. url: string;
  75407. /**
  75408. * Gets or sets the center of the bounding box associated with the cube texture.
  75409. * It must define where the camera used to render the texture was set
  75410. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75411. */
  75412. boundingBoxPosition: Vector3;
  75413. private _boundingBoxSize;
  75414. /**
  75415. * Gets or sets the size of the bounding box associated with the cube texture
  75416. * When defined, the cubemap will switch to local mode
  75417. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75418. * @example https://www.babylonjs-playground.com/#RNASML
  75419. */
  75420. /**
  75421. * Returns the bounding box size
  75422. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75423. */
  75424. boundingBoxSize: Vector3;
  75425. protected _rotationY: number;
  75426. /**
  75427. * Sets texture matrix rotation angle around Y axis in radians.
  75428. */
  75429. /**
  75430. * Gets texture matrix rotation angle around Y axis radians.
  75431. */
  75432. rotationY: number;
  75433. /**
  75434. * Are mip maps generated for this texture or not.
  75435. */
  75436. readonly noMipmap: boolean;
  75437. private _noMipmap;
  75438. private _files;
  75439. protected _forcedExtension: Nullable<string>;
  75440. private _extensions;
  75441. private _textureMatrix;
  75442. private _format;
  75443. private _createPolynomials;
  75444. /** @hidden */
  75445. _prefiltered: boolean;
  75446. /**
  75447. * Creates a cube texture from an array of image urls
  75448. * @param files defines an array of image urls
  75449. * @param scene defines the hosting scene
  75450. * @param noMipmap specifies if mip maps are not used
  75451. * @returns a cube texture
  75452. */
  75453. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75454. /**
  75455. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75456. * @param url defines the url of the prefiltered texture
  75457. * @param scene defines the scene the texture is attached to
  75458. * @param forcedExtension defines the extension of the file if different from the url
  75459. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75460. * @return the prefiltered texture
  75461. */
  75462. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75463. /**
  75464. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75465. * as prefiltered data.
  75466. * @param rootUrl defines the url of the texture or the root name of the six images
  75467. * @param scene defines the scene the texture is attached to
  75468. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75469. * @param noMipmap defines if mipmaps should be created or not
  75470. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75471. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75472. * @param onError defines a callback triggered in case of error during load
  75473. * @param format defines the internal format to use for the texture once loaded
  75474. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75475. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75476. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75477. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75478. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75479. * @return the cube texture
  75480. */
  75481. 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);
  75482. /**
  75483. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75484. */
  75485. readonly isPrefiltered: boolean;
  75486. /**
  75487. * Get the current class name of the texture useful for serialization or dynamic coding.
  75488. * @returns "CubeTexture"
  75489. */
  75490. getClassName(): string;
  75491. /**
  75492. * Update the url (and optional buffer) of this texture if url was null during construction.
  75493. * @param url the url of the texture
  75494. * @param forcedExtension defines the extension to use
  75495. * @param onLoad callback called when the texture is loaded (defaults to null)
  75496. */
  75497. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75498. /**
  75499. * Delays loading of the cube texture
  75500. * @param forcedExtension defines the extension to use
  75501. */
  75502. delayLoad(forcedExtension?: string): void;
  75503. /**
  75504. * Returns the reflection texture matrix
  75505. * @returns the reflection texture matrix
  75506. */
  75507. getReflectionTextureMatrix(): Matrix;
  75508. /**
  75509. * Sets the reflection texture matrix
  75510. * @param value Reflection texture matrix
  75511. */
  75512. setReflectionTextureMatrix(value: Matrix): void;
  75513. /**
  75514. * Parses text to create a cube texture
  75515. * @param parsedTexture define the serialized text to read from
  75516. * @param scene defines the hosting scene
  75517. * @param rootUrl defines the root url of the cube texture
  75518. * @returns a cube texture
  75519. */
  75520. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75521. /**
  75522. * Makes a clone, or deep copy, of the cube texture
  75523. * @returns a new cube texture
  75524. */
  75525. clone(): CubeTexture;
  75526. }
  75527. }
  75528. declare module BABYLON {
  75529. /**
  75530. * Manages the defines for the Material
  75531. */
  75532. export class MaterialDefines {
  75533. /** @hidden */
  75534. protected _keys: string[];
  75535. private _isDirty;
  75536. /** @hidden */
  75537. _renderId: number;
  75538. /** @hidden */
  75539. _areLightsDirty: boolean;
  75540. /** @hidden */
  75541. _areLightsDisposed: boolean;
  75542. /** @hidden */
  75543. _areAttributesDirty: boolean;
  75544. /** @hidden */
  75545. _areTexturesDirty: boolean;
  75546. /** @hidden */
  75547. _areFresnelDirty: boolean;
  75548. /** @hidden */
  75549. _areMiscDirty: boolean;
  75550. /** @hidden */
  75551. _areImageProcessingDirty: boolean;
  75552. /** @hidden */
  75553. _normals: boolean;
  75554. /** @hidden */
  75555. _uvs: boolean;
  75556. /** @hidden */
  75557. _needNormals: boolean;
  75558. /** @hidden */
  75559. _needUVs: boolean;
  75560. [id: string]: any;
  75561. /**
  75562. * Specifies if the material needs to be re-calculated
  75563. */
  75564. readonly isDirty: boolean;
  75565. /**
  75566. * Marks the material to indicate that it has been re-calculated
  75567. */
  75568. markAsProcessed(): void;
  75569. /**
  75570. * Marks the material to indicate that it needs to be re-calculated
  75571. */
  75572. markAsUnprocessed(): void;
  75573. /**
  75574. * Marks the material to indicate all of its defines need to be re-calculated
  75575. */
  75576. markAllAsDirty(): void;
  75577. /**
  75578. * Marks the material to indicate that image processing needs to be re-calculated
  75579. */
  75580. markAsImageProcessingDirty(): void;
  75581. /**
  75582. * Marks the material to indicate the lights need to be re-calculated
  75583. * @param disposed Defines whether the light is dirty due to dispose or not
  75584. */
  75585. markAsLightDirty(disposed?: boolean): void;
  75586. /**
  75587. * Marks the attribute state as changed
  75588. */
  75589. markAsAttributesDirty(): void;
  75590. /**
  75591. * Marks the texture state as changed
  75592. */
  75593. markAsTexturesDirty(): void;
  75594. /**
  75595. * Marks the fresnel state as changed
  75596. */
  75597. markAsFresnelDirty(): void;
  75598. /**
  75599. * Marks the misc state as changed
  75600. */
  75601. markAsMiscDirty(): void;
  75602. /**
  75603. * Rebuilds the material defines
  75604. */
  75605. rebuild(): void;
  75606. /**
  75607. * Specifies if two material defines are equal
  75608. * @param other - A material define instance to compare to
  75609. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75610. */
  75611. isEqual(other: MaterialDefines): boolean;
  75612. /**
  75613. * Clones this instance's defines to another instance
  75614. * @param other - material defines to clone values to
  75615. */
  75616. cloneTo(other: MaterialDefines): void;
  75617. /**
  75618. * Resets the material define values
  75619. */
  75620. reset(): void;
  75621. /**
  75622. * Converts the material define values to a string
  75623. * @returns - String of material define information
  75624. */
  75625. toString(): string;
  75626. }
  75627. }
  75628. declare module BABYLON {
  75629. /**
  75630. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75631. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75632. * 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;
  75633. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75634. */
  75635. export class ColorCurves {
  75636. private _dirty;
  75637. private _tempColor;
  75638. private _globalCurve;
  75639. private _highlightsCurve;
  75640. private _midtonesCurve;
  75641. private _shadowsCurve;
  75642. private _positiveCurve;
  75643. private _negativeCurve;
  75644. private _globalHue;
  75645. private _globalDensity;
  75646. private _globalSaturation;
  75647. private _globalExposure;
  75648. /**
  75649. * Gets the global Hue value.
  75650. * 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).
  75651. */
  75652. /**
  75653. * Sets the global Hue value.
  75654. * 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).
  75655. */
  75656. globalHue: number;
  75657. /**
  75658. * Gets the global Density value.
  75659. * 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.
  75660. * Values less than zero provide a filter of opposite hue.
  75661. */
  75662. /**
  75663. * Sets the global Density value.
  75664. * 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.
  75665. * Values less than zero provide a filter of opposite hue.
  75666. */
  75667. globalDensity: number;
  75668. /**
  75669. * Gets the global Saturation value.
  75670. * 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.
  75671. */
  75672. /**
  75673. * Sets the global Saturation value.
  75674. * 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.
  75675. */
  75676. globalSaturation: number;
  75677. /**
  75678. * Gets the global Exposure value.
  75679. * 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.
  75680. */
  75681. /**
  75682. * Sets the global Exposure value.
  75683. * 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.
  75684. */
  75685. globalExposure: number;
  75686. private _highlightsHue;
  75687. private _highlightsDensity;
  75688. private _highlightsSaturation;
  75689. private _highlightsExposure;
  75690. /**
  75691. * Gets the highlights Hue value.
  75692. * 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).
  75693. */
  75694. /**
  75695. * Sets the highlights Hue value.
  75696. * 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).
  75697. */
  75698. highlightsHue: number;
  75699. /**
  75700. * Gets the highlights Density value.
  75701. * 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.
  75702. * Values less than zero provide a filter of opposite hue.
  75703. */
  75704. /**
  75705. * Sets the highlights Density value.
  75706. * 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.
  75707. * Values less than zero provide a filter of opposite hue.
  75708. */
  75709. highlightsDensity: number;
  75710. /**
  75711. * Gets the highlights Saturation value.
  75712. * 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.
  75713. */
  75714. /**
  75715. * Sets the highlights Saturation value.
  75716. * 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.
  75717. */
  75718. highlightsSaturation: number;
  75719. /**
  75720. * Gets the highlights Exposure value.
  75721. * 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.
  75722. */
  75723. /**
  75724. * Sets the highlights Exposure value.
  75725. * 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.
  75726. */
  75727. highlightsExposure: number;
  75728. private _midtonesHue;
  75729. private _midtonesDensity;
  75730. private _midtonesSaturation;
  75731. private _midtonesExposure;
  75732. /**
  75733. * Gets the midtones Hue value.
  75734. * 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).
  75735. */
  75736. /**
  75737. * Sets the midtones Hue value.
  75738. * 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).
  75739. */
  75740. midtonesHue: number;
  75741. /**
  75742. * Gets the midtones Density value.
  75743. * 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.
  75744. * Values less than zero provide a filter of opposite hue.
  75745. */
  75746. /**
  75747. * Sets the midtones Density value.
  75748. * 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.
  75749. * Values less than zero provide a filter of opposite hue.
  75750. */
  75751. midtonesDensity: number;
  75752. /**
  75753. * Gets the midtones Saturation value.
  75754. * 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.
  75755. */
  75756. /**
  75757. * Sets the midtones Saturation value.
  75758. * 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.
  75759. */
  75760. midtonesSaturation: number;
  75761. /**
  75762. * Gets the midtones Exposure value.
  75763. * 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.
  75764. */
  75765. /**
  75766. * Sets the midtones Exposure value.
  75767. * 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.
  75768. */
  75769. midtonesExposure: number;
  75770. private _shadowsHue;
  75771. private _shadowsDensity;
  75772. private _shadowsSaturation;
  75773. private _shadowsExposure;
  75774. /**
  75775. * Gets the shadows Hue value.
  75776. * 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).
  75777. */
  75778. /**
  75779. * Sets the shadows Hue value.
  75780. * 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).
  75781. */
  75782. shadowsHue: number;
  75783. /**
  75784. * Gets the shadows Density value.
  75785. * 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.
  75786. * Values less than zero provide a filter of opposite hue.
  75787. */
  75788. /**
  75789. * Sets the shadows Density value.
  75790. * 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.
  75791. * Values less than zero provide a filter of opposite hue.
  75792. */
  75793. shadowsDensity: number;
  75794. /**
  75795. * Gets the shadows Saturation value.
  75796. * 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.
  75797. */
  75798. /**
  75799. * Sets the shadows Saturation value.
  75800. * 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.
  75801. */
  75802. shadowsSaturation: number;
  75803. /**
  75804. * Gets the shadows Exposure value.
  75805. * 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.
  75806. */
  75807. /**
  75808. * Sets the shadows Exposure value.
  75809. * 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.
  75810. */
  75811. shadowsExposure: number;
  75812. /**
  75813. * Returns the class name
  75814. * @returns The class name
  75815. */
  75816. getClassName(): string;
  75817. /**
  75818. * Binds the color curves to the shader.
  75819. * @param colorCurves The color curve to bind
  75820. * @param effect The effect to bind to
  75821. * @param positiveUniform The positive uniform shader parameter
  75822. * @param neutralUniform The neutral uniform shader parameter
  75823. * @param negativeUniform The negative uniform shader parameter
  75824. */
  75825. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75826. /**
  75827. * Prepare the list of uniforms associated with the ColorCurves effects.
  75828. * @param uniformsList The list of uniforms used in the effect
  75829. */
  75830. static PrepareUniforms(uniformsList: string[]): void;
  75831. /**
  75832. * Returns color grading data based on a hue, density, saturation and exposure value.
  75833. * @param filterHue The hue of the color filter.
  75834. * @param filterDensity The density of the color filter.
  75835. * @param saturation The saturation.
  75836. * @param exposure The exposure.
  75837. * @param result The result data container.
  75838. */
  75839. private getColorGradingDataToRef;
  75840. /**
  75841. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75842. * @param value The input slider value in range [-100,100].
  75843. * @returns Adjusted value.
  75844. */
  75845. private static applyColorGradingSliderNonlinear;
  75846. /**
  75847. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75848. * @param hue The hue (H) input.
  75849. * @param saturation The saturation (S) input.
  75850. * @param brightness The brightness (B) input.
  75851. * @result An RGBA color represented as Vector4.
  75852. */
  75853. private static fromHSBToRef;
  75854. /**
  75855. * Returns a value clamped between min and max
  75856. * @param value The value to clamp
  75857. * @param min The minimum of value
  75858. * @param max The maximum of value
  75859. * @returns The clamped value.
  75860. */
  75861. private static clamp;
  75862. /**
  75863. * Clones the current color curve instance.
  75864. * @return The cloned curves
  75865. */
  75866. clone(): ColorCurves;
  75867. /**
  75868. * Serializes the current color curve instance to a json representation.
  75869. * @return a JSON representation
  75870. */
  75871. serialize(): any;
  75872. /**
  75873. * Parses the color curve from a json representation.
  75874. * @param source the JSON source to parse
  75875. * @return The parsed curves
  75876. */
  75877. static Parse(source: any): ColorCurves;
  75878. }
  75879. }
  75880. declare module BABYLON {
  75881. /**
  75882. * Interface to follow in your material defines to integrate easily the
  75883. * Image proccessing functions.
  75884. * @hidden
  75885. */
  75886. export interface IImageProcessingConfigurationDefines {
  75887. IMAGEPROCESSING: boolean;
  75888. VIGNETTE: boolean;
  75889. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75890. VIGNETTEBLENDMODEOPAQUE: boolean;
  75891. TONEMAPPING: boolean;
  75892. TONEMAPPING_ACES: boolean;
  75893. CONTRAST: boolean;
  75894. EXPOSURE: boolean;
  75895. COLORCURVES: boolean;
  75896. COLORGRADING: boolean;
  75897. COLORGRADING3D: boolean;
  75898. SAMPLER3DGREENDEPTH: boolean;
  75899. SAMPLER3DBGRMAP: boolean;
  75900. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75901. }
  75902. /**
  75903. * @hidden
  75904. */
  75905. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75906. IMAGEPROCESSING: boolean;
  75907. VIGNETTE: boolean;
  75908. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75909. VIGNETTEBLENDMODEOPAQUE: boolean;
  75910. TONEMAPPING: boolean;
  75911. TONEMAPPING_ACES: boolean;
  75912. CONTRAST: boolean;
  75913. COLORCURVES: boolean;
  75914. COLORGRADING: boolean;
  75915. COLORGRADING3D: boolean;
  75916. SAMPLER3DGREENDEPTH: boolean;
  75917. SAMPLER3DBGRMAP: boolean;
  75918. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75919. EXPOSURE: boolean;
  75920. constructor();
  75921. }
  75922. /**
  75923. * This groups together the common properties used for image processing either in direct forward pass
  75924. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75925. * or not.
  75926. */
  75927. export class ImageProcessingConfiguration {
  75928. /**
  75929. * Default tone mapping applied in BabylonJS.
  75930. */
  75931. static readonly TONEMAPPING_STANDARD: number;
  75932. /**
  75933. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75934. * to other engines rendering to increase portability.
  75935. */
  75936. static readonly TONEMAPPING_ACES: number;
  75937. /**
  75938. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75939. */
  75940. colorCurves: Nullable<ColorCurves>;
  75941. private _colorCurvesEnabled;
  75942. /**
  75943. * Gets wether the color curves effect is enabled.
  75944. */
  75945. /**
  75946. * Sets wether the color curves effect is enabled.
  75947. */
  75948. colorCurvesEnabled: boolean;
  75949. private _colorGradingTexture;
  75950. /**
  75951. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75952. */
  75953. /**
  75954. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75955. */
  75956. colorGradingTexture: Nullable<BaseTexture>;
  75957. private _colorGradingEnabled;
  75958. /**
  75959. * Gets wether the color grading effect is enabled.
  75960. */
  75961. /**
  75962. * Sets wether the color grading effect is enabled.
  75963. */
  75964. colorGradingEnabled: boolean;
  75965. private _colorGradingWithGreenDepth;
  75966. /**
  75967. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75968. */
  75969. /**
  75970. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75971. */
  75972. colorGradingWithGreenDepth: boolean;
  75973. private _colorGradingBGR;
  75974. /**
  75975. * Gets wether the color grading texture contains BGR values.
  75976. */
  75977. /**
  75978. * Sets wether the color grading texture contains BGR values.
  75979. */
  75980. colorGradingBGR: boolean;
  75981. /** @hidden */
  75982. _exposure: number;
  75983. /**
  75984. * Gets the Exposure used in the effect.
  75985. */
  75986. /**
  75987. * Sets the Exposure used in the effect.
  75988. */
  75989. exposure: number;
  75990. private _toneMappingEnabled;
  75991. /**
  75992. * Gets wether the tone mapping effect is enabled.
  75993. */
  75994. /**
  75995. * Sets wether the tone mapping effect is enabled.
  75996. */
  75997. toneMappingEnabled: boolean;
  75998. private _toneMappingType;
  75999. /**
  76000. * Gets the type of tone mapping effect.
  76001. */
  76002. /**
  76003. * Sets the type of tone mapping effect used in BabylonJS.
  76004. */
  76005. toneMappingType: number;
  76006. protected _contrast: number;
  76007. /**
  76008. * Gets the contrast used in the effect.
  76009. */
  76010. /**
  76011. * Sets the contrast used in the effect.
  76012. */
  76013. contrast: number;
  76014. /**
  76015. * Vignette stretch size.
  76016. */
  76017. vignetteStretch: number;
  76018. /**
  76019. * Vignette centre X Offset.
  76020. */
  76021. vignetteCentreX: number;
  76022. /**
  76023. * Vignette centre Y Offset.
  76024. */
  76025. vignetteCentreY: number;
  76026. /**
  76027. * Vignette weight or intensity of the vignette effect.
  76028. */
  76029. vignetteWeight: number;
  76030. /**
  76031. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76032. * if vignetteEnabled is set to true.
  76033. */
  76034. vignetteColor: Color4;
  76035. /**
  76036. * Camera field of view used by the Vignette effect.
  76037. */
  76038. vignetteCameraFov: number;
  76039. private _vignetteBlendMode;
  76040. /**
  76041. * Gets the vignette blend mode allowing different kind of effect.
  76042. */
  76043. /**
  76044. * Sets the vignette blend mode allowing different kind of effect.
  76045. */
  76046. vignetteBlendMode: number;
  76047. private _vignetteEnabled;
  76048. /**
  76049. * Gets wether the vignette effect is enabled.
  76050. */
  76051. /**
  76052. * Sets wether the vignette effect is enabled.
  76053. */
  76054. vignetteEnabled: boolean;
  76055. private _applyByPostProcess;
  76056. /**
  76057. * Gets wether the image processing is applied through a post process or not.
  76058. */
  76059. /**
  76060. * Sets wether the image processing is applied through a post process or not.
  76061. */
  76062. applyByPostProcess: boolean;
  76063. private _isEnabled;
  76064. /**
  76065. * Gets wether the image processing is enabled or not.
  76066. */
  76067. /**
  76068. * Sets wether the image processing is enabled or not.
  76069. */
  76070. isEnabled: boolean;
  76071. /**
  76072. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76073. */
  76074. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76075. /**
  76076. * Method called each time the image processing information changes requires to recompile the effect.
  76077. */
  76078. protected _updateParameters(): void;
  76079. /**
  76080. * Gets the current class name.
  76081. * @return "ImageProcessingConfiguration"
  76082. */
  76083. getClassName(): string;
  76084. /**
  76085. * Prepare the list of uniforms associated with the Image Processing effects.
  76086. * @param uniforms The list of uniforms used in the effect
  76087. * @param defines the list of defines currently in use
  76088. */
  76089. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76090. /**
  76091. * Prepare the list of samplers associated with the Image Processing effects.
  76092. * @param samplersList The list of uniforms used in the effect
  76093. * @param defines the list of defines currently in use
  76094. */
  76095. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76096. /**
  76097. * Prepare the list of defines associated to the shader.
  76098. * @param defines the list of defines to complete
  76099. * @param forPostProcess Define if we are currently in post process mode or not
  76100. */
  76101. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76102. /**
  76103. * Returns true if all the image processing information are ready.
  76104. * @returns True if ready, otherwise, false
  76105. */
  76106. isReady(): boolean;
  76107. /**
  76108. * Binds the image processing to the shader.
  76109. * @param effect The effect to bind to
  76110. * @param overrideAspectRatio Override the aspect ratio of the effect
  76111. */
  76112. bind(effect: Effect, overrideAspectRatio?: number): void;
  76113. /**
  76114. * Clones the current image processing instance.
  76115. * @return The cloned image processing
  76116. */
  76117. clone(): ImageProcessingConfiguration;
  76118. /**
  76119. * Serializes the current image processing instance to a json representation.
  76120. * @return a JSON representation
  76121. */
  76122. serialize(): any;
  76123. /**
  76124. * Parses the image processing from a json representation.
  76125. * @param source the JSON source to parse
  76126. * @return The parsed image processing
  76127. */
  76128. static Parse(source: any): ImageProcessingConfiguration;
  76129. private static _VIGNETTEMODE_MULTIPLY;
  76130. private static _VIGNETTEMODE_OPAQUE;
  76131. /**
  76132. * Used to apply the vignette as a mix with the pixel color.
  76133. */
  76134. static readonly VIGNETTEMODE_MULTIPLY: number;
  76135. /**
  76136. * Used to apply the vignette as a replacement of the pixel color.
  76137. */
  76138. static readonly VIGNETTEMODE_OPAQUE: number;
  76139. }
  76140. }
  76141. declare module BABYLON {
  76142. /** @hidden */
  76143. export var postprocessVertexShader: {
  76144. name: string;
  76145. shader: string;
  76146. };
  76147. }
  76148. declare module BABYLON {
  76149. interface ThinEngine {
  76150. /**
  76151. * Creates a new render target texture
  76152. * @param size defines the size of the texture
  76153. * @param options defines the options used to create the texture
  76154. * @returns a new render target texture stored in an InternalTexture
  76155. */
  76156. createRenderTargetTexture(size: number | {
  76157. width: number;
  76158. height: number;
  76159. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76160. /**
  76161. * Creates a depth stencil texture.
  76162. * This is only available in WebGL 2 or with the depth texture extension available.
  76163. * @param size The size of face edge in the texture.
  76164. * @param options The options defining the texture.
  76165. * @returns The texture
  76166. */
  76167. createDepthStencilTexture(size: number | {
  76168. width: number;
  76169. height: number;
  76170. }, options: DepthTextureCreationOptions): InternalTexture;
  76171. /** @hidden */
  76172. _createDepthStencilTexture(size: number | {
  76173. width: number;
  76174. height: number;
  76175. }, options: DepthTextureCreationOptions): InternalTexture;
  76176. }
  76177. }
  76178. declare module BABYLON {
  76179. /** Defines supported spaces */
  76180. export enum Space {
  76181. /** Local (object) space */
  76182. LOCAL = 0,
  76183. /** World space */
  76184. WORLD = 1,
  76185. /** Bone space */
  76186. BONE = 2
  76187. }
  76188. /** Defines the 3 main axes */
  76189. export class Axis {
  76190. /** X axis */
  76191. static X: Vector3;
  76192. /** Y axis */
  76193. static Y: Vector3;
  76194. /** Z axis */
  76195. static Z: Vector3;
  76196. }
  76197. }
  76198. declare module BABYLON {
  76199. /**
  76200. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76201. * This is the base of the follow, arc rotate cameras and Free camera
  76202. * @see http://doc.babylonjs.com/features/cameras
  76203. */
  76204. export class TargetCamera extends Camera {
  76205. private static _RigCamTransformMatrix;
  76206. private static _TargetTransformMatrix;
  76207. private static _TargetFocalPoint;
  76208. /**
  76209. * Define the current direction the camera is moving to
  76210. */
  76211. cameraDirection: Vector3;
  76212. /**
  76213. * Define the current rotation the camera is rotating to
  76214. */
  76215. cameraRotation: Vector2;
  76216. /**
  76217. * When set, the up vector of the camera will be updated by the rotation of the camera
  76218. */
  76219. updateUpVectorFromRotation: boolean;
  76220. private _tmpQuaternion;
  76221. /**
  76222. * Define the current rotation of the camera
  76223. */
  76224. rotation: Vector3;
  76225. /**
  76226. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76227. */
  76228. rotationQuaternion: Quaternion;
  76229. /**
  76230. * Define the current speed of the camera
  76231. */
  76232. speed: number;
  76233. /**
  76234. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76235. * around all axis.
  76236. */
  76237. noRotationConstraint: boolean;
  76238. /**
  76239. * Define the current target of the camera as an object or a position.
  76240. */
  76241. lockedTarget: any;
  76242. /** @hidden */
  76243. _currentTarget: Vector3;
  76244. /** @hidden */
  76245. _initialFocalDistance: number;
  76246. /** @hidden */
  76247. _viewMatrix: Matrix;
  76248. /** @hidden */
  76249. _camMatrix: Matrix;
  76250. /** @hidden */
  76251. _cameraTransformMatrix: Matrix;
  76252. /** @hidden */
  76253. _cameraRotationMatrix: Matrix;
  76254. /** @hidden */
  76255. _referencePoint: Vector3;
  76256. /** @hidden */
  76257. _transformedReferencePoint: Vector3;
  76258. protected _globalCurrentTarget: Vector3;
  76259. protected _globalCurrentUpVector: Vector3;
  76260. /** @hidden */
  76261. _reset: () => void;
  76262. private _defaultUp;
  76263. /**
  76264. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76265. * This is the base of the follow, arc rotate cameras and Free camera
  76266. * @see http://doc.babylonjs.com/features/cameras
  76267. * @param name Defines the name of the camera in the scene
  76268. * @param position Defines the start position of the camera in the scene
  76269. * @param scene Defines the scene the camera belongs to
  76270. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76271. */
  76272. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76273. /**
  76274. * Gets the position in front of the camera at a given distance.
  76275. * @param distance The distance from the camera we want the position to be
  76276. * @returns the position
  76277. */
  76278. getFrontPosition(distance: number): Vector3;
  76279. /** @hidden */
  76280. _getLockedTargetPosition(): Nullable<Vector3>;
  76281. private _storedPosition;
  76282. private _storedRotation;
  76283. private _storedRotationQuaternion;
  76284. /**
  76285. * Store current camera state of the camera (fov, position, rotation, etc..)
  76286. * @returns the camera
  76287. */
  76288. storeState(): Camera;
  76289. /**
  76290. * Restored camera state. You must call storeState() first
  76291. * @returns whether it was successful or not
  76292. * @hidden
  76293. */
  76294. _restoreStateValues(): boolean;
  76295. /** @hidden */
  76296. _initCache(): void;
  76297. /** @hidden */
  76298. _updateCache(ignoreParentClass?: boolean): void;
  76299. /** @hidden */
  76300. _isSynchronizedViewMatrix(): boolean;
  76301. /** @hidden */
  76302. _computeLocalCameraSpeed(): number;
  76303. /**
  76304. * Defines the target the camera should look at.
  76305. * @param target Defines the new target as a Vector or a mesh
  76306. */
  76307. setTarget(target: Vector3): void;
  76308. /**
  76309. * Return the current target position of the camera. This value is expressed in local space.
  76310. * @returns the target position
  76311. */
  76312. getTarget(): Vector3;
  76313. /** @hidden */
  76314. _decideIfNeedsToMove(): boolean;
  76315. /** @hidden */
  76316. _updatePosition(): void;
  76317. /** @hidden */
  76318. _checkInputs(): void;
  76319. protected _updateCameraRotationMatrix(): void;
  76320. /**
  76321. * 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)
  76322. * @returns the current camera
  76323. */
  76324. private _rotateUpVectorWithCameraRotationMatrix;
  76325. private _cachedRotationZ;
  76326. private _cachedQuaternionRotationZ;
  76327. /** @hidden */
  76328. _getViewMatrix(): Matrix;
  76329. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76330. /**
  76331. * @hidden
  76332. */
  76333. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76334. /**
  76335. * @hidden
  76336. */
  76337. _updateRigCameras(): void;
  76338. private _getRigCamPositionAndTarget;
  76339. /**
  76340. * Gets the current object class name.
  76341. * @return the class name
  76342. */
  76343. getClassName(): string;
  76344. }
  76345. }
  76346. declare module BABYLON {
  76347. /**
  76348. * Gather the list of keyboard event types as constants.
  76349. */
  76350. export class KeyboardEventTypes {
  76351. /**
  76352. * The keydown event is fired when a key becomes active (pressed).
  76353. */
  76354. static readonly KEYDOWN: number;
  76355. /**
  76356. * The keyup event is fired when a key has been released.
  76357. */
  76358. static readonly KEYUP: number;
  76359. }
  76360. /**
  76361. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76362. */
  76363. export class KeyboardInfo {
  76364. /**
  76365. * Defines the type of event (KeyboardEventTypes)
  76366. */
  76367. type: number;
  76368. /**
  76369. * Defines the related dom event
  76370. */
  76371. event: KeyboardEvent;
  76372. /**
  76373. * Instantiates a new keyboard info.
  76374. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76375. * @param type Defines the type of event (KeyboardEventTypes)
  76376. * @param event Defines the related dom event
  76377. */
  76378. constructor(
  76379. /**
  76380. * Defines the type of event (KeyboardEventTypes)
  76381. */
  76382. type: number,
  76383. /**
  76384. * Defines the related dom event
  76385. */
  76386. event: KeyboardEvent);
  76387. }
  76388. /**
  76389. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76390. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76391. */
  76392. export class KeyboardInfoPre extends KeyboardInfo {
  76393. /**
  76394. * Defines the type of event (KeyboardEventTypes)
  76395. */
  76396. type: number;
  76397. /**
  76398. * Defines the related dom event
  76399. */
  76400. event: KeyboardEvent;
  76401. /**
  76402. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76403. */
  76404. skipOnPointerObservable: boolean;
  76405. /**
  76406. * Instantiates a new keyboard pre info.
  76407. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76408. * @param type Defines the type of event (KeyboardEventTypes)
  76409. * @param event Defines the related dom event
  76410. */
  76411. constructor(
  76412. /**
  76413. * Defines the type of event (KeyboardEventTypes)
  76414. */
  76415. type: number,
  76416. /**
  76417. * Defines the related dom event
  76418. */
  76419. event: KeyboardEvent);
  76420. }
  76421. }
  76422. declare module BABYLON {
  76423. /**
  76424. * Manage the keyboard inputs to control the movement of a free camera.
  76425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76426. */
  76427. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76428. /**
  76429. * Defines the camera the input is attached to.
  76430. */
  76431. camera: FreeCamera;
  76432. /**
  76433. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76434. */
  76435. keysUp: number[];
  76436. /**
  76437. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76438. */
  76439. keysDown: number[];
  76440. /**
  76441. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76442. */
  76443. keysLeft: number[];
  76444. /**
  76445. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76446. */
  76447. keysRight: number[];
  76448. private _keys;
  76449. private _onCanvasBlurObserver;
  76450. private _onKeyboardObserver;
  76451. private _engine;
  76452. private _scene;
  76453. /**
  76454. * Attach the input controls to a specific dom element to get the input from.
  76455. * @param element Defines the element the controls should be listened from
  76456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76457. */
  76458. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76459. /**
  76460. * Detach the current controls from the specified dom element.
  76461. * @param element Defines the element to stop listening the inputs from
  76462. */
  76463. detachControl(element: Nullable<HTMLElement>): void;
  76464. /**
  76465. * Update the current camera state depending on the inputs that have been used this frame.
  76466. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76467. */
  76468. checkInputs(): void;
  76469. /**
  76470. * Gets the class name of the current intput.
  76471. * @returns the class name
  76472. */
  76473. getClassName(): string;
  76474. /** @hidden */
  76475. _onLostFocus(): void;
  76476. /**
  76477. * Get the friendly name associated with the input class.
  76478. * @returns the input friendly name
  76479. */
  76480. getSimpleName(): string;
  76481. }
  76482. }
  76483. declare module BABYLON {
  76484. /**
  76485. * Interface describing all the common properties and methods a shadow light needs to implement.
  76486. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76487. * as well as binding the different shadow properties to the effects.
  76488. */
  76489. export interface IShadowLight extends Light {
  76490. /**
  76491. * The light id in the scene (used in scene.findLighById for instance)
  76492. */
  76493. id: string;
  76494. /**
  76495. * The position the shdow will be casted from.
  76496. */
  76497. position: Vector3;
  76498. /**
  76499. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76500. */
  76501. direction: Vector3;
  76502. /**
  76503. * The transformed position. Position of the light in world space taking parenting in account.
  76504. */
  76505. transformedPosition: Vector3;
  76506. /**
  76507. * The transformed direction. Direction of the light in world space taking parenting in account.
  76508. */
  76509. transformedDirection: Vector3;
  76510. /**
  76511. * The friendly name of the light in the scene.
  76512. */
  76513. name: string;
  76514. /**
  76515. * Defines the shadow projection clipping minimum z value.
  76516. */
  76517. shadowMinZ: number;
  76518. /**
  76519. * Defines the shadow projection clipping maximum z value.
  76520. */
  76521. shadowMaxZ: number;
  76522. /**
  76523. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76524. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76525. */
  76526. computeTransformedInformation(): boolean;
  76527. /**
  76528. * Gets the scene the light belongs to.
  76529. * @returns The scene
  76530. */
  76531. getScene(): Scene;
  76532. /**
  76533. * Callback defining a custom Projection Matrix Builder.
  76534. * This can be used to override the default projection matrix computation.
  76535. */
  76536. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76537. /**
  76538. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76539. * @param matrix The materix to updated with the projection information
  76540. * @param viewMatrix The transform matrix of the light
  76541. * @param renderList The list of mesh to render in the map
  76542. * @returns The current light
  76543. */
  76544. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76545. /**
  76546. * Gets the current depth scale used in ESM.
  76547. * @returns The scale
  76548. */
  76549. getDepthScale(): number;
  76550. /**
  76551. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76552. * @returns true if a cube texture needs to be use
  76553. */
  76554. needCube(): boolean;
  76555. /**
  76556. * Detects if the projection matrix requires to be recomputed this frame.
  76557. * @returns true if it requires to be recomputed otherwise, false.
  76558. */
  76559. needProjectionMatrixCompute(): boolean;
  76560. /**
  76561. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76562. */
  76563. forceProjectionMatrixCompute(): void;
  76564. /**
  76565. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76566. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76567. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76568. */
  76569. getShadowDirection(faceIndex?: number): Vector3;
  76570. /**
  76571. * Gets the minZ used for shadow according to both the scene and the light.
  76572. * @param activeCamera The camera we are returning the min for
  76573. * @returns the depth min z
  76574. */
  76575. getDepthMinZ(activeCamera: Camera): number;
  76576. /**
  76577. * Gets the maxZ used for shadow according to both the scene and the light.
  76578. * @param activeCamera The camera we are returning the max for
  76579. * @returns the depth max z
  76580. */
  76581. getDepthMaxZ(activeCamera: Camera): number;
  76582. }
  76583. /**
  76584. * Base implementation IShadowLight
  76585. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76586. */
  76587. export abstract class ShadowLight extends Light implements IShadowLight {
  76588. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76589. protected _position: Vector3;
  76590. protected _setPosition(value: Vector3): void;
  76591. /**
  76592. * Sets the position the shadow will be casted from. Also use as the light position for both
  76593. * point and spot lights.
  76594. */
  76595. /**
  76596. * Sets the position the shadow will be casted from. Also use as the light position for both
  76597. * point and spot lights.
  76598. */
  76599. position: Vector3;
  76600. protected _direction: Vector3;
  76601. protected _setDirection(value: Vector3): void;
  76602. /**
  76603. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76604. * Also use as the light direction on spot and directional lights.
  76605. */
  76606. /**
  76607. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76608. * Also use as the light direction on spot and directional lights.
  76609. */
  76610. direction: Vector3;
  76611. private _shadowMinZ;
  76612. /**
  76613. * Gets the shadow projection clipping minimum z value.
  76614. */
  76615. /**
  76616. * Sets the shadow projection clipping minimum z value.
  76617. */
  76618. shadowMinZ: number;
  76619. private _shadowMaxZ;
  76620. /**
  76621. * Sets the shadow projection clipping maximum z value.
  76622. */
  76623. /**
  76624. * Gets the shadow projection clipping maximum z value.
  76625. */
  76626. shadowMaxZ: number;
  76627. /**
  76628. * Callback defining a custom Projection Matrix Builder.
  76629. * This can be used to override the default projection matrix computation.
  76630. */
  76631. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76632. /**
  76633. * The transformed position. Position of the light in world space taking parenting in account.
  76634. */
  76635. transformedPosition: Vector3;
  76636. /**
  76637. * The transformed direction. Direction of the light in world space taking parenting in account.
  76638. */
  76639. transformedDirection: Vector3;
  76640. private _needProjectionMatrixCompute;
  76641. /**
  76642. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76643. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76644. */
  76645. computeTransformedInformation(): boolean;
  76646. /**
  76647. * Return the depth scale used for the shadow map.
  76648. * @returns the depth scale.
  76649. */
  76650. getDepthScale(): number;
  76651. /**
  76652. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76653. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76654. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76655. */
  76656. getShadowDirection(faceIndex?: number): Vector3;
  76657. /**
  76658. * Returns the ShadowLight absolute position in the World.
  76659. * @returns the position vector in world space
  76660. */
  76661. getAbsolutePosition(): Vector3;
  76662. /**
  76663. * Sets the ShadowLight direction toward the passed target.
  76664. * @param target The point to target in local space
  76665. * @returns the updated ShadowLight direction
  76666. */
  76667. setDirectionToTarget(target: Vector3): Vector3;
  76668. /**
  76669. * Returns the light rotation in euler definition.
  76670. * @returns the x y z rotation in local space.
  76671. */
  76672. getRotation(): Vector3;
  76673. /**
  76674. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76675. * @returns true if a cube texture needs to be use
  76676. */
  76677. needCube(): boolean;
  76678. /**
  76679. * Detects if the projection matrix requires to be recomputed this frame.
  76680. * @returns true if it requires to be recomputed otherwise, false.
  76681. */
  76682. needProjectionMatrixCompute(): boolean;
  76683. /**
  76684. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76685. */
  76686. forceProjectionMatrixCompute(): void;
  76687. /** @hidden */
  76688. _initCache(): void;
  76689. /** @hidden */
  76690. _isSynchronized(): boolean;
  76691. /**
  76692. * Computes the world matrix of the node
  76693. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76694. * @returns the world matrix
  76695. */
  76696. computeWorldMatrix(force?: boolean): Matrix;
  76697. /**
  76698. * Gets the minZ used for shadow according to both the scene and the light.
  76699. * @param activeCamera The camera we are returning the min for
  76700. * @returns the depth min z
  76701. */
  76702. getDepthMinZ(activeCamera: Camera): number;
  76703. /**
  76704. * Gets the maxZ used for shadow according to both the scene and the light.
  76705. * @param activeCamera The camera we are returning the max for
  76706. * @returns the depth max z
  76707. */
  76708. getDepthMaxZ(activeCamera: Camera): number;
  76709. /**
  76710. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76711. * @param matrix The materix to updated with the projection information
  76712. * @param viewMatrix The transform matrix of the light
  76713. * @param renderList The list of mesh to render in the map
  76714. * @returns The current light
  76715. */
  76716. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76717. }
  76718. }
  76719. declare module BABYLON {
  76720. /**
  76721. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76722. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76723. */
  76724. export class EffectFallbacks implements IEffectFallbacks {
  76725. private _defines;
  76726. private _currentRank;
  76727. private _maxRank;
  76728. private _mesh;
  76729. /**
  76730. * Removes the fallback from the bound mesh.
  76731. */
  76732. unBindMesh(): void;
  76733. /**
  76734. * Adds a fallback on the specified property.
  76735. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76736. * @param define The name of the define in the shader
  76737. */
  76738. addFallback(rank: number, define: string): void;
  76739. /**
  76740. * Sets the mesh to use CPU skinning when needing to fallback.
  76741. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76742. * @param mesh The mesh to use the fallbacks.
  76743. */
  76744. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76745. /**
  76746. * Checks to see if more fallbacks are still availible.
  76747. */
  76748. readonly hasMoreFallbacks: boolean;
  76749. /**
  76750. * Removes the defines that should be removed when falling back.
  76751. * @param currentDefines defines the current define statements for the shader.
  76752. * @param effect defines the current effect we try to compile
  76753. * @returns The resulting defines with defines of the current rank removed.
  76754. */
  76755. reduce(currentDefines: string, effect: Effect): string;
  76756. }
  76757. }
  76758. declare module BABYLON {
  76759. /**
  76760. * "Static Class" containing the most commonly used helper while dealing with material for
  76761. * rendering purpose.
  76762. *
  76763. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76764. *
  76765. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76766. */
  76767. export class MaterialHelper {
  76768. /**
  76769. * Bind the current view position to an effect.
  76770. * @param effect The effect to be bound
  76771. * @param scene The scene the eyes position is used from
  76772. */
  76773. static BindEyePosition(effect: Effect, scene: Scene): void;
  76774. /**
  76775. * Helps preparing the defines values about the UVs in used in the effect.
  76776. * UVs are shared as much as we can accross channels in the shaders.
  76777. * @param texture The texture we are preparing the UVs for
  76778. * @param defines The defines to update
  76779. * @param key The channel key "diffuse", "specular"... used in the shader
  76780. */
  76781. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76782. /**
  76783. * Binds a texture matrix value to its corrsponding uniform
  76784. * @param texture The texture to bind the matrix for
  76785. * @param uniformBuffer The uniform buffer receivin the data
  76786. * @param key The channel key "diffuse", "specular"... used in the shader
  76787. */
  76788. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76789. /**
  76790. * Gets the current status of the fog (should it be enabled?)
  76791. * @param mesh defines the mesh to evaluate for fog support
  76792. * @param scene defines the hosting scene
  76793. * @returns true if fog must be enabled
  76794. */
  76795. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76796. /**
  76797. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76798. * @param mesh defines the current mesh
  76799. * @param scene defines the current scene
  76800. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76801. * @param pointsCloud defines if point cloud rendering has to be turned on
  76802. * @param fogEnabled defines if fog has to be turned on
  76803. * @param alphaTest defines if alpha testing has to be turned on
  76804. * @param defines defines the current list of defines
  76805. */
  76806. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76807. /**
  76808. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76809. * @param scene defines the current scene
  76810. * @param engine defines the current engine
  76811. * @param defines specifies the list of active defines
  76812. * @param useInstances defines if instances have to be turned on
  76813. * @param useClipPlane defines if clip plane have to be turned on
  76814. */
  76815. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76816. /**
  76817. * Prepares the defines for bones
  76818. * @param mesh The mesh containing the geometry data we will draw
  76819. * @param defines The defines to update
  76820. */
  76821. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76822. /**
  76823. * Prepares the defines for morph targets
  76824. * @param mesh The mesh containing the geometry data we will draw
  76825. * @param defines The defines to update
  76826. */
  76827. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76828. /**
  76829. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76830. * @param mesh The mesh containing the geometry data we will draw
  76831. * @param defines The defines to update
  76832. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76833. * @param useBones Precise whether bones should be used or not (override mesh info)
  76834. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76835. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76836. * @returns false if defines are considered not dirty and have not been checked
  76837. */
  76838. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76839. /**
  76840. * Prepares the defines related to multiview
  76841. * @param scene The scene we are intending to draw
  76842. * @param defines The defines to update
  76843. */
  76844. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76845. /**
  76846. * Prepares the defines related to the light information passed in parameter
  76847. * @param scene The scene we are intending to draw
  76848. * @param mesh The mesh the effect is compiling for
  76849. * @param light The light the effect is compiling for
  76850. * @param lightIndex The index of the light
  76851. * @param defines The defines to update
  76852. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76853. * @param state Defines the current state regarding what is needed (normals, etc...)
  76854. */
  76855. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76856. needNormals: boolean;
  76857. needRebuild: boolean;
  76858. shadowEnabled: boolean;
  76859. specularEnabled: boolean;
  76860. lightmapMode: boolean;
  76861. }): void;
  76862. /**
  76863. * Prepares the defines related to the light information passed in parameter
  76864. * @param scene The scene we are intending to draw
  76865. * @param mesh The mesh the effect is compiling for
  76866. * @param defines The defines to update
  76867. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76868. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76869. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76870. * @returns true if normals will be required for the rest of the effect
  76871. */
  76872. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76873. /**
  76874. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76875. * @param lightIndex defines the light index
  76876. * @param uniformsList The uniform list
  76877. * @param samplersList The sampler list
  76878. * @param projectedLightTexture defines if projected texture must be used
  76879. * @param uniformBuffersList defines an optional list of uniform buffers
  76880. */
  76881. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76882. /**
  76883. * Prepares the uniforms and samplers list to be used in the effect
  76884. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76885. * @param samplersList The sampler list
  76886. * @param defines The defines helping in the list generation
  76887. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76888. */
  76889. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76890. /**
  76891. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76892. * @param defines The defines to update while falling back
  76893. * @param fallbacks The authorized effect fallbacks
  76894. * @param maxSimultaneousLights The maximum number of lights allowed
  76895. * @param rank the current rank of the Effect
  76896. * @returns The newly affected rank
  76897. */
  76898. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76899. private static _TmpMorphInfluencers;
  76900. /**
  76901. * Prepares the list of attributes required for morph targets according to the effect defines.
  76902. * @param attribs The current list of supported attribs
  76903. * @param mesh The mesh to prepare the morph targets attributes for
  76904. * @param influencers The number of influencers
  76905. */
  76906. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76907. /**
  76908. * Prepares the list of attributes required for morph targets according to the effect defines.
  76909. * @param attribs The current list of supported attribs
  76910. * @param mesh The mesh to prepare the morph targets attributes for
  76911. * @param defines The current Defines of the effect
  76912. */
  76913. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76914. /**
  76915. * Prepares the list of attributes required for bones according to the effect defines.
  76916. * @param attribs The current list of supported attribs
  76917. * @param mesh The mesh to prepare the bones attributes for
  76918. * @param defines The current Defines of the effect
  76919. * @param fallbacks The current efffect fallback strategy
  76920. */
  76921. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76922. /**
  76923. * Check and prepare the list of attributes required for instances according to the effect defines.
  76924. * @param attribs The current list of supported attribs
  76925. * @param defines The current MaterialDefines of the effect
  76926. */
  76927. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76928. /**
  76929. * Add the list of attributes required for instances to the attribs array.
  76930. * @param attribs The current list of supported attribs
  76931. */
  76932. static PushAttributesForInstances(attribs: string[]): void;
  76933. /**
  76934. * Binds the light information to the effect.
  76935. * @param light The light containing the generator
  76936. * @param effect The effect we are binding the data to
  76937. * @param lightIndex The light index in the effect used to render
  76938. */
  76939. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76940. /**
  76941. * Binds the lights information from the scene to the effect for the given mesh.
  76942. * @param light Light to bind
  76943. * @param lightIndex Light index
  76944. * @param scene The scene where the light belongs to
  76945. * @param effect The effect we are binding the data to
  76946. * @param useSpecular Defines if specular is supported
  76947. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76948. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76949. */
  76950. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76951. /**
  76952. * Binds the lights information from the scene to the effect for the given mesh.
  76953. * @param scene The scene the lights belongs to
  76954. * @param mesh The mesh we are binding the information to render
  76955. * @param effect The effect we are binding the data to
  76956. * @param defines The generated defines for the effect
  76957. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76958. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76959. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76960. */
  76961. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76962. private static _tempFogColor;
  76963. /**
  76964. * Binds the fog information from the scene to the effect for the given mesh.
  76965. * @param scene The scene the lights belongs to
  76966. * @param mesh The mesh we are binding the information to render
  76967. * @param effect The effect we are binding the data to
  76968. * @param linearSpace Defines if the fog effect is applied in linear space
  76969. */
  76970. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76971. /**
  76972. * Binds the bones information from the mesh to the effect.
  76973. * @param mesh The mesh we are binding the information to render
  76974. * @param effect The effect we are binding the data to
  76975. */
  76976. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76977. /**
  76978. * Binds the morph targets information from the mesh to the effect.
  76979. * @param abstractMesh The mesh we are binding the information to render
  76980. * @param effect The effect we are binding the data to
  76981. */
  76982. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76983. /**
  76984. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76985. * @param defines The generated defines used in the effect
  76986. * @param effect The effect we are binding the data to
  76987. * @param scene The scene we are willing to render with logarithmic scale for
  76988. */
  76989. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76990. /**
  76991. * Binds the clip plane information from the scene to the effect.
  76992. * @param scene The scene the clip plane information are extracted from
  76993. * @param effect The effect we are binding the data to
  76994. */
  76995. static BindClipPlane(effect: Effect, scene: Scene): void;
  76996. }
  76997. }
  76998. declare module BABYLON {
  76999. /** @hidden */
  77000. export var packingFunctions: {
  77001. name: string;
  77002. shader: string;
  77003. };
  77004. }
  77005. declare module BABYLON {
  77006. /** @hidden */
  77007. export var shadowMapPixelShader: {
  77008. name: string;
  77009. shader: string;
  77010. };
  77011. }
  77012. declare module BABYLON {
  77013. /** @hidden */
  77014. export var bonesDeclaration: {
  77015. name: string;
  77016. shader: string;
  77017. };
  77018. }
  77019. declare module BABYLON {
  77020. /** @hidden */
  77021. export var morphTargetsVertexGlobalDeclaration: {
  77022. name: string;
  77023. shader: string;
  77024. };
  77025. }
  77026. declare module BABYLON {
  77027. /** @hidden */
  77028. export var morphTargetsVertexDeclaration: {
  77029. name: string;
  77030. shader: string;
  77031. };
  77032. }
  77033. declare module BABYLON {
  77034. /** @hidden */
  77035. export var instancesDeclaration: {
  77036. name: string;
  77037. shader: string;
  77038. };
  77039. }
  77040. declare module BABYLON {
  77041. /** @hidden */
  77042. export var helperFunctions: {
  77043. name: string;
  77044. shader: string;
  77045. };
  77046. }
  77047. declare module BABYLON {
  77048. /** @hidden */
  77049. export var morphTargetsVertex: {
  77050. name: string;
  77051. shader: string;
  77052. };
  77053. }
  77054. declare module BABYLON {
  77055. /** @hidden */
  77056. export var instancesVertex: {
  77057. name: string;
  77058. shader: string;
  77059. };
  77060. }
  77061. declare module BABYLON {
  77062. /** @hidden */
  77063. export var bonesVertex: {
  77064. name: string;
  77065. shader: string;
  77066. };
  77067. }
  77068. declare module BABYLON {
  77069. /** @hidden */
  77070. export var shadowMapVertexShader: {
  77071. name: string;
  77072. shader: string;
  77073. };
  77074. }
  77075. declare module BABYLON {
  77076. /** @hidden */
  77077. export var depthBoxBlurPixelShader: {
  77078. name: string;
  77079. shader: string;
  77080. };
  77081. }
  77082. declare module BABYLON {
  77083. /**
  77084. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77085. */
  77086. export interface ICustomShaderOptions {
  77087. /**
  77088. * Gets or sets the custom shader name to use
  77089. */
  77090. shaderName: string;
  77091. /**
  77092. * The list of attribute names used in the shader
  77093. */
  77094. attributes?: string[];
  77095. /**
  77096. * The list of unifrom names used in the shader
  77097. */
  77098. uniforms?: string[];
  77099. /**
  77100. * The list of sampler names used in the shader
  77101. */
  77102. samplers?: string[];
  77103. /**
  77104. * The list of defines used in the shader
  77105. */
  77106. defines?: string[];
  77107. }
  77108. /**
  77109. * Interface to implement to create a shadow generator compatible with BJS.
  77110. */
  77111. export interface IShadowGenerator {
  77112. /**
  77113. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77114. * @returns The render target texture if present otherwise, null
  77115. */
  77116. getShadowMap(): Nullable<RenderTargetTexture>;
  77117. /**
  77118. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77119. * @returns The render target texture if the shadow map is present otherwise, null
  77120. */
  77121. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77122. /**
  77123. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77124. * @param subMesh The submesh we want to render in the shadow map
  77125. * @param useInstances Defines wether will draw in the map using instances
  77126. * @returns true if ready otherwise, false
  77127. */
  77128. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77129. /**
  77130. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77131. * @param defines Defines of the material we want to update
  77132. * @param lightIndex Index of the light in the enabled light list of the material
  77133. */
  77134. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77135. /**
  77136. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77137. * defined in the generator but impacting the effect).
  77138. * It implies the unifroms available on the materials are the standard BJS ones.
  77139. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77140. * @param effect The effect we are binfing the information for
  77141. */
  77142. bindShadowLight(lightIndex: string, effect: Effect): void;
  77143. /**
  77144. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77145. * (eq to shadow prjection matrix * light transform matrix)
  77146. * @returns The transform matrix used to create the shadow map
  77147. */
  77148. getTransformMatrix(): Matrix;
  77149. /**
  77150. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77151. * Cube and 2D textures for instance.
  77152. */
  77153. recreateShadowMap(): void;
  77154. /**
  77155. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77156. * @param onCompiled Callback triggered at the and of the effects compilation
  77157. * @param options Sets of optional options forcing the compilation with different modes
  77158. */
  77159. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77160. useInstances: boolean;
  77161. }>): void;
  77162. /**
  77163. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77164. * @param options Sets of optional options forcing the compilation with different modes
  77165. * @returns A promise that resolves when the compilation completes
  77166. */
  77167. forceCompilationAsync(options?: Partial<{
  77168. useInstances: boolean;
  77169. }>): Promise<void>;
  77170. /**
  77171. * Serializes the shadow generator setup to a json object.
  77172. * @returns The serialized JSON object
  77173. */
  77174. serialize(): any;
  77175. /**
  77176. * Disposes the Shadow map and related Textures and effects.
  77177. */
  77178. dispose(): void;
  77179. }
  77180. /**
  77181. * Default implementation IShadowGenerator.
  77182. * This is the main object responsible of generating shadows in the framework.
  77183. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77184. */
  77185. export class ShadowGenerator implements IShadowGenerator {
  77186. /**
  77187. * Shadow generator mode None: no filtering applied.
  77188. */
  77189. static readonly FILTER_NONE: number;
  77190. /**
  77191. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77192. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77193. */
  77194. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77195. /**
  77196. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77197. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77198. */
  77199. static readonly FILTER_POISSONSAMPLING: number;
  77200. /**
  77201. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77202. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77203. */
  77204. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77205. /**
  77206. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77207. * edge artifacts on steep falloff.
  77208. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77209. */
  77210. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77211. /**
  77212. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77213. * edge artifacts on steep falloff.
  77214. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77215. */
  77216. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77217. /**
  77218. * Shadow generator mode PCF: Percentage Closer Filtering
  77219. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77220. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77221. */
  77222. static readonly FILTER_PCF: number;
  77223. /**
  77224. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77225. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77226. * Contact Hardening
  77227. */
  77228. static readonly FILTER_PCSS: number;
  77229. /**
  77230. * Reserved for PCF and PCSS
  77231. * Highest Quality.
  77232. *
  77233. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77234. *
  77235. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77236. */
  77237. static readonly QUALITY_HIGH: number;
  77238. /**
  77239. * Reserved for PCF and PCSS
  77240. * Good tradeoff for quality/perf cross devices
  77241. *
  77242. * Execute PCF on a 3*3 kernel.
  77243. *
  77244. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77245. */
  77246. static readonly QUALITY_MEDIUM: number;
  77247. /**
  77248. * Reserved for PCF and PCSS
  77249. * The lowest quality but the fastest.
  77250. *
  77251. * Execute PCF on a 1*1 kernel.
  77252. *
  77253. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77254. */
  77255. static readonly QUALITY_LOW: number;
  77256. /** Gets or sets the custom shader name to use */
  77257. customShaderOptions: ICustomShaderOptions;
  77258. /**
  77259. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77260. */
  77261. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77262. /**
  77263. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77264. */
  77265. onAfterShadowMapRenderObservable: Observable<Effect>;
  77266. /**
  77267. * Observable triggered before a mesh is rendered in the shadow map.
  77268. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77269. */
  77270. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77271. /**
  77272. * Observable triggered after a mesh is rendered in the shadow map.
  77273. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77274. */
  77275. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77276. private _bias;
  77277. /**
  77278. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77279. */
  77280. /**
  77281. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77282. */
  77283. bias: number;
  77284. private _normalBias;
  77285. /**
  77286. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77287. */
  77288. /**
  77289. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77290. */
  77291. normalBias: number;
  77292. private _blurBoxOffset;
  77293. /**
  77294. * Gets the blur box offset: offset applied during the blur pass.
  77295. * Only useful if useKernelBlur = false
  77296. */
  77297. /**
  77298. * Sets the blur box offset: offset applied during the blur pass.
  77299. * Only useful if useKernelBlur = false
  77300. */
  77301. blurBoxOffset: number;
  77302. private _blurScale;
  77303. /**
  77304. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77305. * 2 means half of the size.
  77306. */
  77307. /**
  77308. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77309. * 2 means half of the size.
  77310. */
  77311. blurScale: number;
  77312. private _blurKernel;
  77313. /**
  77314. * Gets the blur kernel: kernel size of the blur pass.
  77315. * Only useful if useKernelBlur = true
  77316. */
  77317. /**
  77318. * Sets the blur kernel: kernel size of the blur pass.
  77319. * Only useful if useKernelBlur = true
  77320. */
  77321. blurKernel: number;
  77322. private _useKernelBlur;
  77323. /**
  77324. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77325. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77326. */
  77327. /**
  77328. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77329. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77330. */
  77331. useKernelBlur: boolean;
  77332. private _depthScale;
  77333. /**
  77334. * Gets the depth scale used in ESM mode.
  77335. */
  77336. /**
  77337. * Sets the depth scale used in ESM mode.
  77338. * This can override the scale stored on the light.
  77339. */
  77340. depthScale: number;
  77341. private _filter;
  77342. /**
  77343. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77344. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77345. */
  77346. /**
  77347. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77348. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77349. */
  77350. filter: number;
  77351. /**
  77352. * Gets if the current filter is set to Poisson Sampling.
  77353. */
  77354. /**
  77355. * Sets the current filter to Poisson Sampling.
  77356. */
  77357. usePoissonSampling: boolean;
  77358. /**
  77359. * Gets if the current filter is set to ESM.
  77360. */
  77361. /**
  77362. * Sets the current filter is to ESM.
  77363. */
  77364. useExponentialShadowMap: boolean;
  77365. /**
  77366. * Gets if the current filter is set to filtered ESM.
  77367. */
  77368. /**
  77369. * Gets if the current filter is set to filtered ESM.
  77370. */
  77371. useBlurExponentialShadowMap: boolean;
  77372. /**
  77373. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77374. * exponential to prevent steep falloff artifacts).
  77375. */
  77376. /**
  77377. * Sets the current filter to "close ESM" (using the inverse of the
  77378. * exponential to prevent steep falloff artifacts).
  77379. */
  77380. useCloseExponentialShadowMap: boolean;
  77381. /**
  77382. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77383. * exponential to prevent steep falloff artifacts).
  77384. */
  77385. /**
  77386. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77387. * exponential to prevent steep falloff artifacts).
  77388. */
  77389. useBlurCloseExponentialShadowMap: boolean;
  77390. /**
  77391. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77392. */
  77393. /**
  77394. * Sets the current filter to "PCF" (percentage closer filtering).
  77395. */
  77396. usePercentageCloserFiltering: boolean;
  77397. private _filteringQuality;
  77398. /**
  77399. * Gets the PCF or PCSS Quality.
  77400. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77401. */
  77402. /**
  77403. * Sets the PCF or PCSS Quality.
  77404. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77405. */
  77406. filteringQuality: number;
  77407. /**
  77408. * Gets if the current filter is set to "PCSS" (contact hardening).
  77409. */
  77410. /**
  77411. * Sets the current filter to "PCSS" (contact hardening).
  77412. */
  77413. useContactHardeningShadow: boolean;
  77414. private _contactHardeningLightSizeUVRatio;
  77415. /**
  77416. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77417. * Using a ratio helps keeping shape stability independently of the map size.
  77418. *
  77419. * It does not account for the light projection as it was having too much
  77420. * instability during the light setup or during light position changes.
  77421. *
  77422. * Only valid if useContactHardeningShadow is true.
  77423. */
  77424. /**
  77425. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77426. * Using a ratio helps keeping shape stability independently of the map size.
  77427. *
  77428. * It does not account for the light projection as it was having too much
  77429. * instability during the light setup or during light position changes.
  77430. *
  77431. * Only valid if useContactHardeningShadow is true.
  77432. */
  77433. contactHardeningLightSizeUVRatio: number;
  77434. private _darkness;
  77435. /** Gets or sets the actual darkness of a shadow */
  77436. darkness: number;
  77437. /**
  77438. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77439. * 0 means strongest and 1 would means no shadow.
  77440. * @returns the darkness.
  77441. */
  77442. getDarkness(): number;
  77443. /**
  77444. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77445. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77446. * @returns the shadow generator allowing fluent coding.
  77447. */
  77448. setDarkness(darkness: number): ShadowGenerator;
  77449. private _transparencyShadow;
  77450. /** Gets or sets the ability to have transparent shadow */
  77451. transparencyShadow: boolean;
  77452. /**
  77453. * Sets the ability to have transparent shadow (boolean).
  77454. * @param transparent True if transparent else False
  77455. * @returns the shadow generator allowing fluent coding
  77456. */
  77457. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77458. private _shadowMap;
  77459. private _shadowMap2;
  77460. /**
  77461. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77462. * @returns The render target texture if present otherwise, null
  77463. */
  77464. getShadowMap(): Nullable<RenderTargetTexture>;
  77465. /**
  77466. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77467. * @returns The render target texture if the shadow map is present otherwise, null
  77468. */
  77469. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77470. /**
  77471. * Gets the class name of that object
  77472. * @returns "ShadowGenerator"
  77473. */
  77474. getClassName(): string;
  77475. /**
  77476. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77477. * @param mesh Mesh to add
  77478. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77479. * @returns the Shadow Generator itself
  77480. */
  77481. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77482. /**
  77483. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77484. * @param mesh Mesh to remove
  77485. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77486. * @returns the Shadow Generator itself
  77487. */
  77488. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77489. /**
  77490. * Controls the extent to which the shadows fade out at the edge of the frustum
  77491. * Used only by directionals and spots
  77492. */
  77493. frustumEdgeFalloff: number;
  77494. private _light;
  77495. /**
  77496. * Returns the associated light object.
  77497. * @returns the light generating the shadow
  77498. */
  77499. getLight(): IShadowLight;
  77500. /**
  77501. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77502. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77503. * It might on the other hand introduce peter panning.
  77504. */
  77505. forceBackFacesOnly: boolean;
  77506. private _scene;
  77507. private _lightDirection;
  77508. private _effect;
  77509. private _viewMatrix;
  77510. private _projectionMatrix;
  77511. private _transformMatrix;
  77512. private _cachedPosition;
  77513. private _cachedDirection;
  77514. private _cachedDefines;
  77515. private _currentRenderID;
  77516. private _boxBlurPostprocess;
  77517. private _kernelBlurXPostprocess;
  77518. private _kernelBlurYPostprocess;
  77519. private _blurPostProcesses;
  77520. private _mapSize;
  77521. private _currentFaceIndex;
  77522. private _currentFaceIndexCache;
  77523. private _textureType;
  77524. private _defaultTextureMatrix;
  77525. private _storedUniqueId;
  77526. /** @hidden */
  77527. static _SceneComponentInitialization: (scene: Scene) => void;
  77528. /**
  77529. * Creates a ShadowGenerator object.
  77530. * A ShadowGenerator is the required tool to use the shadows.
  77531. * Each light casting shadows needs to use its own ShadowGenerator.
  77532. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77533. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77534. * @param light The light object generating the shadows.
  77535. * @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.
  77536. */
  77537. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77538. private _initializeGenerator;
  77539. private _initializeShadowMap;
  77540. private _initializeBlurRTTAndPostProcesses;
  77541. private _renderForShadowMap;
  77542. private _renderSubMeshForShadowMap;
  77543. private _applyFilterValues;
  77544. /**
  77545. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77546. * @param onCompiled Callback triggered at the and of the effects compilation
  77547. * @param options Sets of optional options forcing the compilation with different modes
  77548. */
  77549. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77550. useInstances: boolean;
  77551. }>): void;
  77552. /**
  77553. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77554. * @param options Sets of optional options forcing the compilation with different modes
  77555. * @returns A promise that resolves when the compilation completes
  77556. */
  77557. forceCompilationAsync(options?: Partial<{
  77558. useInstances: boolean;
  77559. }>): Promise<void>;
  77560. /**
  77561. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77562. * @param subMesh The submesh we want to render in the shadow map
  77563. * @param useInstances Defines wether will draw in the map using instances
  77564. * @returns true if ready otherwise, false
  77565. */
  77566. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77567. /**
  77568. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77569. * @param defines Defines of the material we want to update
  77570. * @param lightIndex Index of the light in the enabled light list of the material
  77571. */
  77572. prepareDefines(defines: any, lightIndex: number): void;
  77573. /**
  77574. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77575. * defined in the generator but impacting the effect).
  77576. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77577. * @param effect The effect we are binfing the information for
  77578. */
  77579. bindShadowLight(lightIndex: string, effect: Effect): void;
  77580. /**
  77581. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77582. * (eq to shadow prjection matrix * light transform matrix)
  77583. * @returns The transform matrix used to create the shadow map
  77584. */
  77585. getTransformMatrix(): Matrix;
  77586. /**
  77587. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77588. * Cube and 2D textures for instance.
  77589. */
  77590. recreateShadowMap(): void;
  77591. private _disposeBlurPostProcesses;
  77592. private _disposeRTTandPostProcesses;
  77593. /**
  77594. * Disposes the ShadowGenerator.
  77595. * Returns nothing.
  77596. */
  77597. dispose(): void;
  77598. /**
  77599. * Serializes the shadow generator setup to a json object.
  77600. * @returns The serialized JSON object
  77601. */
  77602. serialize(): any;
  77603. /**
  77604. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77605. * @param parsedShadowGenerator The JSON object to parse
  77606. * @param scene The scene to create the shadow map for
  77607. * @returns The parsed shadow generator
  77608. */
  77609. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77610. }
  77611. }
  77612. declare module BABYLON {
  77613. /**
  77614. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77615. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77616. * 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.
  77617. */
  77618. export abstract class Light extends Node {
  77619. /**
  77620. * Falloff Default: light is falling off following the material specification:
  77621. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77622. */
  77623. static readonly FALLOFF_DEFAULT: number;
  77624. /**
  77625. * Falloff Physical: light is falling off following the inverse squared distance law.
  77626. */
  77627. static readonly FALLOFF_PHYSICAL: number;
  77628. /**
  77629. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77630. * to enhance interoperability with other engines.
  77631. */
  77632. static readonly FALLOFF_GLTF: number;
  77633. /**
  77634. * Falloff Standard: light is falling off like in the standard material
  77635. * to enhance interoperability with other materials.
  77636. */
  77637. static readonly FALLOFF_STANDARD: number;
  77638. /**
  77639. * If every light affecting the material is in this lightmapMode,
  77640. * material.lightmapTexture adds or multiplies
  77641. * (depends on material.useLightmapAsShadowmap)
  77642. * after every other light calculations.
  77643. */
  77644. static readonly LIGHTMAP_DEFAULT: number;
  77645. /**
  77646. * material.lightmapTexture as only diffuse lighting from this light
  77647. * adds only specular lighting from this light
  77648. * adds dynamic shadows
  77649. */
  77650. static readonly LIGHTMAP_SPECULAR: number;
  77651. /**
  77652. * material.lightmapTexture as only lighting
  77653. * no light calculation from this light
  77654. * only adds dynamic shadows from this light
  77655. */
  77656. static readonly LIGHTMAP_SHADOWSONLY: number;
  77657. /**
  77658. * Each light type uses the default quantity according to its type:
  77659. * point/spot lights use luminous intensity
  77660. * directional lights use illuminance
  77661. */
  77662. static readonly INTENSITYMODE_AUTOMATIC: number;
  77663. /**
  77664. * lumen (lm)
  77665. */
  77666. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77667. /**
  77668. * candela (lm/sr)
  77669. */
  77670. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77671. /**
  77672. * lux (lm/m^2)
  77673. */
  77674. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77675. /**
  77676. * nit (cd/m^2)
  77677. */
  77678. static readonly INTENSITYMODE_LUMINANCE: number;
  77679. /**
  77680. * Light type const id of the point light.
  77681. */
  77682. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77683. /**
  77684. * Light type const id of the directional light.
  77685. */
  77686. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77687. /**
  77688. * Light type const id of the spot light.
  77689. */
  77690. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77691. /**
  77692. * Light type const id of the hemispheric light.
  77693. */
  77694. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77695. /**
  77696. * Diffuse gives the basic color to an object.
  77697. */
  77698. diffuse: Color3;
  77699. /**
  77700. * Specular produces a highlight color on an object.
  77701. * Note: This is note affecting PBR materials.
  77702. */
  77703. specular: Color3;
  77704. /**
  77705. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77706. * falling off base on range or angle.
  77707. * This can be set to any values in Light.FALLOFF_x.
  77708. *
  77709. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77710. * other types of materials.
  77711. */
  77712. falloffType: number;
  77713. /**
  77714. * Strength of the light.
  77715. * Note: By default it is define in the framework own unit.
  77716. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77717. */
  77718. intensity: number;
  77719. private _range;
  77720. protected _inverseSquaredRange: number;
  77721. /**
  77722. * Defines how far from the source the light is impacting in scene units.
  77723. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77724. */
  77725. /**
  77726. * Defines how far from the source the light is impacting in scene units.
  77727. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77728. */
  77729. range: number;
  77730. /**
  77731. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77732. * of light.
  77733. */
  77734. private _photometricScale;
  77735. private _intensityMode;
  77736. /**
  77737. * Gets the photometric scale used to interpret the intensity.
  77738. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77739. */
  77740. /**
  77741. * Sets the photometric scale used to interpret the intensity.
  77742. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77743. */
  77744. intensityMode: number;
  77745. private _radius;
  77746. /**
  77747. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77748. */
  77749. /**
  77750. * sets the light radius used by PBR Materials to simulate soft area lights.
  77751. */
  77752. radius: number;
  77753. private _renderPriority;
  77754. /**
  77755. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77756. * exceeding the number allowed of the materials.
  77757. */
  77758. renderPriority: number;
  77759. private _shadowEnabled;
  77760. /**
  77761. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77762. * the current shadow generator.
  77763. */
  77764. /**
  77765. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77766. * the current shadow generator.
  77767. */
  77768. shadowEnabled: boolean;
  77769. private _includedOnlyMeshes;
  77770. /**
  77771. * Gets the only meshes impacted by this light.
  77772. */
  77773. /**
  77774. * Sets the only meshes impacted by this light.
  77775. */
  77776. includedOnlyMeshes: AbstractMesh[];
  77777. private _excludedMeshes;
  77778. /**
  77779. * Gets the meshes not impacted by this light.
  77780. */
  77781. /**
  77782. * Sets the meshes not impacted by this light.
  77783. */
  77784. excludedMeshes: AbstractMesh[];
  77785. private _excludeWithLayerMask;
  77786. /**
  77787. * Gets the layer id use to find what meshes are not impacted by the light.
  77788. * Inactive if 0
  77789. */
  77790. /**
  77791. * Sets the layer id use to find what meshes are not impacted by the light.
  77792. * Inactive if 0
  77793. */
  77794. excludeWithLayerMask: number;
  77795. private _includeOnlyWithLayerMask;
  77796. /**
  77797. * Gets the layer id use to find what meshes are impacted by the light.
  77798. * Inactive if 0
  77799. */
  77800. /**
  77801. * Sets the layer id use to find what meshes are impacted by the light.
  77802. * Inactive if 0
  77803. */
  77804. includeOnlyWithLayerMask: number;
  77805. private _lightmapMode;
  77806. /**
  77807. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77808. */
  77809. /**
  77810. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77811. */
  77812. lightmapMode: number;
  77813. /**
  77814. * Shadow generator associted to the light.
  77815. * @hidden Internal use only.
  77816. */
  77817. _shadowGenerator: Nullable<IShadowGenerator>;
  77818. /**
  77819. * @hidden Internal use only.
  77820. */
  77821. _excludedMeshesIds: string[];
  77822. /**
  77823. * @hidden Internal use only.
  77824. */
  77825. _includedOnlyMeshesIds: string[];
  77826. /**
  77827. * The current light unifom buffer.
  77828. * @hidden Internal use only.
  77829. */
  77830. _uniformBuffer: UniformBuffer;
  77831. /** @hidden */
  77832. _renderId: number;
  77833. /**
  77834. * Creates a Light object in the scene.
  77835. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77836. * @param name The firendly name of the light
  77837. * @param scene The scene the light belongs too
  77838. */
  77839. constructor(name: string, scene: Scene);
  77840. protected abstract _buildUniformLayout(): void;
  77841. /**
  77842. * Sets the passed Effect "effect" with the Light information.
  77843. * @param effect The effect to update
  77844. * @param lightIndex The index of the light in the effect to update
  77845. * @returns The light
  77846. */
  77847. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77848. /**
  77849. * Sets the passed Effect "effect" with the Light information.
  77850. * @param effect The effect to update
  77851. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77852. * @returns The light
  77853. */
  77854. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77855. /**
  77856. * Returns the string "Light".
  77857. * @returns the class name
  77858. */
  77859. getClassName(): string;
  77860. /** @hidden */
  77861. readonly _isLight: boolean;
  77862. /**
  77863. * Converts the light information to a readable string for debug purpose.
  77864. * @param fullDetails Supports for multiple levels of logging within scene loading
  77865. * @returns the human readable light info
  77866. */
  77867. toString(fullDetails?: boolean): string;
  77868. /** @hidden */
  77869. protected _syncParentEnabledState(): void;
  77870. /**
  77871. * Set the enabled state of this node.
  77872. * @param value - the new enabled state
  77873. */
  77874. setEnabled(value: boolean): void;
  77875. /**
  77876. * Returns the Light associated shadow generator if any.
  77877. * @return the associated shadow generator.
  77878. */
  77879. getShadowGenerator(): Nullable<IShadowGenerator>;
  77880. /**
  77881. * Returns a Vector3, the absolute light position in the World.
  77882. * @returns the world space position of the light
  77883. */
  77884. getAbsolutePosition(): Vector3;
  77885. /**
  77886. * Specifies if the light will affect the passed mesh.
  77887. * @param mesh The mesh to test against the light
  77888. * @return true the mesh is affected otherwise, false.
  77889. */
  77890. canAffectMesh(mesh: AbstractMesh): boolean;
  77891. /**
  77892. * Sort function to order lights for rendering.
  77893. * @param a First Light object to compare to second.
  77894. * @param b Second Light object to compare first.
  77895. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77896. */
  77897. static CompareLightsPriority(a: Light, b: Light): number;
  77898. /**
  77899. * Releases resources associated with this node.
  77900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77902. */
  77903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77904. /**
  77905. * Returns the light type ID (integer).
  77906. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77907. */
  77908. getTypeID(): number;
  77909. /**
  77910. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77911. * @returns the scaled intensity in intensity mode unit
  77912. */
  77913. getScaledIntensity(): number;
  77914. /**
  77915. * Returns a new Light object, named "name", from the current one.
  77916. * @param name The name of the cloned light
  77917. * @returns the new created light
  77918. */
  77919. clone(name: string): Nullable<Light>;
  77920. /**
  77921. * Serializes the current light into a Serialization object.
  77922. * @returns the serialized object.
  77923. */
  77924. serialize(): any;
  77925. /**
  77926. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77927. * This new light is named "name" and added to the passed scene.
  77928. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77929. * @param name The friendly name of the light
  77930. * @param scene The scene the new light will belong to
  77931. * @returns the constructor function
  77932. */
  77933. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77934. /**
  77935. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77936. * @param parsedLight The JSON representation of the light
  77937. * @param scene The scene to create the parsed light in
  77938. * @returns the created light after parsing
  77939. */
  77940. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77941. private _hookArrayForExcluded;
  77942. private _hookArrayForIncludedOnly;
  77943. private _resyncMeshes;
  77944. /**
  77945. * Forces the meshes to update their light related information in their rendering used effects
  77946. * @hidden Internal Use Only
  77947. */
  77948. _markMeshesAsLightDirty(): void;
  77949. /**
  77950. * Recomputes the cached photometric scale if needed.
  77951. */
  77952. private _computePhotometricScale;
  77953. /**
  77954. * Returns the Photometric Scale according to the light type and intensity mode.
  77955. */
  77956. private _getPhotometricScale;
  77957. /**
  77958. * Reorder the light in the scene according to their defined priority.
  77959. * @hidden Internal Use Only
  77960. */
  77961. _reorderLightsInScene(): void;
  77962. /**
  77963. * Prepares the list of defines specific to the light type.
  77964. * @param defines the list of defines
  77965. * @param lightIndex defines the index of the light for the effect
  77966. */
  77967. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77968. }
  77969. }
  77970. declare module BABYLON {
  77971. /**
  77972. * Interface used to define Action
  77973. */
  77974. export interface IAction {
  77975. /**
  77976. * Trigger for the action
  77977. */
  77978. trigger: number;
  77979. /** Options of the trigger */
  77980. triggerOptions: any;
  77981. /**
  77982. * Gets the trigger parameters
  77983. * @returns the trigger parameters
  77984. */
  77985. getTriggerParameter(): any;
  77986. /**
  77987. * Internal only - executes current action event
  77988. * @hidden
  77989. */
  77990. _executeCurrent(evt?: ActionEvent): void;
  77991. /**
  77992. * Serialize placeholder for child classes
  77993. * @param parent of child
  77994. * @returns the serialized object
  77995. */
  77996. serialize(parent: any): any;
  77997. /**
  77998. * Internal only
  77999. * @hidden
  78000. */
  78001. _prepare(): void;
  78002. /**
  78003. * Internal only - manager for action
  78004. * @hidden
  78005. */
  78006. _actionManager: AbstractActionManager;
  78007. /**
  78008. * Adds action to chain of actions, may be a DoNothingAction
  78009. * @param action defines the next action to execute
  78010. * @returns The action passed in
  78011. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78012. */
  78013. then(action: IAction): IAction;
  78014. }
  78015. /**
  78016. * The action to be carried out following a trigger
  78017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78018. */
  78019. export class Action implements IAction {
  78020. /** the trigger, with or without parameters, for the action */
  78021. triggerOptions: any;
  78022. /**
  78023. * Trigger for the action
  78024. */
  78025. trigger: number;
  78026. /**
  78027. * Internal only - manager for action
  78028. * @hidden
  78029. */
  78030. _actionManager: ActionManager;
  78031. private _nextActiveAction;
  78032. private _child;
  78033. private _condition?;
  78034. private _triggerParameter;
  78035. /**
  78036. * An event triggered prior to action being executed.
  78037. */
  78038. onBeforeExecuteObservable: Observable<Action>;
  78039. /**
  78040. * Creates a new Action
  78041. * @param triggerOptions the trigger, with or without parameters, for the action
  78042. * @param condition an optional determinant of action
  78043. */
  78044. constructor(
  78045. /** the trigger, with or without parameters, for the action */
  78046. triggerOptions: any, condition?: Condition);
  78047. /**
  78048. * Internal only
  78049. * @hidden
  78050. */
  78051. _prepare(): void;
  78052. /**
  78053. * Gets the trigger parameters
  78054. * @returns the trigger parameters
  78055. */
  78056. getTriggerParameter(): any;
  78057. /**
  78058. * Internal only - executes current action event
  78059. * @hidden
  78060. */
  78061. _executeCurrent(evt?: ActionEvent): void;
  78062. /**
  78063. * Execute placeholder for child classes
  78064. * @param evt optional action event
  78065. */
  78066. execute(evt?: ActionEvent): void;
  78067. /**
  78068. * Skips to next active action
  78069. */
  78070. skipToNextActiveAction(): void;
  78071. /**
  78072. * Adds action to chain of actions, may be a DoNothingAction
  78073. * @param action defines the next action to execute
  78074. * @returns The action passed in
  78075. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78076. */
  78077. then(action: Action): Action;
  78078. /**
  78079. * Internal only
  78080. * @hidden
  78081. */
  78082. _getProperty(propertyPath: string): string;
  78083. /**
  78084. * Internal only
  78085. * @hidden
  78086. */
  78087. _getEffectiveTarget(target: any, propertyPath: string): any;
  78088. /**
  78089. * Serialize placeholder for child classes
  78090. * @param parent of child
  78091. * @returns the serialized object
  78092. */
  78093. serialize(parent: any): any;
  78094. /**
  78095. * Internal only called by serialize
  78096. * @hidden
  78097. */
  78098. protected _serialize(serializedAction: any, parent?: any): any;
  78099. /**
  78100. * Internal only
  78101. * @hidden
  78102. */
  78103. static _SerializeValueAsString: (value: any) => string;
  78104. /**
  78105. * Internal only
  78106. * @hidden
  78107. */
  78108. static _GetTargetProperty: (target: Node | Scene) => {
  78109. name: string;
  78110. targetType: string;
  78111. value: string;
  78112. };
  78113. }
  78114. }
  78115. declare module BABYLON {
  78116. /**
  78117. * A Condition applied to an Action
  78118. */
  78119. export class Condition {
  78120. /**
  78121. * Internal only - manager for action
  78122. * @hidden
  78123. */
  78124. _actionManager: ActionManager;
  78125. /**
  78126. * Internal only
  78127. * @hidden
  78128. */
  78129. _evaluationId: number;
  78130. /**
  78131. * Internal only
  78132. * @hidden
  78133. */
  78134. _currentResult: boolean;
  78135. /**
  78136. * Creates a new Condition
  78137. * @param actionManager the manager of the action the condition is applied to
  78138. */
  78139. constructor(actionManager: ActionManager);
  78140. /**
  78141. * Check if the current condition is valid
  78142. * @returns a boolean
  78143. */
  78144. isValid(): boolean;
  78145. /**
  78146. * Internal only
  78147. * @hidden
  78148. */
  78149. _getProperty(propertyPath: string): string;
  78150. /**
  78151. * Internal only
  78152. * @hidden
  78153. */
  78154. _getEffectiveTarget(target: any, propertyPath: string): any;
  78155. /**
  78156. * Serialize placeholder for child classes
  78157. * @returns the serialized object
  78158. */
  78159. serialize(): any;
  78160. /**
  78161. * Internal only
  78162. * @hidden
  78163. */
  78164. protected _serialize(serializedCondition: any): any;
  78165. }
  78166. /**
  78167. * Defines specific conditional operators as extensions of Condition
  78168. */
  78169. export class ValueCondition extends Condition {
  78170. /** path to specify the property of the target the conditional operator uses */
  78171. propertyPath: string;
  78172. /** the value compared by the conditional operator against the current value of the property */
  78173. value: any;
  78174. /** the conditional operator, default ValueCondition.IsEqual */
  78175. operator: number;
  78176. /**
  78177. * Internal only
  78178. * @hidden
  78179. */
  78180. private static _IsEqual;
  78181. /**
  78182. * Internal only
  78183. * @hidden
  78184. */
  78185. private static _IsDifferent;
  78186. /**
  78187. * Internal only
  78188. * @hidden
  78189. */
  78190. private static _IsGreater;
  78191. /**
  78192. * Internal only
  78193. * @hidden
  78194. */
  78195. private static _IsLesser;
  78196. /**
  78197. * returns the number for IsEqual
  78198. */
  78199. static readonly IsEqual: number;
  78200. /**
  78201. * Returns the number for IsDifferent
  78202. */
  78203. static readonly IsDifferent: number;
  78204. /**
  78205. * Returns the number for IsGreater
  78206. */
  78207. static readonly IsGreater: number;
  78208. /**
  78209. * Returns the number for IsLesser
  78210. */
  78211. static readonly IsLesser: number;
  78212. /**
  78213. * Internal only The action manager for the condition
  78214. * @hidden
  78215. */
  78216. _actionManager: ActionManager;
  78217. /**
  78218. * Internal only
  78219. * @hidden
  78220. */
  78221. private _target;
  78222. /**
  78223. * Internal only
  78224. * @hidden
  78225. */
  78226. private _effectiveTarget;
  78227. /**
  78228. * Internal only
  78229. * @hidden
  78230. */
  78231. private _property;
  78232. /**
  78233. * Creates a new ValueCondition
  78234. * @param actionManager manager for the action the condition applies to
  78235. * @param target for the action
  78236. * @param propertyPath path to specify the property of the target the conditional operator uses
  78237. * @param value the value compared by the conditional operator against the current value of the property
  78238. * @param operator the conditional operator, default ValueCondition.IsEqual
  78239. */
  78240. constructor(actionManager: ActionManager, target: any,
  78241. /** path to specify the property of the target the conditional operator uses */
  78242. propertyPath: string,
  78243. /** the value compared by the conditional operator against the current value of the property */
  78244. value: any,
  78245. /** the conditional operator, default ValueCondition.IsEqual */
  78246. operator?: number);
  78247. /**
  78248. * Compares the given value with the property value for the specified conditional operator
  78249. * @returns the result of the comparison
  78250. */
  78251. isValid(): boolean;
  78252. /**
  78253. * Serialize the ValueCondition into a JSON compatible object
  78254. * @returns serialization object
  78255. */
  78256. serialize(): any;
  78257. /**
  78258. * Gets the name of the conditional operator for the ValueCondition
  78259. * @param operator the conditional operator
  78260. * @returns the name
  78261. */
  78262. static GetOperatorName(operator: number): string;
  78263. }
  78264. /**
  78265. * Defines a predicate condition as an extension of Condition
  78266. */
  78267. export class PredicateCondition extends Condition {
  78268. /** defines the predicate function used to validate the condition */
  78269. predicate: () => boolean;
  78270. /**
  78271. * Internal only - manager for action
  78272. * @hidden
  78273. */
  78274. _actionManager: ActionManager;
  78275. /**
  78276. * Creates a new PredicateCondition
  78277. * @param actionManager manager for the action the condition applies to
  78278. * @param predicate defines the predicate function used to validate the condition
  78279. */
  78280. constructor(actionManager: ActionManager,
  78281. /** defines the predicate function used to validate the condition */
  78282. predicate: () => boolean);
  78283. /**
  78284. * @returns the validity of the predicate condition
  78285. */
  78286. isValid(): boolean;
  78287. }
  78288. /**
  78289. * Defines a state condition as an extension of Condition
  78290. */
  78291. export class StateCondition extends Condition {
  78292. /** Value to compare with target state */
  78293. value: string;
  78294. /**
  78295. * Internal only - manager for action
  78296. * @hidden
  78297. */
  78298. _actionManager: ActionManager;
  78299. /**
  78300. * Internal only
  78301. * @hidden
  78302. */
  78303. private _target;
  78304. /**
  78305. * Creates a new StateCondition
  78306. * @param actionManager manager for the action the condition applies to
  78307. * @param target of the condition
  78308. * @param value to compare with target state
  78309. */
  78310. constructor(actionManager: ActionManager, target: any,
  78311. /** Value to compare with target state */
  78312. value: string);
  78313. /**
  78314. * Gets a boolean indicating if the current condition is met
  78315. * @returns the validity of the state
  78316. */
  78317. isValid(): boolean;
  78318. /**
  78319. * Serialize the StateCondition into a JSON compatible object
  78320. * @returns serialization object
  78321. */
  78322. serialize(): any;
  78323. }
  78324. }
  78325. declare module BABYLON {
  78326. /**
  78327. * This defines an action responsible to toggle a boolean once triggered.
  78328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78329. */
  78330. export class SwitchBooleanAction extends Action {
  78331. /**
  78332. * The path to the boolean property in the target object
  78333. */
  78334. propertyPath: string;
  78335. private _target;
  78336. private _effectiveTarget;
  78337. private _property;
  78338. /**
  78339. * Instantiate the action
  78340. * @param triggerOptions defines the trigger options
  78341. * @param target defines the object containing the boolean
  78342. * @param propertyPath defines the path to the boolean property in the target object
  78343. * @param condition defines the trigger related conditions
  78344. */
  78345. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78346. /** @hidden */
  78347. _prepare(): void;
  78348. /**
  78349. * Execute the action toggle the boolean value.
  78350. */
  78351. execute(): void;
  78352. /**
  78353. * Serializes the actions and its related information.
  78354. * @param parent defines the object to serialize in
  78355. * @returns the serialized object
  78356. */
  78357. serialize(parent: any): any;
  78358. }
  78359. /**
  78360. * This defines an action responsible to set a the state field of the target
  78361. * to a desired value once triggered.
  78362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78363. */
  78364. export class SetStateAction extends Action {
  78365. /**
  78366. * The value to store in the state field.
  78367. */
  78368. value: string;
  78369. private _target;
  78370. /**
  78371. * Instantiate the action
  78372. * @param triggerOptions defines the trigger options
  78373. * @param target defines the object containing the state property
  78374. * @param value defines the value to store in the state field
  78375. * @param condition defines the trigger related conditions
  78376. */
  78377. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78378. /**
  78379. * Execute the action and store the value on the target state property.
  78380. */
  78381. execute(): void;
  78382. /**
  78383. * Serializes the actions and its related information.
  78384. * @param parent defines the object to serialize in
  78385. * @returns the serialized object
  78386. */
  78387. serialize(parent: any): any;
  78388. }
  78389. /**
  78390. * This defines an action responsible to set a property of the target
  78391. * to a desired value once triggered.
  78392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78393. */
  78394. export class SetValueAction extends Action {
  78395. /**
  78396. * The path of the property to set in the target.
  78397. */
  78398. propertyPath: string;
  78399. /**
  78400. * The value to set in the property
  78401. */
  78402. value: any;
  78403. private _target;
  78404. private _effectiveTarget;
  78405. private _property;
  78406. /**
  78407. * Instantiate the action
  78408. * @param triggerOptions defines the trigger options
  78409. * @param target defines the object containing the property
  78410. * @param propertyPath defines the path of the property to set in the target
  78411. * @param value defines the value to set in the property
  78412. * @param condition defines the trigger related conditions
  78413. */
  78414. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78415. /** @hidden */
  78416. _prepare(): void;
  78417. /**
  78418. * Execute the action and set the targetted property to the desired value.
  78419. */
  78420. execute(): void;
  78421. /**
  78422. * Serializes the actions and its related information.
  78423. * @param parent defines the object to serialize in
  78424. * @returns the serialized object
  78425. */
  78426. serialize(parent: any): any;
  78427. }
  78428. /**
  78429. * This defines an action responsible to increment the target value
  78430. * to a desired value once triggered.
  78431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78432. */
  78433. export class IncrementValueAction extends Action {
  78434. /**
  78435. * The path of the property to increment in the target.
  78436. */
  78437. propertyPath: string;
  78438. /**
  78439. * The value we should increment the property by.
  78440. */
  78441. value: any;
  78442. private _target;
  78443. private _effectiveTarget;
  78444. private _property;
  78445. /**
  78446. * Instantiate the action
  78447. * @param triggerOptions defines the trigger options
  78448. * @param target defines the object containing the property
  78449. * @param propertyPath defines the path of the property to increment in the target
  78450. * @param value defines the value value we should increment the property by
  78451. * @param condition defines the trigger related conditions
  78452. */
  78453. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78454. /** @hidden */
  78455. _prepare(): void;
  78456. /**
  78457. * Execute the action and increment the target of the value amount.
  78458. */
  78459. execute(): void;
  78460. /**
  78461. * Serializes the actions and its related information.
  78462. * @param parent defines the object to serialize in
  78463. * @returns the serialized object
  78464. */
  78465. serialize(parent: any): any;
  78466. }
  78467. /**
  78468. * This defines an action responsible to start an animation once triggered.
  78469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78470. */
  78471. export class PlayAnimationAction extends Action {
  78472. /**
  78473. * Where the animation should start (animation frame)
  78474. */
  78475. from: number;
  78476. /**
  78477. * Where the animation should stop (animation frame)
  78478. */
  78479. to: number;
  78480. /**
  78481. * Define if the animation should loop or stop after the first play.
  78482. */
  78483. loop?: boolean;
  78484. private _target;
  78485. /**
  78486. * Instantiate the action
  78487. * @param triggerOptions defines the trigger options
  78488. * @param target defines the target animation or animation name
  78489. * @param from defines from where the animation should start (animation frame)
  78490. * @param end defines where the animation should stop (animation frame)
  78491. * @param loop defines if the animation should loop or stop after the first play
  78492. * @param condition defines the trigger related conditions
  78493. */
  78494. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78495. /** @hidden */
  78496. _prepare(): void;
  78497. /**
  78498. * Execute the action and play the animation.
  78499. */
  78500. execute(): void;
  78501. /**
  78502. * Serializes the actions and its related information.
  78503. * @param parent defines the object to serialize in
  78504. * @returns the serialized object
  78505. */
  78506. serialize(parent: any): any;
  78507. }
  78508. /**
  78509. * This defines an action responsible to stop an animation once triggered.
  78510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78511. */
  78512. export class StopAnimationAction extends Action {
  78513. private _target;
  78514. /**
  78515. * Instantiate the action
  78516. * @param triggerOptions defines the trigger options
  78517. * @param target defines the target animation or animation name
  78518. * @param condition defines the trigger related conditions
  78519. */
  78520. constructor(triggerOptions: any, target: any, condition?: Condition);
  78521. /** @hidden */
  78522. _prepare(): void;
  78523. /**
  78524. * Execute the action and stop the animation.
  78525. */
  78526. execute(): void;
  78527. /**
  78528. * Serializes the actions and its related information.
  78529. * @param parent defines the object to serialize in
  78530. * @returns the serialized object
  78531. */
  78532. serialize(parent: any): any;
  78533. }
  78534. /**
  78535. * This defines an action responsible that does nothing once triggered.
  78536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78537. */
  78538. export class DoNothingAction extends Action {
  78539. /**
  78540. * Instantiate the action
  78541. * @param triggerOptions defines the trigger options
  78542. * @param condition defines the trigger related conditions
  78543. */
  78544. constructor(triggerOptions?: any, condition?: Condition);
  78545. /**
  78546. * Execute the action and do nothing.
  78547. */
  78548. execute(): void;
  78549. /**
  78550. * Serializes the actions and its related information.
  78551. * @param parent defines the object to serialize in
  78552. * @returns the serialized object
  78553. */
  78554. serialize(parent: any): any;
  78555. }
  78556. /**
  78557. * This defines an action responsible to trigger several actions once triggered.
  78558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78559. */
  78560. export class CombineAction extends Action {
  78561. /**
  78562. * The list of aggregated animations to run.
  78563. */
  78564. children: Action[];
  78565. /**
  78566. * Instantiate the action
  78567. * @param triggerOptions defines the trigger options
  78568. * @param children defines the list of aggregated animations to run
  78569. * @param condition defines the trigger related conditions
  78570. */
  78571. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78572. /** @hidden */
  78573. _prepare(): void;
  78574. /**
  78575. * Execute the action and executes all the aggregated actions.
  78576. */
  78577. execute(evt: ActionEvent): void;
  78578. /**
  78579. * Serializes the actions and its related information.
  78580. * @param parent defines the object to serialize in
  78581. * @returns the serialized object
  78582. */
  78583. serialize(parent: any): any;
  78584. }
  78585. /**
  78586. * This defines an action responsible to run code (external event) once triggered.
  78587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78588. */
  78589. export class ExecuteCodeAction extends Action {
  78590. /**
  78591. * The callback function to run.
  78592. */
  78593. func: (evt: ActionEvent) => void;
  78594. /**
  78595. * Instantiate the action
  78596. * @param triggerOptions defines the trigger options
  78597. * @param func defines the callback function to run
  78598. * @param condition defines the trigger related conditions
  78599. */
  78600. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78601. /**
  78602. * Execute the action and run the attached code.
  78603. */
  78604. execute(evt: ActionEvent): void;
  78605. }
  78606. /**
  78607. * This defines an action responsible to set the parent property of the target once triggered.
  78608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78609. */
  78610. export class SetParentAction extends Action {
  78611. private _parent;
  78612. private _target;
  78613. /**
  78614. * Instantiate the action
  78615. * @param triggerOptions defines the trigger options
  78616. * @param target defines the target containing the parent property
  78617. * @param parent defines from where the animation should start (animation frame)
  78618. * @param condition defines the trigger related conditions
  78619. */
  78620. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78621. /** @hidden */
  78622. _prepare(): void;
  78623. /**
  78624. * Execute the action and set the parent property.
  78625. */
  78626. execute(): void;
  78627. /**
  78628. * Serializes the actions and its related information.
  78629. * @param parent defines the object to serialize in
  78630. * @returns the serialized object
  78631. */
  78632. serialize(parent: any): any;
  78633. }
  78634. }
  78635. declare module BABYLON {
  78636. /**
  78637. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78638. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78640. */
  78641. export class ActionManager extends AbstractActionManager {
  78642. /**
  78643. * Nothing
  78644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78645. */
  78646. static readonly NothingTrigger: number;
  78647. /**
  78648. * On pick
  78649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78650. */
  78651. static readonly OnPickTrigger: number;
  78652. /**
  78653. * On left pick
  78654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78655. */
  78656. static readonly OnLeftPickTrigger: number;
  78657. /**
  78658. * On right pick
  78659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78660. */
  78661. static readonly OnRightPickTrigger: number;
  78662. /**
  78663. * On center pick
  78664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78665. */
  78666. static readonly OnCenterPickTrigger: number;
  78667. /**
  78668. * On pick down
  78669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78670. */
  78671. static readonly OnPickDownTrigger: number;
  78672. /**
  78673. * On double pick
  78674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78675. */
  78676. static readonly OnDoublePickTrigger: number;
  78677. /**
  78678. * On pick up
  78679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78680. */
  78681. static readonly OnPickUpTrigger: number;
  78682. /**
  78683. * On pick out.
  78684. * This trigger will only be raised if you also declared a OnPickDown
  78685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78686. */
  78687. static readonly OnPickOutTrigger: number;
  78688. /**
  78689. * On long press
  78690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78691. */
  78692. static readonly OnLongPressTrigger: number;
  78693. /**
  78694. * On pointer over
  78695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78696. */
  78697. static readonly OnPointerOverTrigger: number;
  78698. /**
  78699. * On pointer out
  78700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78701. */
  78702. static readonly OnPointerOutTrigger: number;
  78703. /**
  78704. * On every frame
  78705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78706. */
  78707. static readonly OnEveryFrameTrigger: number;
  78708. /**
  78709. * On intersection enter
  78710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78711. */
  78712. static readonly OnIntersectionEnterTrigger: number;
  78713. /**
  78714. * On intersection exit
  78715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78716. */
  78717. static readonly OnIntersectionExitTrigger: number;
  78718. /**
  78719. * On key down
  78720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78721. */
  78722. static readonly OnKeyDownTrigger: number;
  78723. /**
  78724. * On key up
  78725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78726. */
  78727. static readonly OnKeyUpTrigger: number;
  78728. private _scene;
  78729. /**
  78730. * Creates a new action manager
  78731. * @param scene defines the hosting scene
  78732. */
  78733. constructor(scene: Scene);
  78734. /**
  78735. * Releases all associated resources
  78736. */
  78737. dispose(): void;
  78738. /**
  78739. * Gets hosting scene
  78740. * @returns the hosting scene
  78741. */
  78742. getScene(): Scene;
  78743. /**
  78744. * Does this action manager handles actions of any of the given triggers
  78745. * @param triggers defines the triggers to be tested
  78746. * @return a boolean indicating whether one (or more) of the triggers is handled
  78747. */
  78748. hasSpecificTriggers(triggers: number[]): boolean;
  78749. /**
  78750. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78751. * speed.
  78752. * @param triggerA defines the trigger to be tested
  78753. * @param triggerB defines the trigger to be tested
  78754. * @return a boolean indicating whether one (or more) of the triggers is handled
  78755. */
  78756. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78757. /**
  78758. * Does this action manager handles actions of a given trigger
  78759. * @param trigger defines the trigger to be tested
  78760. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78761. * @return whether the trigger is handled
  78762. */
  78763. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78764. /**
  78765. * Does this action manager has pointer triggers
  78766. */
  78767. readonly hasPointerTriggers: boolean;
  78768. /**
  78769. * Does this action manager has pick triggers
  78770. */
  78771. readonly hasPickTriggers: boolean;
  78772. /**
  78773. * Registers an action to this action manager
  78774. * @param action defines the action to be registered
  78775. * @return the action amended (prepared) after registration
  78776. */
  78777. registerAction(action: IAction): Nullable<IAction>;
  78778. /**
  78779. * Unregisters an action to this action manager
  78780. * @param action defines the action to be unregistered
  78781. * @return a boolean indicating whether the action has been unregistered
  78782. */
  78783. unregisterAction(action: IAction): Boolean;
  78784. /**
  78785. * Process a specific trigger
  78786. * @param trigger defines the trigger to process
  78787. * @param evt defines the event details to be processed
  78788. */
  78789. processTrigger(trigger: number, evt?: IActionEvent): void;
  78790. /** @hidden */
  78791. _getEffectiveTarget(target: any, propertyPath: string): any;
  78792. /** @hidden */
  78793. _getProperty(propertyPath: string): string;
  78794. /**
  78795. * Serialize this manager to a JSON object
  78796. * @param name defines the property name to store this manager
  78797. * @returns a JSON representation of this manager
  78798. */
  78799. serialize(name: string): any;
  78800. /**
  78801. * Creates a new ActionManager from a JSON data
  78802. * @param parsedActions defines the JSON data to read from
  78803. * @param object defines the hosting mesh
  78804. * @param scene defines the hosting scene
  78805. */
  78806. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78807. /**
  78808. * Get a trigger name by index
  78809. * @param trigger defines the trigger index
  78810. * @returns a trigger name
  78811. */
  78812. static GetTriggerName(trigger: number): string;
  78813. }
  78814. }
  78815. declare module BABYLON {
  78816. /**
  78817. * Class representing a ray with position and direction
  78818. */
  78819. export class Ray {
  78820. /** origin point */
  78821. origin: Vector3;
  78822. /** direction */
  78823. direction: Vector3;
  78824. /** length of the ray */
  78825. length: number;
  78826. private static readonly TmpVector3;
  78827. private _tmpRay;
  78828. /**
  78829. * Creates a new ray
  78830. * @param origin origin point
  78831. * @param direction direction
  78832. * @param length length of the ray
  78833. */
  78834. constructor(
  78835. /** origin point */
  78836. origin: Vector3,
  78837. /** direction */
  78838. direction: Vector3,
  78839. /** length of the ray */
  78840. length?: number);
  78841. /**
  78842. * Checks if the ray intersects a box
  78843. * @param minimum bound of the box
  78844. * @param maximum bound of the box
  78845. * @param intersectionTreshold extra extend to be added to the box in all direction
  78846. * @returns if the box was hit
  78847. */
  78848. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78849. /**
  78850. * Checks if the ray intersects a box
  78851. * @param box the bounding box to check
  78852. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78853. * @returns if the box was hit
  78854. */
  78855. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78856. /**
  78857. * If the ray hits a sphere
  78858. * @param sphere the bounding sphere to check
  78859. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78860. * @returns true if it hits the sphere
  78861. */
  78862. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78863. /**
  78864. * If the ray hits a triange
  78865. * @param vertex0 triangle vertex
  78866. * @param vertex1 triangle vertex
  78867. * @param vertex2 triangle vertex
  78868. * @returns intersection information if hit
  78869. */
  78870. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78871. /**
  78872. * Checks if ray intersects a plane
  78873. * @param plane the plane to check
  78874. * @returns the distance away it was hit
  78875. */
  78876. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78877. /**
  78878. * Calculate the intercept of a ray on a given axis
  78879. * @param axis to check 'x' | 'y' | 'z'
  78880. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78881. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78882. */
  78883. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78884. /**
  78885. * Checks if ray intersects a mesh
  78886. * @param mesh the mesh to check
  78887. * @param fastCheck if only the bounding box should checked
  78888. * @returns picking info of the intersecton
  78889. */
  78890. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78891. /**
  78892. * Checks if ray intersects a mesh
  78893. * @param meshes the meshes to check
  78894. * @param fastCheck if only the bounding box should checked
  78895. * @param results array to store result in
  78896. * @returns Array of picking infos
  78897. */
  78898. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78899. private _comparePickingInfo;
  78900. private static smallnum;
  78901. private static rayl;
  78902. /**
  78903. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78904. * @param sega the first point of the segment to test the intersection against
  78905. * @param segb the second point of the segment to test the intersection against
  78906. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78907. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78908. */
  78909. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78910. /**
  78911. * Update the ray from viewport position
  78912. * @param x position
  78913. * @param y y position
  78914. * @param viewportWidth viewport width
  78915. * @param viewportHeight viewport height
  78916. * @param world world matrix
  78917. * @param view view matrix
  78918. * @param projection projection matrix
  78919. * @returns this ray updated
  78920. */
  78921. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78922. /**
  78923. * Creates a ray with origin and direction of 0,0,0
  78924. * @returns the new ray
  78925. */
  78926. static Zero(): Ray;
  78927. /**
  78928. * Creates a new ray from screen space and viewport
  78929. * @param x position
  78930. * @param y y position
  78931. * @param viewportWidth viewport width
  78932. * @param viewportHeight viewport height
  78933. * @param world world matrix
  78934. * @param view view matrix
  78935. * @param projection projection matrix
  78936. * @returns new ray
  78937. */
  78938. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78939. /**
  78940. * 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
  78941. * transformed to the given world matrix.
  78942. * @param origin The origin point
  78943. * @param end The end point
  78944. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78945. * @returns the new ray
  78946. */
  78947. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78948. /**
  78949. * Transforms a ray by a matrix
  78950. * @param ray ray to transform
  78951. * @param matrix matrix to apply
  78952. * @returns the resulting new ray
  78953. */
  78954. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78955. /**
  78956. * Transforms a ray by a matrix
  78957. * @param ray ray to transform
  78958. * @param matrix matrix to apply
  78959. * @param result ray to store result in
  78960. */
  78961. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78962. /**
  78963. * Unproject a ray from screen space to object space
  78964. * @param sourceX defines the screen space x coordinate to use
  78965. * @param sourceY defines the screen space y coordinate to use
  78966. * @param viewportWidth defines the current width of the viewport
  78967. * @param viewportHeight defines the current height of the viewport
  78968. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78969. * @param view defines the view matrix to use
  78970. * @param projection defines the projection matrix to use
  78971. */
  78972. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78973. }
  78974. /**
  78975. * Type used to define predicate used to select faces when a mesh intersection is detected
  78976. */
  78977. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78978. interface Scene {
  78979. /** @hidden */
  78980. _tempPickingRay: Nullable<Ray>;
  78981. /** @hidden */
  78982. _cachedRayForTransform: Ray;
  78983. /** @hidden */
  78984. _pickWithRayInverseMatrix: Matrix;
  78985. /** @hidden */
  78986. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78987. /** @hidden */
  78988. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78989. }
  78990. }
  78991. declare module BABYLON {
  78992. /**
  78993. * Groups all the scene component constants in one place to ease maintenance.
  78994. * @hidden
  78995. */
  78996. export class SceneComponentConstants {
  78997. static readonly NAME_EFFECTLAYER: string;
  78998. static readonly NAME_LAYER: string;
  78999. static readonly NAME_LENSFLARESYSTEM: string;
  79000. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79001. static readonly NAME_PARTICLESYSTEM: string;
  79002. static readonly NAME_GAMEPAD: string;
  79003. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79004. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79005. static readonly NAME_DEPTHRENDERER: string;
  79006. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79007. static readonly NAME_SPRITE: string;
  79008. static readonly NAME_OUTLINERENDERER: string;
  79009. static readonly NAME_PROCEDURALTEXTURE: string;
  79010. static readonly NAME_SHADOWGENERATOR: string;
  79011. static readonly NAME_OCTREE: string;
  79012. static readonly NAME_PHYSICSENGINE: string;
  79013. static readonly NAME_AUDIO: string;
  79014. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79015. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79016. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79017. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79018. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79019. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79020. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79021. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79022. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79023. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79024. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79025. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79026. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79027. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79028. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79029. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79030. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79031. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79032. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79033. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79034. static readonly STEP_AFTERRENDER_AUDIO: number;
  79035. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79036. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79037. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79038. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79039. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79040. static readonly STEP_POINTERMOVE_SPRITE: number;
  79041. static readonly STEP_POINTERDOWN_SPRITE: number;
  79042. static readonly STEP_POINTERUP_SPRITE: number;
  79043. }
  79044. /**
  79045. * This represents a scene component.
  79046. *
  79047. * This is used to decouple the dependency the scene is having on the different workloads like
  79048. * layers, post processes...
  79049. */
  79050. export interface ISceneComponent {
  79051. /**
  79052. * The name of the component. Each component must have a unique name.
  79053. */
  79054. name: string;
  79055. /**
  79056. * The scene the component belongs to.
  79057. */
  79058. scene: Scene;
  79059. /**
  79060. * Register the component to one instance of a scene.
  79061. */
  79062. register(): void;
  79063. /**
  79064. * Rebuilds the elements related to this component in case of
  79065. * context lost for instance.
  79066. */
  79067. rebuild(): void;
  79068. /**
  79069. * Disposes the component and the associated ressources.
  79070. */
  79071. dispose(): void;
  79072. }
  79073. /**
  79074. * This represents a SERIALIZABLE scene component.
  79075. *
  79076. * This extends Scene Component to add Serialization methods on top.
  79077. */
  79078. export interface ISceneSerializableComponent extends ISceneComponent {
  79079. /**
  79080. * Adds all the elements from the container to the scene
  79081. * @param container the container holding the elements
  79082. */
  79083. addFromContainer(container: AbstractScene): void;
  79084. /**
  79085. * Removes all the elements in the container from the scene
  79086. * @param container contains the elements to remove
  79087. * @param dispose if the removed element should be disposed (default: false)
  79088. */
  79089. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79090. /**
  79091. * Serializes the component data to the specified json object
  79092. * @param serializationObject The object to serialize to
  79093. */
  79094. serialize(serializationObject: any): void;
  79095. }
  79096. /**
  79097. * Strong typing of a Mesh related stage step action
  79098. */
  79099. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79100. /**
  79101. * Strong typing of a Evaluate Sub Mesh related stage step action
  79102. */
  79103. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79104. /**
  79105. * Strong typing of a Active Mesh related stage step action
  79106. */
  79107. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79108. /**
  79109. * Strong typing of a Camera related stage step action
  79110. */
  79111. export type CameraStageAction = (camera: Camera) => void;
  79112. /**
  79113. * Strong typing of a Camera Frame buffer related stage step action
  79114. */
  79115. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79116. /**
  79117. * Strong typing of a Render Target related stage step action
  79118. */
  79119. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79120. /**
  79121. * Strong typing of a RenderingGroup related stage step action
  79122. */
  79123. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79124. /**
  79125. * Strong typing of a Mesh Render related stage step action
  79126. */
  79127. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79128. /**
  79129. * Strong typing of a simple stage step action
  79130. */
  79131. export type SimpleStageAction = () => void;
  79132. /**
  79133. * Strong typing of a render target action.
  79134. */
  79135. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79136. /**
  79137. * Strong typing of a pointer move action.
  79138. */
  79139. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79140. /**
  79141. * Strong typing of a pointer up/down action.
  79142. */
  79143. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79144. /**
  79145. * Representation of a stage in the scene (Basically a list of ordered steps)
  79146. * @hidden
  79147. */
  79148. export class Stage<T extends Function> extends Array<{
  79149. index: number;
  79150. component: ISceneComponent;
  79151. action: T;
  79152. }> {
  79153. /**
  79154. * Hide ctor from the rest of the world.
  79155. * @param items The items to add.
  79156. */
  79157. private constructor();
  79158. /**
  79159. * Creates a new Stage.
  79160. * @returns A new instance of a Stage
  79161. */
  79162. static Create<T extends Function>(): Stage<T>;
  79163. /**
  79164. * Registers a step in an ordered way in the targeted stage.
  79165. * @param index Defines the position to register the step in
  79166. * @param component Defines the component attached to the step
  79167. * @param action Defines the action to launch during the step
  79168. */
  79169. registerStep(index: number, component: ISceneComponent, action: T): void;
  79170. /**
  79171. * Clears all the steps from the stage.
  79172. */
  79173. clear(): void;
  79174. }
  79175. }
  79176. declare module BABYLON {
  79177. interface Scene {
  79178. /** @hidden */
  79179. _pointerOverSprite: Nullable<Sprite>;
  79180. /** @hidden */
  79181. _pickedDownSprite: Nullable<Sprite>;
  79182. /** @hidden */
  79183. _tempSpritePickingRay: Nullable<Ray>;
  79184. /**
  79185. * All of the sprite managers added to this scene
  79186. * @see http://doc.babylonjs.com/babylon101/sprites
  79187. */
  79188. spriteManagers: Array<ISpriteManager>;
  79189. /**
  79190. * An event triggered when sprites rendering is about to start
  79191. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79192. */
  79193. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79194. /**
  79195. * An event triggered when sprites rendering is done
  79196. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79197. */
  79198. onAfterSpritesRenderingObservable: Observable<Scene>;
  79199. /** @hidden */
  79200. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79201. /** Launch a ray to try to pick a sprite in the scene
  79202. * @param x position on screen
  79203. * @param y position on screen
  79204. * @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
  79205. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79206. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79207. * @returns a PickingInfo
  79208. */
  79209. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79210. /** Use the given ray to pick a sprite in the scene
  79211. * @param ray The ray (in world space) to use to pick meshes
  79212. * @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
  79213. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79214. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79215. * @returns a PickingInfo
  79216. */
  79217. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79218. /** @hidden */
  79219. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79220. /** Launch a ray to try to pick sprites in the scene
  79221. * @param x position on screen
  79222. * @param y position on screen
  79223. * @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
  79224. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79225. * @returns a PickingInfo array
  79226. */
  79227. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79228. /** Use the given ray to pick sprites in the scene
  79229. * @param ray The ray (in world space) to use to pick meshes
  79230. * @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
  79231. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79232. * @returns a PickingInfo array
  79233. */
  79234. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79235. /**
  79236. * Force the sprite under the pointer
  79237. * @param sprite defines the sprite to use
  79238. */
  79239. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79240. /**
  79241. * Gets the sprite under the pointer
  79242. * @returns a Sprite or null if no sprite is under the pointer
  79243. */
  79244. getPointerOverSprite(): Nullable<Sprite>;
  79245. }
  79246. /**
  79247. * Defines the sprite scene component responsible to manage sprites
  79248. * in a given scene.
  79249. */
  79250. export class SpriteSceneComponent implements ISceneComponent {
  79251. /**
  79252. * The component name helpfull to identify the component in the list of scene components.
  79253. */
  79254. readonly name: string;
  79255. /**
  79256. * The scene the component belongs to.
  79257. */
  79258. scene: Scene;
  79259. /** @hidden */
  79260. private _spritePredicate;
  79261. /**
  79262. * Creates a new instance of the component for the given scene
  79263. * @param scene Defines the scene to register the component in
  79264. */
  79265. constructor(scene: Scene);
  79266. /**
  79267. * Registers the component in a given scene
  79268. */
  79269. register(): void;
  79270. /**
  79271. * Rebuilds the elements related to this component in case of
  79272. * context lost for instance.
  79273. */
  79274. rebuild(): void;
  79275. /**
  79276. * Disposes the component and the associated ressources.
  79277. */
  79278. dispose(): void;
  79279. private _pickSpriteButKeepRay;
  79280. private _pointerMove;
  79281. private _pointerDown;
  79282. private _pointerUp;
  79283. }
  79284. }
  79285. declare module BABYLON {
  79286. /** @hidden */
  79287. export var fogFragmentDeclaration: {
  79288. name: string;
  79289. shader: string;
  79290. };
  79291. }
  79292. declare module BABYLON {
  79293. /** @hidden */
  79294. export var fogFragment: {
  79295. name: string;
  79296. shader: string;
  79297. };
  79298. }
  79299. declare module BABYLON {
  79300. /** @hidden */
  79301. export var spritesPixelShader: {
  79302. name: string;
  79303. shader: string;
  79304. };
  79305. }
  79306. declare module BABYLON {
  79307. /** @hidden */
  79308. export var fogVertexDeclaration: {
  79309. name: string;
  79310. shader: string;
  79311. };
  79312. }
  79313. declare module BABYLON {
  79314. /** @hidden */
  79315. export var spritesVertexShader: {
  79316. name: string;
  79317. shader: string;
  79318. };
  79319. }
  79320. declare module BABYLON {
  79321. /**
  79322. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79323. */
  79324. export interface ISpriteManager extends IDisposable {
  79325. /**
  79326. * Restricts the camera to viewing objects with the same layerMask.
  79327. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79328. */
  79329. layerMask: number;
  79330. /**
  79331. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79332. */
  79333. isPickable: boolean;
  79334. /**
  79335. * Specifies the rendering group id for this mesh (0 by default)
  79336. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79337. */
  79338. renderingGroupId: number;
  79339. /**
  79340. * Defines the list of sprites managed by the manager.
  79341. */
  79342. sprites: Array<Sprite>;
  79343. /**
  79344. * Tests the intersection of a sprite with a specific ray.
  79345. * @param ray The ray we are sending to test the collision
  79346. * @param camera The camera space we are sending rays in
  79347. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79348. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79349. * @returns picking info or null.
  79350. */
  79351. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79352. /**
  79353. * Intersects the sprites with a ray
  79354. * @param ray defines the ray to intersect with
  79355. * @param camera defines the current active camera
  79356. * @param predicate defines a predicate used to select candidate sprites
  79357. * @returns null if no hit or a PickingInfo array
  79358. */
  79359. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79360. /**
  79361. * Renders the list of sprites on screen.
  79362. */
  79363. render(): void;
  79364. }
  79365. /**
  79366. * Class used to manage multiple sprites on the same spritesheet
  79367. * @see http://doc.babylonjs.com/babylon101/sprites
  79368. */
  79369. export class SpriteManager implements ISpriteManager {
  79370. /** defines the manager's name */
  79371. name: string;
  79372. /** Gets the list of sprites */
  79373. sprites: Sprite[];
  79374. /** Gets or sets the rendering group id (0 by default) */
  79375. renderingGroupId: number;
  79376. /** Gets or sets camera layer mask */
  79377. layerMask: number;
  79378. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79379. fogEnabled: boolean;
  79380. /** Gets or sets a boolean indicating if the sprites are pickable */
  79381. isPickable: boolean;
  79382. /** Defines the default width of a cell in the spritesheet */
  79383. cellWidth: number;
  79384. /** Defines the default height of a cell in the spritesheet */
  79385. cellHeight: number;
  79386. /** Associative array from JSON sprite data file */
  79387. private _cellData;
  79388. /** Array of sprite names from JSON sprite data file */
  79389. private _spriteMap;
  79390. /** True when packed cell data from JSON file is ready*/
  79391. private _packedAndReady;
  79392. /**
  79393. * An event triggered when the manager is disposed.
  79394. */
  79395. onDisposeObservable: Observable<SpriteManager>;
  79396. private _onDisposeObserver;
  79397. /**
  79398. * Callback called when the manager is disposed
  79399. */
  79400. onDispose: () => void;
  79401. private _capacity;
  79402. private _fromPacked;
  79403. private _spriteTexture;
  79404. private _epsilon;
  79405. private _scene;
  79406. private _vertexData;
  79407. private _buffer;
  79408. private _vertexBuffers;
  79409. private _indexBuffer;
  79410. private _effectBase;
  79411. private _effectFog;
  79412. /**
  79413. * Gets or sets the spritesheet texture
  79414. */
  79415. texture: Texture;
  79416. /**
  79417. * Creates a new sprite manager
  79418. * @param name defines the manager's name
  79419. * @param imgUrl defines the sprite sheet url
  79420. * @param capacity defines the maximum allowed number of sprites
  79421. * @param cellSize defines the size of a sprite cell
  79422. * @param scene defines the hosting scene
  79423. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79424. * @param samplingMode defines the smapling mode to use with spritesheet
  79425. * @param fromPacked set to false; do not alter
  79426. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79427. */
  79428. constructor(
  79429. /** defines the manager's name */
  79430. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79431. private _makePacked;
  79432. private _appendSpriteVertex;
  79433. /**
  79434. * Intersects the sprites with a ray
  79435. * @param ray defines the ray to intersect with
  79436. * @param camera defines the current active camera
  79437. * @param predicate defines a predicate used to select candidate sprites
  79438. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79439. * @returns null if no hit or a PickingInfo
  79440. */
  79441. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79442. /**
  79443. * Intersects the sprites with a ray
  79444. * @param ray defines the ray to intersect with
  79445. * @param camera defines the current active camera
  79446. * @param predicate defines a predicate used to select candidate sprites
  79447. * @returns null if no hit or a PickingInfo array
  79448. */
  79449. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79450. /**
  79451. * Render all child sprites
  79452. */
  79453. render(): void;
  79454. /**
  79455. * Release associated resources
  79456. */
  79457. dispose(): void;
  79458. }
  79459. }
  79460. declare module BABYLON {
  79461. /**
  79462. * Class used to represent a sprite
  79463. * @see http://doc.babylonjs.com/babylon101/sprites
  79464. */
  79465. export class Sprite {
  79466. /** defines the name */
  79467. name: string;
  79468. /** Gets or sets the current world position */
  79469. position: Vector3;
  79470. /** Gets or sets the main color */
  79471. color: Color4;
  79472. /** Gets or sets the width */
  79473. width: number;
  79474. /** Gets or sets the height */
  79475. height: number;
  79476. /** Gets or sets rotation angle */
  79477. angle: number;
  79478. /** Gets or sets the cell index in the sprite sheet */
  79479. cellIndex: number;
  79480. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79481. cellRef: string;
  79482. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79483. invertU: number;
  79484. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79485. invertV: number;
  79486. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79487. disposeWhenFinishedAnimating: boolean;
  79488. /** Gets the list of attached animations */
  79489. animations: Animation[];
  79490. /** Gets or sets a boolean indicating if the sprite can be picked */
  79491. isPickable: boolean;
  79492. /**
  79493. * Gets or sets the associated action manager
  79494. */
  79495. actionManager: Nullable<ActionManager>;
  79496. private _animationStarted;
  79497. private _loopAnimation;
  79498. private _fromIndex;
  79499. private _toIndex;
  79500. private _delay;
  79501. private _direction;
  79502. private _manager;
  79503. private _time;
  79504. private _onAnimationEnd;
  79505. /**
  79506. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79507. */
  79508. isVisible: boolean;
  79509. /**
  79510. * Gets or sets the sprite size
  79511. */
  79512. size: number;
  79513. /**
  79514. * Creates a new Sprite
  79515. * @param name defines the name
  79516. * @param manager defines the manager
  79517. */
  79518. constructor(
  79519. /** defines the name */
  79520. name: string, manager: ISpriteManager);
  79521. /**
  79522. * Starts an animation
  79523. * @param from defines the initial key
  79524. * @param to defines the end key
  79525. * @param loop defines if the animation must loop
  79526. * @param delay defines the start delay (in ms)
  79527. * @param onAnimationEnd defines a callback to call when animation ends
  79528. */
  79529. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79530. /** Stops current animation (if any) */
  79531. stopAnimation(): void;
  79532. /** @hidden */
  79533. _animate(deltaTime: number): void;
  79534. /** Release associated resources */
  79535. dispose(): void;
  79536. }
  79537. }
  79538. declare module BABYLON {
  79539. /**
  79540. * Information about the result of picking within a scene
  79541. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79542. */
  79543. export class PickingInfo {
  79544. /** @hidden */
  79545. _pickingUnavailable: boolean;
  79546. /**
  79547. * If the pick collided with an object
  79548. */
  79549. hit: boolean;
  79550. /**
  79551. * Distance away where the pick collided
  79552. */
  79553. distance: number;
  79554. /**
  79555. * The location of pick collision
  79556. */
  79557. pickedPoint: Nullable<Vector3>;
  79558. /**
  79559. * The mesh corresponding the the pick collision
  79560. */
  79561. pickedMesh: Nullable<AbstractMesh>;
  79562. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79563. bu: number;
  79564. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79565. bv: number;
  79566. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79567. faceId: number;
  79568. /** Id of the the submesh that was picked */
  79569. subMeshId: number;
  79570. /** If a sprite was picked, this will be the sprite the pick collided with */
  79571. pickedSprite: Nullable<Sprite>;
  79572. /**
  79573. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79574. */
  79575. originMesh: Nullable<AbstractMesh>;
  79576. /**
  79577. * The ray that was used to perform the picking.
  79578. */
  79579. ray: Nullable<Ray>;
  79580. /**
  79581. * Gets the normal correspodning to the face the pick collided with
  79582. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79583. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79584. * @returns The normal correspodning to the face the pick collided with
  79585. */
  79586. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79587. /**
  79588. * Gets the texture coordinates of where the pick occured
  79589. * @returns the vector containing the coordnates of the texture
  79590. */
  79591. getTextureCoordinates(): Nullable<Vector2>;
  79592. }
  79593. }
  79594. declare module BABYLON {
  79595. /**
  79596. * Gather the list of pointer event types as constants.
  79597. */
  79598. export class PointerEventTypes {
  79599. /**
  79600. * 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.
  79601. */
  79602. static readonly POINTERDOWN: number;
  79603. /**
  79604. * The pointerup event is fired when a pointer is no longer active.
  79605. */
  79606. static readonly POINTERUP: number;
  79607. /**
  79608. * The pointermove event is fired when a pointer changes coordinates.
  79609. */
  79610. static readonly POINTERMOVE: number;
  79611. /**
  79612. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79613. */
  79614. static readonly POINTERWHEEL: number;
  79615. /**
  79616. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79617. */
  79618. static readonly POINTERPICK: number;
  79619. /**
  79620. * The pointertap event is fired when a the object has been touched and released without drag.
  79621. */
  79622. static readonly POINTERTAP: number;
  79623. /**
  79624. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79625. */
  79626. static readonly POINTERDOUBLETAP: number;
  79627. }
  79628. /**
  79629. * Base class of pointer info types.
  79630. */
  79631. export class PointerInfoBase {
  79632. /**
  79633. * Defines the type of event (PointerEventTypes)
  79634. */
  79635. type: number;
  79636. /**
  79637. * Defines the related dom event
  79638. */
  79639. event: PointerEvent | MouseWheelEvent;
  79640. /**
  79641. * Instantiates the base class of pointers info.
  79642. * @param type Defines the type of event (PointerEventTypes)
  79643. * @param event Defines the related dom event
  79644. */
  79645. constructor(
  79646. /**
  79647. * Defines the type of event (PointerEventTypes)
  79648. */
  79649. type: number,
  79650. /**
  79651. * Defines the related dom event
  79652. */
  79653. event: PointerEvent | MouseWheelEvent);
  79654. }
  79655. /**
  79656. * This class is used to store pointer related info for the onPrePointerObservable event.
  79657. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79658. */
  79659. export class PointerInfoPre extends PointerInfoBase {
  79660. /**
  79661. * Ray from a pointer if availible (eg. 6dof controller)
  79662. */
  79663. ray: Nullable<Ray>;
  79664. /**
  79665. * Defines the local position of the pointer on the canvas.
  79666. */
  79667. localPosition: Vector2;
  79668. /**
  79669. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79670. */
  79671. skipOnPointerObservable: boolean;
  79672. /**
  79673. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79674. * @param type Defines the type of event (PointerEventTypes)
  79675. * @param event Defines the related dom event
  79676. * @param localX Defines the local x coordinates of the pointer when the event occured
  79677. * @param localY Defines the local y coordinates of the pointer when the event occured
  79678. */
  79679. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79680. }
  79681. /**
  79682. * This type contains all the data related to a pointer event in Babylon.js.
  79683. * 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.
  79684. */
  79685. export class PointerInfo extends PointerInfoBase {
  79686. /**
  79687. * Defines the picking info associated to the info (if any)\
  79688. */
  79689. pickInfo: Nullable<PickingInfo>;
  79690. /**
  79691. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79692. * @param type Defines the type of event (PointerEventTypes)
  79693. * @param event Defines the related dom event
  79694. * @param pickInfo Defines the picking info associated to the info (if any)\
  79695. */
  79696. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79697. /**
  79698. * Defines the picking info associated to the info (if any)\
  79699. */
  79700. pickInfo: Nullable<PickingInfo>);
  79701. }
  79702. /**
  79703. * Data relating to a touch event on the screen.
  79704. */
  79705. export interface PointerTouch {
  79706. /**
  79707. * X coordinate of touch.
  79708. */
  79709. x: number;
  79710. /**
  79711. * Y coordinate of touch.
  79712. */
  79713. y: number;
  79714. /**
  79715. * Id of touch. Unique for each finger.
  79716. */
  79717. pointerId: number;
  79718. /**
  79719. * Event type passed from DOM.
  79720. */
  79721. type: any;
  79722. }
  79723. }
  79724. declare module BABYLON {
  79725. /**
  79726. * Manage the mouse inputs to control the movement of a free camera.
  79727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79728. */
  79729. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79730. /**
  79731. * Define if touch is enabled in the mouse input
  79732. */
  79733. touchEnabled: boolean;
  79734. /**
  79735. * Defines the camera the input is attached to.
  79736. */
  79737. camera: FreeCamera;
  79738. /**
  79739. * Defines the buttons associated with the input to handle camera move.
  79740. */
  79741. buttons: number[];
  79742. /**
  79743. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79744. */
  79745. angularSensibility: number;
  79746. private _pointerInput;
  79747. private _onMouseMove;
  79748. private _observer;
  79749. private previousPosition;
  79750. /**
  79751. * Observable for when a pointer move event occurs containing the move offset
  79752. */
  79753. onPointerMovedObservable: Observable<{
  79754. offsetX: number;
  79755. offsetY: number;
  79756. }>;
  79757. /**
  79758. * @hidden
  79759. * If the camera should be rotated automatically based on pointer movement
  79760. */
  79761. _allowCameraRotation: boolean;
  79762. /**
  79763. * Manage the mouse inputs to control the movement of a free camera.
  79764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79765. * @param touchEnabled Defines if touch is enabled or not
  79766. */
  79767. constructor(
  79768. /**
  79769. * Define if touch is enabled in the mouse input
  79770. */
  79771. touchEnabled?: boolean);
  79772. /**
  79773. * Attach the input controls to a specific dom element to get the input from.
  79774. * @param element Defines the element the controls should be listened from
  79775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79776. */
  79777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79778. /**
  79779. * Called on JS contextmenu event.
  79780. * Override this method to provide functionality.
  79781. */
  79782. protected onContextMenu(evt: PointerEvent): void;
  79783. /**
  79784. * Detach the current controls from the specified dom element.
  79785. * @param element Defines the element to stop listening the inputs from
  79786. */
  79787. detachControl(element: Nullable<HTMLElement>): void;
  79788. /**
  79789. * Gets the class name of the current intput.
  79790. * @returns the class name
  79791. */
  79792. getClassName(): string;
  79793. /**
  79794. * Get the friendly name associated with the input class.
  79795. * @returns the input friendly name
  79796. */
  79797. getSimpleName(): string;
  79798. }
  79799. }
  79800. declare module BABYLON {
  79801. /**
  79802. * Manage the touch inputs to control the movement of a free camera.
  79803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79804. */
  79805. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79806. /**
  79807. * Defines the camera the input is attached to.
  79808. */
  79809. camera: FreeCamera;
  79810. /**
  79811. * Defines the touch sensibility for rotation.
  79812. * The higher the faster.
  79813. */
  79814. touchAngularSensibility: number;
  79815. /**
  79816. * Defines the touch sensibility for move.
  79817. * The higher the faster.
  79818. */
  79819. touchMoveSensibility: number;
  79820. private _offsetX;
  79821. private _offsetY;
  79822. private _pointerPressed;
  79823. private _pointerInput;
  79824. private _observer;
  79825. private _onLostFocus;
  79826. /**
  79827. * Attach the input controls to a specific dom element to get the input from.
  79828. * @param element Defines the element the controls should be listened from
  79829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79830. */
  79831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79832. /**
  79833. * Detach the current controls from the specified dom element.
  79834. * @param element Defines the element to stop listening the inputs from
  79835. */
  79836. detachControl(element: Nullable<HTMLElement>): void;
  79837. /**
  79838. * Update the current camera state depending on the inputs that have been used this frame.
  79839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79840. */
  79841. checkInputs(): void;
  79842. /**
  79843. * Gets the class name of the current intput.
  79844. * @returns the class name
  79845. */
  79846. getClassName(): string;
  79847. /**
  79848. * Get the friendly name associated with the input class.
  79849. * @returns the input friendly name
  79850. */
  79851. getSimpleName(): string;
  79852. }
  79853. }
  79854. declare module BABYLON {
  79855. /**
  79856. * Default Inputs manager for the FreeCamera.
  79857. * It groups all the default supported inputs for ease of use.
  79858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79859. */
  79860. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79861. /**
  79862. * @hidden
  79863. */
  79864. _mouseInput: Nullable<FreeCameraMouseInput>;
  79865. /**
  79866. * Instantiates a new FreeCameraInputsManager.
  79867. * @param camera Defines the camera the inputs belong to
  79868. */
  79869. constructor(camera: FreeCamera);
  79870. /**
  79871. * Add keyboard input support to the input manager.
  79872. * @returns the current input manager
  79873. */
  79874. addKeyboard(): FreeCameraInputsManager;
  79875. /**
  79876. * Add mouse input support to the input manager.
  79877. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79878. * @returns the current input manager
  79879. */
  79880. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79881. /**
  79882. * Removes the mouse input support from the manager
  79883. * @returns the current input manager
  79884. */
  79885. removeMouse(): FreeCameraInputsManager;
  79886. /**
  79887. * Add touch input support to the input manager.
  79888. * @returns the current input manager
  79889. */
  79890. addTouch(): FreeCameraInputsManager;
  79891. /**
  79892. * Remove all attached input methods from a camera
  79893. */
  79894. clear(): void;
  79895. }
  79896. }
  79897. declare module BABYLON {
  79898. /**
  79899. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79900. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79901. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79902. */
  79903. export class FreeCamera extends TargetCamera {
  79904. /**
  79905. * Define the collision ellipsoid of the camera.
  79906. * This is helpful to simulate a camera body like the player body around the camera
  79907. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79908. */
  79909. ellipsoid: Vector3;
  79910. /**
  79911. * Define an offset for the position of the ellipsoid around the camera.
  79912. * This can be helpful to determine the center of the body near the gravity center of the body
  79913. * instead of its head.
  79914. */
  79915. ellipsoidOffset: Vector3;
  79916. /**
  79917. * Enable or disable collisions of the camera with the rest of the scene objects.
  79918. */
  79919. checkCollisions: boolean;
  79920. /**
  79921. * Enable or disable gravity on the camera.
  79922. */
  79923. applyGravity: boolean;
  79924. /**
  79925. * Define the input manager associated to the camera.
  79926. */
  79927. inputs: FreeCameraInputsManager;
  79928. /**
  79929. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79930. * Higher values reduce sensitivity.
  79931. */
  79932. /**
  79933. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79934. * Higher values reduce sensitivity.
  79935. */
  79936. angularSensibility: number;
  79937. /**
  79938. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79939. */
  79940. keysUp: number[];
  79941. /**
  79942. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79943. */
  79944. keysDown: number[];
  79945. /**
  79946. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79947. */
  79948. keysLeft: number[];
  79949. /**
  79950. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79951. */
  79952. keysRight: number[];
  79953. /**
  79954. * Event raised when the camera collide with a mesh in the scene.
  79955. */
  79956. onCollide: (collidedMesh: AbstractMesh) => void;
  79957. private _collider;
  79958. private _needMoveForGravity;
  79959. private _oldPosition;
  79960. private _diffPosition;
  79961. private _newPosition;
  79962. /** @hidden */
  79963. _localDirection: Vector3;
  79964. /** @hidden */
  79965. _transformedDirection: Vector3;
  79966. /**
  79967. * Instantiates a Free Camera.
  79968. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79969. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79970. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79971. * @param name Define the name of the camera in the scene
  79972. * @param position Define the start position of the camera in the scene
  79973. * @param scene Define the scene the camera belongs to
  79974. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79975. */
  79976. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79977. /**
  79978. * Attached controls to the current camera.
  79979. * @param element Defines the element the controls should be listened from
  79980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79981. */
  79982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79983. /**
  79984. * Detach the current controls from the camera.
  79985. * The camera will stop reacting to inputs.
  79986. * @param element Defines the element to stop listening the inputs from
  79987. */
  79988. detachControl(element: HTMLElement): void;
  79989. private _collisionMask;
  79990. /**
  79991. * Define a collision mask to limit the list of object the camera can collide with
  79992. */
  79993. collisionMask: number;
  79994. /** @hidden */
  79995. _collideWithWorld(displacement: Vector3): void;
  79996. private _onCollisionPositionChange;
  79997. /** @hidden */
  79998. _checkInputs(): void;
  79999. /** @hidden */
  80000. _decideIfNeedsToMove(): boolean;
  80001. /** @hidden */
  80002. _updatePosition(): void;
  80003. /**
  80004. * Destroy the camera and release the current resources hold by it.
  80005. */
  80006. dispose(): void;
  80007. /**
  80008. * Gets the current object class name.
  80009. * @return the class name
  80010. */
  80011. getClassName(): string;
  80012. }
  80013. }
  80014. declare module BABYLON {
  80015. /**
  80016. * Represents a gamepad control stick position
  80017. */
  80018. export class StickValues {
  80019. /**
  80020. * The x component of the control stick
  80021. */
  80022. x: number;
  80023. /**
  80024. * The y component of the control stick
  80025. */
  80026. y: number;
  80027. /**
  80028. * Initializes the gamepad x and y control stick values
  80029. * @param x The x component of the gamepad control stick value
  80030. * @param y The y component of the gamepad control stick value
  80031. */
  80032. constructor(
  80033. /**
  80034. * The x component of the control stick
  80035. */
  80036. x: number,
  80037. /**
  80038. * The y component of the control stick
  80039. */
  80040. y: number);
  80041. }
  80042. /**
  80043. * An interface which manages callbacks for gamepad button changes
  80044. */
  80045. export interface GamepadButtonChanges {
  80046. /**
  80047. * Called when a gamepad has been changed
  80048. */
  80049. changed: boolean;
  80050. /**
  80051. * Called when a gamepad press event has been triggered
  80052. */
  80053. pressChanged: boolean;
  80054. /**
  80055. * Called when a touch event has been triggered
  80056. */
  80057. touchChanged: boolean;
  80058. /**
  80059. * Called when a value has changed
  80060. */
  80061. valueChanged: boolean;
  80062. }
  80063. /**
  80064. * Represents a gamepad
  80065. */
  80066. export class Gamepad {
  80067. /**
  80068. * The id of the gamepad
  80069. */
  80070. id: string;
  80071. /**
  80072. * The index of the gamepad
  80073. */
  80074. index: number;
  80075. /**
  80076. * The browser gamepad
  80077. */
  80078. browserGamepad: any;
  80079. /**
  80080. * Specifies what type of gamepad this represents
  80081. */
  80082. type: number;
  80083. private _leftStick;
  80084. private _rightStick;
  80085. /** @hidden */
  80086. _isConnected: boolean;
  80087. private _leftStickAxisX;
  80088. private _leftStickAxisY;
  80089. private _rightStickAxisX;
  80090. private _rightStickAxisY;
  80091. /**
  80092. * Triggered when the left control stick has been changed
  80093. */
  80094. private _onleftstickchanged;
  80095. /**
  80096. * Triggered when the right control stick has been changed
  80097. */
  80098. private _onrightstickchanged;
  80099. /**
  80100. * Represents a gamepad controller
  80101. */
  80102. static GAMEPAD: number;
  80103. /**
  80104. * Represents a generic controller
  80105. */
  80106. static GENERIC: number;
  80107. /**
  80108. * Represents an XBox controller
  80109. */
  80110. static XBOX: number;
  80111. /**
  80112. * Represents a pose-enabled controller
  80113. */
  80114. static POSE_ENABLED: number;
  80115. /**
  80116. * Represents an Dual Shock controller
  80117. */
  80118. static DUALSHOCK: number;
  80119. /**
  80120. * Specifies whether the left control stick should be Y-inverted
  80121. */
  80122. protected _invertLeftStickY: boolean;
  80123. /**
  80124. * Specifies if the gamepad has been connected
  80125. */
  80126. readonly isConnected: boolean;
  80127. /**
  80128. * Initializes the gamepad
  80129. * @param id The id of the gamepad
  80130. * @param index The index of the gamepad
  80131. * @param browserGamepad The browser gamepad
  80132. * @param leftStickX The x component of the left joystick
  80133. * @param leftStickY The y component of the left joystick
  80134. * @param rightStickX The x component of the right joystick
  80135. * @param rightStickY The y component of the right joystick
  80136. */
  80137. constructor(
  80138. /**
  80139. * The id of the gamepad
  80140. */
  80141. id: string,
  80142. /**
  80143. * The index of the gamepad
  80144. */
  80145. index: number,
  80146. /**
  80147. * The browser gamepad
  80148. */
  80149. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80150. /**
  80151. * Callback triggered when the left joystick has changed
  80152. * @param callback
  80153. */
  80154. onleftstickchanged(callback: (values: StickValues) => void): void;
  80155. /**
  80156. * Callback triggered when the right joystick has changed
  80157. * @param callback
  80158. */
  80159. onrightstickchanged(callback: (values: StickValues) => void): void;
  80160. /**
  80161. * Gets the left joystick
  80162. */
  80163. /**
  80164. * Sets the left joystick values
  80165. */
  80166. leftStick: StickValues;
  80167. /**
  80168. * Gets the right joystick
  80169. */
  80170. /**
  80171. * Sets the right joystick value
  80172. */
  80173. rightStick: StickValues;
  80174. /**
  80175. * Updates the gamepad joystick positions
  80176. */
  80177. update(): void;
  80178. /**
  80179. * Disposes the gamepad
  80180. */
  80181. dispose(): void;
  80182. }
  80183. /**
  80184. * Represents a generic gamepad
  80185. */
  80186. export class GenericPad extends Gamepad {
  80187. private _buttons;
  80188. private _onbuttondown;
  80189. private _onbuttonup;
  80190. /**
  80191. * Observable triggered when a button has been pressed
  80192. */
  80193. onButtonDownObservable: Observable<number>;
  80194. /**
  80195. * Observable triggered when a button has been released
  80196. */
  80197. onButtonUpObservable: Observable<number>;
  80198. /**
  80199. * Callback triggered when a button has been pressed
  80200. * @param callback Called when a button has been pressed
  80201. */
  80202. onbuttondown(callback: (buttonPressed: number) => void): void;
  80203. /**
  80204. * Callback triggered when a button has been released
  80205. * @param callback Called when a button has been released
  80206. */
  80207. onbuttonup(callback: (buttonReleased: number) => void): void;
  80208. /**
  80209. * Initializes the generic gamepad
  80210. * @param id The id of the generic gamepad
  80211. * @param index The index of the generic gamepad
  80212. * @param browserGamepad The browser gamepad
  80213. */
  80214. constructor(id: string, index: number, browserGamepad: any);
  80215. private _setButtonValue;
  80216. /**
  80217. * Updates the generic gamepad
  80218. */
  80219. update(): void;
  80220. /**
  80221. * Disposes the generic gamepad
  80222. */
  80223. dispose(): void;
  80224. }
  80225. }
  80226. declare module BABYLON {
  80227. interface Engine {
  80228. /**
  80229. * Creates a raw texture
  80230. * @param data defines the data to store in the texture
  80231. * @param width defines the width of the texture
  80232. * @param height defines the height of the texture
  80233. * @param format defines the format of the data
  80234. * @param generateMipMaps defines if the engine should generate the mip levels
  80235. * @param invertY defines if data must be stored with Y axis inverted
  80236. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80237. * @param compression defines the compression used (null by default)
  80238. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80239. * @returns the raw texture inside an InternalTexture
  80240. */
  80241. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80242. /**
  80243. * Update a raw texture
  80244. * @param texture defines the texture to update
  80245. * @param data defines the data to store in the texture
  80246. * @param format defines the format of the data
  80247. * @param invertY defines if data must be stored with Y axis inverted
  80248. */
  80249. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80250. /**
  80251. * Update a raw texture
  80252. * @param texture defines the texture to update
  80253. * @param data defines the data to store in the texture
  80254. * @param format defines the format of the data
  80255. * @param invertY defines if data must be stored with Y axis inverted
  80256. * @param compression defines the compression used (null by default)
  80257. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80258. */
  80259. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80260. /**
  80261. * Creates a new raw cube texture
  80262. * @param data defines the array of data to use to create each face
  80263. * @param size defines the size of the textures
  80264. * @param format defines the format of the data
  80265. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80266. * @param generateMipMaps defines if the engine should generate the mip levels
  80267. * @param invertY defines if data must be stored with Y axis inverted
  80268. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80269. * @param compression defines the compression used (null by default)
  80270. * @returns the cube texture as an InternalTexture
  80271. */
  80272. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80273. /**
  80274. * Update a raw cube texture
  80275. * @param texture defines the texture to udpdate
  80276. * @param data defines the data to store
  80277. * @param format defines the data format
  80278. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80279. * @param invertY defines if data must be stored with Y axis inverted
  80280. */
  80281. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80282. /**
  80283. * Update a raw cube texture
  80284. * @param texture defines the texture to udpdate
  80285. * @param data defines the data to store
  80286. * @param format defines the data format
  80287. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80288. * @param invertY defines if data must be stored with Y axis inverted
  80289. * @param compression defines the compression used (null by default)
  80290. */
  80291. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80292. /**
  80293. * Update a raw cube texture
  80294. * @param texture defines the texture to udpdate
  80295. * @param data defines the data to store
  80296. * @param format defines the data format
  80297. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80298. * @param invertY defines if data must be stored with Y axis inverted
  80299. * @param compression defines the compression used (null by default)
  80300. * @param level defines which level of the texture to update
  80301. */
  80302. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80303. /**
  80304. * Creates a new raw cube texture from a specified url
  80305. * @param url defines the url where the data is located
  80306. * @param scene defines the current scene
  80307. * @param size defines the size of the textures
  80308. * @param format defines the format of the data
  80309. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80310. * @param noMipmap defines if the engine should avoid generating the mip levels
  80311. * @param callback defines a callback used to extract texture data from loaded data
  80312. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80313. * @param onLoad defines a callback called when texture is loaded
  80314. * @param onError defines a callback called if there is an error
  80315. * @returns the cube texture as an InternalTexture
  80316. */
  80317. 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;
  80318. /**
  80319. * Creates a new raw cube texture from a specified url
  80320. * @param url defines the url where the data is located
  80321. * @param scene defines the current scene
  80322. * @param size defines the size of the textures
  80323. * @param format defines the format of the data
  80324. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80325. * @param noMipmap defines if the engine should avoid generating the mip levels
  80326. * @param callback defines a callback used to extract texture data from loaded data
  80327. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80328. * @param onLoad defines a callback called when texture is loaded
  80329. * @param onError defines a callback called if there is an error
  80330. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80331. * @param invertY defines if data must be stored with Y axis inverted
  80332. * @returns the cube texture as an InternalTexture
  80333. */
  80334. 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;
  80335. /**
  80336. * Creates a new raw 3D texture
  80337. * @param data defines the data used to create the texture
  80338. * @param width defines the width of the texture
  80339. * @param height defines the height of the texture
  80340. * @param depth defines the depth of the texture
  80341. * @param format defines the format of the texture
  80342. * @param generateMipMaps defines if the engine must generate mip levels
  80343. * @param invertY defines if data must be stored with Y axis inverted
  80344. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80345. * @param compression defines the compressed used (can be null)
  80346. * @param textureType defines the compressed used (can be null)
  80347. * @returns a new raw 3D texture (stored in an InternalTexture)
  80348. */
  80349. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80350. /**
  80351. * Update a raw 3D texture
  80352. * @param texture defines the texture to update
  80353. * @param data defines the data to store
  80354. * @param format defines the data format
  80355. * @param invertY defines if data must be stored with Y axis inverted
  80356. */
  80357. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80358. /**
  80359. * Update a raw 3D texture
  80360. * @param texture defines the texture to update
  80361. * @param data defines the data to store
  80362. * @param format defines the data format
  80363. * @param invertY defines if data must be stored with Y axis inverted
  80364. * @param compression defines the used compression (can be null)
  80365. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80366. */
  80367. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80368. /**
  80369. * Creates a new raw 2D array texture
  80370. * @param data defines the data used to create the texture
  80371. * @param width defines the width of the texture
  80372. * @param height defines the height of the texture
  80373. * @param depth defines the number of layers of the texture
  80374. * @param format defines the format of the texture
  80375. * @param generateMipMaps defines if the engine must generate mip levels
  80376. * @param invertY defines if data must be stored with Y axis inverted
  80377. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80378. * @param compression defines the compressed used (can be null)
  80379. * @param textureType defines the compressed used (can be null)
  80380. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80381. */
  80382. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80383. /**
  80384. * Update a raw 2D array texture
  80385. * @param texture defines the texture to update
  80386. * @param data defines the data to store
  80387. * @param format defines the data format
  80388. * @param invertY defines if data must be stored with Y axis inverted
  80389. */
  80390. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80391. /**
  80392. * Update a raw 2D array texture
  80393. * @param texture defines the texture to update
  80394. * @param data defines the data to store
  80395. * @param format defines the data format
  80396. * @param invertY defines if data must be stored with Y axis inverted
  80397. * @param compression defines the used compression (can be null)
  80398. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80399. */
  80400. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80401. }
  80402. }
  80403. declare module BABYLON {
  80404. /**
  80405. * Raw texture can help creating a texture directly from an array of data.
  80406. * This can be super useful if you either get the data from an uncompressed source or
  80407. * if you wish to create your texture pixel by pixel.
  80408. */
  80409. export class RawTexture extends Texture {
  80410. /**
  80411. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80412. */
  80413. format: number;
  80414. private _engine;
  80415. /**
  80416. * Instantiates a new RawTexture.
  80417. * Raw texture can help creating a texture directly from an array of data.
  80418. * This can be super useful if you either get the data from an uncompressed source or
  80419. * if you wish to create your texture pixel by pixel.
  80420. * @param data define the array of data to use to create the texture
  80421. * @param width define the width of the texture
  80422. * @param height define the height of the texture
  80423. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80424. * @param scene define the scene the texture belongs to
  80425. * @param generateMipMaps define whether mip maps should be generated or not
  80426. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80427. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80428. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80429. */
  80430. constructor(data: ArrayBufferView, width: number, height: number,
  80431. /**
  80432. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80433. */
  80434. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80435. /**
  80436. * Updates the texture underlying data.
  80437. * @param data Define the new data of the texture
  80438. */
  80439. update(data: ArrayBufferView): void;
  80440. /**
  80441. * Creates a luminance texture from some data.
  80442. * @param data Define the texture data
  80443. * @param width Define the width of the texture
  80444. * @param height Define the height of the texture
  80445. * @param scene Define the scene the texture belongs to
  80446. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80447. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80448. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80449. * @returns the luminance texture
  80450. */
  80451. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80452. /**
  80453. * Creates a luminance alpha texture from some data.
  80454. * @param data Define the texture data
  80455. * @param width Define the width of the texture
  80456. * @param height Define the height of the texture
  80457. * @param scene Define the scene the texture belongs to
  80458. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80459. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80460. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80461. * @returns the luminance alpha texture
  80462. */
  80463. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80464. /**
  80465. * Creates an alpha texture from some data.
  80466. * @param data Define the texture data
  80467. * @param width Define the width of the texture
  80468. * @param height Define the height of the texture
  80469. * @param scene Define the scene the texture belongs to
  80470. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80471. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80472. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80473. * @returns the alpha texture
  80474. */
  80475. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80476. /**
  80477. * Creates a RGB texture from some data.
  80478. * @param data Define the texture data
  80479. * @param width Define the width of the texture
  80480. * @param height Define the height of the texture
  80481. * @param scene Define the scene the texture belongs to
  80482. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80483. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80484. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80485. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80486. * @returns the RGB alpha texture
  80487. */
  80488. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80489. /**
  80490. * Creates a RGBA texture from some data.
  80491. * @param data Define the texture data
  80492. * @param width Define the width of the texture
  80493. * @param height Define the height of the texture
  80494. * @param scene Define the scene the texture belongs to
  80495. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80496. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80497. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80498. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80499. * @returns the RGBA texture
  80500. */
  80501. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80502. /**
  80503. * Creates a R texture from some data.
  80504. * @param data Define the texture data
  80505. * @param width Define the width of the texture
  80506. * @param height Define the height of the texture
  80507. * @param scene Define the scene the texture belongs to
  80508. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80509. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80510. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80511. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80512. * @returns the R texture
  80513. */
  80514. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80515. }
  80516. }
  80517. declare module BABYLON {
  80518. /**
  80519. * Interface for the size containing width and height
  80520. */
  80521. export interface ISize {
  80522. /**
  80523. * Width
  80524. */
  80525. width: number;
  80526. /**
  80527. * Heighht
  80528. */
  80529. height: number;
  80530. }
  80531. /**
  80532. * Size containing widht and height
  80533. */
  80534. export class Size implements ISize {
  80535. /**
  80536. * Width
  80537. */
  80538. width: number;
  80539. /**
  80540. * Height
  80541. */
  80542. height: number;
  80543. /**
  80544. * Creates a Size object from the given width and height (floats).
  80545. * @param width width of the new size
  80546. * @param height height of the new size
  80547. */
  80548. constructor(width: number, height: number);
  80549. /**
  80550. * Returns a string with the Size width and height
  80551. * @returns a string with the Size width and height
  80552. */
  80553. toString(): string;
  80554. /**
  80555. * "Size"
  80556. * @returns the string "Size"
  80557. */
  80558. getClassName(): string;
  80559. /**
  80560. * Returns the Size hash code.
  80561. * @returns a hash code for a unique width and height
  80562. */
  80563. getHashCode(): number;
  80564. /**
  80565. * Updates the current size from the given one.
  80566. * @param src the given size
  80567. */
  80568. copyFrom(src: Size): void;
  80569. /**
  80570. * Updates in place the current Size from the given floats.
  80571. * @param width width of the new size
  80572. * @param height height of the new size
  80573. * @returns the updated Size.
  80574. */
  80575. copyFromFloats(width: number, height: number): Size;
  80576. /**
  80577. * Updates in place the current Size from the given floats.
  80578. * @param width width to set
  80579. * @param height height to set
  80580. * @returns the updated Size.
  80581. */
  80582. set(width: number, height: number): Size;
  80583. /**
  80584. * Multiplies the width and height by numbers
  80585. * @param w factor to multiple the width by
  80586. * @param h factor to multiple the height by
  80587. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80588. */
  80589. multiplyByFloats(w: number, h: number): Size;
  80590. /**
  80591. * Clones the size
  80592. * @returns a new Size copied from the given one.
  80593. */
  80594. clone(): Size;
  80595. /**
  80596. * True if the current Size and the given one width and height are strictly equal.
  80597. * @param other the other size to compare against
  80598. * @returns True if the current Size and the given one width and height are strictly equal.
  80599. */
  80600. equals(other: Size): boolean;
  80601. /**
  80602. * The surface of the Size : width * height (float).
  80603. */
  80604. readonly surface: number;
  80605. /**
  80606. * Create a new size of zero
  80607. * @returns a new Size set to (0.0, 0.0)
  80608. */
  80609. static Zero(): Size;
  80610. /**
  80611. * Sums the width and height of two sizes
  80612. * @param otherSize size to add to this size
  80613. * @returns a new Size set as the addition result of the current Size and the given one.
  80614. */
  80615. add(otherSize: Size): Size;
  80616. /**
  80617. * Subtracts the width and height of two
  80618. * @param otherSize size to subtract to this size
  80619. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80620. */
  80621. subtract(otherSize: Size): Size;
  80622. /**
  80623. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80624. * @param start starting size to lerp between
  80625. * @param end end size to lerp between
  80626. * @param amount amount to lerp between the start and end values
  80627. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80628. */
  80629. static Lerp(start: Size, end: Size, amount: number): Size;
  80630. }
  80631. }
  80632. declare module BABYLON {
  80633. /**
  80634. * Defines a runtime animation
  80635. */
  80636. export class RuntimeAnimation {
  80637. private _events;
  80638. /**
  80639. * The current frame of the runtime animation
  80640. */
  80641. private _currentFrame;
  80642. /**
  80643. * The animation used by the runtime animation
  80644. */
  80645. private _animation;
  80646. /**
  80647. * The target of the runtime animation
  80648. */
  80649. private _target;
  80650. /**
  80651. * The initiating animatable
  80652. */
  80653. private _host;
  80654. /**
  80655. * The original value of the runtime animation
  80656. */
  80657. private _originalValue;
  80658. /**
  80659. * The original blend value of the runtime animation
  80660. */
  80661. private _originalBlendValue;
  80662. /**
  80663. * The offsets cache of the runtime animation
  80664. */
  80665. private _offsetsCache;
  80666. /**
  80667. * The high limits cache of the runtime animation
  80668. */
  80669. private _highLimitsCache;
  80670. /**
  80671. * Specifies if the runtime animation has been stopped
  80672. */
  80673. private _stopped;
  80674. /**
  80675. * The blending factor of the runtime animation
  80676. */
  80677. private _blendingFactor;
  80678. /**
  80679. * The BabylonJS scene
  80680. */
  80681. private _scene;
  80682. /**
  80683. * The current value of the runtime animation
  80684. */
  80685. private _currentValue;
  80686. /** @hidden */
  80687. _animationState: _IAnimationState;
  80688. /**
  80689. * The active target of the runtime animation
  80690. */
  80691. private _activeTargets;
  80692. private _currentActiveTarget;
  80693. private _directTarget;
  80694. /**
  80695. * The target path of the runtime animation
  80696. */
  80697. private _targetPath;
  80698. /**
  80699. * The weight of the runtime animation
  80700. */
  80701. private _weight;
  80702. /**
  80703. * The ratio offset of the runtime animation
  80704. */
  80705. private _ratioOffset;
  80706. /**
  80707. * The previous delay of the runtime animation
  80708. */
  80709. private _previousDelay;
  80710. /**
  80711. * The previous ratio of the runtime animation
  80712. */
  80713. private _previousRatio;
  80714. private _enableBlending;
  80715. private _keys;
  80716. private _minFrame;
  80717. private _maxFrame;
  80718. private _minValue;
  80719. private _maxValue;
  80720. private _targetIsArray;
  80721. /**
  80722. * Gets the current frame of the runtime animation
  80723. */
  80724. readonly currentFrame: number;
  80725. /**
  80726. * Gets the weight of the runtime animation
  80727. */
  80728. readonly weight: number;
  80729. /**
  80730. * Gets the current value of the runtime animation
  80731. */
  80732. readonly currentValue: any;
  80733. /**
  80734. * Gets the target path of the runtime animation
  80735. */
  80736. readonly targetPath: string;
  80737. /**
  80738. * Gets the actual target of the runtime animation
  80739. */
  80740. readonly target: any;
  80741. /** @hidden */
  80742. _onLoop: () => void;
  80743. /**
  80744. * Create a new RuntimeAnimation object
  80745. * @param target defines the target of the animation
  80746. * @param animation defines the source animation object
  80747. * @param scene defines the hosting scene
  80748. * @param host defines the initiating Animatable
  80749. */
  80750. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80751. private _preparePath;
  80752. /**
  80753. * Gets the animation from the runtime animation
  80754. */
  80755. readonly animation: Animation;
  80756. /**
  80757. * Resets the runtime animation to the beginning
  80758. * @param restoreOriginal defines whether to restore the target property to the original value
  80759. */
  80760. reset(restoreOriginal?: boolean): void;
  80761. /**
  80762. * Specifies if the runtime animation is stopped
  80763. * @returns Boolean specifying if the runtime animation is stopped
  80764. */
  80765. isStopped(): boolean;
  80766. /**
  80767. * Disposes of the runtime animation
  80768. */
  80769. dispose(): void;
  80770. /**
  80771. * Apply the interpolated value to the target
  80772. * @param currentValue defines the value computed by the animation
  80773. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80774. */
  80775. setValue(currentValue: any, weight: number): void;
  80776. private _getOriginalValues;
  80777. private _setValue;
  80778. /**
  80779. * Gets the loop pmode of the runtime animation
  80780. * @returns Loop Mode
  80781. */
  80782. private _getCorrectLoopMode;
  80783. /**
  80784. * Move the current animation to a given frame
  80785. * @param frame defines the frame to move to
  80786. */
  80787. goToFrame(frame: number): void;
  80788. /**
  80789. * @hidden Internal use only
  80790. */
  80791. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80792. /**
  80793. * Execute the current animation
  80794. * @param delay defines the delay to add to the current frame
  80795. * @param from defines the lower bound of the animation range
  80796. * @param to defines the upper bound of the animation range
  80797. * @param loop defines if the current animation must loop
  80798. * @param speedRatio defines the current speed ratio
  80799. * @param weight defines the weight of the animation (default is -1 so no weight)
  80800. * @param onLoop optional callback called when animation loops
  80801. * @returns a boolean indicating if the animation is running
  80802. */
  80803. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80804. }
  80805. }
  80806. declare module BABYLON {
  80807. /**
  80808. * Class used to store an actual running animation
  80809. */
  80810. export class Animatable {
  80811. /** defines the target object */
  80812. target: any;
  80813. /** defines the starting frame number (default is 0) */
  80814. fromFrame: number;
  80815. /** defines the ending frame number (default is 100) */
  80816. toFrame: number;
  80817. /** defines if the animation must loop (default is false) */
  80818. loopAnimation: boolean;
  80819. /** defines a callback to call when animation ends if it is not looping */
  80820. onAnimationEnd?: (() => void) | null | undefined;
  80821. /** defines a callback to call when animation loops */
  80822. onAnimationLoop?: (() => void) | null | undefined;
  80823. private _localDelayOffset;
  80824. private _pausedDelay;
  80825. private _runtimeAnimations;
  80826. private _paused;
  80827. private _scene;
  80828. private _speedRatio;
  80829. private _weight;
  80830. private _syncRoot;
  80831. /**
  80832. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80833. * This will only apply for non looping animation (default is true)
  80834. */
  80835. disposeOnEnd: boolean;
  80836. /**
  80837. * Gets a boolean indicating if the animation has started
  80838. */
  80839. animationStarted: boolean;
  80840. /**
  80841. * Observer raised when the animation ends
  80842. */
  80843. onAnimationEndObservable: Observable<Animatable>;
  80844. /**
  80845. * Observer raised when the animation loops
  80846. */
  80847. onAnimationLoopObservable: Observable<Animatable>;
  80848. /**
  80849. * Gets the root Animatable used to synchronize and normalize animations
  80850. */
  80851. readonly syncRoot: Nullable<Animatable>;
  80852. /**
  80853. * Gets the current frame of the first RuntimeAnimation
  80854. * Used to synchronize Animatables
  80855. */
  80856. readonly masterFrame: number;
  80857. /**
  80858. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80859. */
  80860. weight: number;
  80861. /**
  80862. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80863. */
  80864. speedRatio: number;
  80865. /**
  80866. * Creates a new Animatable
  80867. * @param scene defines the hosting scene
  80868. * @param target defines the target object
  80869. * @param fromFrame defines the starting frame number (default is 0)
  80870. * @param toFrame defines the ending frame number (default is 100)
  80871. * @param loopAnimation defines if the animation must loop (default is false)
  80872. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80873. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80874. * @param animations defines a group of animation to add to the new Animatable
  80875. * @param onAnimationLoop defines a callback to call when animation loops
  80876. */
  80877. constructor(scene: Scene,
  80878. /** defines the target object */
  80879. target: any,
  80880. /** defines the starting frame number (default is 0) */
  80881. fromFrame?: number,
  80882. /** defines the ending frame number (default is 100) */
  80883. toFrame?: number,
  80884. /** defines if the animation must loop (default is false) */
  80885. loopAnimation?: boolean, speedRatio?: number,
  80886. /** defines a callback to call when animation ends if it is not looping */
  80887. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80888. /** defines a callback to call when animation loops */
  80889. onAnimationLoop?: (() => void) | null | undefined);
  80890. /**
  80891. * Synchronize and normalize current Animatable with a source Animatable
  80892. * This is useful when using animation weights and when animations are not of the same length
  80893. * @param root defines the root Animatable to synchronize with
  80894. * @returns the current Animatable
  80895. */
  80896. syncWith(root: Animatable): Animatable;
  80897. /**
  80898. * Gets the list of runtime animations
  80899. * @returns an array of RuntimeAnimation
  80900. */
  80901. getAnimations(): RuntimeAnimation[];
  80902. /**
  80903. * Adds more animations to the current animatable
  80904. * @param target defines the target of the animations
  80905. * @param animations defines the new animations to add
  80906. */
  80907. appendAnimations(target: any, animations: Animation[]): void;
  80908. /**
  80909. * Gets the source animation for a specific property
  80910. * @param property defines the propertyu to look for
  80911. * @returns null or the source animation for the given property
  80912. */
  80913. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80914. /**
  80915. * Gets the runtime animation for a specific property
  80916. * @param property defines the propertyu to look for
  80917. * @returns null or the runtime animation for the given property
  80918. */
  80919. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80920. /**
  80921. * Resets the animatable to its original state
  80922. */
  80923. reset(): void;
  80924. /**
  80925. * Allows the animatable to blend with current running animations
  80926. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80927. * @param blendingSpeed defines the blending speed to use
  80928. */
  80929. enableBlending(blendingSpeed: number): void;
  80930. /**
  80931. * Disable animation blending
  80932. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80933. */
  80934. disableBlending(): void;
  80935. /**
  80936. * Jump directly to a given frame
  80937. * @param frame defines the frame to jump to
  80938. */
  80939. goToFrame(frame: number): void;
  80940. /**
  80941. * Pause the animation
  80942. */
  80943. pause(): void;
  80944. /**
  80945. * Restart the animation
  80946. */
  80947. restart(): void;
  80948. private _raiseOnAnimationEnd;
  80949. /**
  80950. * Stop and delete the current animation
  80951. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80952. * @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)
  80953. */
  80954. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80955. /**
  80956. * Wait asynchronously for the animation to end
  80957. * @returns a promise which will be fullfilled when the animation ends
  80958. */
  80959. waitAsync(): Promise<Animatable>;
  80960. /** @hidden */
  80961. _animate(delay: number): boolean;
  80962. }
  80963. interface Scene {
  80964. /** @hidden */
  80965. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80966. /** @hidden */
  80967. _processLateAnimationBindingsForMatrices(holder: {
  80968. totalWeight: number;
  80969. animations: RuntimeAnimation[];
  80970. originalValue: Matrix;
  80971. }): any;
  80972. /** @hidden */
  80973. _processLateAnimationBindingsForQuaternions(holder: {
  80974. totalWeight: number;
  80975. animations: RuntimeAnimation[];
  80976. originalValue: Quaternion;
  80977. }, refQuaternion: Quaternion): Quaternion;
  80978. /** @hidden */
  80979. _processLateAnimationBindings(): void;
  80980. /**
  80981. * Will start the animation sequence of a given target
  80982. * @param target defines the target
  80983. * @param from defines from which frame should animation start
  80984. * @param to defines until which frame should animation run.
  80985. * @param weight defines the weight to apply to the animation (1.0 by default)
  80986. * @param loop defines if the animation loops
  80987. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80988. * @param onAnimationEnd defines the function to be executed when the animation ends
  80989. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80990. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80991. * @param onAnimationLoop defines the callback to call when an animation loops
  80992. * @returns the animatable object created for this animation
  80993. */
  80994. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80995. /**
  80996. * Will start the animation sequence of a given target
  80997. * @param target defines the target
  80998. * @param from defines from which frame should animation start
  80999. * @param to defines until which frame should animation run.
  81000. * @param loop defines if the animation loops
  81001. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81002. * @param onAnimationEnd defines the function to be executed when the animation ends
  81003. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81004. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81005. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81006. * @param onAnimationLoop defines the callback to call when an animation loops
  81007. * @returns the animatable object created for this animation
  81008. */
  81009. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81010. /**
  81011. * Will start the animation sequence of a given target and its hierarchy
  81012. * @param target defines the target
  81013. * @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.
  81014. * @param from defines from which frame should animation start
  81015. * @param to defines until which frame should animation run.
  81016. * @param loop defines if the animation loops
  81017. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81018. * @param onAnimationEnd defines the function to be executed when the animation ends
  81019. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81020. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81021. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81022. * @param onAnimationLoop defines the callback to call when an animation loops
  81023. * @returns the list of created animatables
  81024. */
  81025. 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[];
  81026. /**
  81027. * Begin a new animation on a given node
  81028. * @param target defines the target where the animation will take place
  81029. * @param animations defines the list of animations to start
  81030. * @param from defines the initial value
  81031. * @param to defines the final value
  81032. * @param loop defines if you want animation to loop (off by default)
  81033. * @param speedRatio defines the speed ratio to apply to all animations
  81034. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81035. * @param onAnimationLoop defines the callback to call when an animation loops
  81036. * @returns the list of created animatables
  81037. */
  81038. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81039. /**
  81040. * Begin a new animation on a given node and its hierarchy
  81041. * @param target defines the root node where the animation will take place
  81042. * @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.
  81043. * @param animations defines the list of animations to start
  81044. * @param from defines the initial value
  81045. * @param to defines the final value
  81046. * @param loop defines if you want animation to loop (off by default)
  81047. * @param speedRatio defines the speed ratio to apply to all animations
  81048. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81049. * @param onAnimationLoop defines the callback to call when an animation loops
  81050. * @returns the list of animatables created for all nodes
  81051. */
  81052. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81053. /**
  81054. * Gets the animatable associated with a specific target
  81055. * @param target defines the target of the animatable
  81056. * @returns the required animatable if found
  81057. */
  81058. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81059. /**
  81060. * Gets all animatables associated with a given target
  81061. * @param target defines the target to look animatables for
  81062. * @returns an array of Animatables
  81063. */
  81064. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81065. /**
  81066. * Stops and removes all animations that have been applied to the scene
  81067. */
  81068. stopAllAnimations(): void;
  81069. /**
  81070. * Gets the current delta time used by animation engine
  81071. */
  81072. deltaTime: number;
  81073. }
  81074. interface Bone {
  81075. /**
  81076. * Copy an animation range from another bone
  81077. * @param source defines the source bone
  81078. * @param rangeName defines the range name to copy
  81079. * @param frameOffset defines the frame offset
  81080. * @param rescaleAsRequired defines if rescaling must be applied if required
  81081. * @param skelDimensionsRatio defines the scaling ratio
  81082. * @returns true if operation was successful
  81083. */
  81084. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81085. }
  81086. }
  81087. declare module BABYLON {
  81088. /**
  81089. * Class used to override all child animations of a given target
  81090. */
  81091. export class AnimationPropertiesOverride {
  81092. /**
  81093. * Gets or sets a value indicating if animation blending must be used
  81094. */
  81095. enableBlending: boolean;
  81096. /**
  81097. * Gets or sets the blending speed to use when enableBlending is true
  81098. */
  81099. blendingSpeed: number;
  81100. /**
  81101. * Gets or sets the default loop mode to use
  81102. */
  81103. loopMode: number;
  81104. }
  81105. }
  81106. declare module BABYLON {
  81107. /**
  81108. * Class used to handle skinning animations
  81109. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81110. */
  81111. export class Skeleton implements IAnimatable {
  81112. /** defines the skeleton name */
  81113. name: string;
  81114. /** defines the skeleton Id */
  81115. id: string;
  81116. /**
  81117. * Defines the list of child bones
  81118. */
  81119. bones: Bone[];
  81120. /**
  81121. * Defines an estimate of the dimension of the skeleton at rest
  81122. */
  81123. dimensionsAtRest: Vector3;
  81124. /**
  81125. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81126. */
  81127. needInitialSkinMatrix: boolean;
  81128. /**
  81129. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81130. */
  81131. overrideMesh: Nullable<AbstractMesh>;
  81132. /**
  81133. * Gets the list of animations attached to this skeleton
  81134. */
  81135. animations: Array<Animation>;
  81136. private _scene;
  81137. private _isDirty;
  81138. private _transformMatrices;
  81139. private _transformMatrixTexture;
  81140. private _meshesWithPoseMatrix;
  81141. private _animatables;
  81142. private _identity;
  81143. private _synchronizedWithMesh;
  81144. private _ranges;
  81145. private _lastAbsoluteTransformsUpdateId;
  81146. private _canUseTextureForBones;
  81147. private _uniqueId;
  81148. /** @hidden */
  81149. _numBonesWithLinkedTransformNode: number;
  81150. /** @hidden */
  81151. _hasWaitingData: Nullable<boolean>;
  81152. /**
  81153. * Specifies if the skeleton should be serialized
  81154. */
  81155. doNotSerialize: boolean;
  81156. private _useTextureToStoreBoneMatrices;
  81157. /**
  81158. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81159. * Please note that this option is not available if the hardware does not support it
  81160. */
  81161. useTextureToStoreBoneMatrices: boolean;
  81162. private _animationPropertiesOverride;
  81163. /**
  81164. * Gets or sets the animation properties override
  81165. */
  81166. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81167. /**
  81168. * List of inspectable custom properties (used by the Inspector)
  81169. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81170. */
  81171. inspectableCustomProperties: IInspectable[];
  81172. /**
  81173. * An observable triggered before computing the skeleton's matrices
  81174. */
  81175. onBeforeComputeObservable: Observable<Skeleton>;
  81176. /**
  81177. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81178. */
  81179. readonly isUsingTextureForMatrices: boolean;
  81180. /**
  81181. * Gets the unique ID of this skeleton
  81182. */
  81183. readonly uniqueId: number;
  81184. /**
  81185. * Creates a new skeleton
  81186. * @param name defines the skeleton name
  81187. * @param id defines the skeleton Id
  81188. * @param scene defines the hosting scene
  81189. */
  81190. constructor(
  81191. /** defines the skeleton name */
  81192. name: string,
  81193. /** defines the skeleton Id */
  81194. id: string, scene: Scene);
  81195. /**
  81196. * Gets the current object class name.
  81197. * @return the class name
  81198. */
  81199. getClassName(): string;
  81200. /**
  81201. * Returns an array containing the root bones
  81202. * @returns an array containing the root bones
  81203. */
  81204. getChildren(): Array<Bone>;
  81205. /**
  81206. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81207. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81208. * @returns a Float32Array containing matrices data
  81209. */
  81210. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81211. /**
  81212. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81213. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81214. * @returns a raw texture containing the data
  81215. */
  81216. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81217. /**
  81218. * Gets the current hosting scene
  81219. * @returns a scene object
  81220. */
  81221. getScene(): Scene;
  81222. /**
  81223. * Gets a string representing the current skeleton data
  81224. * @param fullDetails defines a boolean indicating if we want a verbose version
  81225. * @returns a string representing the current skeleton data
  81226. */
  81227. toString(fullDetails?: boolean): string;
  81228. /**
  81229. * Get bone's index searching by name
  81230. * @param name defines bone's name to search for
  81231. * @return the indice of the bone. Returns -1 if not found
  81232. */
  81233. getBoneIndexByName(name: string): number;
  81234. /**
  81235. * Creater a new animation range
  81236. * @param name defines the name of the range
  81237. * @param from defines the start key
  81238. * @param to defines the end key
  81239. */
  81240. createAnimationRange(name: string, from: number, to: number): void;
  81241. /**
  81242. * Delete a specific animation range
  81243. * @param name defines the name of the range
  81244. * @param deleteFrames defines if frames must be removed as well
  81245. */
  81246. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81247. /**
  81248. * Gets a specific animation range
  81249. * @param name defines the name of the range to look for
  81250. * @returns the requested animation range or null if not found
  81251. */
  81252. getAnimationRange(name: string): Nullable<AnimationRange>;
  81253. /**
  81254. * Gets the list of all animation ranges defined on this skeleton
  81255. * @returns an array
  81256. */
  81257. getAnimationRanges(): Nullable<AnimationRange>[];
  81258. /**
  81259. * Copy animation range from a source skeleton.
  81260. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81261. * @param source defines the source skeleton
  81262. * @param name defines the name of the range to copy
  81263. * @param rescaleAsRequired defines if rescaling must be applied if required
  81264. * @returns true if operation was successful
  81265. */
  81266. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81267. /**
  81268. * Forces the skeleton to go to rest pose
  81269. */
  81270. returnToRest(): void;
  81271. private _getHighestAnimationFrame;
  81272. /**
  81273. * Begin a specific animation range
  81274. * @param name defines the name of the range to start
  81275. * @param loop defines if looping must be turned on (false by default)
  81276. * @param speedRatio defines the speed ratio to apply (1 by default)
  81277. * @param onAnimationEnd defines a callback which will be called when animation will end
  81278. * @returns a new animatable
  81279. */
  81280. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81281. /** @hidden */
  81282. _markAsDirty(): void;
  81283. /** @hidden */
  81284. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81285. /** @hidden */
  81286. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81287. private _computeTransformMatrices;
  81288. /**
  81289. * Build all resources required to render a skeleton
  81290. */
  81291. prepare(): void;
  81292. /**
  81293. * Gets the list of animatables currently running for this skeleton
  81294. * @returns an array of animatables
  81295. */
  81296. getAnimatables(): IAnimatable[];
  81297. /**
  81298. * Clone the current skeleton
  81299. * @param name defines the name of the new skeleton
  81300. * @param id defines the id of the new skeleton
  81301. * @returns the new skeleton
  81302. */
  81303. clone(name: string, id?: string): Skeleton;
  81304. /**
  81305. * Enable animation blending for this skeleton
  81306. * @param blendingSpeed defines the blending speed to apply
  81307. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81308. */
  81309. enableBlending(blendingSpeed?: number): void;
  81310. /**
  81311. * Releases all resources associated with the current skeleton
  81312. */
  81313. dispose(): void;
  81314. /**
  81315. * Serialize the skeleton in a JSON object
  81316. * @returns a JSON object
  81317. */
  81318. serialize(): any;
  81319. /**
  81320. * Creates a new skeleton from serialized data
  81321. * @param parsedSkeleton defines the serialized data
  81322. * @param scene defines the hosting scene
  81323. * @returns a new skeleton
  81324. */
  81325. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81326. /**
  81327. * Compute all node absolute transforms
  81328. * @param forceUpdate defines if computation must be done even if cache is up to date
  81329. */
  81330. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81331. /**
  81332. * Gets the root pose matrix
  81333. * @returns a matrix
  81334. */
  81335. getPoseMatrix(): Nullable<Matrix>;
  81336. /**
  81337. * Sorts bones per internal index
  81338. */
  81339. sortBones(): void;
  81340. private _sortBones;
  81341. }
  81342. }
  81343. declare module BABYLON {
  81344. /**
  81345. * Class used to store bone information
  81346. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81347. */
  81348. export class Bone extends Node {
  81349. /**
  81350. * defines the bone name
  81351. */
  81352. name: string;
  81353. private static _tmpVecs;
  81354. private static _tmpQuat;
  81355. private static _tmpMats;
  81356. /**
  81357. * Gets the list of child bones
  81358. */
  81359. children: Bone[];
  81360. /** Gets the animations associated with this bone */
  81361. animations: Animation[];
  81362. /**
  81363. * Gets or sets bone length
  81364. */
  81365. length: number;
  81366. /**
  81367. * @hidden Internal only
  81368. * Set this value to map this bone to a different index in the transform matrices
  81369. * Set this value to -1 to exclude the bone from the transform matrices
  81370. */
  81371. _index: Nullable<number>;
  81372. private _skeleton;
  81373. private _localMatrix;
  81374. private _restPose;
  81375. private _baseMatrix;
  81376. private _absoluteTransform;
  81377. private _invertedAbsoluteTransform;
  81378. private _parent;
  81379. private _scalingDeterminant;
  81380. private _worldTransform;
  81381. private _localScaling;
  81382. private _localRotation;
  81383. private _localPosition;
  81384. private _needToDecompose;
  81385. private _needToCompose;
  81386. /** @hidden */
  81387. _linkedTransformNode: Nullable<TransformNode>;
  81388. /** @hidden */
  81389. _waitingTransformNodeId: Nullable<string>;
  81390. /** @hidden */
  81391. /** @hidden */
  81392. _matrix: Matrix;
  81393. /**
  81394. * Create a new bone
  81395. * @param name defines the bone name
  81396. * @param skeleton defines the parent skeleton
  81397. * @param parentBone defines the parent (can be null if the bone is the root)
  81398. * @param localMatrix defines the local matrix
  81399. * @param restPose defines the rest pose matrix
  81400. * @param baseMatrix defines the base matrix
  81401. * @param index defines index of the bone in the hiearchy
  81402. */
  81403. constructor(
  81404. /**
  81405. * defines the bone name
  81406. */
  81407. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81408. /**
  81409. * Gets the current object class name.
  81410. * @return the class name
  81411. */
  81412. getClassName(): string;
  81413. /**
  81414. * Gets the parent skeleton
  81415. * @returns a skeleton
  81416. */
  81417. getSkeleton(): Skeleton;
  81418. /**
  81419. * Gets parent bone
  81420. * @returns a bone or null if the bone is the root of the bone hierarchy
  81421. */
  81422. getParent(): Nullable<Bone>;
  81423. /**
  81424. * Returns an array containing the root bones
  81425. * @returns an array containing the root bones
  81426. */
  81427. getChildren(): Array<Bone>;
  81428. /**
  81429. * Gets the node index in matrix array generated for rendering
  81430. * @returns the node index
  81431. */
  81432. getIndex(): number;
  81433. /**
  81434. * Sets the parent bone
  81435. * @param parent defines the parent (can be null if the bone is the root)
  81436. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81437. */
  81438. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81439. /**
  81440. * Gets the local matrix
  81441. * @returns a matrix
  81442. */
  81443. getLocalMatrix(): Matrix;
  81444. /**
  81445. * Gets the base matrix (initial matrix which remains unchanged)
  81446. * @returns a matrix
  81447. */
  81448. getBaseMatrix(): Matrix;
  81449. /**
  81450. * Gets the rest pose matrix
  81451. * @returns a matrix
  81452. */
  81453. getRestPose(): Matrix;
  81454. /**
  81455. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81456. */
  81457. getWorldMatrix(): Matrix;
  81458. /**
  81459. * Sets the local matrix to rest pose matrix
  81460. */
  81461. returnToRest(): void;
  81462. /**
  81463. * Gets the inverse of the absolute transform matrix.
  81464. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81465. * @returns a matrix
  81466. */
  81467. getInvertedAbsoluteTransform(): Matrix;
  81468. /**
  81469. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81470. * @returns a matrix
  81471. */
  81472. getAbsoluteTransform(): Matrix;
  81473. /**
  81474. * Links with the given transform node.
  81475. * The local matrix of this bone is copied from the transform node every frame.
  81476. * @param transformNode defines the transform node to link to
  81477. */
  81478. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81479. /**
  81480. * Gets the node used to drive the bone's transformation
  81481. * @returns a transform node or null
  81482. */
  81483. getTransformNode(): Nullable<TransformNode>;
  81484. /** Gets or sets current position (in local space) */
  81485. position: Vector3;
  81486. /** Gets or sets current rotation (in local space) */
  81487. rotation: Vector3;
  81488. /** Gets or sets current rotation quaternion (in local space) */
  81489. rotationQuaternion: Quaternion;
  81490. /** Gets or sets current scaling (in local space) */
  81491. scaling: Vector3;
  81492. /**
  81493. * Gets the animation properties override
  81494. */
  81495. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81496. private _decompose;
  81497. private _compose;
  81498. /**
  81499. * Update the base and local matrices
  81500. * @param matrix defines the new base or local matrix
  81501. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81502. * @param updateLocalMatrix defines if the local matrix should be updated
  81503. */
  81504. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81505. /** @hidden */
  81506. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81507. /**
  81508. * Flag the bone as dirty (Forcing it to update everything)
  81509. */
  81510. markAsDirty(): void;
  81511. /** @hidden */
  81512. _markAsDirtyAndCompose(): void;
  81513. private _markAsDirtyAndDecompose;
  81514. /**
  81515. * Translate the bone in local or world space
  81516. * @param vec The amount to translate the bone
  81517. * @param space The space that the translation is in
  81518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81519. */
  81520. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81521. /**
  81522. * Set the postion of the bone in local or world space
  81523. * @param position The position to set the bone
  81524. * @param space The space that the position is in
  81525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81526. */
  81527. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81528. /**
  81529. * Set the absolute position of the bone (world space)
  81530. * @param position The position to set the bone
  81531. * @param mesh The mesh that this bone is attached to
  81532. */
  81533. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81534. /**
  81535. * Scale the bone on the x, y and z axes (in local space)
  81536. * @param x The amount to scale the bone on the x axis
  81537. * @param y The amount to scale the bone on the y axis
  81538. * @param z The amount to scale the bone on the z axis
  81539. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81540. */
  81541. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81542. /**
  81543. * Set the bone scaling in local space
  81544. * @param scale defines the scaling vector
  81545. */
  81546. setScale(scale: Vector3): void;
  81547. /**
  81548. * Gets the current scaling in local space
  81549. * @returns the current scaling vector
  81550. */
  81551. getScale(): Vector3;
  81552. /**
  81553. * Gets the current scaling in local space and stores it in a target vector
  81554. * @param result defines the target vector
  81555. */
  81556. getScaleToRef(result: Vector3): void;
  81557. /**
  81558. * Set the yaw, pitch, and roll of the bone in local or world space
  81559. * @param yaw The rotation of the bone on the y axis
  81560. * @param pitch The rotation of the bone on the x axis
  81561. * @param roll The rotation of the bone on the z axis
  81562. * @param space The space that the axes of rotation are in
  81563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81564. */
  81565. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81566. /**
  81567. * Add a rotation to the bone on an axis in local or world space
  81568. * @param axis The axis to rotate the bone on
  81569. * @param amount The amount to rotate the bone
  81570. * @param space The space that the axis is in
  81571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81572. */
  81573. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81574. /**
  81575. * Set the rotation of the bone to a particular axis angle in local or world space
  81576. * @param axis The axis to rotate the bone on
  81577. * @param angle The angle that the bone should be rotated to
  81578. * @param space The space that the axis is in
  81579. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81580. */
  81581. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81582. /**
  81583. * Set the euler rotation of the bone in local of world space
  81584. * @param rotation The euler rotation that the bone should be set to
  81585. * @param space The space that the rotation is in
  81586. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81587. */
  81588. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81589. /**
  81590. * Set the quaternion rotation of the bone in local of world space
  81591. * @param quat The quaternion rotation that the bone should be set to
  81592. * @param space The space that the rotation is in
  81593. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81594. */
  81595. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81596. /**
  81597. * Set the rotation matrix of the bone in local of world space
  81598. * @param rotMat The rotation matrix that the bone should be set to
  81599. * @param space The space that the rotation is in
  81600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81601. */
  81602. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81603. private _rotateWithMatrix;
  81604. private _getNegativeRotationToRef;
  81605. /**
  81606. * Get the position of the bone in local or world space
  81607. * @param space The space that the returned position is in
  81608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81609. * @returns The position of the bone
  81610. */
  81611. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81612. /**
  81613. * Copy the position of the bone to a vector3 in local or world space
  81614. * @param space The space that the returned position is in
  81615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81616. * @param result The vector3 to copy the position to
  81617. */
  81618. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81619. /**
  81620. * Get the absolute position of the bone (world space)
  81621. * @param mesh The mesh that this bone is attached to
  81622. * @returns The absolute position of the bone
  81623. */
  81624. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81625. /**
  81626. * Copy the absolute position of the bone (world space) to the result param
  81627. * @param mesh The mesh that this bone is attached to
  81628. * @param result The vector3 to copy the absolute position to
  81629. */
  81630. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81631. /**
  81632. * Compute the absolute transforms of this bone and its children
  81633. */
  81634. computeAbsoluteTransforms(): void;
  81635. /**
  81636. * Get the world direction from an axis that is in the local space of the bone
  81637. * @param localAxis The local direction that is used to compute the world direction
  81638. * @param mesh The mesh that this bone is attached to
  81639. * @returns The world direction
  81640. */
  81641. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81642. /**
  81643. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81644. * @param localAxis The local direction that is used to compute the world direction
  81645. * @param mesh The mesh that this bone is attached to
  81646. * @param result The vector3 that the world direction will be copied to
  81647. */
  81648. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81649. /**
  81650. * Get the euler rotation of the bone in local or world space
  81651. * @param space The space that the rotation should be in
  81652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81653. * @returns The euler rotation
  81654. */
  81655. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81656. /**
  81657. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81658. * @param space The space that the rotation should be in
  81659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81660. * @param result The vector3 that the rotation should be copied to
  81661. */
  81662. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81663. /**
  81664. * Get the quaternion rotation of the bone in either local or world space
  81665. * @param space The space that the rotation should be in
  81666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81667. * @returns The quaternion rotation
  81668. */
  81669. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81670. /**
  81671. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81672. * @param space The space that the rotation should be in
  81673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81674. * @param result The quaternion that the rotation should be copied to
  81675. */
  81676. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81677. /**
  81678. * Get the rotation matrix of the bone in local or world space
  81679. * @param space The space that the rotation should be in
  81680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81681. * @returns The rotation matrix
  81682. */
  81683. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81684. /**
  81685. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81686. * @param space The space that the rotation should be in
  81687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81688. * @param result The quaternion that the rotation should be copied to
  81689. */
  81690. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81691. /**
  81692. * Get the world position of a point that is in the local space of the bone
  81693. * @param position The local position
  81694. * @param mesh The mesh that this bone is attached to
  81695. * @returns The world position
  81696. */
  81697. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81698. /**
  81699. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81700. * @param position The local position
  81701. * @param mesh The mesh that this bone is attached to
  81702. * @param result The vector3 that the world position should be copied to
  81703. */
  81704. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81705. /**
  81706. * Get the local position of a point that is in world space
  81707. * @param position The world position
  81708. * @param mesh The mesh that this bone is attached to
  81709. * @returns The local position
  81710. */
  81711. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81712. /**
  81713. * Get the local position of a point that is in world space and copy it to the result param
  81714. * @param position The world position
  81715. * @param mesh The mesh that this bone is attached to
  81716. * @param result The vector3 that the local position should be copied to
  81717. */
  81718. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81719. }
  81720. }
  81721. declare module BABYLON {
  81722. /**
  81723. * 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.
  81724. * @see https://doc.babylonjs.com/how_to/transformnode
  81725. */
  81726. export class TransformNode extends Node {
  81727. /**
  81728. * Object will not rotate to face the camera
  81729. */
  81730. static BILLBOARDMODE_NONE: number;
  81731. /**
  81732. * Object will rotate to face the camera but only on the x axis
  81733. */
  81734. static BILLBOARDMODE_X: number;
  81735. /**
  81736. * Object will rotate to face the camera but only on the y axis
  81737. */
  81738. static BILLBOARDMODE_Y: number;
  81739. /**
  81740. * Object will rotate to face the camera but only on the z axis
  81741. */
  81742. static BILLBOARDMODE_Z: number;
  81743. /**
  81744. * Object will rotate to face the camera
  81745. */
  81746. static BILLBOARDMODE_ALL: number;
  81747. /**
  81748. * Object will rotate to face the camera's position instead of orientation
  81749. */
  81750. static BILLBOARDMODE_USE_POSITION: number;
  81751. private _forward;
  81752. private _forwardInverted;
  81753. private _up;
  81754. private _right;
  81755. private _rightInverted;
  81756. private _position;
  81757. private _rotation;
  81758. private _rotationQuaternion;
  81759. protected _scaling: Vector3;
  81760. protected _isDirty: boolean;
  81761. private _transformToBoneReferal;
  81762. private _isAbsoluteSynced;
  81763. private _billboardMode;
  81764. /**
  81765. * Gets or sets the billboard mode. Default is 0.
  81766. *
  81767. * | Value | Type | Description |
  81768. * | --- | --- | --- |
  81769. * | 0 | BILLBOARDMODE_NONE | |
  81770. * | 1 | BILLBOARDMODE_X | |
  81771. * | 2 | BILLBOARDMODE_Y | |
  81772. * | 4 | BILLBOARDMODE_Z | |
  81773. * | 7 | BILLBOARDMODE_ALL | |
  81774. *
  81775. */
  81776. billboardMode: number;
  81777. private _preserveParentRotationForBillboard;
  81778. /**
  81779. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81780. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81781. */
  81782. preserveParentRotationForBillboard: boolean;
  81783. /**
  81784. * 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
  81785. */
  81786. scalingDeterminant: number;
  81787. private _infiniteDistance;
  81788. /**
  81789. * Gets or sets the distance of the object to max, often used by skybox
  81790. */
  81791. infiniteDistance: boolean;
  81792. /**
  81793. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81794. * By default the system will update normals to compensate
  81795. */
  81796. ignoreNonUniformScaling: boolean;
  81797. /**
  81798. * 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
  81799. */
  81800. reIntegrateRotationIntoRotationQuaternion: boolean;
  81801. /** @hidden */
  81802. _poseMatrix: Nullable<Matrix>;
  81803. /** @hidden */
  81804. _localMatrix: Matrix;
  81805. private _usePivotMatrix;
  81806. private _absolutePosition;
  81807. private _absoluteScaling;
  81808. private _absoluteRotationQuaternion;
  81809. private _pivotMatrix;
  81810. private _pivotMatrixInverse;
  81811. protected _postMultiplyPivotMatrix: boolean;
  81812. protected _isWorldMatrixFrozen: boolean;
  81813. /** @hidden */
  81814. _indexInSceneTransformNodesArray: number;
  81815. /**
  81816. * An event triggered after the world matrix is updated
  81817. */
  81818. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81819. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81820. /**
  81821. * Gets a string identifying the name of the class
  81822. * @returns "TransformNode" string
  81823. */
  81824. getClassName(): string;
  81825. /**
  81826. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81827. */
  81828. position: Vector3;
  81829. /**
  81830. * 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)).
  81831. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81832. */
  81833. rotation: Vector3;
  81834. /**
  81835. * 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)).
  81836. */
  81837. scaling: Vector3;
  81838. /**
  81839. * 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).
  81840. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81841. */
  81842. rotationQuaternion: Nullable<Quaternion>;
  81843. /**
  81844. * The forward direction of that transform in world space.
  81845. */
  81846. readonly forward: Vector3;
  81847. /**
  81848. * The up direction of that transform in world space.
  81849. */
  81850. readonly up: Vector3;
  81851. /**
  81852. * The right direction of that transform in world space.
  81853. */
  81854. readonly right: Vector3;
  81855. /**
  81856. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81857. * @param matrix the matrix to copy the pose from
  81858. * @returns this TransformNode.
  81859. */
  81860. updatePoseMatrix(matrix: Matrix): TransformNode;
  81861. /**
  81862. * Returns the mesh Pose matrix.
  81863. * @returns the pose matrix
  81864. */
  81865. getPoseMatrix(): Matrix;
  81866. /** @hidden */
  81867. _isSynchronized(): boolean;
  81868. /** @hidden */
  81869. _initCache(): void;
  81870. /**
  81871. * Flag the transform node as dirty (Forcing it to update everything)
  81872. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81873. * @returns this transform node
  81874. */
  81875. markAsDirty(property: string): TransformNode;
  81876. /**
  81877. * Returns the current mesh absolute position.
  81878. * Returns a Vector3.
  81879. */
  81880. readonly absolutePosition: Vector3;
  81881. /**
  81882. * Returns the current mesh absolute scaling.
  81883. * Returns a Vector3.
  81884. */
  81885. readonly absoluteScaling: Vector3;
  81886. /**
  81887. * Returns the current mesh absolute rotation.
  81888. * Returns a Quaternion.
  81889. */
  81890. readonly absoluteRotationQuaternion: Quaternion;
  81891. /**
  81892. * Sets a new matrix to apply before all other transformation
  81893. * @param matrix defines the transform matrix
  81894. * @returns the current TransformNode
  81895. */
  81896. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81897. /**
  81898. * Sets a new pivot matrix to the current node
  81899. * @param matrix defines the new pivot matrix to use
  81900. * @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
  81901. * @returns the current TransformNode
  81902. */
  81903. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81904. /**
  81905. * Returns the mesh pivot matrix.
  81906. * Default : Identity.
  81907. * @returns the matrix
  81908. */
  81909. getPivotMatrix(): Matrix;
  81910. /**
  81911. * Instantiate (when possible) or clone that node with its hierarchy
  81912. * @param newParent defines the new parent to use for the instance (or clone)
  81913. * @param options defines options to configure how copy is done
  81914. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  81915. * @returns an instance (or a clone) of the current node with its hiearchy
  81916. */
  81917. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  81918. doNotInstantiate: boolean;
  81919. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  81920. /**
  81921. * Prevents the World matrix to be computed any longer
  81922. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81923. * @returns the TransformNode.
  81924. */
  81925. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81926. /**
  81927. * Allows back the World matrix computation.
  81928. * @returns the TransformNode.
  81929. */
  81930. unfreezeWorldMatrix(): this;
  81931. /**
  81932. * True if the World matrix has been frozen.
  81933. */
  81934. readonly isWorldMatrixFrozen: boolean;
  81935. /**
  81936. * Retuns the mesh absolute position in the World.
  81937. * @returns a Vector3.
  81938. */
  81939. getAbsolutePosition(): Vector3;
  81940. /**
  81941. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81942. * @param absolutePosition the absolute position to set
  81943. * @returns the TransformNode.
  81944. */
  81945. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81946. /**
  81947. * Sets the mesh position in its local space.
  81948. * @param vector3 the position to set in localspace
  81949. * @returns the TransformNode.
  81950. */
  81951. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81952. /**
  81953. * Returns the mesh position in the local space from the current World matrix values.
  81954. * @returns a new Vector3.
  81955. */
  81956. getPositionExpressedInLocalSpace(): Vector3;
  81957. /**
  81958. * Translates the mesh along the passed Vector3 in its local space.
  81959. * @param vector3 the distance to translate in localspace
  81960. * @returns the TransformNode.
  81961. */
  81962. locallyTranslate(vector3: Vector3): TransformNode;
  81963. private static _lookAtVectorCache;
  81964. /**
  81965. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81966. * @param targetPoint the position (must be in same space as current mesh) to look at
  81967. * @param yawCor optional yaw (y-axis) correction in radians
  81968. * @param pitchCor optional pitch (x-axis) correction in radians
  81969. * @param rollCor optional roll (z-axis) correction in radians
  81970. * @param space the choosen space of the target
  81971. * @returns the TransformNode.
  81972. */
  81973. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81974. /**
  81975. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81976. * This Vector3 is expressed in the World space.
  81977. * @param localAxis axis to rotate
  81978. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81979. */
  81980. getDirection(localAxis: Vector3): Vector3;
  81981. /**
  81982. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81983. * localAxis is expressed in the mesh local space.
  81984. * result is computed in the Wordl space from the mesh World matrix.
  81985. * @param localAxis axis to rotate
  81986. * @param result the resulting transformnode
  81987. * @returns this TransformNode.
  81988. */
  81989. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81990. /**
  81991. * Sets this transform node rotation to the given local axis.
  81992. * @param localAxis the axis in local space
  81993. * @param yawCor optional yaw (y-axis) correction in radians
  81994. * @param pitchCor optional pitch (x-axis) correction in radians
  81995. * @param rollCor optional roll (z-axis) correction in radians
  81996. * @returns this TransformNode
  81997. */
  81998. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81999. /**
  82000. * Sets a new pivot point to the current node
  82001. * @param point defines the new pivot point to use
  82002. * @param space defines if the point is in world or local space (local by default)
  82003. * @returns the current TransformNode
  82004. */
  82005. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82006. /**
  82007. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82008. * @returns the pivot point
  82009. */
  82010. getPivotPoint(): Vector3;
  82011. /**
  82012. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82013. * @param result the vector3 to store the result
  82014. * @returns this TransformNode.
  82015. */
  82016. getPivotPointToRef(result: Vector3): TransformNode;
  82017. /**
  82018. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82019. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82020. */
  82021. getAbsolutePivotPoint(): Vector3;
  82022. /**
  82023. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82024. * @param result vector3 to store the result
  82025. * @returns this TransformNode.
  82026. */
  82027. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82028. /**
  82029. * Defines the passed node as the parent of the current node.
  82030. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82031. * @see https://doc.babylonjs.com/how_to/parenting
  82032. * @param node the node ot set as the parent
  82033. * @returns this TransformNode.
  82034. */
  82035. setParent(node: Nullable<Node>): TransformNode;
  82036. private _nonUniformScaling;
  82037. /**
  82038. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82039. */
  82040. readonly nonUniformScaling: boolean;
  82041. /** @hidden */
  82042. _updateNonUniformScalingState(value: boolean): boolean;
  82043. /**
  82044. * Attach the current TransformNode to another TransformNode associated with a bone
  82045. * @param bone Bone affecting the TransformNode
  82046. * @param affectedTransformNode TransformNode associated with the bone
  82047. * @returns this object
  82048. */
  82049. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82050. /**
  82051. * Detach the transform node if its associated with a bone
  82052. * @returns this object
  82053. */
  82054. detachFromBone(): TransformNode;
  82055. private static _rotationAxisCache;
  82056. /**
  82057. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82058. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82059. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82060. * The passed axis is also normalized.
  82061. * @param axis the axis to rotate around
  82062. * @param amount the amount to rotate in radians
  82063. * @param space Space to rotate in (Default: local)
  82064. * @returns the TransformNode.
  82065. */
  82066. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82067. /**
  82068. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82069. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82070. * The passed axis is also normalized. .
  82071. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82072. * @param point the point to rotate around
  82073. * @param axis the axis to rotate around
  82074. * @param amount the amount to rotate in radians
  82075. * @returns the TransformNode
  82076. */
  82077. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82078. /**
  82079. * Translates the mesh along the axis vector for the passed distance in the given space.
  82080. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82081. * @param axis the axis to translate in
  82082. * @param distance the distance to translate
  82083. * @param space Space to rotate in (Default: local)
  82084. * @returns the TransformNode.
  82085. */
  82086. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82087. /**
  82088. * Adds a rotation step to the mesh current rotation.
  82089. * x, y, z are Euler angles expressed in radians.
  82090. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82091. * This means this rotation is made in the mesh local space only.
  82092. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82093. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82094. * ```javascript
  82095. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82096. * ```
  82097. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82098. * 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.
  82099. * @param x Rotation to add
  82100. * @param y Rotation to add
  82101. * @param z Rotation to add
  82102. * @returns the TransformNode.
  82103. */
  82104. addRotation(x: number, y: number, z: number): TransformNode;
  82105. /**
  82106. * @hidden
  82107. */
  82108. protected _getEffectiveParent(): Nullable<Node>;
  82109. /**
  82110. * Computes the world matrix of the node
  82111. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82112. * @returns the world matrix
  82113. */
  82114. computeWorldMatrix(force?: boolean): Matrix;
  82115. protected _afterComputeWorldMatrix(): void;
  82116. /**
  82117. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82118. * @param func callback function to add
  82119. *
  82120. * @returns the TransformNode.
  82121. */
  82122. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82123. /**
  82124. * Removes a registered callback function.
  82125. * @param func callback function to remove
  82126. * @returns the TransformNode.
  82127. */
  82128. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82129. /**
  82130. * Gets the position of the current mesh in camera space
  82131. * @param camera defines the camera to use
  82132. * @returns a position
  82133. */
  82134. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82135. /**
  82136. * Returns the distance from the mesh to the active camera
  82137. * @param camera defines the camera to use
  82138. * @returns the distance
  82139. */
  82140. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82141. /**
  82142. * Clone the current transform node
  82143. * @param name Name of the new clone
  82144. * @param newParent New parent for the clone
  82145. * @param doNotCloneChildren Do not clone children hierarchy
  82146. * @returns the new transform node
  82147. */
  82148. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82149. /**
  82150. * Serializes the objects information.
  82151. * @param currentSerializationObject defines the object to serialize in
  82152. * @returns the serialized object
  82153. */
  82154. serialize(currentSerializationObject?: any): any;
  82155. /**
  82156. * Returns a new TransformNode object parsed from the source provided.
  82157. * @param parsedTransformNode is the source.
  82158. * @param scene the scne the object belongs to
  82159. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82160. * @returns a new TransformNode object parsed from the source provided.
  82161. */
  82162. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82163. /**
  82164. * Get all child-transformNodes of this node
  82165. * @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
  82166. * @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
  82167. * @returns an array of TransformNode
  82168. */
  82169. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82170. /**
  82171. * Releases resources associated with this transform node.
  82172. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82173. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82174. */
  82175. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82176. /**
  82177. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82178. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82179. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82180. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82181. * @returns the current mesh
  82182. */
  82183. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82184. private _syncAbsoluteScalingAndRotation;
  82185. }
  82186. }
  82187. declare module BABYLON {
  82188. /**
  82189. * Defines the types of pose enabled controllers that are supported
  82190. */
  82191. export enum PoseEnabledControllerType {
  82192. /**
  82193. * HTC Vive
  82194. */
  82195. VIVE = 0,
  82196. /**
  82197. * Oculus Rift
  82198. */
  82199. OCULUS = 1,
  82200. /**
  82201. * Windows mixed reality
  82202. */
  82203. WINDOWS = 2,
  82204. /**
  82205. * Samsung gear VR
  82206. */
  82207. GEAR_VR = 3,
  82208. /**
  82209. * Google Daydream
  82210. */
  82211. DAYDREAM = 4,
  82212. /**
  82213. * Generic
  82214. */
  82215. GENERIC = 5
  82216. }
  82217. /**
  82218. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82219. */
  82220. export interface MutableGamepadButton {
  82221. /**
  82222. * Value of the button/trigger
  82223. */
  82224. value: number;
  82225. /**
  82226. * If the button/trigger is currently touched
  82227. */
  82228. touched: boolean;
  82229. /**
  82230. * If the button/trigger is currently pressed
  82231. */
  82232. pressed: boolean;
  82233. }
  82234. /**
  82235. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82236. * @hidden
  82237. */
  82238. export interface ExtendedGamepadButton extends GamepadButton {
  82239. /**
  82240. * If the button/trigger is currently pressed
  82241. */
  82242. readonly pressed: boolean;
  82243. /**
  82244. * If the button/trigger is currently touched
  82245. */
  82246. readonly touched: boolean;
  82247. /**
  82248. * Value of the button/trigger
  82249. */
  82250. readonly value: number;
  82251. }
  82252. /** @hidden */
  82253. export interface _GamePadFactory {
  82254. /**
  82255. * Returns wether or not the current gamepad can be created for this type of controller.
  82256. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82257. * @returns true if it can be created, otherwise false
  82258. */
  82259. canCreate(gamepadInfo: any): boolean;
  82260. /**
  82261. * Creates a new instance of the Gamepad.
  82262. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82263. * @returns the new gamepad instance
  82264. */
  82265. create(gamepadInfo: any): Gamepad;
  82266. }
  82267. /**
  82268. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82269. */
  82270. export class PoseEnabledControllerHelper {
  82271. /** @hidden */
  82272. static _ControllerFactories: _GamePadFactory[];
  82273. /** @hidden */
  82274. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82275. /**
  82276. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82277. * @param vrGamepad the gamepad to initialized
  82278. * @returns a vr controller of the type the gamepad identified as
  82279. */
  82280. static InitiateController(vrGamepad: any): Gamepad;
  82281. }
  82282. /**
  82283. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82284. */
  82285. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82286. /**
  82287. * If the controller is used in a webXR session
  82288. */
  82289. isXR: boolean;
  82290. private _deviceRoomPosition;
  82291. private _deviceRoomRotationQuaternion;
  82292. /**
  82293. * The device position in babylon space
  82294. */
  82295. devicePosition: Vector3;
  82296. /**
  82297. * The device rotation in babylon space
  82298. */
  82299. deviceRotationQuaternion: Quaternion;
  82300. /**
  82301. * The scale factor of the device in babylon space
  82302. */
  82303. deviceScaleFactor: number;
  82304. /**
  82305. * (Likely devicePosition should be used instead) The device position in its room space
  82306. */
  82307. position: Vector3;
  82308. /**
  82309. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82310. */
  82311. rotationQuaternion: Quaternion;
  82312. /**
  82313. * The type of controller (Eg. Windows mixed reality)
  82314. */
  82315. controllerType: PoseEnabledControllerType;
  82316. protected _calculatedPosition: Vector3;
  82317. private _calculatedRotation;
  82318. /**
  82319. * The raw pose from the device
  82320. */
  82321. rawPose: DevicePose;
  82322. private _trackPosition;
  82323. private _maxRotationDistFromHeadset;
  82324. private _draggedRoomRotation;
  82325. /**
  82326. * @hidden
  82327. */
  82328. _disableTrackPosition(fixedPosition: Vector3): void;
  82329. /**
  82330. * Internal, the mesh attached to the controller
  82331. * @hidden
  82332. */
  82333. _mesh: Nullable<AbstractMesh>;
  82334. private _poseControlledCamera;
  82335. private _leftHandSystemQuaternion;
  82336. /**
  82337. * Internal, matrix used to convert room space to babylon space
  82338. * @hidden
  82339. */
  82340. _deviceToWorld: Matrix;
  82341. /**
  82342. * Node to be used when casting a ray from the controller
  82343. * @hidden
  82344. */
  82345. _pointingPoseNode: Nullable<TransformNode>;
  82346. /**
  82347. * Name of the child mesh that can be used to cast a ray from the controller
  82348. */
  82349. static readonly POINTING_POSE: string;
  82350. /**
  82351. * Creates a new PoseEnabledController from a gamepad
  82352. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82353. */
  82354. constructor(browserGamepad: any);
  82355. private _workingMatrix;
  82356. /**
  82357. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82358. */
  82359. update(): void;
  82360. /**
  82361. * Updates only the pose device and mesh without doing any button event checking
  82362. */
  82363. protected _updatePoseAndMesh(): void;
  82364. /**
  82365. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82366. * @param poseData raw pose fromthe device
  82367. */
  82368. updateFromDevice(poseData: DevicePose): void;
  82369. /**
  82370. * @hidden
  82371. */
  82372. _meshAttachedObservable: Observable<AbstractMesh>;
  82373. /**
  82374. * Attaches a mesh to the controller
  82375. * @param mesh the mesh to be attached
  82376. */
  82377. attachToMesh(mesh: AbstractMesh): void;
  82378. /**
  82379. * Attaches the controllers mesh to a camera
  82380. * @param camera the camera the mesh should be attached to
  82381. */
  82382. attachToPoseControlledCamera(camera: TargetCamera): void;
  82383. /**
  82384. * Disposes of the controller
  82385. */
  82386. dispose(): void;
  82387. /**
  82388. * The mesh that is attached to the controller
  82389. */
  82390. readonly mesh: Nullable<AbstractMesh>;
  82391. /**
  82392. * Gets the ray of the controller in the direction the controller is pointing
  82393. * @param length the length the resulting ray should be
  82394. * @returns a ray in the direction the controller is pointing
  82395. */
  82396. getForwardRay(length?: number): Ray;
  82397. }
  82398. }
  82399. declare module BABYLON {
  82400. /**
  82401. * Defines the WebVRController object that represents controllers tracked in 3D space
  82402. */
  82403. export abstract class WebVRController extends PoseEnabledController {
  82404. /**
  82405. * Internal, the default controller model for the controller
  82406. */
  82407. protected _defaultModel: Nullable<AbstractMesh>;
  82408. /**
  82409. * Fired when the trigger state has changed
  82410. */
  82411. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82412. /**
  82413. * Fired when the main button state has changed
  82414. */
  82415. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82416. /**
  82417. * Fired when the secondary button state has changed
  82418. */
  82419. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82420. /**
  82421. * Fired when the pad state has changed
  82422. */
  82423. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82424. /**
  82425. * Fired when controllers stick values have changed
  82426. */
  82427. onPadValuesChangedObservable: Observable<StickValues>;
  82428. /**
  82429. * Array of button availible on the controller
  82430. */
  82431. protected _buttons: Array<MutableGamepadButton>;
  82432. private _onButtonStateChange;
  82433. /**
  82434. * Fired when a controller button's state has changed
  82435. * @param callback the callback containing the button that was modified
  82436. */
  82437. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82438. /**
  82439. * X and Y axis corresponding to the controllers joystick
  82440. */
  82441. pad: StickValues;
  82442. /**
  82443. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82444. */
  82445. hand: string;
  82446. /**
  82447. * The default controller model for the controller
  82448. */
  82449. readonly defaultModel: Nullable<AbstractMesh>;
  82450. /**
  82451. * Creates a new WebVRController from a gamepad
  82452. * @param vrGamepad the gamepad that the WebVRController should be created from
  82453. */
  82454. constructor(vrGamepad: any);
  82455. /**
  82456. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82457. */
  82458. update(): void;
  82459. /**
  82460. * Function to be called when a button is modified
  82461. */
  82462. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82463. /**
  82464. * Loads a mesh and attaches it to the controller
  82465. * @param scene the scene the mesh should be added to
  82466. * @param meshLoaded callback for when the mesh has been loaded
  82467. */
  82468. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82469. private _setButtonValue;
  82470. private _changes;
  82471. private _checkChanges;
  82472. /**
  82473. * Disposes of th webVRCOntroller
  82474. */
  82475. dispose(): void;
  82476. }
  82477. }
  82478. declare module BABYLON {
  82479. /**
  82480. * The HemisphericLight simulates the ambient environment light,
  82481. * so the passed direction is the light reflection direction, not the incoming direction.
  82482. */
  82483. export class HemisphericLight extends Light {
  82484. /**
  82485. * The groundColor is the light in the opposite direction to the one specified during creation.
  82486. * 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.
  82487. */
  82488. groundColor: Color3;
  82489. /**
  82490. * The light reflection direction, not the incoming direction.
  82491. */
  82492. direction: Vector3;
  82493. /**
  82494. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82495. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82496. * The HemisphericLight can't cast shadows.
  82497. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82498. * @param name The friendly name of the light
  82499. * @param direction The direction of the light reflection
  82500. * @param scene The scene the light belongs to
  82501. */
  82502. constructor(name: string, direction: Vector3, scene: Scene);
  82503. protected _buildUniformLayout(): void;
  82504. /**
  82505. * Returns the string "HemisphericLight".
  82506. * @return The class name
  82507. */
  82508. getClassName(): string;
  82509. /**
  82510. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82511. * Returns the updated direction.
  82512. * @param target The target the direction should point to
  82513. * @return The computed direction
  82514. */
  82515. setDirectionToTarget(target: Vector3): Vector3;
  82516. /**
  82517. * Returns the shadow generator associated to the light.
  82518. * @returns Always null for hemispheric lights because it does not support shadows.
  82519. */
  82520. getShadowGenerator(): Nullable<IShadowGenerator>;
  82521. /**
  82522. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82523. * @param effect The effect to update
  82524. * @param lightIndex The index of the light in the effect to update
  82525. * @returns The hemispheric light
  82526. */
  82527. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82528. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82529. /**
  82530. * Computes the world matrix of the node
  82531. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82532. * @param useWasUpdatedFlag defines a reserved property
  82533. * @returns the world matrix
  82534. */
  82535. computeWorldMatrix(): Matrix;
  82536. /**
  82537. * Returns the integer 3.
  82538. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82539. */
  82540. getTypeID(): number;
  82541. /**
  82542. * Prepares the list of defines specific to the light type.
  82543. * @param defines the list of defines
  82544. * @param lightIndex defines the index of the light for the effect
  82545. */
  82546. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82547. }
  82548. }
  82549. declare module BABYLON {
  82550. /** @hidden */
  82551. export var vrMultiviewToSingleviewPixelShader: {
  82552. name: string;
  82553. shader: string;
  82554. };
  82555. }
  82556. declare module BABYLON {
  82557. /**
  82558. * Renders to multiple views with a single draw call
  82559. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82560. */
  82561. export class MultiviewRenderTarget extends RenderTargetTexture {
  82562. /**
  82563. * Creates a multiview render target
  82564. * @param scene scene used with the render target
  82565. * @param size the size of the render target (used for each view)
  82566. */
  82567. constructor(scene: Scene, size?: number | {
  82568. width: number;
  82569. height: number;
  82570. } | {
  82571. ratio: number;
  82572. });
  82573. /**
  82574. * @hidden
  82575. * @param faceIndex the face index, if its a cube texture
  82576. */
  82577. _bindFrameBuffer(faceIndex?: number): void;
  82578. /**
  82579. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82580. * @returns the view count
  82581. */
  82582. getViewCount(): number;
  82583. }
  82584. }
  82585. declare module BABYLON {
  82586. /**
  82587. * Represents a camera frustum
  82588. */
  82589. export class Frustum {
  82590. /**
  82591. * Gets the planes representing the frustum
  82592. * @param transform matrix to be applied to the returned planes
  82593. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82594. */
  82595. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82596. /**
  82597. * Gets the near frustum plane transformed by the transform matrix
  82598. * @param transform transformation matrix to be applied to the resulting frustum plane
  82599. * @param frustumPlane the resuling frustum plane
  82600. */
  82601. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82602. /**
  82603. * Gets the far frustum plane transformed by the transform matrix
  82604. * @param transform transformation matrix to be applied to the resulting frustum plane
  82605. * @param frustumPlane the resuling frustum plane
  82606. */
  82607. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82608. /**
  82609. * Gets the left frustum plane transformed by the transform matrix
  82610. * @param transform transformation matrix to be applied to the resulting frustum plane
  82611. * @param frustumPlane the resuling frustum plane
  82612. */
  82613. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82614. /**
  82615. * Gets the right frustum plane transformed by the transform matrix
  82616. * @param transform transformation matrix to be applied to the resulting frustum plane
  82617. * @param frustumPlane the resuling frustum plane
  82618. */
  82619. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82620. /**
  82621. * Gets the top frustum plane transformed by the transform matrix
  82622. * @param transform transformation matrix to be applied to the resulting frustum plane
  82623. * @param frustumPlane the resuling frustum plane
  82624. */
  82625. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82626. /**
  82627. * Gets the bottom frustum plane transformed by the transform matrix
  82628. * @param transform transformation matrix to be applied to the resulting frustum plane
  82629. * @param frustumPlane the resuling frustum plane
  82630. */
  82631. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82632. /**
  82633. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82634. * @param transform transformation matrix to be applied to the resulting frustum planes
  82635. * @param frustumPlanes the resuling frustum planes
  82636. */
  82637. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82638. }
  82639. }
  82640. declare module BABYLON {
  82641. interface Engine {
  82642. /**
  82643. * Creates a new multiview render target
  82644. * @param width defines the width of the texture
  82645. * @param height defines the height of the texture
  82646. * @returns the created multiview texture
  82647. */
  82648. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82649. /**
  82650. * Binds a multiview framebuffer to be drawn to
  82651. * @param multiviewTexture texture to bind
  82652. */
  82653. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82654. }
  82655. interface Camera {
  82656. /**
  82657. * @hidden
  82658. * 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)
  82659. */
  82660. _useMultiviewToSingleView: boolean;
  82661. /**
  82662. * @hidden
  82663. * 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)
  82664. */
  82665. _multiviewTexture: Nullable<RenderTargetTexture>;
  82666. /**
  82667. * @hidden
  82668. * ensures the multiview texture of the camera exists and has the specified width/height
  82669. * @param width height to set on the multiview texture
  82670. * @param height width to set on the multiview texture
  82671. */
  82672. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82673. }
  82674. interface Scene {
  82675. /** @hidden */
  82676. _transformMatrixR: Matrix;
  82677. /** @hidden */
  82678. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82679. /** @hidden */
  82680. _createMultiviewUbo(): void;
  82681. /** @hidden */
  82682. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82683. /** @hidden */
  82684. _renderMultiviewToSingleView(camera: Camera): void;
  82685. }
  82686. }
  82687. declare module BABYLON {
  82688. /**
  82689. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82690. * This will not be used for webXR as it supports displaying texture arrays directly
  82691. */
  82692. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82693. /**
  82694. * Initializes a VRMultiviewToSingleview
  82695. * @param name name of the post process
  82696. * @param camera camera to be applied to
  82697. * @param scaleFactor scaling factor to the size of the output texture
  82698. */
  82699. constructor(name: string, camera: Camera, scaleFactor: number);
  82700. }
  82701. }
  82702. declare module BABYLON {
  82703. /**
  82704. * Interface used to define additional presentation attributes
  82705. */
  82706. export interface IVRPresentationAttributes {
  82707. /**
  82708. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  82709. */
  82710. highRefreshRate: boolean;
  82711. /**
  82712. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  82713. */
  82714. foveationLevel: number;
  82715. }
  82716. interface Engine {
  82717. /** @hidden */
  82718. _vrDisplay: any;
  82719. /** @hidden */
  82720. _vrSupported: boolean;
  82721. /** @hidden */
  82722. _oldSize: Size;
  82723. /** @hidden */
  82724. _oldHardwareScaleFactor: number;
  82725. /** @hidden */
  82726. _vrExclusivePointerMode: boolean;
  82727. /** @hidden */
  82728. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82729. /** @hidden */
  82730. _onVRDisplayPointerRestricted: () => void;
  82731. /** @hidden */
  82732. _onVRDisplayPointerUnrestricted: () => void;
  82733. /** @hidden */
  82734. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82735. /** @hidden */
  82736. _onVrDisplayDisconnect: Nullable<() => void>;
  82737. /** @hidden */
  82738. _onVrDisplayPresentChange: Nullable<() => void>;
  82739. /**
  82740. * Observable signaled when VR display mode changes
  82741. */
  82742. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82743. /**
  82744. * Observable signaled when VR request present is complete
  82745. */
  82746. onVRRequestPresentComplete: Observable<boolean>;
  82747. /**
  82748. * Observable signaled when VR request present starts
  82749. */
  82750. onVRRequestPresentStart: Observable<Engine>;
  82751. /**
  82752. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82753. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82754. */
  82755. isInVRExclusivePointerMode: boolean;
  82756. /**
  82757. * Gets a boolean indicating if a webVR device was detected
  82758. * @returns true if a webVR device was detected
  82759. */
  82760. isVRDevicePresent(): boolean;
  82761. /**
  82762. * Gets the current webVR device
  82763. * @returns the current webVR device (or null)
  82764. */
  82765. getVRDevice(): any;
  82766. /**
  82767. * Initializes a webVR display and starts listening to display change events
  82768. * The onVRDisplayChangedObservable will be notified upon these changes
  82769. * @returns A promise containing a VRDisplay and if vr is supported
  82770. */
  82771. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82772. /** @hidden */
  82773. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82774. /**
  82775. * Gets or sets the presentation attributes used to configure VR rendering
  82776. */
  82777. vrPresentationAttributes?: IVRPresentationAttributes;
  82778. /**
  82779. * Call this function to switch to webVR mode
  82780. * Will do nothing if webVR is not supported or if there is no webVR device
  82781. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82782. */
  82783. enableVR(): void;
  82784. /** @hidden */
  82785. _onVRFullScreenTriggered(): void;
  82786. }
  82787. }
  82788. declare module BABYLON {
  82789. /**
  82790. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82791. * IMPORTANT!! The data is right-hand data.
  82792. * @export
  82793. * @interface DevicePose
  82794. */
  82795. export interface DevicePose {
  82796. /**
  82797. * The position of the device, values in array are [x,y,z].
  82798. */
  82799. readonly position: Nullable<Float32Array>;
  82800. /**
  82801. * The linearVelocity of the device, values in array are [x,y,z].
  82802. */
  82803. readonly linearVelocity: Nullable<Float32Array>;
  82804. /**
  82805. * The linearAcceleration of the device, values in array are [x,y,z].
  82806. */
  82807. readonly linearAcceleration: Nullable<Float32Array>;
  82808. /**
  82809. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82810. */
  82811. readonly orientation: Nullable<Float32Array>;
  82812. /**
  82813. * The angularVelocity of the device, values in array are [x,y,z].
  82814. */
  82815. readonly angularVelocity: Nullable<Float32Array>;
  82816. /**
  82817. * The angularAcceleration of the device, values in array are [x,y,z].
  82818. */
  82819. readonly angularAcceleration: Nullable<Float32Array>;
  82820. }
  82821. /**
  82822. * Interface representing a pose controlled object in Babylon.
  82823. * A pose controlled object has both regular pose values as well as pose values
  82824. * from an external device such as a VR head mounted display
  82825. */
  82826. export interface PoseControlled {
  82827. /**
  82828. * The position of the object in babylon space.
  82829. */
  82830. position: Vector3;
  82831. /**
  82832. * The rotation quaternion of the object in babylon space.
  82833. */
  82834. rotationQuaternion: Quaternion;
  82835. /**
  82836. * The position of the device in babylon space.
  82837. */
  82838. devicePosition?: Vector3;
  82839. /**
  82840. * The rotation quaternion of the device in babylon space.
  82841. */
  82842. deviceRotationQuaternion: Quaternion;
  82843. /**
  82844. * The raw pose coming from the device.
  82845. */
  82846. rawPose: Nullable<DevicePose>;
  82847. /**
  82848. * The scale of the device to be used when translating from device space to babylon space.
  82849. */
  82850. deviceScaleFactor: number;
  82851. /**
  82852. * Updates the poseControlled values based on the input device pose.
  82853. * @param poseData the pose data to update the object with
  82854. */
  82855. updateFromDevice(poseData: DevicePose): void;
  82856. }
  82857. /**
  82858. * Set of options to customize the webVRCamera
  82859. */
  82860. export interface WebVROptions {
  82861. /**
  82862. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82863. */
  82864. trackPosition?: boolean;
  82865. /**
  82866. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82867. */
  82868. positionScale?: number;
  82869. /**
  82870. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82871. */
  82872. displayName?: string;
  82873. /**
  82874. * Should the native controller meshes be initialized. (default: true)
  82875. */
  82876. controllerMeshes?: boolean;
  82877. /**
  82878. * Creating a default HemiLight only on controllers. (default: true)
  82879. */
  82880. defaultLightingOnControllers?: boolean;
  82881. /**
  82882. * If you don't want to use the default VR button of the helper. (default: false)
  82883. */
  82884. useCustomVRButton?: boolean;
  82885. /**
  82886. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82887. */
  82888. customVRButton?: HTMLButtonElement;
  82889. /**
  82890. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82891. */
  82892. rayLength?: number;
  82893. /**
  82894. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82895. */
  82896. defaultHeight?: number;
  82897. /**
  82898. * If multiview should be used if availible (default: false)
  82899. */
  82900. useMultiview?: boolean;
  82901. }
  82902. /**
  82903. * This represents a WebVR camera.
  82904. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82905. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82906. */
  82907. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82908. private webVROptions;
  82909. /**
  82910. * @hidden
  82911. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82912. */
  82913. _vrDevice: any;
  82914. /**
  82915. * The rawPose of the vrDevice.
  82916. */
  82917. rawPose: Nullable<DevicePose>;
  82918. private _onVREnabled;
  82919. private _specsVersion;
  82920. private _attached;
  82921. private _frameData;
  82922. protected _descendants: Array<Node>;
  82923. private _deviceRoomPosition;
  82924. /** @hidden */
  82925. _deviceRoomRotationQuaternion: Quaternion;
  82926. private _standingMatrix;
  82927. /**
  82928. * Represents device position in babylon space.
  82929. */
  82930. devicePosition: Vector3;
  82931. /**
  82932. * Represents device rotation in babylon space.
  82933. */
  82934. deviceRotationQuaternion: Quaternion;
  82935. /**
  82936. * The scale of the device to be used when translating from device space to babylon space.
  82937. */
  82938. deviceScaleFactor: number;
  82939. private _deviceToWorld;
  82940. private _worldToDevice;
  82941. /**
  82942. * References to the webVR controllers for the vrDevice.
  82943. */
  82944. controllers: Array<WebVRController>;
  82945. /**
  82946. * Emits an event when a controller is attached.
  82947. */
  82948. onControllersAttachedObservable: Observable<WebVRController[]>;
  82949. /**
  82950. * Emits an event when a controller's mesh has been loaded;
  82951. */
  82952. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82953. /**
  82954. * Emits an event when the HMD's pose has been updated.
  82955. */
  82956. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82957. private _poseSet;
  82958. /**
  82959. * If the rig cameras be used as parent instead of this camera.
  82960. */
  82961. rigParenting: boolean;
  82962. private _lightOnControllers;
  82963. private _defaultHeight?;
  82964. /**
  82965. * Instantiates a WebVRFreeCamera.
  82966. * @param name The name of the WebVRFreeCamera
  82967. * @param position The starting anchor position for the camera
  82968. * @param scene The scene the camera belongs to
  82969. * @param webVROptions a set of customizable options for the webVRCamera
  82970. */
  82971. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82972. /**
  82973. * Gets the device distance from the ground in meters.
  82974. * @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.
  82975. */
  82976. deviceDistanceToRoomGround(): number;
  82977. /**
  82978. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82979. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82980. */
  82981. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82982. /**
  82983. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82984. * @returns A promise with a boolean set to if the standing matrix is supported.
  82985. */
  82986. useStandingMatrixAsync(): Promise<boolean>;
  82987. /**
  82988. * Disposes the camera
  82989. */
  82990. dispose(): void;
  82991. /**
  82992. * Gets a vrController by name.
  82993. * @param name The name of the controller to retreive
  82994. * @returns the controller matching the name specified or null if not found
  82995. */
  82996. getControllerByName(name: string): Nullable<WebVRController>;
  82997. private _leftController;
  82998. /**
  82999. * The controller corresponding to the users left hand.
  83000. */
  83001. readonly leftController: Nullable<WebVRController>;
  83002. private _rightController;
  83003. /**
  83004. * The controller corresponding to the users right hand.
  83005. */
  83006. readonly rightController: Nullable<WebVRController>;
  83007. /**
  83008. * Casts a ray forward from the vrCamera's gaze.
  83009. * @param length Length of the ray (default: 100)
  83010. * @returns the ray corresponding to the gaze
  83011. */
  83012. getForwardRay(length?: number): Ray;
  83013. /**
  83014. * @hidden
  83015. * Updates the camera based on device's frame data
  83016. */
  83017. _checkInputs(): void;
  83018. /**
  83019. * Updates the poseControlled values based on the input device pose.
  83020. * @param poseData Pose coming from the device
  83021. */
  83022. updateFromDevice(poseData: DevicePose): void;
  83023. private _htmlElementAttached;
  83024. private _detachIfAttached;
  83025. /**
  83026. * WebVR's attach control will start broadcasting frames to the device.
  83027. * Note that in certain browsers (chrome for example) this function must be called
  83028. * within a user-interaction callback. Example:
  83029. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83030. *
  83031. * @param element html element to attach the vrDevice to
  83032. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83033. */
  83034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83035. /**
  83036. * Detaches the camera from the html element and disables VR
  83037. *
  83038. * @param element html element to detach from
  83039. */
  83040. detachControl(element: HTMLElement): void;
  83041. /**
  83042. * @returns the name of this class
  83043. */
  83044. getClassName(): string;
  83045. /**
  83046. * Calls resetPose on the vrDisplay
  83047. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83048. */
  83049. resetToCurrentRotation(): void;
  83050. /**
  83051. * @hidden
  83052. * Updates the rig cameras (left and right eye)
  83053. */
  83054. _updateRigCameras(): void;
  83055. private _workingVector;
  83056. private _oneVector;
  83057. private _workingMatrix;
  83058. private updateCacheCalled;
  83059. private _correctPositionIfNotTrackPosition;
  83060. /**
  83061. * @hidden
  83062. * Updates the cached values of the camera
  83063. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83064. */
  83065. _updateCache(ignoreParentClass?: boolean): void;
  83066. /**
  83067. * @hidden
  83068. * Get current device position in babylon world
  83069. */
  83070. _computeDevicePosition(): void;
  83071. /**
  83072. * Updates the current device position and rotation in the babylon world
  83073. */
  83074. update(): void;
  83075. /**
  83076. * @hidden
  83077. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83078. * @returns an identity matrix
  83079. */
  83080. _getViewMatrix(): Matrix;
  83081. private _tmpMatrix;
  83082. /**
  83083. * This function is called by the two RIG cameras.
  83084. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83085. * @hidden
  83086. */
  83087. _getWebVRViewMatrix(): Matrix;
  83088. /** @hidden */
  83089. _getWebVRProjectionMatrix(): Matrix;
  83090. private _onGamepadConnectedObserver;
  83091. private _onGamepadDisconnectedObserver;
  83092. private _updateCacheWhenTrackingDisabledObserver;
  83093. /**
  83094. * Initializes the controllers and their meshes
  83095. */
  83096. initControllers(): void;
  83097. }
  83098. }
  83099. declare module BABYLON {
  83100. /**
  83101. * Size options for a post process
  83102. */
  83103. export type PostProcessOptions = {
  83104. width: number;
  83105. height: number;
  83106. };
  83107. /**
  83108. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83109. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83110. */
  83111. export class PostProcess {
  83112. /** Name of the PostProcess. */
  83113. name: string;
  83114. /**
  83115. * Gets or sets the unique id of the post process
  83116. */
  83117. uniqueId: number;
  83118. /**
  83119. * Width of the texture to apply the post process on
  83120. */
  83121. width: number;
  83122. /**
  83123. * Height of the texture to apply the post process on
  83124. */
  83125. height: number;
  83126. /**
  83127. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83128. * @hidden
  83129. */
  83130. _outputTexture: Nullable<InternalTexture>;
  83131. /**
  83132. * Sampling mode used by the shader
  83133. * See https://doc.babylonjs.com/classes/3.1/texture
  83134. */
  83135. renderTargetSamplingMode: number;
  83136. /**
  83137. * Clear color to use when screen clearing
  83138. */
  83139. clearColor: Color4;
  83140. /**
  83141. * If the buffer needs to be cleared before applying the post process. (default: true)
  83142. * Should be set to false if shader will overwrite all previous pixels.
  83143. */
  83144. autoClear: boolean;
  83145. /**
  83146. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83147. */
  83148. alphaMode: number;
  83149. /**
  83150. * Sets the setAlphaBlendConstants of the babylon engine
  83151. */
  83152. alphaConstants: Color4;
  83153. /**
  83154. * Animations to be used for the post processing
  83155. */
  83156. animations: Animation[];
  83157. /**
  83158. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83159. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83160. */
  83161. enablePixelPerfectMode: boolean;
  83162. /**
  83163. * Force the postprocess to be applied without taking in account viewport
  83164. */
  83165. forceFullscreenViewport: boolean;
  83166. /**
  83167. * List of inspectable custom properties (used by the Inspector)
  83168. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83169. */
  83170. inspectableCustomProperties: IInspectable[];
  83171. /**
  83172. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83173. *
  83174. * | Value | Type | Description |
  83175. * | ----- | ----------------------------------- | ----------- |
  83176. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83177. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83178. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83179. *
  83180. */
  83181. scaleMode: number;
  83182. /**
  83183. * Force textures to be a power of two (default: false)
  83184. */
  83185. alwaysForcePOT: boolean;
  83186. private _samples;
  83187. /**
  83188. * Number of sample textures (default: 1)
  83189. */
  83190. samples: number;
  83191. /**
  83192. * Modify the scale of the post process to be the same as the viewport (default: false)
  83193. */
  83194. adaptScaleToCurrentViewport: boolean;
  83195. private _camera;
  83196. private _scene;
  83197. private _engine;
  83198. private _options;
  83199. private _reusable;
  83200. private _textureType;
  83201. /**
  83202. * Smart array of input and output textures for the post process.
  83203. * @hidden
  83204. */
  83205. _textures: SmartArray<InternalTexture>;
  83206. /**
  83207. * The index in _textures that corresponds to the output texture.
  83208. * @hidden
  83209. */
  83210. _currentRenderTextureInd: number;
  83211. private _effect;
  83212. private _samplers;
  83213. private _fragmentUrl;
  83214. private _vertexUrl;
  83215. private _parameters;
  83216. private _scaleRatio;
  83217. protected _indexParameters: any;
  83218. private _shareOutputWithPostProcess;
  83219. private _texelSize;
  83220. private _forcedOutputTexture;
  83221. /**
  83222. * Returns the fragment url or shader name used in the post process.
  83223. * @returns the fragment url or name in the shader store.
  83224. */
  83225. getEffectName(): string;
  83226. /**
  83227. * An event triggered when the postprocess is activated.
  83228. */
  83229. onActivateObservable: Observable<Camera>;
  83230. private _onActivateObserver;
  83231. /**
  83232. * A function that is added to the onActivateObservable
  83233. */
  83234. onActivate: Nullable<(camera: Camera) => void>;
  83235. /**
  83236. * An event triggered when the postprocess changes its size.
  83237. */
  83238. onSizeChangedObservable: Observable<PostProcess>;
  83239. private _onSizeChangedObserver;
  83240. /**
  83241. * A function that is added to the onSizeChangedObservable
  83242. */
  83243. onSizeChanged: (postProcess: PostProcess) => void;
  83244. /**
  83245. * An event triggered when the postprocess applies its effect.
  83246. */
  83247. onApplyObservable: Observable<Effect>;
  83248. private _onApplyObserver;
  83249. /**
  83250. * A function that is added to the onApplyObservable
  83251. */
  83252. onApply: (effect: Effect) => void;
  83253. /**
  83254. * An event triggered before rendering the postprocess
  83255. */
  83256. onBeforeRenderObservable: Observable<Effect>;
  83257. private _onBeforeRenderObserver;
  83258. /**
  83259. * A function that is added to the onBeforeRenderObservable
  83260. */
  83261. onBeforeRender: (effect: Effect) => void;
  83262. /**
  83263. * An event triggered after rendering the postprocess
  83264. */
  83265. onAfterRenderObservable: Observable<Effect>;
  83266. private _onAfterRenderObserver;
  83267. /**
  83268. * A function that is added to the onAfterRenderObservable
  83269. */
  83270. onAfterRender: (efect: Effect) => void;
  83271. /**
  83272. * 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
  83273. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83274. */
  83275. inputTexture: InternalTexture;
  83276. /**
  83277. * Gets the camera which post process is applied to.
  83278. * @returns The camera the post process is applied to.
  83279. */
  83280. getCamera(): Camera;
  83281. /**
  83282. * Gets the texel size of the postprocess.
  83283. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83284. */
  83285. readonly texelSize: Vector2;
  83286. /**
  83287. * Creates a new instance PostProcess
  83288. * @param name The name of the PostProcess.
  83289. * @param fragmentUrl The url of the fragment shader to be used.
  83290. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83291. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83292. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83293. * @param camera The camera to apply the render pass to.
  83294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83295. * @param engine The engine which the post process will be applied. (default: current engine)
  83296. * @param reusable If the post process can be reused on the same frame. (default: false)
  83297. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83298. * @param textureType Type of textures used when performing the post process. (default: 0)
  83299. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83300. * @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
  83301. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83302. */
  83303. constructor(
  83304. /** Name of the PostProcess. */
  83305. 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);
  83306. /**
  83307. * Gets a string idenfifying the name of the class
  83308. * @returns "PostProcess" string
  83309. */
  83310. getClassName(): string;
  83311. /**
  83312. * Gets the engine which this post process belongs to.
  83313. * @returns The engine the post process was enabled with.
  83314. */
  83315. getEngine(): Engine;
  83316. /**
  83317. * The effect that is created when initializing the post process.
  83318. * @returns The created effect corresponding the the postprocess.
  83319. */
  83320. getEffect(): Effect;
  83321. /**
  83322. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83323. * @param postProcess The post process to share the output with.
  83324. * @returns This post process.
  83325. */
  83326. shareOutputWith(postProcess: PostProcess): PostProcess;
  83327. /**
  83328. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83329. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83330. */
  83331. useOwnOutput(): void;
  83332. /**
  83333. * Updates the effect with the current post process compile time values and recompiles the shader.
  83334. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83335. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83336. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83337. * @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
  83338. * @param onCompiled Called when the shader has been compiled.
  83339. * @param onError Called if there is an error when compiling a shader.
  83340. */
  83341. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83342. /**
  83343. * The post process is reusable if it can be used multiple times within one frame.
  83344. * @returns If the post process is reusable
  83345. */
  83346. isReusable(): boolean;
  83347. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83348. markTextureDirty(): void;
  83349. /**
  83350. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83351. * 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.
  83352. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83353. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83354. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83355. * @returns The target texture that was bound to be written to.
  83356. */
  83357. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83358. /**
  83359. * If the post process is supported.
  83360. */
  83361. readonly isSupported: boolean;
  83362. /**
  83363. * The aspect ratio of the output texture.
  83364. */
  83365. readonly aspectRatio: number;
  83366. /**
  83367. * Get a value indicating if the post-process is ready to be used
  83368. * @returns true if the post-process is ready (shader is compiled)
  83369. */
  83370. isReady(): boolean;
  83371. /**
  83372. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83373. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83374. */
  83375. apply(): Nullable<Effect>;
  83376. private _disposeTextures;
  83377. /**
  83378. * Disposes the post process.
  83379. * @param camera The camera to dispose the post process on.
  83380. */
  83381. dispose(camera?: Camera): void;
  83382. }
  83383. }
  83384. declare module BABYLON {
  83385. /** @hidden */
  83386. export var kernelBlurVaryingDeclaration: {
  83387. name: string;
  83388. shader: string;
  83389. };
  83390. }
  83391. declare module BABYLON {
  83392. /** @hidden */
  83393. export var kernelBlurFragment: {
  83394. name: string;
  83395. shader: string;
  83396. };
  83397. }
  83398. declare module BABYLON {
  83399. /** @hidden */
  83400. export var kernelBlurFragment2: {
  83401. name: string;
  83402. shader: string;
  83403. };
  83404. }
  83405. declare module BABYLON {
  83406. /** @hidden */
  83407. export var kernelBlurPixelShader: {
  83408. name: string;
  83409. shader: string;
  83410. };
  83411. }
  83412. declare module BABYLON {
  83413. /** @hidden */
  83414. export var kernelBlurVertex: {
  83415. name: string;
  83416. shader: string;
  83417. };
  83418. }
  83419. declare module BABYLON {
  83420. /** @hidden */
  83421. export var kernelBlurVertexShader: {
  83422. name: string;
  83423. shader: string;
  83424. };
  83425. }
  83426. declare module BABYLON {
  83427. /**
  83428. * The Blur Post Process which blurs an image based on a kernel and direction.
  83429. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83430. */
  83431. export class BlurPostProcess extends PostProcess {
  83432. /** The direction in which to blur the image. */
  83433. direction: Vector2;
  83434. private blockCompilation;
  83435. protected _kernel: number;
  83436. protected _idealKernel: number;
  83437. protected _packedFloat: boolean;
  83438. private _staticDefines;
  83439. /**
  83440. * Sets the length in pixels of the blur sample region
  83441. */
  83442. /**
  83443. * Gets the length in pixels of the blur sample region
  83444. */
  83445. kernel: number;
  83446. /**
  83447. * Sets wether or not the blur needs to unpack/repack floats
  83448. */
  83449. /**
  83450. * Gets wether or not the blur is unpacking/repacking floats
  83451. */
  83452. packedFloat: boolean;
  83453. /**
  83454. * Creates a new instance BlurPostProcess
  83455. * @param name The name of the effect.
  83456. * @param direction The direction in which to blur the image.
  83457. * @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.
  83458. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83459. * @param camera The camera to apply the render pass to.
  83460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83461. * @param engine The engine which the post process will be applied. (default: current engine)
  83462. * @param reusable If the post process can be reused on the same frame. (default: false)
  83463. * @param textureType Type of textures used when performing the post process. (default: 0)
  83464. * @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)
  83465. */
  83466. constructor(name: string,
  83467. /** The direction in which to blur the image. */
  83468. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83469. /**
  83470. * Updates the effect with the current post process compile time values and recompiles the shader.
  83471. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83472. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83473. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83474. * @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
  83475. * @param onCompiled Called when the shader has been compiled.
  83476. * @param onError Called if there is an error when compiling a shader.
  83477. */
  83478. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83479. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83480. /**
  83481. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83482. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83483. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83484. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83485. * The gaps between physical kernels are compensated for in the weighting of the samples
  83486. * @param idealKernel Ideal blur kernel.
  83487. * @return Nearest best kernel.
  83488. */
  83489. protected _nearestBestKernel(idealKernel: number): number;
  83490. /**
  83491. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83492. * @param x The point on the Gaussian distribution to sample.
  83493. * @return the value of the Gaussian function at x.
  83494. */
  83495. protected _gaussianWeight(x: number): number;
  83496. /**
  83497. * Generates a string that can be used as a floating point number in GLSL.
  83498. * @param x Value to print.
  83499. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83500. * @return GLSL float string.
  83501. */
  83502. protected _glslFloat(x: number, decimalFigures?: number): string;
  83503. }
  83504. }
  83505. declare module BABYLON {
  83506. /**
  83507. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83508. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83509. * You can then easily use it as a reflectionTexture on a flat surface.
  83510. * In case the surface is not a plane, please consider relying on reflection probes.
  83511. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83512. */
  83513. export class MirrorTexture extends RenderTargetTexture {
  83514. private scene;
  83515. /**
  83516. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83517. * 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.
  83518. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83519. */
  83520. mirrorPlane: Plane;
  83521. /**
  83522. * Define the blur ratio used to blur the reflection if needed.
  83523. */
  83524. blurRatio: number;
  83525. /**
  83526. * Define the adaptive blur kernel used to blur the reflection if needed.
  83527. * This will autocompute the closest best match for the `blurKernel`
  83528. */
  83529. adaptiveBlurKernel: number;
  83530. /**
  83531. * Define the blur kernel used to blur the reflection if needed.
  83532. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83533. */
  83534. blurKernel: number;
  83535. /**
  83536. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83537. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83538. */
  83539. blurKernelX: number;
  83540. /**
  83541. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83542. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83543. */
  83544. blurKernelY: number;
  83545. private _autoComputeBlurKernel;
  83546. protected _onRatioRescale(): void;
  83547. private _updateGammaSpace;
  83548. private _imageProcessingConfigChangeObserver;
  83549. private _transformMatrix;
  83550. private _mirrorMatrix;
  83551. private _savedViewMatrix;
  83552. private _blurX;
  83553. private _blurY;
  83554. private _adaptiveBlurKernel;
  83555. private _blurKernelX;
  83556. private _blurKernelY;
  83557. private _blurRatio;
  83558. /**
  83559. * Instantiates a Mirror Texture.
  83560. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83561. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83562. * You can then easily use it as a reflectionTexture on a flat surface.
  83563. * In case the surface is not a plane, please consider relying on reflection probes.
  83564. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83565. * @param name
  83566. * @param size
  83567. * @param scene
  83568. * @param generateMipMaps
  83569. * @param type
  83570. * @param samplingMode
  83571. * @param generateDepthBuffer
  83572. */
  83573. constructor(name: string, size: number | {
  83574. width: number;
  83575. height: number;
  83576. } | {
  83577. ratio: number;
  83578. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83579. private _preparePostProcesses;
  83580. /**
  83581. * Clone the mirror texture.
  83582. * @returns the cloned texture
  83583. */
  83584. clone(): MirrorTexture;
  83585. /**
  83586. * Serialize the texture to a JSON representation you could use in Parse later on
  83587. * @returns the serialized JSON representation
  83588. */
  83589. serialize(): any;
  83590. /**
  83591. * Dispose the texture and release its associated resources.
  83592. */
  83593. dispose(): void;
  83594. }
  83595. }
  83596. declare module BABYLON {
  83597. /**
  83598. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83599. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83600. */
  83601. export class Texture extends BaseTexture {
  83602. /**
  83603. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83604. */
  83605. static SerializeBuffers: boolean;
  83606. /** @hidden */
  83607. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83608. /** @hidden */
  83609. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83610. /** @hidden */
  83611. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83612. /** nearest is mag = nearest and min = nearest and mip = linear */
  83613. static readonly NEAREST_SAMPLINGMODE: number;
  83614. /** nearest is mag = nearest and min = nearest and mip = linear */
  83615. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83616. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83617. static readonly BILINEAR_SAMPLINGMODE: number;
  83618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83619. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83620. /** Trilinear is mag = linear and min = linear and mip = linear */
  83621. static readonly TRILINEAR_SAMPLINGMODE: number;
  83622. /** Trilinear is mag = linear and min = linear and mip = linear */
  83623. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83624. /** mag = nearest and min = nearest and mip = nearest */
  83625. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83626. /** mag = nearest and min = linear and mip = nearest */
  83627. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83628. /** mag = nearest and min = linear and mip = linear */
  83629. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83630. /** mag = nearest and min = linear and mip = none */
  83631. static readonly NEAREST_LINEAR: number;
  83632. /** mag = nearest and min = nearest and mip = none */
  83633. static readonly NEAREST_NEAREST: number;
  83634. /** mag = linear and min = nearest and mip = nearest */
  83635. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83636. /** mag = linear and min = nearest and mip = linear */
  83637. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83638. /** mag = linear and min = linear and mip = none */
  83639. static readonly LINEAR_LINEAR: number;
  83640. /** mag = linear and min = nearest and mip = none */
  83641. static readonly LINEAR_NEAREST: number;
  83642. /** Explicit coordinates mode */
  83643. static readonly EXPLICIT_MODE: number;
  83644. /** Spherical coordinates mode */
  83645. static readonly SPHERICAL_MODE: number;
  83646. /** Planar coordinates mode */
  83647. static readonly PLANAR_MODE: number;
  83648. /** Cubic coordinates mode */
  83649. static readonly CUBIC_MODE: number;
  83650. /** Projection coordinates mode */
  83651. static readonly PROJECTION_MODE: number;
  83652. /** Inverse Cubic coordinates mode */
  83653. static readonly SKYBOX_MODE: number;
  83654. /** Inverse Cubic coordinates mode */
  83655. static readonly INVCUBIC_MODE: number;
  83656. /** Equirectangular coordinates mode */
  83657. static readonly EQUIRECTANGULAR_MODE: number;
  83658. /** Equirectangular Fixed coordinates mode */
  83659. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83660. /** Equirectangular Fixed Mirrored coordinates mode */
  83661. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83662. /** Texture is not repeating outside of 0..1 UVs */
  83663. static readonly CLAMP_ADDRESSMODE: number;
  83664. /** Texture is repeating outside of 0..1 UVs */
  83665. static readonly WRAP_ADDRESSMODE: number;
  83666. /** Texture is repeating and mirrored */
  83667. static readonly MIRROR_ADDRESSMODE: number;
  83668. /**
  83669. * 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
  83670. */
  83671. static UseSerializedUrlIfAny: boolean;
  83672. /**
  83673. * Define the url of the texture.
  83674. */
  83675. url: Nullable<string>;
  83676. /**
  83677. * Define an offset on the texture to offset the u coordinates of the UVs
  83678. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83679. */
  83680. uOffset: number;
  83681. /**
  83682. * Define an offset on the texture to offset the v coordinates of the UVs
  83683. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83684. */
  83685. vOffset: number;
  83686. /**
  83687. * Define an offset on the texture to scale the u coordinates of the UVs
  83688. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83689. */
  83690. uScale: number;
  83691. /**
  83692. * Define an offset on the texture to scale the v coordinates of the UVs
  83693. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83694. */
  83695. vScale: number;
  83696. /**
  83697. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83698. * @see http://doc.babylonjs.com/how_to/more_materials
  83699. */
  83700. uAng: number;
  83701. /**
  83702. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83703. * @see http://doc.babylonjs.com/how_to/more_materials
  83704. */
  83705. vAng: number;
  83706. /**
  83707. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83708. * @see http://doc.babylonjs.com/how_to/more_materials
  83709. */
  83710. wAng: number;
  83711. /**
  83712. * Defines the center of rotation (U)
  83713. */
  83714. uRotationCenter: number;
  83715. /**
  83716. * Defines the center of rotation (V)
  83717. */
  83718. vRotationCenter: number;
  83719. /**
  83720. * Defines the center of rotation (W)
  83721. */
  83722. wRotationCenter: number;
  83723. /**
  83724. * Are mip maps generated for this texture or not.
  83725. */
  83726. readonly noMipmap: boolean;
  83727. /**
  83728. * List of inspectable custom properties (used by the Inspector)
  83729. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83730. */
  83731. inspectableCustomProperties: Nullable<IInspectable[]>;
  83732. private _noMipmap;
  83733. /** @hidden */
  83734. _invertY: boolean;
  83735. private _rowGenerationMatrix;
  83736. private _cachedTextureMatrix;
  83737. private _projectionModeMatrix;
  83738. private _t0;
  83739. private _t1;
  83740. private _t2;
  83741. private _cachedUOffset;
  83742. private _cachedVOffset;
  83743. private _cachedUScale;
  83744. private _cachedVScale;
  83745. private _cachedUAng;
  83746. private _cachedVAng;
  83747. private _cachedWAng;
  83748. private _cachedProjectionMatrixId;
  83749. private _cachedCoordinatesMode;
  83750. /** @hidden */
  83751. protected _initialSamplingMode: number;
  83752. /** @hidden */
  83753. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83754. private _deleteBuffer;
  83755. protected _format: Nullable<number>;
  83756. private _delayedOnLoad;
  83757. private _delayedOnError;
  83758. private _mimeType?;
  83759. /**
  83760. * Observable triggered once the texture has been loaded.
  83761. */
  83762. onLoadObservable: Observable<Texture>;
  83763. protected _isBlocking: boolean;
  83764. /**
  83765. * Is the texture preventing material to render while loading.
  83766. * If false, a default texture will be used instead of the loading one during the preparation step.
  83767. */
  83768. isBlocking: boolean;
  83769. /**
  83770. * Get the current sampling mode associated with the texture.
  83771. */
  83772. readonly samplingMode: number;
  83773. /**
  83774. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83775. */
  83776. readonly invertY: boolean;
  83777. /**
  83778. * Instantiates a new texture.
  83779. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83780. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83781. * @param url defines the url of the picture to load as a texture
  83782. * @param scene defines the scene or engine the texture will belong to
  83783. * @param noMipmap defines if the texture will require mip maps or not
  83784. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83785. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83786. * @param onLoad defines a callback triggered when the texture has been loaded
  83787. * @param onError defines a callback triggered when an error occurred during the loading session
  83788. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83789. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83790. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83791. * @param mimeType defines an optional mime type information
  83792. */
  83793. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  83794. /**
  83795. * Update the url (and optional buffer) of this texture if url was null during construction.
  83796. * @param url the url of the texture
  83797. * @param buffer the buffer of the texture (defaults to null)
  83798. * @param onLoad callback called when the texture is loaded (defaults to null)
  83799. */
  83800. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83801. /**
  83802. * Finish the loading sequence of a texture flagged as delayed load.
  83803. * @hidden
  83804. */
  83805. delayLoad(): void;
  83806. private _prepareRowForTextureGeneration;
  83807. /**
  83808. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83809. * @returns the transform matrix of the texture.
  83810. */
  83811. getTextureMatrix(): Matrix;
  83812. /**
  83813. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83814. * @returns The reflection texture transform
  83815. */
  83816. getReflectionTextureMatrix(): Matrix;
  83817. /**
  83818. * Clones the texture.
  83819. * @returns the cloned texture
  83820. */
  83821. clone(): Texture;
  83822. /**
  83823. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83824. * @returns The JSON representation of the texture
  83825. */
  83826. serialize(): any;
  83827. /**
  83828. * Get the current class name of the texture useful for serialization or dynamic coding.
  83829. * @returns "Texture"
  83830. */
  83831. getClassName(): string;
  83832. /**
  83833. * Dispose the texture and release its associated resources.
  83834. */
  83835. dispose(): void;
  83836. /**
  83837. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83838. * @param parsedTexture Define the JSON representation of the texture
  83839. * @param scene Define the scene the parsed texture should be instantiated in
  83840. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83841. * @returns The parsed texture if successful
  83842. */
  83843. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83844. /**
  83845. * Creates a texture from its base 64 representation.
  83846. * @param data Define the base64 payload without the data: prefix
  83847. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83848. * @param scene Define the scene the texture should belong to
  83849. * @param noMipmap Forces the texture to not create mip map information if true
  83850. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83851. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83852. * @param onLoad define a callback triggered when the texture has been loaded
  83853. * @param onError define a callback triggered when an error occurred during the loading session
  83854. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83855. * @returns the created texture
  83856. */
  83857. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83858. /**
  83859. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83860. * @param data Define the base64 payload without the data: prefix
  83861. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83862. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83863. * @param scene Define the scene the texture should belong to
  83864. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83865. * @param noMipmap Forces the texture to not create mip map information if true
  83866. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83867. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83868. * @param onLoad define a callback triggered when the texture has been loaded
  83869. * @param onError define a callback triggered when an error occurred during the loading session
  83870. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83871. * @returns the created texture
  83872. */
  83873. 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;
  83874. }
  83875. }
  83876. declare module BABYLON {
  83877. /**
  83878. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83879. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83880. */
  83881. export class PostProcessManager {
  83882. private _scene;
  83883. private _indexBuffer;
  83884. private _vertexBuffers;
  83885. /**
  83886. * Creates a new instance PostProcess
  83887. * @param scene The scene that the post process is associated with.
  83888. */
  83889. constructor(scene: Scene);
  83890. private _prepareBuffers;
  83891. private _buildIndexBuffer;
  83892. /**
  83893. * Rebuilds the vertex buffers of the manager.
  83894. * @hidden
  83895. */
  83896. _rebuild(): void;
  83897. /**
  83898. * Prepares a frame to be run through a post process.
  83899. * @param sourceTexture The input texture to the post procesess. (default: null)
  83900. * @param postProcesses An array of post processes to be run. (default: null)
  83901. * @returns True if the post processes were able to be run.
  83902. * @hidden
  83903. */
  83904. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83905. /**
  83906. * Manually render a set of post processes to a texture.
  83907. * @param postProcesses An array of post processes to be run.
  83908. * @param targetTexture The target texture to render to.
  83909. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83910. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83911. * @param lodLevel defines which lod of the texture to render to
  83912. */
  83913. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83914. /**
  83915. * Finalize the result of the output of the postprocesses.
  83916. * @param doNotPresent If true the result will not be displayed to the screen.
  83917. * @param targetTexture The target texture to render to.
  83918. * @param faceIndex The index of the face to bind the target texture to.
  83919. * @param postProcesses The array of post processes to render.
  83920. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83921. * @hidden
  83922. */
  83923. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83924. /**
  83925. * Disposes of the post process manager.
  83926. */
  83927. dispose(): void;
  83928. }
  83929. }
  83930. declare module BABYLON {
  83931. /** Interface used by value gradients (color, factor, ...) */
  83932. export interface IValueGradient {
  83933. /**
  83934. * Gets or sets the gradient value (between 0 and 1)
  83935. */
  83936. gradient: number;
  83937. }
  83938. /** Class used to store color4 gradient */
  83939. export class ColorGradient implements IValueGradient {
  83940. /**
  83941. * Gets or sets the gradient value (between 0 and 1)
  83942. */
  83943. gradient: number;
  83944. /**
  83945. * Gets or sets first associated color
  83946. */
  83947. color1: Color4;
  83948. /**
  83949. * Gets or sets second associated color
  83950. */
  83951. color2?: Color4;
  83952. /**
  83953. * Will get a color picked randomly between color1 and color2.
  83954. * If color2 is undefined then color1 will be used
  83955. * @param result defines the target Color4 to store the result in
  83956. */
  83957. getColorToRef(result: Color4): void;
  83958. }
  83959. /** Class used to store color 3 gradient */
  83960. export class Color3Gradient implements IValueGradient {
  83961. /**
  83962. * Gets or sets the gradient value (between 0 and 1)
  83963. */
  83964. gradient: number;
  83965. /**
  83966. * Gets or sets the associated color
  83967. */
  83968. color: Color3;
  83969. }
  83970. /** Class used to store factor gradient */
  83971. export class FactorGradient implements IValueGradient {
  83972. /**
  83973. * Gets or sets the gradient value (between 0 and 1)
  83974. */
  83975. gradient: number;
  83976. /**
  83977. * Gets or sets first associated factor
  83978. */
  83979. factor1: number;
  83980. /**
  83981. * Gets or sets second associated factor
  83982. */
  83983. factor2?: number;
  83984. /**
  83985. * Will get a number picked randomly between factor1 and factor2.
  83986. * If factor2 is undefined then factor1 will be used
  83987. * @returns the picked number
  83988. */
  83989. getFactor(): number;
  83990. }
  83991. /**
  83992. * Helper used to simplify some generic gradient tasks
  83993. */
  83994. export class GradientHelper {
  83995. /**
  83996. * Gets the current gradient from an array of IValueGradient
  83997. * @param ratio defines the current ratio to get
  83998. * @param gradients defines the array of IValueGradient
  83999. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84000. */
  84001. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84002. }
  84003. }
  84004. declare module BABYLON {
  84005. interface ThinEngine {
  84006. /**
  84007. * Creates a dynamic texture
  84008. * @param width defines the width of the texture
  84009. * @param height defines the height of the texture
  84010. * @param generateMipMaps defines if the engine should generate the mip levels
  84011. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84012. * @returns the dynamic texture inside an InternalTexture
  84013. */
  84014. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84015. /**
  84016. * Update the content of a dynamic texture
  84017. * @param texture defines the texture to update
  84018. * @param canvas defines the canvas containing the source
  84019. * @param invertY defines if data must be stored with Y axis inverted
  84020. * @param premulAlpha defines if alpha is stored as premultiplied
  84021. * @param format defines the format of the data
  84022. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84023. */
  84024. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84025. }
  84026. }
  84027. declare module BABYLON {
  84028. /**
  84029. * Helper class used to generate a canvas to manipulate images
  84030. */
  84031. export class CanvasGenerator {
  84032. /**
  84033. * Create a new canvas (or offscreen canvas depending on the context)
  84034. * @param width defines the expected width
  84035. * @param height defines the expected height
  84036. * @return a new canvas or offscreen canvas
  84037. */
  84038. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84039. }
  84040. }
  84041. declare module BABYLON {
  84042. /**
  84043. * A class extending Texture allowing drawing on a texture
  84044. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84045. */
  84046. export class DynamicTexture extends Texture {
  84047. private _generateMipMaps;
  84048. private _canvas;
  84049. private _context;
  84050. private _engine;
  84051. /**
  84052. * Creates a DynamicTexture
  84053. * @param name defines the name of the texture
  84054. * @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
  84055. * @param scene defines the scene where you want the texture
  84056. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84057. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84058. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84059. */
  84060. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84061. /**
  84062. * Get the current class name of the texture useful for serialization or dynamic coding.
  84063. * @returns "DynamicTexture"
  84064. */
  84065. getClassName(): string;
  84066. /**
  84067. * Gets the current state of canRescale
  84068. */
  84069. readonly canRescale: boolean;
  84070. private _recreate;
  84071. /**
  84072. * Scales the texture
  84073. * @param ratio the scale factor to apply to both width and height
  84074. */
  84075. scale(ratio: number): void;
  84076. /**
  84077. * Resizes the texture
  84078. * @param width the new width
  84079. * @param height the new height
  84080. */
  84081. scaleTo(width: number, height: number): void;
  84082. /**
  84083. * Gets the context of the canvas used by the texture
  84084. * @returns the canvas context of the dynamic texture
  84085. */
  84086. getContext(): CanvasRenderingContext2D;
  84087. /**
  84088. * Clears the texture
  84089. */
  84090. clear(): void;
  84091. /**
  84092. * Updates the texture
  84093. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84094. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84095. */
  84096. update(invertY?: boolean, premulAlpha?: boolean): void;
  84097. /**
  84098. * Draws text onto the texture
  84099. * @param text defines the text to be drawn
  84100. * @param x defines the placement of the text from the left
  84101. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84102. * @param font defines the font to be used with font-style, font-size, font-name
  84103. * @param color defines the color used for the text
  84104. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84105. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84106. * @param update defines whether texture is immediately update (default is true)
  84107. */
  84108. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84109. /**
  84110. * Clones the texture
  84111. * @returns the clone of the texture.
  84112. */
  84113. clone(): DynamicTexture;
  84114. /**
  84115. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84116. * @returns a serialized dynamic texture object
  84117. */
  84118. serialize(): any;
  84119. /** @hidden */
  84120. _rebuild(): void;
  84121. }
  84122. }
  84123. declare module BABYLON {
  84124. interface AbstractScene {
  84125. /**
  84126. * The list of procedural textures added to the scene
  84127. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84128. */
  84129. proceduralTextures: Array<ProceduralTexture>;
  84130. }
  84131. /**
  84132. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84133. * in a given scene.
  84134. */
  84135. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84136. /**
  84137. * The component name helpfull to identify the component in the list of scene components.
  84138. */
  84139. readonly name: string;
  84140. /**
  84141. * The scene the component belongs to.
  84142. */
  84143. scene: Scene;
  84144. /**
  84145. * Creates a new instance of the component for the given scene
  84146. * @param scene Defines the scene to register the component in
  84147. */
  84148. constructor(scene: Scene);
  84149. /**
  84150. * Registers the component in a given scene
  84151. */
  84152. register(): void;
  84153. /**
  84154. * Rebuilds the elements related to this component in case of
  84155. * context lost for instance.
  84156. */
  84157. rebuild(): void;
  84158. /**
  84159. * Disposes the component and the associated ressources.
  84160. */
  84161. dispose(): void;
  84162. private _beforeClear;
  84163. }
  84164. }
  84165. declare module BABYLON {
  84166. interface ThinEngine {
  84167. /**
  84168. * Creates a new render target cube texture
  84169. * @param size defines the size of the texture
  84170. * @param options defines the options used to create the texture
  84171. * @returns a new render target cube texture stored in an InternalTexture
  84172. */
  84173. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84174. }
  84175. }
  84176. declare module BABYLON {
  84177. /** @hidden */
  84178. export var proceduralVertexShader: {
  84179. name: string;
  84180. shader: string;
  84181. };
  84182. }
  84183. declare module BABYLON {
  84184. /**
  84185. * 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.
  84186. * This is the base class of any Procedural texture and contains most of the shareable code.
  84187. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84188. */
  84189. export class ProceduralTexture extends Texture {
  84190. isCube: boolean;
  84191. /**
  84192. * Define if the texture is enabled or not (disabled texture will not render)
  84193. */
  84194. isEnabled: boolean;
  84195. /**
  84196. * Define if the texture must be cleared before rendering (default is true)
  84197. */
  84198. autoClear: boolean;
  84199. /**
  84200. * Callback called when the texture is generated
  84201. */
  84202. onGenerated: () => void;
  84203. /**
  84204. * Event raised when the texture is generated
  84205. */
  84206. onGeneratedObservable: Observable<ProceduralTexture>;
  84207. /** @hidden */
  84208. _generateMipMaps: boolean;
  84209. /** @hidden **/
  84210. _effect: Effect;
  84211. /** @hidden */
  84212. _textures: {
  84213. [key: string]: Texture;
  84214. };
  84215. private _size;
  84216. private _currentRefreshId;
  84217. private _refreshRate;
  84218. private _vertexBuffers;
  84219. private _indexBuffer;
  84220. private _uniforms;
  84221. private _samplers;
  84222. private _fragment;
  84223. private _floats;
  84224. private _ints;
  84225. private _floatsArrays;
  84226. private _colors3;
  84227. private _colors4;
  84228. private _vectors2;
  84229. private _vectors3;
  84230. private _matrices;
  84231. private _fallbackTexture;
  84232. private _fallbackTextureUsed;
  84233. private _engine;
  84234. private _cachedDefines;
  84235. private _contentUpdateId;
  84236. private _contentData;
  84237. /**
  84238. * Instantiates a new procedural texture.
  84239. * 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.
  84240. * This is the base class of any Procedural texture and contains most of the shareable code.
  84241. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84242. * @param name Define the name of the texture
  84243. * @param size Define the size of the texture to create
  84244. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84245. * @param scene Define the scene the texture belongs to
  84246. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84247. * @param generateMipMaps Define if the texture should creates mip maps or not
  84248. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84249. */
  84250. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84251. /**
  84252. * The effect that is created when initializing the post process.
  84253. * @returns The created effect corresponding the the postprocess.
  84254. */
  84255. getEffect(): Effect;
  84256. /**
  84257. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84258. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84259. */
  84260. getContent(): Nullable<ArrayBufferView>;
  84261. private _createIndexBuffer;
  84262. /** @hidden */
  84263. _rebuild(): void;
  84264. /**
  84265. * Resets the texture in order to recreate its associated resources.
  84266. * This can be called in case of context loss
  84267. */
  84268. reset(): void;
  84269. protected _getDefines(): string;
  84270. /**
  84271. * Is the texture ready to be used ? (rendered at least once)
  84272. * @returns true if ready, otherwise, false.
  84273. */
  84274. isReady(): boolean;
  84275. /**
  84276. * Resets the refresh counter of the texture and start bak from scratch.
  84277. * Could be useful to regenerate the texture if it is setup to render only once.
  84278. */
  84279. resetRefreshCounter(): void;
  84280. /**
  84281. * Set the fragment shader to use in order to render the texture.
  84282. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84283. */
  84284. setFragment(fragment: any): void;
  84285. /**
  84286. * Define the refresh rate of the texture or the rendering frequency.
  84287. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84288. */
  84289. refreshRate: number;
  84290. /** @hidden */
  84291. _shouldRender(): boolean;
  84292. /**
  84293. * Get the size the texture is rendering at.
  84294. * @returns the size (texture is always squared)
  84295. */
  84296. getRenderSize(): number;
  84297. /**
  84298. * Resize the texture to new value.
  84299. * @param size Define the new size the texture should have
  84300. * @param generateMipMaps Define whether the new texture should create mip maps
  84301. */
  84302. resize(size: number, generateMipMaps: boolean): void;
  84303. private _checkUniform;
  84304. /**
  84305. * Set a texture in the shader program used to render.
  84306. * @param name Define the name of the uniform samplers as defined in the shader
  84307. * @param texture Define the texture to bind to this sampler
  84308. * @return the texture itself allowing "fluent" like uniform updates
  84309. */
  84310. setTexture(name: string, texture: Texture): ProceduralTexture;
  84311. /**
  84312. * Set a float in the shader.
  84313. * @param name Define the name of the uniform as defined in the shader
  84314. * @param value Define the value to give to the uniform
  84315. * @return the texture itself allowing "fluent" like uniform updates
  84316. */
  84317. setFloat(name: string, value: number): ProceduralTexture;
  84318. /**
  84319. * Set a int in the shader.
  84320. * @param name Define the name of the uniform as defined in the shader
  84321. * @param value Define the value to give to the uniform
  84322. * @return the texture itself allowing "fluent" like uniform updates
  84323. */
  84324. setInt(name: string, value: number): ProceduralTexture;
  84325. /**
  84326. * Set an array of floats in the shader.
  84327. * @param name Define the name of the uniform as defined in the shader
  84328. * @param value Define the value to give to the uniform
  84329. * @return the texture itself allowing "fluent" like uniform updates
  84330. */
  84331. setFloats(name: string, value: number[]): ProceduralTexture;
  84332. /**
  84333. * Set a vec3 in the shader from a Color3.
  84334. * @param name Define the name of the uniform as defined in the shader
  84335. * @param value Define the value to give to the uniform
  84336. * @return the texture itself allowing "fluent" like uniform updates
  84337. */
  84338. setColor3(name: string, value: Color3): ProceduralTexture;
  84339. /**
  84340. * Set a vec4 in the shader from a Color4.
  84341. * @param name Define the name of the uniform as defined in the shader
  84342. * @param value Define the value to give to the uniform
  84343. * @return the texture itself allowing "fluent" like uniform updates
  84344. */
  84345. setColor4(name: string, value: Color4): ProceduralTexture;
  84346. /**
  84347. * Set a vec2 in the shader from a Vector2.
  84348. * @param name Define the name of the uniform as defined in the shader
  84349. * @param value Define the value to give to the uniform
  84350. * @return the texture itself allowing "fluent" like uniform updates
  84351. */
  84352. setVector2(name: string, value: Vector2): ProceduralTexture;
  84353. /**
  84354. * Set a vec3 in the shader from a Vector3.
  84355. * @param name Define the name of the uniform as defined in the shader
  84356. * @param value Define the value to give to the uniform
  84357. * @return the texture itself allowing "fluent" like uniform updates
  84358. */
  84359. setVector3(name: string, value: Vector3): ProceduralTexture;
  84360. /**
  84361. * Set a mat4 in the shader from a MAtrix.
  84362. * @param name Define the name of the uniform as defined in the shader
  84363. * @param value Define the value to give to the uniform
  84364. * @return the texture itself allowing "fluent" like uniform updates
  84365. */
  84366. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84367. /**
  84368. * Render the texture to its associated render target.
  84369. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84370. */
  84371. render(useCameraPostProcess?: boolean): void;
  84372. /**
  84373. * Clone the texture.
  84374. * @returns the cloned texture
  84375. */
  84376. clone(): ProceduralTexture;
  84377. /**
  84378. * Dispose the texture and release its asoociated resources.
  84379. */
  84380. dispose(): void;
  84381. }
  84382. }
  84383. declare module BABYLON {
  84384. /**
  84385. * This represents the base class for particle system in Babylon.
  84386. * 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.
  84387. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84388. * @example https://doc.babylonjs.com/babylon101/particles
  84389. */
  84390. export class BaseParticleSystem {
  84391. /**
  84392. * Source color is added to the destination color without alpha affecting the result
  84393. */
  84394. static BLENDMODE_ONEONE: number;
  84395. /**
  84396. * Blend current color and particle color using particle’s alpha
  84397. */
  84398. static BLENDMODE_STANDARD: number;
  84399. /**
  84400. * Add current color and particle color multiplied by particle’s alpha
  84401. */
  84402. static BLENDMODE_ADD: number;
  84403. /**
  84404. * Multiply current color with particle color
  84405. */
  84406. static BLENDMODE_MULTIPLY: number;
  84407. /**
  84408. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84409. */
  84410. static BLENDMODE_MULTIPLYADD: number;
  84411. /**
  84412. * List of animations used by the particle system.
  84413. */
  84414. animations: Animation[];
  84415. /**
  84416. * The id of the Particle system.
  84417. */
  84418. id: string;
  84419. /**
  84420. * The friendly name of the Particle system.
  84421. */
  84422. name: string;
  84423. /**
  84424. * The rendering group used by the Particle system to chose when to render.
  84425. */
  84426. renderingGroupId: number;
  84427. /**
  84428. * The emitter represents the Mesh or position we are attaching the particle system to.
  84429. */
  84430. emitter: Nullable<AbstractMesh | Vector3>;
  84431. /**
  84432. * The maximum number of particles to emit per frame
  84433. */
  84434. emitRate: number;
  84435. /**
  84436. * If you want to launch only a few particles at once, that can be done, as well.
  84437. */
  84438. manualEmitCount: number;
  84439. /**
  84440. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84441. */
  84442. updateSpeed: number;
  84443. /**
  84444. * The amount of time the particle system is running (depends of the overall update speed).
  84445. */
  84446. targetStopDuration: number;
  84447. /**
  84448. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84449. */
  84450. disposeOnStop: boolean;
  84451. /**
  84452. * Minimum power of emitting particles.
  84453. */
  84454. minEmitPower: number;
  84455. /**
  84456. * Maximum power of emitting particles.
  84457. */
  84458. maxEmitPower: number;
  84459. /**
  84460. * Minimum life time of emitting particles.
  84461. */
  84462. minLifeTime: number;
  84463. /**
  84464. * Maximum life time of emitting particles.
  84465. */
  84466. maxLifeTime: number;
  84467. /**
  84468. * Minimum Size of emitting particles.
  84469. */
  84470. minSize: number;
  84471. /**
  84472. * Maximum Size of emitting particles.
  84473. */
  84474. maxSize: number;
  84475. /**
  84476. * Minimum scale of emitting particles on X axis.
  84477. */
  84478. minScaleX: number;
  84479. /**
  84480. * Maximum scale of emitting particles on X axis.
  84481. */
  84482. maxScaleX: number;
  84483. /**
  84484. * Minimum scale of emitting particles on Y axis.
  84485. */
  84486. minScaleY: number;
  84487. /**
  84488. * Maximum scale of emitting particles on Y axis.
  84489. */
  84490. maxScaleY: number;
  84491. /**
  84492. * Gets or sets the minimal initial rotation in radians.
  84493. */
  84494. minInitialRotation: number;
  84495. /**
  84496. * Gets or sets the maximal initial rotation in radians.
  84497. */
  84498. maxInitialRotation: number;
  84499. /**
  84500. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84501. */
  84502. minAngularSpeed: number;
  84503. /**
  84504. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84505. */
  84506. maxAngularSpeed: number;
  84507. /**
  84508. * The texture used to render each particle. (this can be a spritesheet)
  84509. */
  84510. particleTexture: Nullable<Texture>;
  84511. /**
  84512. * The layer mask we are rendering the particles through.
  84513. */
  84514. layerMask: number;
  84515. /**
  84516. * This can help using your own shader to render the particle system.
  84517. * The according effect will be created
  84518. */
  84519. customShader: any;
  84520. /**
  84521. * By default particle system starts as soon as they are created. This prevents the
  84522. * automatic start to happen and let you decide when to start emitting particles.
  84523. */
  84524. preventAutoStart: boolean;
  84525. private _noiseTexture;
  84526. /**
  84527. * Gets or sets a texture used to add random noise to particle positions
  84528. */
  84529. noiseTexture: Nullable<ProceduralTexture>;
  84530. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84531. noiseStrength: Vector3;
  84532. /**
  84533. * Callback triggered when the particle animation is ending.
  84534. */
  84535. onAnimationEnd: Nullable<() => void>;
  84536. /**
  84537. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84538. */
  84539. blendMode: number;
  84540. /**
  84541. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84542. * to override the particles.
  84543. */
  84544. forceDepthWrite: boolean;
  84545. /** 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 */
  84546. preWarmCycles: number;
  84547. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84548. preWarmStepOffset: number;
  84549. /**
  84550. * 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)
  84551. */
  84552. spriteCellChangeSpeed: number;
  84553. /**
  84554. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84555. */
  84556. startSpriteCellID: number;
  84557. /**
  84558. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84559. */
  84560. endSpriteCellID: number;
  84561. /**
  84562. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84563. */
  84564. spriteCellWidth: number;
  84565. /**
  84566. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84567. */
  84568. spriteCellHeight: number;
  84569. /**
  84570. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84571. */
  84572. spriteRandomStartCell: boolean;
  84573. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84574. translationPivot: Vector2;
  84575. /** @hidden */
  84576. protected _isAnimationSheetEnabled: boolean;
  84577. /**
  84578. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84579. */
  84580. beginAnimationOnStart: boolean;
  84581. /**
  84582. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84583. */
  84584. beginAnimationFrom: number;
  84585. /**
  84586. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84587. */
  84588. beginAnimationTo: number;
  84589. /**
  84590. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84591. */
  84592. beginAnimationLoop: boolean;
  84593. /**
  84594. * Gets or sets a world offset applied to all particles
  84595. */
  84596. worldOffset: Vector3;
  84597. /**
  84598. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84599. */
  84600. isAnimationSheetEnabled: boolean;
  84601. /**
  84602. * Get hosting scene
  84603. * @returns the scene
  84604. */
  84605. getScene(): Scene;
  84606. /**
  84607. * You can use gravity if you want to give an orientation to your particles.
  84608. */
  84609. gravity: Vector3;
  84610. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84611. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84612. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84613. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84614. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84615. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84616. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84617. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84618. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84619. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84620. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84621. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84622. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84623. /**
  84624. * Defines the delay in milliseconds before starting the system (0 by default)
  84625. */
  84626. startDelay: number;
  84627. /**
  84628. * Gets the current list of drag gradients.
  84629. * You must use addDragGradient and removeDragGradient to udpate this list
  84630. * @returns the list of drag gradients
  84631. */
  84632. getDragGradients(): Nullable<Array<FactorGradient>>;
  84633. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84634. limitVelocityDamping: number;
  84635. /**
  84636. * Gets the current list of limit velocity gradients.
  84637. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84638. * @returns the list of limit velocity gradients
  84639. */
  84640. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84641. /**
  84642. * Gets the current list of color gradients.
  84643. * You must use addColorGradient and removeColorGradient to udpate this list
  84644. * @returns the list of color gradients
  84645. */
  84646. getColorGradients(): Nullable<Array<ColorGradient>>;
  84647. /**
  84648. * Gets the current list of size gradients.
  84649. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84650. * @returns the list of size gradients
  84651. */
  84652. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84653. /**
  84654. * Gets the current list of color remap gradients.
  84655. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84656. * @returns the list of color remap gradients
  84657. */
  84658. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84659. /**
  84660. * Gets the current list of alpha remap gradients.
  84661. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84662. * @returns the list of alpha remap gradients
  84663. */
  84664. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84665. /**
  84666. * Gets the current list of life time gradients.
  84667. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84668. * @returns the list of life time gradients
  84669. */
  84670. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84671. /**
  84672. * Gets the current list of angular speed gradients.
  84673. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84674. * @returns the list of angular speed gradients
  84675. */
  84676. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84677. /**
  84678. * Gets the current list of velocity gradients.
  84679. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84680. * @returns the list of velocity gradients
  84681. */
  84682. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84683. /**
  84684. * Gets the current list of start size gradients.
  84685. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84686. * @returns the list of start size gradients
  84687. */
  84688. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84689. /**
  84690. * Gets the current list of emit rate gradients.
  84691. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84692. * @returns the list of emit rate gradients
  84693. */
  84694. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84695. /**
  84696. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84697. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84698. */
  84699. direction1: Vector3;
  84700. /**
  84701. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84702. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84703. */
  84704. direction2: Vector3;
  84705. /**
  84706. * 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.
  84707. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84708. */
  84709. minEmitBox: Vector3;
  84710. /**
  84711. * 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.
  84712. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84713. */
  84714. maxEmitBox: Vector3;
  84715. /**
  84716. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84717. */
  84718. color1: Color4;
  84719. /**
  84720. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84721. */
  84722. color2: Color4;
  84723. /**
  84724. * Color the particle will have at the end of its lifetime
  84725. */
  84726. colorDead: Color4;
  84727. /**
  84728. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84729. */
  84730. textureMask: Color4;
  84731. /**
  84732. * The particle emitter type defines the emitter used by the particle system.
  84733. * It can be for example box, sphere, or cone...
  84734. */
  84735. particleEmitterType: IParticleEmitterType;
  84736. /** @hidden */
  84737. _isSubEmitter: boolean;
  84738. /**
  84739. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84740. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84741. */
  84742. billboardMode: number;
  84743. protected _isBillboardBased: boolean;
  84744. /**
  84745. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84746. */
  84747. isBillboardBased: boolean;
  84748. /**
  84749. * The scene the particle system belongs to.
  84750. */
  84751. protected _scene: Scene;
  84752. /**
  84753. * Local cache of defines for image processing.
  84754. */
  84755. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84756. /**
  84757. * Default configuration related to image processing available in the standard Material.
  84758. */
  84759. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84760. /**
  84761. * Gets the image processing configuration used either in this material.
  84762. */
  84763. /**
  84764. * Sets the Default image processing configuration used either in the this material.
  84765. *
  84766. * If sets to null, the scene one is in use.
  84767. */
  84768. imageProcessingConfiguration: ImageProcessingConfiguration;
  84769. /**
  84770. * Attaches a new image processing configuration to the Standard Material.
  84771. * @param configuration
  84772. */
  84773. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84774. /** @hidden */
  84775. protected _reset(): void;
  84776. /** @hidden */
  84777. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84778. /**
  84779. * Instantiates a particle system.
  84780. * 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.
  84781. * @param name The name of the particle system
  84782. */
  84783. constructor(name: string);
  84784. /**
  84785. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84786. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84787. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84788. * @returns the emitter
  84789. */
  84790. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84791. /**
  84792. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84793. * @param radius The radius of the hemisphere to emit from
  84794. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84795. * @returns the emitter
  84796. */
  84797. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84798. /**
  84799. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84800. * @param radius The radius of the sphere to emit from
  84801. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84802. * @returns the emitter
  84803. */
  84804. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84805. /**
  84806. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84807. * @param radius The radius of the sphere to emit from
  84808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84810. * @returns the emitter
  84811. */
  84812. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84813. /**
  84814. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84815. * @param radius The radius of the emission cylinder
  84816. * @param height The height of the emission cylinder
  84817. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84818. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84819. * @returns the emitter
  84820. */
  84821. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84822. /**
  84823. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84824. * @param radius The radius of the cylinder to emit from
  84825. * @param height The height of the emission cylinder
  84826. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84827. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84828. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84829. * @returns the emitter
  84830. */
  84831. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84832. /**
  84833. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84834. * @param radius The radius of the cone to emit from
  84835. * @param angle The base angle of the cone
  84836. * @returns the emitter
  84837. */
  84838. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84839. /**
  84840. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84841. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84842. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84843. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84844. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84845. * @returns the emitter
  84846. */
  84847. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84848. }
  84849. }
  84850. declare module BABYLON {
  84851. /**
  84852. * Type of sub emitter
  84853. */
  84854. export enum SubEmitterType {
  84855. /**
  84856. * Attached to the particle over it's lifetime
  84857. */
  84858. ATTACHED = 0,
  84859. /**
  84860. * Created when the particle dies
  84861. */
  84862. END = 1
  84863. }
  84864. /**
  84865. * Sub emitter class used to emit particles from an existing particle
  84866. */
  84867. export class SubEmitter {
  84868. /**
  84869. * the particle system to be used by the sub emitter
  84870. */
  84871. particleSystem: ParticleSystem;
  84872. /**
  84873. * Type of the submitter (Default: END)
  84874. */
  84875. type: SubEmitterType;
  84876. /**
  84877. * 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)
  84878. * Note: This only is supported when using an emitter of type Mesh
  84879. */
  84880. inheritDirection: boolean;
  84881. /**
  84882. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84883. */
  84884. inheritedVelocityAmount: number;
  84885. /**
  84886. * Creates a sub emitter
  84887. * @param particleSystem the particle system to be used by the sub emitter
  84888. */
  84889. constructor(
  84890. /**
  84891. * the particle system to be used by the sub emitter
  84892. */
  84893. particleSystem: ParticleSystem);
  84894. /**
  84895. * Clones the sub emitter
  84896. * @returns the cloned sub emitter
  84897. */
  84898. clone(): SubEmitter;
  84899. /**
  84900. * Serialize current object to a JSON object
  84901. * @returns the serialized object
  84902. */
  84903. serialize(): any;
  84904. /** @hidden */
  84905. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84906. /**
  84907. * Creates a new SubEmitter from a serialized JSON version
  84908. * @param serializationObject defines the JSON object to read from
  84909. * @param scene defines the hosting scene
  84910. * @param rootUrl defines the rootUrl for data loading
  84911. * @returns a new SubEmitter
  84912. */
  84913. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84914. /** Release associated resources */
  84915. dispose(): void;
  84916. }
  84917. }
  84918. declare module BABYLON {
  84919. /** @hidden */
  84920. export var clipPlaneFragmentDeclaration: {
  84921. name: string;
  84922. shader: string;
  84923. };
  84924. }
  84925. declare module BABYLON {
  84926. /** @hidden */
  84927. export var imageProcessingDeclaration: {
  84928. name: string;
  84929. shader: string;
  84930. };
  84931. }
  84932. declare module BABYLON {
  84933. /** @hidden */
  84934. export var imageProcessingFunctions: {
  84935. name: string;
  84936. shader: string;
  84937. };
  84938. }
  84939. declare module BABYLON {
  84940. /** @hidden */
  84941. export var clipPlaneFragment: {
  84942. name: string;
  84943. shader: string;
  84944. };
  84945. }
  84946. declare module BABYLON {
  84947. /** @hidden */
  84948. export var particlesPixelShader: {
  84949. name: string;
  84950. shader: string;
  84951. };
  84952. }
  84953. declare module BABYLON {
  84954. /** @hidden */
  84955. export var clipPlaneVertexDeclaration: {
  84956. name: string;
  84957. shader: string;
  84958. };
  84959. }
  84960. declare module BABYLON {
  84961. /** @hidden */
  84962. export var clipPlaneVertex: {
  84963. name: string;
  84964. shader: string;
  84965. };
  84966. }
  84967. declare module BABYLON {
  84968. /** @hidden */
  84969. export var particlesVertexShader: {
  84970. name: string;
  84971. shader: string;
  84972. };
  84973. }
  84974. declare module BABYLON {
  84975. /**
  84976. * This represents a particle system in Babylon.
  84977. * 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.
  84978. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84979. * @example https://doc.babylonjs.com/babylon101/particles
  84980. */
  84981. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84982. /**
  84983. * Billboard mode will only apply to Y axis
  84984. */
  84985. static readonly BILLBOARDMODE_Y: number;
  84986. /**
  84987. * Billboard mode will apply to all axes
  84988. */
  84989. static readonly BILLBOARDMODE_ALL: number;
  84990. /**
  84991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84992. */
  84993. static readonly BILLBOARDMODE_STRETCHED: number;
  84994. /**
  84995. * This function can be defined to provide custom update for active particles.
  84996. * This function will be called instead of regular update (age, position, color, etc.).
  84997. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84998. */
  84999. updateFunction: (particles: Particle[]) => void;
  85000. private _emitterWorldMatrix;
  85001. /**
  85002. * This function can be defined to specify initial direction for every new particle.
  85003. * It by default use the emitterType defined function
  85004. */
  85005. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85006. /**
  85007. * This function can be defined to specify initial position for every new particle.
  85008. * It by default use the emitterType defined function
  85009. */
  85010. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85011. /**
  85012. * @hidden
  85013. */
  85014. _inheritedVelocityOffset: Vector3;
  85015. /**
  85016. * An event triggered when the system is disposed
  85017. */
  85018. onDisposeObservable: Observable<ParticleSystem>;
  85019. private _onDisposeObserver;
  85020. /**
  85021. * Sets a callback that will be triggered when the system is disposed
  85022. */
  85023. onDispose: () => void;
  85024. private _particles;
  85025. private _epsilon;
  85026. private _capacity;
  85027. private _stockParticles;
  85028. private _newPartsExcess;
  85029. private _vertexData;
  85030. private _vertexBuffer;
  85031. private _vertexBuffers;
  85032. private _spriteBuffer;
  85033. private _indexBuffer;
  85034. private _effect;
  85035. private _customEffect;
  85036. private _cachedDefines;
  85037. private _scaledColorStep;
  85038. private _colorDiff;
  85039. private _scaledDirection;
  85040. private _scaledGravity;
  85041. private _currentRenderId;
  85042. private _alive;
  85043. private _useInstancing;
  85044. private _started;
  85045. private _stopped;
  85046. private _actualFrame;
  85047. private _scaledUpdateSpeed;
  85048. private _vertexBufferSize;
  85049. /** @hidden */
  85050. _currentEmitRateGradient: Nullable<FactorGradient>;
  85051. /** @hidden */
  85052. _currentEmitRate1: number;
  85053. /** @hidden */
  85054. _currentEmitRate2: number;
  85055. /** @hidden */
  85056. _currentStartSizeGradient: Nullable<FactorGradient>;
  85057. /** @hidden */
  85058. _currentStartSize1: number;
  85059. /** @hidden */
  85060. _currentStartSize2: number;
  85061. private readonly _rawTextureWidth;
  85062. private _rampGradientsTexture;
  85063. private _useRampGradients;
  85064. /** Gets or sets a boolean indicating that ramp gradients must be used
  85065. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85066. */
  85067. useRampGradients: boolean;
  85068. /**
  85069. * 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.
  85070. * 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: [])
  85071. */
  85072. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85073. private _subEmitters;
  85074. /**
  85075. * @hidden
  85076. * If the particle systems emitter should be disposed when the particle system is disposed
  85077. */
  85078. _disposeEmitterOnDispose: boolean;
  85079. /**
  85080. * The current active Sub-systems, this property is used by the root particle system only.
  85081. */
  85082. activeSubSystems: Array<ParticleSystem>;
  85083. private _rootParticleSystem;
  85084. /**
  85085. * Gets the current list of active particles
  85086. */
  85087. readonly particles: Particle[];
  85088. /**
  85089. * Returns the string "ParticleSystem"
  85090. * @returns a string containing the class name
  85091. */
  85092. getClassName(): string;
  85093. /**
  85094. * Instantiates a particle system.
  85095. * 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.
  85096. * @param name The name of the particle system
  85097. * @param capacity The max number of particles alive at the same time
  85098. * @param scene The scene the particle system belongs to
  85099. * @param customEffect a custom effect used to change the way particles are rendered by default
  85100. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85101. * @param epsilon Offset used to render the particles
  85102. */
  85103. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85104. private _addFactorGradient;
  85105. private _removeFactorGradient;
  85106. /**
  85107. * Adds a new life time gradient
  85108. * @param gradient defines the gradient to use (between 0 and 1)
  85109. * @param factor defines the life time factor to affect to the specified gradient
  85110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85111. * @returns the current particle system
  85112. */
  85113. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85114. /**
  85115. * Remove a specific life time gradient
  85116. * @param gradient defines the gradient to remove
  85117. * @returns the current particle system
  85118. */
  85119. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85120. /**
  85121. * Adds a new size gradient
  85122. * @param gradient defines the gradient to use (between 0 and 1)
  85123. * @param factor defines the size factor to affect to the specified gradient
  85124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85125. * @returns the current particle system
  85126. */
  85127. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85128. /**
  85129. * Remove a specific size gradient
  85130. * @param gradient defines the gradient to remove
  85131. * @returns the current particle system
  85132. */
  85133. removeSizeGradient(gradient: number): IParticleSystem;
  85134. /**
  85135. * Adds a new color remap gradient
  85136. * @param gradient defines the gradient to use (between 0 and 1)
  85137. * @param min defines the color remap minimal range
  85138. * @param max defines the color remap maximal range
  85139. * @returns the current particle system
  85140. */
  85141. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85142. /**
  85143. * Remove a specific color remap gradient
  85144. * @param gradient defines the gradient to remove
  85145. * @returns the current particle system
  85146. */
  85147. removeColorRemapGradient(gradient: number): IParticleSystem;
  85148. /**
  85149. * Adds a new alpha remap gradient
  85150. * @param gradient defines the gradient to use (between 0 and 1)
  85151. * @param min defines the alpha remap minimal range
  85152. * @param max defines the alpha remap maximal range
  85153. * @returns the current particle system
  85154. */
  85155. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85156. /**
  85157. * Remove a specific alpha remap gradient
  85158. * @param gradient defines the gradient to remove
  85159. * @returns the current particle system
  85160. */
  85161. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85162. /**
  85163. * Adds a new angular speed gradient
  85164. * @param gradient defines the gradient to use (between 0 and 1)
  85165. * @param factor defines the angular speed to affect to the specified gradient
  85166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85167. * @returns the current particle system
  85168. */
  85169. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85170. /**
  85171. * Remove a specific angular speed gradient
  85172. * @param gradient defines the gradient to remove
  85173. * @returns the current particle system
  85174. */
  85175. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85176. /**
  85177. * Adds a new velocity gradient
  85178. * @param gradient defines the gradient to use (between 0 and 1)
  85179. * @param factor defines the velocity to affect to the specified gradient
  85180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85181. * @returns the current particle system
  85182. */
  85183. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85184. /**
  85185. * Remove a specific velocity gradient
  85186. * @param gradient defines the gradient to remove
  85187. * @returns the current particle system
  85188. */
  85189. removeVelocityGradient(gradient: number): IParticleSystem;
  85190. /**
  85191. * Adds a new limit velocity gradient
  85192. * @param gradient defines the gradient to use (between 0 and 1)
  85193. * @param factor defines the limit velocity value to affect to the specified gradient
  85194. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85195. * @returns the current particle system
  85196. */
  85197. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85198. /**
  85199. * Remove a specific limit velocity gradient
  85200. * @param gradient defines the gradient to remove
  85201. * @returns the current particle system
  85202. */
  85203. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85204. /**
  85205. * Adds a new drag gradient
  85206. * @param gradient defines the gradient to use (between 0 and 1)
  85207. * @param factor defines the drag value to affect to the specified gradient
  85208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85209. * @returns the current particle system
  85210. */
  85211. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85212. /**
  85213. * Remove a specific drag gradient
  85214. * @param gradient defines the gradient to remove
  85215. * @returns the current particle system
  85216. */
  85217. removeDragGradient(gradient: number): IParticleSystem;
  85218. /**
  85219. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85220. * @param gradient defines the gradient to use (between 0 and 1)
  85221. * @param factor defines the emit rate value to affect to the specified gradient
  85222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85223. * @returns the current particle system
  85224. */
  85225. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85226. /**
  85227. * Remove a specific emit rate gradient
  85228. * @param gradient defines the gradient to remove
  85229. * @returns the current particle system
  85230. */
  85231. removeEmitRateGradient(gradient: number): IParticleSystem;
  85232. /**
  85233. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85234. * @param gradient defines the gradient to use (between 0 and 1)
  85235. * @param factor defines the start size value to affect to the specified gradient
  85236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85237. * @returns the current particle system
  85238. */
  85239. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85240. /**
  85241. * Remove a specific start size gradient
  85242. * @param gradient defines the gradient to remove
  85243. * @returns the current particle system
  85244. */
  85245. removeStartSizeGradient(gradient: number): IParticleSystem;
  85246. private _createRampGradientTexture;
  85247. /**
  85248. * Gets the current list of ramp gradients.
  85249. * You must use addRampGradient and removeRampGradient to udpate this list
  85250. * @returns the list of ramp gradients
  85251. */
  85252. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85253. /**
  85254. * Adds a new ramp gradient used to remap particle colors
  85255. * @param gradient defines the gradient to use (between 0 and 1)
  85256. * @param color defines the color to affect to the specified gradient
  85257. * @returns the current particle system
  85258. */
  85259. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85260. /**
  85261. * Remove a specific ramp gradient
  85262. * @param gradient defines the gradient to remove
  85263. * @returns the current particle system
  85264. */
  85265. removeRampGradient(gradient: number): ParticleSystem;
  85266. /**
  85267. * Adds a new color gradient
  85268. * @param gradient defines the gradient to use (between 0 and 1)
  85269. * @param color1 defines the color to affect to the specified gradient
  85270. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85271. * @returns this particle system
  85272. */
  85273. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85274. /**
  85275. * Remove a specific color gradient
  85276. * @param gradient defines the gradient to remove
  85277. * @returns this particle system
  85278. */
  85279. removeColorGradient(gradient: number): IParticleSystem;
  85280. private _fetchR;
  85281. protected _reset(): void;
  85282. private _resetEffect;
  85283. private _createVertexBuffers;
  85284. private _createIndexBuffer;
  85285. /**
  85286. * Gets the maximum number of particles active at the same time.
  85287. * @returns The max number of active particles.
  85288. */
  85289. getCapacity(): number;
  85290. /**
  85291. * Gets whether there are still active particles in the system.
  85292. * @returns True if it is alive, otherwise false.
  85293. */
  85294. isAlive(): boolean;
  85295. /**
  85296. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85297. * @returns True if it has been started, otherwise false.
  85298. */
  85299. isStarted(): boolean;
  85300. private _prepareSubEmitterInternalArray;
  85301. /**
  85302. * Starts the particle system and begins to emit
  85303. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85304. */
  85305. start(delay?: number): void;
  85306. /**
  85307. * Stops the particle system.
  85308. * @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.
  85309. */
  85310. stop(stopSubEmitters?: boolean): void;
  85311. /**
  85312. * Remove all active particles
  85313. */
  85314. reset(): void;
  85315. /**
  85316. * @hidden (for internal use only)
  85317. */
  85318. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85319. /**
  85320. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85321. * Its lifetime will start back at 0.
  85322. */
  85323. recycleParticle: (particle: Particle) => void;
  85324. private _stopSubEmitters;
  85325. private _createParticle;
  85326. private _removeFromRoot;
  85327. private _emitFromParticle;
  85328. private _update;
  85329. /** @hidden */
  85330. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85331. /** @hidden */
  85332. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85333. /** @hidden */
  85334. private _getEffect;
  85335. /**
  85336. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85337. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85338. */
  85339. animate(preWarmOnly?: boolean): void;
  85340. private _appendParticleVertices;
  85341. /**
  85342. * Rebuilds the particle system.
  85343. */
  85344. rebuild(): void;
  85345. /**
  85346. * Is this system ready to be used/rendered
  85347. * @return true if the system is ready
  85348. */
  85349. isReady(): boolean;
  85350. private _render;
  85351. /**
  85352. * Renders the particle system in its current state.
  85353. * @returns the current number of particles
  85354. */
  85355. render(): number;
  85356. /**
  85357. * Disposes the particle system and free the associated resources
  85358. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85359. */
  85360. dispose(disposeTexture?: boolean): void;
  85361. /**
  85362. * Clones the particle system.
  85363. * @param name The name of the cloned object
  85364. * @param newEmitter The new emitter to use
  85365. * @returns the cloned particle system
  85366. */
  85367. clone(name: string, newEmitter: any): ParticleSystem;
  85368. /**
  85369. * Serializes the particle system to a JSON object.
  85370. * @returns the JSON object
  85371. */
  85372. serialize(): any;
  85373. /** @hidden */
  85374. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85375. /** @hidden */
  85376. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85377. /**
  85378. * Parses a JSON object to create a particle system.
  85379. * @param parsedParticleSystem The JSON object to parse
  85380. * @param scene The scene to create the particle system in
  85381. * @param rootUrl The root url to use to load external dependencies like texture
  85382. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85383. * @returns the Parsed particle system
  85384. */
  85385. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85386. }
  85387. }
  85388. declare module BABYLON {
  85389. /**
  85390. * A particle represents one of the element emitted by a particle system.
  85391. * This is mainly define by its coordinates, direction, velocity and age.
  85392. */
  85393. export class Particle {
  85394. /**
  85395. * The particle system the particle belongs to.
  85396. */
  85397. particleSystem: ParticleSystem;
  85398. private static _Count;
  85399. /**
  85400. * Unique ID of the particle
  85401. */
  85402. id: number;
  85403. /**
  85404. * The world position of the particle in the scene.
  85405. */
  85406. position: Vector3;
  85407. /**
  85408. * The world direction of the particle in the scene.
  85409. */
  85410. direction: Vector3;
  85411. /**
  85412. * The color of the particle.
  85413. */
  85414. color: Color4;
  85415. /**
  85416. * The color change of the particle per step.
  85417. */
  85418. colorStep: Color4;
  85419. /**
  85420. * Defines how long will the life of the particle be.
  85421. */
  85422. lifeTime: number;
  85423. /**
  85424. * The current age of the particle.
  85425. */
  85426. age: number;
  85427. /**
  85428. * The current size of the particle.
  85429. */
  85430. size: number;
  85431. /**
  85432. * The current scale of the particle.
  85433. */
  85434. scale: Vector2;
  85435. /**
  85436. * The current angle of the particle.
  85437. */
  85438. angle: number;
  85439. /**
  85440. * Defines how fast is the angle changing.
  85441. */
  85442. angularSpeed: number;
  85443. /**
  85444. * Defines the cell index used by the particle to be rendered from a sprite.
  85445. */
  85446. cellIndex: number;
  85447. /**
  85448. * The information required to support color remapping
  85449. */
  85450. remapData: Vector4;
  85451. /** @hidden */
  85452. _randomCellOffset?: number;
  85453. /** @hidden */
  85454. _initialDirection: Nullable<Vector3>;
  85455. /** @hidden */
  85456. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85457. /** @hidden */
  85458. _initialStartSpriteCellID: number;
  85459. /** @hidden */
  85460. _initialEndSpriteCellID: number;
  85461. /** @hidden */
  85462. _currentColorGradient: Nullable<ColorGradient>;
  85463. /** @hidden */
  85464. _currentColor1: Color4;
  85465. /** @hidden */
  85466. _currentColor2: Color4;
  85467. /** @hidden */
  85468. _currentSizeGradient: Nullable<FactorGradient>;
  85469. /** @hidden */
  85470. _currentSize1: number;
  85471. /** @hidden */
  85472. _currentSize2: number;
  85473. /** @hidden */
  85474. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85475. /** @hidden */
  85476. _currentAngularSpeed1: number;
  85477. /** @hidden */
  85478. _currentAngularSpeed2: number;
  85479. /** @hidden */
  85480. _currentVelocityGradient: Nullable<FactorGradient>;
  85481. /** @hidden */
  85482. _currentVelocity1: number;
  85483. /** @hidden */
  85484. _currentVelocity2: number;
  85485. /** @hidden */
  85486. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85487. /** @hidden */
  85488. _currentLimitVelocity1: number;
  85489. /** @hidden */
  85490. _currentLimitVelocity2: number;
  85491. /** @hidden */
  85492. _currentDragGradient: Nullable<FactorGradient>;
  85493. /** @hidden */
  85494. _currentDrag1: number;
  85495. /** @hidden */
  85496. _currentDrag2: number;
  85497. /** @hidden */
  85498. _randomNoiseCoordinates1: Vector3;
  85499. /** @hidden */
  85500. _randomNoiseCoordinates2: Vector3;
  85501. /**
  85502. * Creates a new instance Particle
  85503. * @param particleSystem the particle system the particle belongs to
  85504. */
  85505. constructor(
  85506. /**
  85507. * The particle system the particle belongs to.
  85508. */
  85509. particleSystem: ParticleSystem);
  85510. private updateCellInfoFromSystem;
  85511. /**
  85512. * Defines how the sprite cell index is updated for the particle
  85513. */
  85514. updateCellIndex(): void;
  85515. /** @hidden */
  85516. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85517. /** @hidden */
  85518. _inheritParticleInfoToSubEmitters(): void;
  85519. /** @hidden */
  85520. _reset(): void;
  85521. /**
  85522. * Copy the properties of particle to another one.
  85523. * @param other the particle to copy the information to.
  85524. */
  85525. copyTo(other: Particle): void;
  85526. }
  85527. }
  85528. declare module BABYLON {
  85529. /**
  85530. * Particle emitter represents a volume emitting particles.
  85531. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85532. */
  85533. export interface IParticleEmitterType {
  85534. /**
  85535. * Called by the particle System when the direction is computed for the created particle.
  85536. * @param worldMatrix is the world matrix of the particle system
  85537. * @param directionToUpdate is the direction vector to update with the result
  85538. * @param particle is the particle we are computed the direction for
  85539. */
  85540. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85541. /**
  85542. * Called by the particle System when the position is computed for the created particle.
  85543. * @param worldMatrix is the world matrix of the particle system
  85544. * @param positionToUpdate is the position vector to update with the result
  85545. * @param particle is the particle we are computed the position for
  85546. */
  85547. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85548. /**
  85549. * Clones the current emitter and returns a copy of it
  85550. * @returns the new emitter
  85551. */
  85552. clone(): IParticleEmitterType;
  85553. /**
  85554. * Called by the GPUParticleSystem to setup the update shader
  85555. * @param effect defines the update shader
  85556. */
  85557. applyToShader(effect: Effect): void;
  85558. /**
  85559. * Returns a string to use to update the GPU particles update shader
  85560. * @returns the effect defines string
  85561. */
  85562. getEffectDefines(): string;
  85563. /**
  85564. * Returns a string representing the class name
  85565. * @returns a string containing the class name
  85566. */
  85567. getClassName(): string;
  85568. /**
  85569. * Serializes the particle system to a JSON object.
  85570. * @returns the JSON object
  85571. */
  85572. serialize(): any;
  85573. /**
  85574. * Parse properties from a JSON object
  85575. * @param serializationObject defines the JSON object
  85576. */
  85577. parse(serializationObject: any): void;
  85578. }
  85579. }
  85580. declare module BABYLON {
  85581. /**
  85582. * Particle emitter emitting particles from the inside of a box.
  85583. * It emits the particles randomly between 2 given directions.
  85584. */
  85585. export class BoxParticleEmitter implements IParticleEmitterType {
  85586. /**
  85587. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85588. */
  85589. direction1: Vector3;
  85590. /**
  85591. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85592. */
  85593. direction2: Vector3;
  85594. /**
  85595. * 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.
  85596. */
  85597. minEmitBox: Vector3;
  85598. /**
  85599. * 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.
  85600. */
  85601. maxEmitBox: Vector3;
  85602. /**
  85603. * Creates a new instance BoxParticleEmitter
  85604. */
  85605. constructor();
  85606. /**
  85607. * Called by the particle System when the direction is computed for the created particle.
  85608. * @param worldMatrix is the world matrix of the particle system
  85609. * @param directionToUpdate is the direction vector to update with the result
  85610. * @param particle is the particle we are computed the direction for
  85611. */
  85612. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85613. /**
  85614. * Called by the particle System when the position is computed for the created particle.
  85615. * @param worldMatrix is the world matrix of the particle system
  85616. * @param positionToUpdate is the position vector to update with the result
  85617. * @param particle is the particle we are computed the position for
  85618. */
  85619. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85620. /**
  85621. * Clones the current emitter and returns a copy of it
  85622. * @returns the new emitter
  85623. */
  85624. clone(): BoxParticleEmitter;
  85625. /**
  85626. * Called by the GPUParticleSystem to setup the update shader
  85627. * @param effect defines the update shader
  85628. */
  85629. applyToShader(effect: Effect): void;
  85630. /**
  85631. * Returns a string to use to update the GPU particles update shader
  85632. * @returns a string containng the defines string
  85633. */
  85634. getEffectDefines(): string;
  85635. /**
  85636. * Returns the string "BoxParticleEmitter"
  85637. * @returns a string containing the class name
  85638. */
  85639. getClassName(): string;
  85640. /**
  85641. * Serializes the particle system to a JSON object.
  85642. * @returns the JSON object
  85643. */
  85644. serialize(): any;
  85645. /**
  85646. * Parse properties from a JSON object
  85647. * @param serializationObject defines the JSON object
  85648. */
  85649. parse(serializationObject: any): void;
  85650. }
  85651. }
  85652. declare module BABYLON {
  85653. /**
  85654. * Particle emitter emitting particles from the inside of a cone.
  85655. * It emits the particles alongside the cone volume from the base to the particle.
  85656. * The emission direction might be randomized.
  85657. */
  85658. export class ConeParticleEmitter implements IParticleEmitterType {
  85659. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85660. directionRandomizer: number;
  85661. private _radius;
  85662. private _angle;
  85663. private _height;
  85664. /**
  85665. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85666. */
  85667. radiusRange: number;
  85668. /**
  85669. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85670. */
  85671. heightRange: number;
  85672. /**
  85673. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85674. */
  85675. emitFromSpawnPointOnly: boolean;
  85676. /**
  85677. * Gets or sets the radius of the emission cone
  85678. */
  85679. radius: number;
  85680. /**
  85681. * Gets or sets the angle of the emission cone
  85682. */
  85683. angle: number;
  85684. private _buildHeight;
  85685. /**
  85686. * Creates a new instance ConeParticleEmitter
  85687. * @param radius the radius of the emission cone (1 by default)
  85688. * @param angle the cone base angle (PI by default)
  85689. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85690. */
  85691. constructor(radius?: number, angle?: number,
  85692. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85693. directionRandomizer?: number);
  85694. /**
  85695. * Called by the particle System when the direction is computed for the created particle.
  85696. * @param worldMatrix is the world matrix of the particle system
  85697. * @param directionToUpdate is the direction vector to update with the result
  85698. * @param particle is the particle we are computed the direction for
  85699. */
  85700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85701. /**
  85702. * Called by the particle System when the position is computed for the created particle.
  85703. * @param worldMatrix is the world matrix of the particle system
  85704. * @param positionToUpdate is the position vector to update with the result
  85705. * @param particle is the particle we are computed the position for
  85706. */
  85707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85708. /**
  85709. * Clones the current emitter and returns a copy of it
  85710. * @returns the new emitter
  85711. */
  85712. clone(): ConeParticleEmitter;
  85713. /**
  85714. * Called by the GPUParticleSystem to setup the update shader
  85715. * @param effect defines the update shader
  85716. */
  85717. applyToShader(effect: Effect): void;
  85718. /**
  85719. * Returns a string to use to update the GPU particles update shader
  85720. * @returns a string containng the defines string
  85721. */
  85722. getEffectDefines(): string;
  85723. /**
  85724. * Returns the string "ConeParticleEmitter"
  85725. * @returns a string containing the class name
  85726. */
  85727. getClassName(): string;
  85728. /**
  85729. * Serializes the particle system to a JSON object.
  85730. * @returns the JSON object
  85731. */
  85732. serialize(): any;
  85733. /**
  85734. * Parse properties from a JSON object
  85735. * @param serializationObject defines the JSON object
  85736. */
  85737. parse(serializationObject: any): void;
  85738. }
  85739. }
  85740. declare module BABYLON {
  85741. /**
  85742. * Particle emitter emitting particles from the inside of a cylinder.
  85743. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85744. */
  85745. export class CylinderParticleEmitter implements IParticleEmitterType {
  85746. /**
  85747. * The radius of the emission cylinder.
  85748. */
  85749. radius: number;
  85750. /**
  85751. * The height of the emission cylinder.
  85752. */
  85753. height: number;
  85754. /**
  85755. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85756. */
  85757. radiusRange: number;
  85758. /**
  85759. * How much to randomize the particle direction [0-1].
  85760. */
  85761. directionRandomizer: number;
  85762. /**
  85763. * Creates a new instance CylinderParticleEmitter
  85764. * @param radius the radius of the emission cylinder (1 by default)
  85765. * @param height the height of the emission cylinder (1 by default)
  85766. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85767. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85768. */
  85769. constructor(
  85770. /**
  85771. * The radius of the emission cylinder.
  85772. */
  85773. radius?: number,
  85774. /**
  85775. * The height of the emission cylinder.
  85776. */
  85777. height?: number,
  85778. /**
  85779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85780. */
  85781. radiusRange?: number,
  85782. /**
  85783. * How much to randomize the particle direction [0-1].
  85784. */
  85785. directionRandomizer?: number);
  85786. /**
  85787. * Called by the particle System when the direction is computed for the created particle.
  85788. * @param worldMatrix is the world matrix of the particle system
  85789. * @param directionToUpdate is the direction vector to update with the result
  85790. * @param particle is the particle we are computed the direction for
  85791. */
  85792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85793. /**
  85794. * Called by the particle System when the position is computed for the created particle.
  85795. * @param worldMatrix is the world matrix of the particle system
  85796. * @param positionToUpdate is the position vector to update with the result
  85797. * @param particle is the particle we are computed the position for
  85798. */
  85799. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85800. /**
  85801. * Clones the current emitter and returns a copy of it
  85802. * @returns the new emitter
  85803. */
  85804. clone(): CylinderParticleEmitter;
  85805. /**
  85806. * Called by the GPUParticleSystem to setup the update shader
  85807. * @param effect defines the update shader
  85808. */
  85809. applyToShader(effect: Effect): void;
  85810. /**
  85811. * Returns a string to use to update the GPU particles update shader
  85812. * @returns a string containng the defines string
  85813. */
  85814. getEffectDefines(): string;
  85815. /**
  85816. * Returns the string "CylinderParticleEmitter"
  85817. * @returns a string containing the class name
  85818. */
  85819. getClassName(): string;
  85820. /**
  85821. * Serializes the particle system to a JSON object.
  85822. * @returns the JSON object
  85823. */
  85824. serialize(): any;
  85825. /**
  85826. * Parse properties from a JSON object
  85827. * @param serializationObject defines the JSON object
  85828. */
  85829. parse(serializationObject: any): void;
  85830. }
  85831. /**
  85832. * Particle emitter emitting particles from the inside of a cylinder.
  85833. * It emits the particles randomly between two vectors.
  85834. */
  85835. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85836. /**
  85837. * The min limit of the emission direction.
  85838. */
  85839. direction1: Vector3;
  85840. /**
  85841. * The max limit of the emission direction.
  85842. */
  85843. direction2: Vector3;
  85844. /**
  85845. * Creates a new instance CylinderDirectedParticleEmitter
  85846. * @param radius the radius of the emission cylinder (1 by default)
  85847. * @param height the height of the emission cylinder (1 by default)
  85848. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85849. * @param direction1 the min limit of the emission direction (up vector by default)
  85850. * @param direction2 the max limit of the emission direction (up vector by default)
  85851. */
  85852. constructor(radius?: number, height?: number, radiusRange?: number,
  85853. /**
  85854. * The min limit of the emission direction.
  85855. */
  85856. direction1?: Vector3,
  85857. /**
  85858. * The max limit of the emission direction.
  85859. */
  85860. direction2?: Vector3);
  85861. /**
  85862. * Called by the particle System when the direction is computed for the created particle.
  85863. * @param worldMatrix is the world matrix of the particle system
  85864. * @param directionToUpdate is the direction vector to update with the result
  85865. * @param particle is the particle we are computed the direction for
  85866. */
  85867. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85868. /**
  85869. * Clones the current emitter and returns a copy of it
  85870. * @returns the new emitter
  85871. */
  85872. clone(): CylinderDirectedParticleEmitter;
  85873. /**
  85874. * Called by the GPUParticleSystem to setup the update shader
  85875. * @param effect defines the update shader
  85876. */
  85877. applyToShader(effect: Effect): void;
  85878. /**
  85879. * Returns a string to use to update the GPU particles update shader
  85880. * @returns a string containng the defines string
  85881. */
  85882. getEffectDefines(): string;
  85883. /**
  85884. * Returns the string "CylinderDirectedParticleEmitter"
  85885. * @returns a string containing the class name
  85886. */
  85887. getClassName(): string;
  85888. /**
  85889. * Serializes the particle system to a JSON object.
  85890. * @returns the JSON object
  85891. */
  85892. serialize(): any;
  85893. /**
  85894. * Parse properties from a JSON object
  85895. * @param serializationObject defines the JSON object
  85896. */
  85897. parse(serializationObject: any): void;
  85898. }
  85899. }
  85900. declare module BABYLON {
  85901. /**
  85902. * Particle emitter emitting particles from the inside of a hemisphere.
  85903. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85904. */
  85905. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85906. /**
  85907. * The radius of the emission hemisphere.
  85908. */
  85909. radius: number;
  85910. /**
  85911. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85912. */
  85913. radiusRange: number;
  85914. /**
  85915. * How much to randomize the particle direction [0-1].
  85916. */
  85917. directionRandomizer: number;
  85918. /**
  85919. * Creates a new instance HemisphericParticleEmitter
  85920. * @param radius the radius of the emission hemisphere (1 by default)
  85921. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85922. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85923. */
  85924. constructor(
  85925. /**
  85926. * The radius of the emission hemisphere.
  85927. */
  85928. radius?: number,
  85929. /**
  85930. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85931. */
  85932. radiusRange?: number,
  85933. /**
  85934. * How much to randomize the particle direction [0-1].
  85935. */
  85936. directionRandomizer?: number);
  85937. /**
  85938. * Called by the particle System when the direction is computed for the created particle.
  85939. * @param worldMatrix is the world matrix of the particle system
  85940. * @param directionToUpdate is the direction vector to update with the result
  85941. * @param particle is the particle we are computed the direction for
  85942. */
  85943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85944. /**
  85945. * Called by the particle System when the position is computed for the created particle.
  85946. * @param worldMatrix is the world matrix of the particle system
  85947. * @param positionToUpdate is the position vector to update with the result
  85948. * @param particle is the particle we are computed the position for
  85949. */
  85950. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85951. /**
  85952. * Clones the current emitter and returns a copy of it
  85953. * @returns the new emitter
  85954. */
  85955. clone(): HemisphericParticleEmitter;
  85956. /**
  85957. * Called by the GPUParticleSystem to setup the update shader
  85958. * @param effect defines the update shader
  85959. */
  85960. applyToShader(effect: Effect): void;
  85961. /**
  85962. * Returns a string to use to update the GPU particles update shader
  85963. * @returns a string containng the defines string
  85964. */
  85965. getEffectDefines(): string;
  85966. /**
  85967. * Returns the string "HemisphericParticleEmitter"
  85968. * @returns a string containing the class name
  85969. */
  85970. getClassName(): string;
  85971. /**
  85972. * Serializes the particle system to a JSON object.
  85973. * @returns the JSON object
  85974. */
  85975. serialize(): any;
  85976. /**
  85977. * Parse properties from a JSON object
  85978. * @param serializationObject defines the JSON object
  85979. */
  85980. parse(serializationObject: any): void;
  85981. }
  85982. }
  85983. declare module BABYLON {
  85984. /**
  85985. * Particle emitter emitting particles from a point.
  85986. * It emits the particles randomly between 2 given directions.
  85987. */
  85988. export class PointParticleEmitter implements IParticleEmitterType {
  85989. /**
  85990. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85991. */
  85992. direction1: Vector3;
  85993. /**
  85994. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85995. */
  85996. direction2: Vector3;
  85997. /**
  85998. * Creates a new instance PointParticleEmitter
  85999. */
  86000. constructor();
  86001. /**
  86002. * Called by the particle System when the direction is computed for the created particle.
  86003. * @param worldMatrix is the world matrix of the particle system
  86004. * @param directionToUpdate is the direction vector to update with the result
  86005. * @param particle is the particle we are computed the direction for
  86006. */
  86007. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86008. /**
  86009. * Called by the particle System when the position is computed for the created particle.
  86010. * @param worldMatrix is the world matrix of the particle system
  86011. * @param positionToUpdate is the position vector to update with the result
  86012. * @param particle is the particle we are computed the position for
  86013. */
  86014. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86015. /**
  86016. * Clones the current emitter and returns a copy of it
  86017. * @returns the new emitter
  86018. */
  86019. clone(): PointParticleEmitter;
  86020. /**
  86021. * Called by the GPUParticleSystem to setup the update shader
  86022. * @param effect defines the update shader
  86023. */
  86024. applyToShader(effect: Effect): void;
  86025. /**
  86026. * Returns a string to use to update the GPU particles update shader
  86027. * @returns a string containng the defines string
  86028. */
  86029. getEffectDefines(): string;
  86030. /**
  86031. * Returns the string "PointParticleEmitter"
  86032. * @returns a string containing the class name
  86033. */
  86034. getClassName(): string;
  86035. /**
  86036. * Serializes the particle system to a JSON object.
  86037. * @returns the JSON object
  86038. */
  86039. serialize(): any;
  86040. /**
  86041. * Parse properties from a JSON object
  86042. * @param serializationObject defines the JSON object
  86043. */
  86044. parse(serializationObject: any): void;
  86045. }
  86046. }
  86047. declare module BABYLON {
  86048. /**
  86049. * Particle emitter emitting particles from the inside of a sphere.
  86050. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86051. */
  86052. export class SphereParticleEmitter implements IParticleEmitterType {
  86053. /**
  86054. * The radius of the emission sphere.
  86055. */
  86056. radius: number;
  86057. /**
  86058. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86059. */
  86060. radiusRange: number;
  86061. /**
  86062. * How much to randomize the particle direction [0-1].
  86063. */
  86064. directionRandomizer: number;
  86065. /**
  86066. * Creates a new instance SphereParticleEmitter
  86067. * @param radius the radius of the emission sphere (1 by default)
  86068. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86069. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86070. */
  86071. constructor(
  86072. /**
  86073. * The radius of the emission sphere.
  86074. */
  86075. radius?: number,
  86076. /**
  86077. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86078. */
  86079. radiusRange?: number,
  86080. /**
  86081. * How much to randomize the particle direction [0-1].
  86082. */
  86083. directionRandomizer?: number);
  86084. /**
  86085. * Called by the particle System when the direction is computed for the created particle.
  86086. * @param worldMatrix is the world matrix of the particle system
  86087. * @param directionToUpdate is the direction vector to update with the result
  86088. * @param particle is the particle we are computed the direction for
  86089. */
  86090. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86091. /**
  86092. * Called by the particle System when the position is computed for the created particle.
  86093. * @param worldMatrix is the world matrix of the particle system
  86094. * @param positionToUpdate is the position vector to update with the result
  86095. * @param particle is the particle we are computed the position for
  86096. */
  86097. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86098. /**
  86099. * Clones the current emitter and returns a copy of it
  86100. * @returns the new emitter
  86101. */
  86102. clone(): SphereParticleEmitter;
  86103. /**
  86104. * Called by the GPUParticleSystem to setup the update shader
  86105. * @param effect defines the update shader
  86106. */
  86107. applyToShader(effect: Effect): void;
  86108. /**
  86109. * Returns a string to use to update the GPU particles update shader
  86110. * @returns a string containng the defines string
  86111. */
  86112. getEffectDefines(): string;
  86113. /**
  86114. * Returns the string "SphereParticleEmitter"
  86115. * @returns a string containing the class name
  86116. */
  86117. getClassName(): string;
  86118. /**
  86119. * Serializes the particle system to a JSON object.
  86120. * @returns the JSON object
  86121. */
  86122. serialize(): any;
  86123. /**
  86124. * Parse properties from a JSON object
  86125. * @param serializationObject defines the JSON object
  86126. */
  86127. parse(serializationObject: any): void;
  86128. }
  86129. /**
  86130. * Particle emitter emitting particles from the inside of a sphere.
  86131. * It emits the particles randomly between two vectors.
  86132. */
  86133. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86134. /**
  86135. * The min limit of the emission direction.
  86136. */
  86137. direction1: Vector3;
  86138. /**
  86139. * The max limit of the emission direction.
  86140. */
  86141. direction2: Vector3;
  86142. /**
  86143. * Creates a new instance SphereDirectedParticleEmitter
  86144. * @param radius the radius of the emission sphere (1 by default)
  86145. * @param direction1 the min limit of the emission direction (up vector by default)
  86146. * @param direction2 the max limit of the emission direction (up vector by default)
  86147. */
  86148. constructor(radius?: number,
  86149. /**
  86150. * The min limit of the emission direction.
  86151. */
  86152. direction1?: Vector3,
  86153. /**
  86154. * The max limit of the emission direction.
  86155. */
  86156. direction2?: Vector3);
  86157. /**
  86158. * Called by the particle System when the direction is computed for the created particle.
  86159. * @param worldMatrix is the world matrix of the particle system
  86160. * @param directionToUpdate is the direction vector to update with the result
  86161. * @param particle is the particle we are computed the direction for
  86162. */
  86163. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86164. /**
  86165. * Clones the current emitter and returns a copy of it
  86166. * @returns the new emitter
  86167. */
  86168. clone(): SphereDirectedParticleEmitter;
  86169. /**
  86170. * Called by the GPUParticleSystem to setup the update shader
  86171. * @param effect defines the update shader
  86172. */
  86173. applyToShader(effect: Effect): void;
  86174. /**
  86175. * Returns a string to use to update the GPU particles update shader
  86176. * @returns a string containng the defines string
  86177. */
  86178. getEffectDefines(): string;
  86179. /**
  86180. * Returns the string "SphereDirectedParticleEmitter"
  86181. * @returns a string containing the class name
  86182. */
  86183. getClassName(): string;
  86184. /**
  86185. * Serializes the particle system to a JSON object.
  86186. * @returns the JSON object
  86187. */
  86188. serialize(): any;
  86189. /**
  86190. * Parse properties from a JSON object
  86191. * @param serializationObject defines the JSON object
  86192. */
  86193. parse(serializationObject: any): void;
  86194. }
  86195. }
  86196. declare module BABYLON {
  86197. /**
  86198. * Interface representing a particle system in Babylon.js.
  86199. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86200. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86201. */
  86202. export interface IParticleSystem {
  86203. /**
  86204. * List of animations used by the particle system.
  86205. */
  86206. animations: Animation[];
  86207. /**
  86208. * The id of the Particle system.
  86209. */
  86210. id: string;
  86211. /**
  86212. * The name of the Particle system.
  86213. */
  86214. name: string;
  86215. /**
  86216. * The emitter represents the Mesh or position we are attaching the particle system to.
  86217. */
  86218. emitter: Nullable<AbstractMesh | Vector3>;
  86219. /**
  86220. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86221. */
  86222. isBillboardBased: boolean;
  86223. /**
  86224. * The rendering group used by the Particle system to chose when to render.
  86225. */
  86226. renderingGroupId: number;
  86227. /**
  86228. * The layer mask we are rendering the particles through.
  86229. */
  86230. layerMask: number;
  86231. /**
  86232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86233. */
  86234. updateSpeed: number;
  86235. /**
  86236. * The amount of time the particle system is running (depends of the overall update speed).
  86237. */
  86238. targetStopDuration: number;
  86239. /**
  86240. * The texture used to render each particle. (this can be a spritesheet)
  86241. */
  86242. particleTexture: Nullable<Texture>;
  86243. /**
  86244. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86245. */
  86246. blendMode: number;
  86247. /**
  86248. * Minimum life time of emitting particles.
  86249. */
  86250. minLifeTime: number;
  86251. /**
  86252. * Maximum life time of emitting particles.
  86253. */
  86254. maxLifeTime: number;
  86255. /**
  86256. * Minimum Size of emitting particles.
  86257. */
  86258. minSize: number;
  86259. /**
  86260. * Maximum Size of emitting particles.
  86261. */
  86262. maxSize: number;
  86263. /**
  86264. * Minimum scale of emitting particles on X axis.
  86265. */
  86266. minScaleX: number;
  86267. /**
  86268. * Maximum scale of emitting particles on X axis.
  86269. */
  86270. maxScaleX: number;
  86271. /**
  86272. * Minimum scale of emitting particles on Y axis.
  86273. */
  86274. minScaleY: number;
  86275. /**
  86276. * Maximum scale of emitting particles on Y axis.
  86277. */
  86278. maxScaleY: number;
  86279. /**
  86280. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86281. */
  86282. color1: Color4;
  86283. /**
  86284. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86285. */
  86286. color2: Color4;
  86287. /**
  86288. * Color the particle will have at the end of its lifetime.
  86289. */
  86290. colorDead: Color4;
  86291. /**
  86292. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86293. */
  86294. emitRate: number;
  86295. /**
  86296. * You can use gravity if you want to give an orientation to your particles.
  86297. */
  86298. gravity: Vector3;
  86299. /**
  86300. * Minimum power of emitting particles.
  86301. */
  86302. minEmitPower: number;
  86303. /**
  86304. * Maximum power of emitting particles.
  86305. */
  86306. maxEmitPower: number;
  86307. /**
  86308. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86309. */
  86310. minAngularSpeed: number;
  86311. /**
  86312. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86313. */
  86314. maxAngularSpeed: number;
  86315. /**
  86316. * Gets or sets the minimal initial rotation in radians.
  86317. */
  86318. minInitialRotation: number;
  86319. /**
  86320. * Gets or sets the maximal initial rotation in radians.
  86321. */
  86322. maxInitialRotation: number;
  86323. /**
  86324. * The particle emitter type defines the emitter used by the particle system.
  86325. * It can be for example box, sphere, or cone...
  86326. */
  86327. particleEmitterType: Nullable<IParticleEmitterType>;
  86328. /**
  86329. * Defines the delay in milliseconds before starting the system (0 by default)
  86330. */
  86331. startDelay: number;
  86332. /**
  86333. * 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
  86334. */
  86335. preWarmCycles: number;
  86336. /**
  86337. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86338. */
  86339. preWarmStepOffset: number;
  86340. /**
  86341. * 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)
  86342. */
  86343. spriteCellChangeSpeed: number;
  86344. /**
  86345. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86346. */
  86347. startSpriteCellID: number;
  86348. /**
  86349. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86350. */
  86351. endSpriteCellID: number;
  86352. /**
  86353. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86354. */
  86355. spriteCellWidth: number;
  86356. /**
  86357. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86358. */
  86359. spriteCellHeight: number;
  86360. /**
  86361. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86362. */
  86363. spriteRandomStartCell: boolean;
  86364. /**
  86365. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86366. */
  86367. isAnimationSheetEnabled: boolean;
  86368. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86369. translationPivot: Vector2;
  86370. /**
  86371. * Gets or sets a texture used to add random noise to particle positions
  86372. */
  86373. noiseTexture: Nullable<BaseTexture>;
  86374. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86375. noiseStrength: Vector3;
  86376. /**
  86377. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86378. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86379. */
  86380. billboardMode: number;
  86381. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86382. limitVelocityDamping: number;
  86383. /**
  86384. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86385. */
  86386. beginAnimationOnStart: boolean;
  86387. /**
  86388. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86389. */
  86390. beginAnimationFrom: number;
  86391. /**
  86392. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86393. */
  86394. beginAnimationTo: number;
  86395. /**
  86396. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86397. */
  86398. beginAnimationLoop: boolean;
  86399. /**
  86400. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86401. */
  86402. disposeOnStop: boolean;
  86403. /**
  86404. * Gets the maximum number of particles active at the same time.
  86405. * @returns The max number of active particles.
  86406. */
  86407. getCapacity(): number;
  86408. /**
  86409. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86410. * @returns True if it has been started, otherwise false.
  86411. */
  86412. isStarted(): boolean;
  86413. /**
  86414. * Animates the particle system for this frame.
  86415. */
  86416. animate(): void;
  86417. /**
  86418. * Renders the particle system in its current state.
  86419. * @returns the current number of particles
  86420. */
  86421. render(): number;
  86422. /**
  86423. * Dispose the particle system and frees its associated resources.
  86424. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86425. */
  86426. dispose(disposeTexture?: boolean): void;
  86427. /**
  86428. * Clones the particle system.
  86429. * @param name The name of the cloned object
  86430. * @param newEmitter The new emitter to use
  86431. * @returns the cloned particle system
  86432. */
  86433. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86434. /**
  86435. * Serializes the particle system to a JSON object.
  86436. * @returns the JSON object
  86437. */
  86438. serialize(): any;
  86439. /**
  86440. * Rebuild the particle system
  86441. */
  86442. rebuild(): void;
  86443. /**
  86444. * Starts the particle system and begins to emit
  86445. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86446. */
  86447. start(delay?: number): void;
  86448. /**
  86449. * Stops the particle system.
  86450. */
  86451. stop(): void;
  86452. /**
  86453. * Remove all active particles
  86454. */
  86455. reset(): void;
  86456. /**
  86457. * Is this system ready to be used/rendered
  86458. * @return true if the system is ready
  86459. */
  86460. isReady(): boolean;
  86461. /**
  86462. * Adds a new color gradient
  86463. * @param gradient defines the gradient to use (between 0 and 1)
  86464. * @param color1 defines the color to affect to the specified gradient
  86465. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86466. * @returns the current particle system
  86467. */
  86468. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86469. /**
  86470. * Remove a specific color gradient
  86471. * @param gradient defines the gradient to remove
  86472. * @returns the current particle system
  86473. */
  86474. removeColorGradient(gradient: number): IParticleSystem;
  86475. /**
  86476. * Adds a new size gradient
  86477. * @param gradient defines the gradient to use (between 0 and 1)
  86478. * @param factor defines the size factor to affect to the specified gradient
  86479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86480. * @returns the current particle system
  86481. */
  86482. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86483. /**
  86484. * Remove a specific size gradient
  86485. * @param gradient defines the gradient to remove
  86486. * @returns the current particle system
  86487. */
  86488. removeSizeGradient(gradient: number): IParticleSystem;
  86489. /**
  86490. * Gets the current list of color gradients.
  86491. * You must use addColorGradient and removeColorGradient to udpate this list
  86492. * @returns the list of color gradients
  86493. */
  86494. getColorGradients(): Nullable<Array<ColorGradient>>;
  86495. /**
  86496. * Gets the current list of size gradients.
  86497. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86498. * @returns the list of size gradients
  86499. */
  86500. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86501. /**
  86502. * Gets the current list of angular speed gradients.
  86503. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86504. * @returns the list of angular speed gradients
  86505. */
  86506. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86507. /**
  86508. * Adds a new angular speed gradient
  86509. * @param gradient defines the gradient to use (between 0 and 1)
  86510. * @param factor defines the angular speed to affect to the specified gradient
  86511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86512. * @returns the current particle system
  86513. */
  86514. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86515. /**
  86516. * Remove a specific angular speed gradient
  86517. * @param gradient defines the gradient to remove
  86518. * @returns the current particle system
  86519. */
  86520. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86521. /**
  86522. * Gets the current list of velocity gradients.
  86523. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86524. * @returns the list of velocity gradients
  86525. */
  86526. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86527. /**
  86528. * Adds a new velocity gradient
  86529. * @param gradient defines the gradient to use (between 0 and 1)
  86530. * @param factor defines the velocity to affect to the specified gradient
  86531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86532. * @returns the current particle system
  86533. */
  86534. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86535. /**
  86536. * Remove a specific velocity gradient
  86537. * @param gradient defines the gradient to remove
  86538. * @returns the current particle system
  86539. */
  86540. removeVelocityGradient(gradient: number): IParticleSystem;
  86541. /**
  86542. * Gets the current list of limit velocity gradients.
  86543. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86544. * @returns the list of limit velocity gradients
  86545. */
  86546. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86547. /**
  86548. * Adds a new limit velocity gradient
  86549. * @param gradient defines the gradient to use (between 0 and 1)
  86550. * @param factor defines the limit velocity to affect to the specified gradient
  86551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86552. * @returns the current particle system
  86553. */
  86554. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86555. /**
  86556. * Remove a specific limit velocity gradient
  86557. * @param gradient defines the gradient to remove
  86558. * @returns the current particle system
  86559. */
  86560. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86561. /**
  86562. * Adds a new drag gradient
  86563. * @param gradient defines the gradient to use (between 0 and 1)
  86564. * @param factor defines the drag to affect to the specified gradient
  86565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86566. * @returns the current particle system
  86567. */
  86568. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86569. /**
  86570. * Remove a specific drag gradient
  86571. * @param gradient defines the gradient to remove
  86572. * @returns the current particle system
  86573. */
  86574. removeDragGradient(gradient: number): IParticleSystem;
  86575. /**
  86576. * Gets the current list of drag gradients.
  86577. * You must use addDragGradient and removeDragGradient to udpate this list
  86578. * @returns the list of drag gradients
  86579. */
  86580. getDragGradients(): Nullable<Array<FactorGradient>>;
  86581. /**
  86582. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86583. * @param gradient defines the gradient to use (between 0 and 1)
  86584. * @param factor defines the emit rate to affect to the specified gradient
  86585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86586. * @returns the current particle system
  86587. */
  86588. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86589. /**
  86590. * Remove a specific emit rate gradient
  86591. * @param gradient defines the gradient to remove
  86592. * @returns the current particle system
  86593. */
  86594. removeEmitRateGradient(gradient: number): IParticleSystem;
  86595. /**
  86596. * Gets the current list of emit rate gradients.
  86597. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86598. * @returns the list of emit rate gradients
  86599. */
  86600. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86601. /**
  86602. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86603. * @param gradient defines the gradient to use (between 0 and 1)
  86604. * @param factor defines the start size to affect to the specified gradient
  86605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86606. * @returns the current particle system
  86607. */
  86608. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86609. /**
  86610. * Remove a specific start size gradient
  86611. * @param gradient defines the gradient to remove
  86612. * @returns the current particle system
  86613. */
  86614. removeStartSizeGradient(gradient: number): IParticleSystem;
  86615. /**
  86616. * Gets the current list of start size gradients.
  86617. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86618. * @returns the list of start size gradients
  86619. */
  86620. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86621. /**
  86622. * Adds a new life time gradient
  86623. * @param gradient defines the gradient to use (between 0 and 1)
  86624. * @param factor defines the life time factor to affect to the specified gradient
  86625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86626. * @returns the current particle system
  86627. */
  86628. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86629. /**
  86630. * Remove a specific life time gradient
  86631. * @param gradient defines the gradient to remove
  86632. * @returns the current particle system
  86633. */
  86634. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86635. /**
  86636. * Gets the current list of life time gradients.
  86637. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86638. * @returns the list of life time gradients
  86639. */
  86640. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86641. /**
  86642. * Gets the current list of color gradients.
  86643. * You must use addColorGradient and removeColorGradient to udpate this list
  86644. * @returns the list of color gradients
  86645. */
  86646. getColorGradients(): Nullable<Array<ColorGradient>>;
  86647. /**
  86648. * Adds a new ramp gradient used to remap particle colors
  86649. * @param gradient defines the gradient to use (between 0 and 1)
  86650. * @param color defines the color to affect to the specified gradient
  86651. * @returns the current particle system
  86652. */
  86653. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86654. /**
  86655. * Gets the current list of ramp gradients.
  86656. * You must use addRampGradient and removeRampGradient to udpate this list
  86657. * @returns the list of ramp gradients
  86658. */
  86659. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86660. /** Gets or sets a boolean indicating that ramp gradients must be used
  86661. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86662. */
  86663. useRampGradients: boolean;
  86664. /**
  86665. * Adds a new color remap gradient
  86666. * @param gradient defines the gradient to use (between 0 and 1)
  86667. * @param min defines the color remap minimal range
  86668. * @param max defines the color remap maximal range
  86669. * @returns the current particle system
  86670. */
  86671. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86672. /**
  86673. * Gets the current list of color remap gradients.
  86674. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86675. * @returns the list of color remap gradients
  86676. */
  86677. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86678. /**
  86679. * Adds a new alpha remap gradient
  86680. * @param gradient defines the gradient to use (between 0 and 1)
  86681. * @param min defines the alpha remap minimal range
  86682. * @param max defines the alpha remap maximal range
  86683. * @returns the current particle system
  86684. */
  86685. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86686. /**
  86687. * Gets the current list of alpha remap gradients.
  86688. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86689. * @returns the list of alpha remap gradients
  86690. */
  86691. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86692. /**
  86693. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86696. * @returns the emitter
  86697. */
  86698. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86699. /**
  86700. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86701. * @param radius The radius of the hemisphere to emit from
  86702. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86703. * @returns the emitter
  86704. */
  86705. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86706. /**
  86707. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86708. * @param radius The radius of the sphere to emit from
  86709. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86710. * @returns the emitter
  86711. */
  86712. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86713. /**
  86714. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86715. * @param radius The radius of the sphere to emit from
  86716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86718. * @returns the emitter
  86719. */
  86720. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86721. /**
  86722. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86723. * @param radius The radius of the emission cylinder
  86724. * @param height The height of the emission cylinder
  86725. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86726. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86727. * @returns the emitter
  86728. */
  86729. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86730. /**
  86731. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86732. * @param radius The radius of the cylinder to emit from
  86733. * @param height The height of the emission cylinder
  86734. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86735. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86736. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86737. * @returns the emitter
  86738. */
  86739. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86740. /**
  86741. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86742. * @param radius The radius of the cone to emit from
  86743. * @param angle The base angle of the cone
  86744. * @returns the emitter
  86745. */
  86746. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86747. /**
  86748. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86749. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86750. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86751. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86752. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86753. * @returns the emitter
  86754. */
  86755. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86756. /**
  86757. * Get hosting scene
  86758. * @returns the scene
  86759. */
  86760. getScene(): Scene;
  86761. }
  86762. }
  86763. declare module BABYLON {
  86764. /**
  86765. * Creates an instance based on a source mesh.
  86766. */
  86767. export class InstancedMesh extends AbstractMesh {
  86768. private _sourceMesh;
  86769. private _currentLOD;
  86770. /** @hidden */
  86771. _indexInSourceMeshInstanceArray: number;
  86772. constructor(name: string, source: Mesh);
  86773. /**
  86774. * Returns the string "InstancedMesh".
  86775. */
  86776. getClassName(): string;
  86777. /** Gets the list of lights affecting that mesh */
  86778. readonly lightSources: Light[];
  86779. _resyncLightSources(): void;
  86780. _resyncLighSource(light: Light): void;
  86781. _removeLightSource(light: Light, dispose: boolean): void;
  86782. /**
  86783. * If the source mesh receives shadows
  86784. */
  86785. readonly receiveShadows: boolean;
  86786. /**
  86787. * The material of the source mesh
  86788. */
  86789. readonly material: Nullable<Material>;
  86790. /**
  86791. * Visibility of the source mesh
  86792. */
  86793. readonly visibility: number;
  86794. /**
  86795. * Skeleton of the source mesh
  86796. */
  86797. readonly skeleton: Nullable<Skeleton>;
  86798. /**
  86799. * Rendering ground id of the source mesh
  86800. */
  86801. renderingGroupId: number;
  86802. /**
  86803. * Returns the total number of vertices (integer).
  86804. */
  86805. getTotalVertices(): number;
  86806. /**
  86807. * Returns a positive integer : the total number of indices in this mesh geometry.
  86808. * @returns the numner of indices or zero if the mesh has no geometry.
  86809. */
  86810. getTotalIndices(): number;
  86811. /**
  86812. * The source mesh of the instance
  86813. */
  86814. readonly sourceMesh: Mesh;
  86815. /**
  86816. * Is this node ready to be used/rendered
  86817. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86818. * @return {boolean} is it ready
  86819. */
  86820. isReady(completeCheck?: boolean): boolean;
  86821. /**
  86822. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86823. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86824. * @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.
  86825. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86826. */
  86827. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86828. /**
  86829. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86830. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86831. * The `data` are either a numeric array either a Float32Array.
  86832. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86833. * 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).
  86834. * Note that a new underlying VertexBuffer object is created each call.
  86835. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86836. *
  86837. * Possible `kind` values :
  86838. * - VertexBuffer.PositionKind
  86839. * - VertexBuffer.UVKind
  86840. * - VertexBuffer.UV2Kind
  86841. * - VertexBuffer.UV3Kind
  86842. * - VertexBuffer.UV4Kind
  86843. * - VertexBuffer.UV5Kind
  86844. * - VertexBuffer.UV6Kind
  86845. * - VertexBuffer.ColorKind
  86846. * - VertexBuffer.MatricesIndicesKind
  86847. * - VertexBuffer.MatricesIndicesExtraKind
  86848. * - VertexBuffer.MatricesWeightsKind
  86849. * - VertexBuffer.MatricesWeightsExtraKind
  86850. *
  86851. * Returns the Mesh.
  86852. */
  86853. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86854. /**
  86855. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86856. * If the mesh has no geometry, it is simply returned as it is.
  86857. * The `data` are either a numeric array either a Float32Array.
  86858. * No new underlying VertexBuffer object is created.
  86859. * 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.
  86860. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86861. *
  86862. * Possible `kind` values :
  86863. * - VertexBuffer.PositionKind
  86864. * - VertexBuffer.UVKind
  86865. * - VertexBuffer.UV2Kind
  86866. * - VertexBuffer.UV3Kind
  86867. * - VertexBuffer.UV4Kind
  86868. * - VertexBuffer.UV5Kind
  86869. * - VertexBuffer.UV6Kind
  86870. * - VertexBuffer.ColorKind
  86871. * - VertexBuffer.MatricesIndicesKind
  86872. * - VertexBuffer.MatricesIndicesExtraKind
  86873. * - VertexBuffer.MatricesWeightsKind
  86874. * - VertexBuffer.MatricesWeightsExtraKind
  86875. *
  86876. * Returns the Mesh.
  86877. */
  86878. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86879. /**
  86880. * Sets the mesh indices.
  86881. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86882. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86883. * This method creates a new index buffer each call.
  86884. * Returns the Mesh.
  86885. */
  86886. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86887. /**
  86888. * Boolean : True if the mesh owns the requested kind of data.
  86889. */
  86890. isVerticesDataPresent(kind: string): boolean;
  86891. /**
  86892. * Returns an array of indices (IndicesArray).
  86893. */
  86894. getIndices(): Nullable<IndicesArray>;
  86895. readonly _positions: Nullable<Vector3[]>;
  86896. /**
  86897. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86898. * This means the mesh underlying bounding box and sphere are recomputed.
  86899. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86900. * @returns the current mesh
  86901. */
  86902. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86903. /** @hidden */
  86904. _preActivate(): InstancedMesh;
  86905. /** @hidden */
  86906. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86907. /** @hidden */
  86908. _postActivate(): void;
  86909. getWorldMatrix(): Matrix;
  86910. readonly isAnInstance: boolean;
  86911. /**
  86912. * Returns the current associated LOD AbstractMesh.
  86913. */
  86914. getLOD(camera: Camera): AbstractMesh;
  86915. /** @hidden */
  86916. _syncSubMeshes(): InstancedMesh;
  86917. /** @hidden */
  86918. _generatePointsArray(): boolean;
  86919. /**
  86920. * Creates a new InstancedMesh from the current mesh.
  86921. * - name (string) : the cloned mesh name
  86922. * - newParent (optional Node) : the optional Node to parent the clone to.
  86923. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86924. *
  86925. * Returns the clone.
  86926. */
  86927. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86928. /**
  86929. * Disposes the InstancedMesh.
  86930. * Returns nothing.
  86931. */
  86932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86933. }
  86934. interface Mesh {
  86935. /**
  86936. * Register a custom buffer that will be instanced
  86937. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86938. * @param kind defines the buffer kind
  86939. * @param stride defines the stride in floats
  86940. */
  86941. registerInstancedBuffer(kind: string, stride: number): void;
  86942. /** @hidden */
  86943. _userInstancedBuffersStorage: {
  86944. data: {
  86945. [key: string]: Float32Array;
  86946. };
  86947. sizes: {
  86948. [key: string]: number;
  86949. };
  86950. vertexBuffers: {
  86951. [key: string]: Nullable<VertexBuffer>;
  86952. };
  86953. strides: {
  86954. [key: string]: number;
  86955. };
  86956. };
  86957. }
  86958. interface AbstractMesh {
  86959. /**
  86960. * Object used to store instanced buffers defined by user
  86961. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86962. */
  86963. instancedBuffers: {
  86964. [key: string]: any;
  86965. };
  86966. }
  86967. }
  86968. declare module BABYLON {
  86969. /**
  86970. * Defines the options associated with the creation of a shader material.
  86971. */
  86972. export interface IShaderMaterialOptions {
  86973. /**
  86974. * Does the material work in alpha blend mode
  86975. */
  86976. needAlphaBlending: boolean;
  86977. /**
  86978. * Does the material work in alpha test mode
  86979. */
  86980. needAlphaTesting: boolean;
  86981. /**
  86982. * The list of attribute names used in the shader
  86983. */
  86984. attributes: string[];
  86985. /**
  86986. * The list of unifrom names used in the shader
  86987. */
  86988. uniforms: string[];
  86989. /**
  86990. * The list of UBO names used in the shader
  86991. */
  86992. uniformBuffers: string[];
  86993. /**
  86994. * The list of sampler names used in the shader
  86995. */
  86996. samplers: string[];
  86997. /**
  86998. * The list of defines used in the shader
  86999. */
  87000. defines: string[];
  87001. }
  87002. /**
  87003. * 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.
  87004. *
  87005. * This returned material effects how the mesh will look based on the code in the shaders.
  87006. *
  87007. * @see http://doc.babylonjs.com/how_to/shader_material
  87008. */
  87009. export class ShaderMaterial extends Material {
  87010. private _shaderPath;
  87011. private _options;
  87012. private _textures;
  87013. private _textureArrays;
  87014. private _floats;
  87015. private _ints;
  87016. private _floatsArrays;
  87017. private _colors3;
  87018. private _colors3Arrays;
  87019. private _colors4;
  87020. private _colors4Arrays;
  87021. private _vectors2;
  87022. private _vectors3;
  87023. private _vectors4;
  87024. private _matrices;
  87025. private _matrices3x3;
  87026. private _matrices2x2;
  87027. private _vectors2Arrays;
  87028. private _vectors3Arrays;
  87029. private _vectors4Arrays;
  87030. private _cachedWorldViewMatrix;
  87031. private _cachedWorldViewProjectionMatrix;
  87032. private _renderId;
  87033. /**
  87034. * Instantiate a new shader material.
  87035. * 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.
  87036. * This returned material effects how the mesh will look based on the code in the shaders.
  87037. * @see http://doc.babylonjs.com/how_to/shader_material
  87038. * @param name Define the name of the material in the scene
  87039. * @param scene Define the scene the material belongs to
  87040. * @param shaderPath Defines the route to the shader code in one of three ways:
  87041. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87042. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87043. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87044. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87045. * @param options Define the options used to create the shader
  87046. */
  87047. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87048. /**
  87049. * Gets the options used to compile the shader.
  87050. * They can be modified to trigger a new compilation
  87051. */
  87052. readonly options: IShaderMaterialOptions;
  87053. /**
  87054. * Gets the current class name of the material e.g. "ShaderMaterial"
  87055. * Mainly use in serialization.
  87056. * @returns the class name
  87057. */
  87058. getClassName(): string;
  87059. /**
  87060. * Specifies if the material will require alpha blending
  87061. * @returns a boolean specifying if alpha blending is needed
  87062. */
  87063. needAlphaBlending(): boolean;
  87064. /**
  87065. * Specifies if this material should be rendered in alpha test mode
  87066. * @returns a boolean specifying if an alpha test is needed.
  87067. */
  87068. needAlphaTesting(): boolean;
  87069. private _checkUniform;
  87070. /**
  87071. * Set a texture in the shader.
  87072. * @param name Define the name of the uniform samplers as defined in the shader
  87073. * @param texture Define the texture to bind to this sampler
  87074. * @return the material itself allowing "fluent" like uniform updates
  87075. */
  87076. setTexture(name: string, texture: Texture): ShaderMaterial;
  87077. /**
  87078. * Set a texture array in the shader.
  87079. * @param name Define the name of the uniform sampler array as defined in the shader
  87080. * @param textures Define the list of textures to bind to this sampler
  87081. * @return the material itself allowing "fluent" like uniform updates
  87082. */
  87083. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87084. /**
  87085. * Set a float in the shader.
  87086. * @param name Define the name of the uniform as defined in the shader
  87087. * @param value Define the value to give to the uniform
  87088. * @return the material itself allowing "fluent" like uniform updates
  87089. */
  87090. setFloat(name: string, value: number): ShaderMaterial;
  87091. /**
  87092. * Set a int in the shader.
  87093. * @param name Define the name of the uniform as defined in the shader
  87094. * @param value Define the value to give to the uniform
  87095. * @return the material itself allowing "fluent" like uniform updates
  87096. */
  87097. setInt(name: string, value: number): ShaderMaterial;
  87098. /**
  87099. * Set an array of floats in the shader.
  87100. * @param name Define the name of the uniform as defined in the shader
  87101. * @param value Define the value to give to the uniform
  87102. * @return the material itself allowing "fluent" like uniform updates
  87103. */
  87104. setFloats(name: string, value: number[]): ShaderMaterial;
  87105. /**
  87106. * Set a vec3 in the shader from a Color3.
  87107. * @param name Define the name of the uniform as defined in the shader
  87108. * @param value Define the value to give to the uniform
  87109. * @return the material itself allowing "fluent" like uniform updates
  87110. */
  87111. setColor3(name: string, value: Color3): ShaderMaterial;
  87112. /**
  87113. * Set a vec3 array in the shader from a Color3 array.
  87114. * @param name Define the name of the uniform as defined in the shader
  87115. * @param value Define the value to give to the uniform
  87116. * @return the material itself allowing "fluent" like uniform updates
  87117. */
  87118. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87119. /**
  87120. * Set a vec4 in the shader from a Color4.
  87121. * @param name Define the name of the uniform as defined in the shader
  87122. * @param value Define the value to give to the uniform
  87123. * @return the material itself allowing "fluent" like uniform updates
  87124. */
  87125. setColor4(name: string, value: Color4): ShaderMaterial;
  87126. /**
  87127. * Set a vec4 array in the shader from a Color4 array.
  87128. * @param name Define the name of the uniform as defined in the shader
  87129. * @param value Define the value to give to the uniform
  87130. * @return the material itself allowing "fluent" like uniform updates
  87131. */
  87132. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87133. /**
  87134. * Set a vec2 in the shader from a Vector2.
  87135. * @param name Define the name of the uniform as defined in the shader
  87136. * @param value Define the value to give to the uniform
  87137. * @return the material itself allowing "fluent" like uniform updates
  87138. */
  87139. setVector2(name: string, value: Vector2): ShaderMaterial;
  87140. /**
  87141. * Set a vec3 in the shader from a Vector3.
  87142. * @param name Define the name of the uniform as defined in the shader
  87143. * @param value Define the value to give to the uniform
  87144. * @return the material itself allowing "fluent" like uniform updates
  87145. */
  87146. setVector3(name: string, value: Vector3): ShaderMaterial;
  87147. /**
  87148. * Set a vec4 in the shader from a Vector4.
  87149. * @param name Define the name of the uniform as defined in the shader
  87150. * @param value Define the value to give to the uniform
  87151. * @return the material itself allowing "fluent" like uniform updates
  87152. */
  87153. setVector4(name: string, value: Vector4): ShaderMaterial;
  87154. /**
  87155. * Set a mat4 in the shader from a Matrix.
  87156. * @param name Define the name of the uniform as defined in the shader
  87157. * @param value Define the value to give to the uniform
  87158. * @return the material itself allowing "fluent" like uniform updates
  87159. */
  87160. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87161. /**
  87162. * Set a mat3 in the shader from a Float32Array.
  87163. * @param name Define the name of the uniform as defined in the shader
  87164. * @param value Define the value to give to the uniform
  87165. * @return the material itself allowing "fluent" like uniform updates
  87166. */
  87167. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87168. /**
  87169. * Set a mat2 in the shader from a Float32Array.
  87170. * @param name Define the name of the uniform as defined in the shader
  87171. * @param value Define the value to give to the uniform
  87172. * @return the material itself allowing "fluent" like uniform updates
  87173. */
  87174. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87175. /**
  87176. * Set a vec2 array in the shader from a number array.
  87177. * @param name Define the name of the uniform as defined in the shader
  87178. * @param value Define the value to give to the uniform
  87179. * @return the material itself allowing "fluent" like uniform updates
  87180. */
  87181. setArray2(name: string, value: number[]): ShaderMaterial;
  87182. /**
  87183. * Set a vec3 array in the shader from a number array.
  87184. * @param name Define the name of the uniform as defined in the shader
  87185. * @param value Define the value to give to the uniform
  87186. * @return the material itself allowing "fluent" like uniform updates
  87187. */
  87188. setArray3(name: string, value: number[]): ShaderMaterial;
  87189. /**
  87190. * Set a vec4 array in the shader from a number array.
  87191. * @param name Define the name of the uniform as defined in the shader
  87192. * @param value Define the value to give to the uniform
  87193. * @return the material itself allowing "fluent" like uniform updates
  87194. */
  87195. setArray4(name: string, value: number[]): ShaderMaterial;
  87196. private _checkCache;
  87197. /**
  87198. * Specifies that the submesh is ready to be used
  87199. * @param mesh defines the mesh to check
  87200. * @param subMesh defines which submesh to check
  87201. * @param useInstances specifies that instances should be used
  87202. * @returns a boolean indicating that the submesh is ready or not
  87203. */
  87204. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87205. /**
  87206. * Checks if the material is ready to render the requested mesh
  87207. * @param mesh Define the mesh to render
  87208. * @param useInstances Define whether or not the material is used with instances
  87209. * @returns true if ready, otherwise false
  87210. */
  87211. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87212. /**
  87213. * Binds the world matrix to the material
  87214. * @param world defines the world transformation matrix
  87215. */
  87216. bindOnlyWorldMatrix(world: Matrix): void;
  87217. /**
  87218. * Binds the material to the mesh
  87219. * @param world defines the world transformation matrix
  87220. * @param mesh defines the mesh to bind the material to
  87221. */
  87222. bind(world: Matrix, mesh?: Mesh): void;
  87223. /**
  87224. * Gets the active textures from the material
  87225. * @returns an array of textures
  87226. */
  87227. getActiveTextures(): BaseTexture[];
  87228. /**
  87229. * Specifies if the material uses a texture
  87230. * @param texture defines the texture to check against the material
  87231. * @returns a boolean specifying if the material uses the texture
  87232. */
  87233. hasTexture(texture: BaseTexture): boolean;
  87234. /**
  87235. * Makes a duplicate of the material, and gives it a new name
  87236. * @param name defines the new name for the duplicated material
  87237. * @returns the cloned material
  87238. */
  87239. clone(name: string): ShaderMaterial;
  87240. /**
  87241. * Disposes the material
  87242. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87243. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87244. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87245. */
  87246. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87247. /**
  87248. * Serializes this material in a JSON representation
  87249. * @returns the serialized material object
  87250. */
  87251. serialize(): any;
  87252. /**
  87253. * Creates a shader material from parsed shader material data
  87254. * @param source defines the JSON represnetation of the material
  87255. * @param scene defines the hosting scene
  87256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87257. * @returns a new material
  87258. */
  87259. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87260. }
  87261. }
  87262. declare module BABYLON {
  87263. /** @hidden */
  87264. export var colorPixelShader: {
  87265. name: string;
  87266. shader: string;
  87267. };
  87268. }
  87269. declare module BABYLON {
  87270. /** @hidden */
  87271. export var colorVertexShader: {
  87272. name: string;
  87273. shader: string;
  87274. };
  87275. }
  87276. declare module BABYLON {
  87277. /**
  87278. * Line mesh
  87279. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87280. */
  87281. export class LinesMesh extends Mesh {
  87282. /**
  87283. * If vertex color should be applied to the mesh
  87284. */
  87285. readonly useVertexColor?: boolean | undefined;
  87286. /**
  87287. * If vertex alpha should be applied to the mesh
  87288. */
  87289. readonly useVertexAlpha?: boolean | undefined;
  87290. /**
  87291. * Color of the line (Default: White)
  87292. */
  87293. color: Color3;
  87294. /**
  87295. * Alpha of the line (Default: 1)
  87296. */
  87297. alpha: number;
  87298. /**
  87299. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87300. * This margin is expressed in world space coordinates, so its value may vary.
  87301. * Default value is 0.1
  87302. */
  87303. intersectionThreshold: number;
  87304. private _colorShader;
  87305. private color4;
  87306. /**
  87307. * Creates a new LinesMesh
  87308. * @param name defines the name
  87309. * @param scene defines the hosting scene
  87310. * @param parent defines the parent mesh if any
  87311. * @param source defines the optional source LinesMesh used to clone data from
  87312. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87313. * When false, achieved by calling a clone(), also passing False.
  87314. * This will make creation of children, recursive.
  87315. * @param useVertexColor defines if this LinesMesh supports vertex color
  87316. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87317. */
  87318. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87319. /**
  87320. * If vertex color should be applied to the mesh
  87321. */
  87322. useVertexColor?: boolean | undefined,
  87323. /**
  87324. * If vertex alpha should be applied to the mesh
  87325. */
  87326. useVertexAlpha?: boolean | undefined);
  87327. private _addClipPlaneDefine;
  87328. private _removeClipPlaneDefine;
  87329. isReady(): boolean;
  87330. /**
  87331. * Returns the string "LineMesh"
  87332. */
  87333. getClassName(): string;
  87334. /**
  87335. * @hidden
  87336. */
  87337. /**
  87338. * @hidden
  87339. */
  87340. material: Material;
  87341. /**
  87342. * @hidden
  87343. */
  87344. readonly checkCollisions: boolean;
  87345. /** @hidden */
  87346. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87347. /** @hidden */
  87348. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87349. /**
  87350. * Disposes of the line mesh
  87351. * @param doNotRecurse If children should be disposed
  87352. */
  87353. dispose(doNotRecurse?: boolean): void;
  87354. /**
  87355. * Returns a new LineMesh object cloned from the current one.
  87356. */
  87357. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87358. /**
  87359. * Creates a new InstancedLinesMesh object from the mesh model.
  87360. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87361. * @param name defines the name of the new instance
  87362. * @returns a new InstancedLinesMesh
  87363. */
  87364. createInstance(name: string): InstancedLinesMesh;
  87365. }
  87366. /**
  87367. * Creates an instance based on a source LinesMesh
  87368. */
  87369. export class InstancedLinesMesh extends InstancedMesh {
  87370. /**
  87371. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87372. * This margin is expressed in world space coordinates, so its value may vary.
  87373. * Initilized with the intersectionThreshold value of the source LinesMesh
  87374. */
  87375. intersectionThreshold: number;
  87376. constructor(name: string, source: LinesMesh);
  87377. /**
  87378. * Returns the string "InstancedLinesMesh".
  87379. */
  87380. getClassName(): string;
  87381. }
  87382. }
  87383. declare module BABYLON {
  87384. /** @hidden */
  87385. export var linePixelShader: {
  87386. name: string;
  87387. shader: string;
  87388. };
  87389. }
  87390. declare module BABYLON {
  87391. /** @hidden */
  87392. export var lineVertexShader: {
  87393. name: string;
  87394. shader: string;
  87395. };
  87396. }
  87397. declare module BABYLON {
  87398. interface AbstractMesh {
  87399. /**
  87400. * Gets the edgesRenderer associated with the mesh
  87401. */
  87402. edgesRenderer: Nullable<EdgesRenderer>;
  87403. }
  87404. interface LinesMesh {
  87405. /**
  87406. * Enables the edge rendering mode on the mesh.
  87407. * This mode makes the mesh edges visible
  87408. * @param epsilon defines the maximal distance between two angles to detect a face
  87409. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87410. * @returns the currentAbstractMesh
  87411. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87412. */
  87413. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87414. }
  87415. interface InstancedLinesMesh {
  87416. /**
  87417. * Enables the edge rendering mode on the mesh.
  87418. * This mode makes the mesh edges visible
  87419. * @param epsilon defines the maximal distance between two angles to detect a face
  87420. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87421. * @returns the current InstancedLinesMesh
  87422. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87423. */
  87424. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87425. }
  87426. /**
  87427. * Defines the minimum contract an Edges renderer should follow.
  87428. */
  87429. export interface IEdgesRenderer extends IDisposable {
  87430. /**
  87431. * Gets or sets a boolean indicating if the edgesRenderer is active
  87432. */
  87433. isEnabled: boolean;
  87434. /**
  87435. * Renders the edges of the attached mesh,
  87436. */
  87437. render(): void;
  87438. /**
  87439. * Checks wether or not the edges renderer is ready to render.
  87440. * @return true if ready, otherwise false.
  87441. */
  87442. isReady(): boolean;
  87443. }
  87444. /**
  87445. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87446. */
  87447. export class EdgesRenderer implements IEdgesRenderer {
  87448. /**
  87449. * Define the size of the edges with an orthographic camera
  87450. */
  87451. edgesWidthScalerForOrthographic: number;
  87452. /**
  87453. * Define the size of the edges with a perspective camera
  87454. */
  87455. edgesWidthScalerForPerspective: number;
  87456. protected _source: AbstractMesh;
  87457. protected _linesPositions: number[];
  87458. protected _linesNormals: number[];
  87459. protected _linesIndices: number[];
  87460. protected _epsilon: number;
  87461. protected _indicesCount: number;
  87462. protected _lineShader: ShaderMaterial;
  87463. protected _ib: DataBuffer;
  87464. protected _buffers: {
  87465. [key: string]: Nullable<VertexBuffer>;
  87466. };
  87467. protected _checkVerticesInsteadOfIndices: boolean;
  87468. private _meshRebuildObserver;
  87469. private _meshDisposeObserver;
  87470. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87471. isEnabled: boolean;
  87472. /**
  87473. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87474. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87475. * @param source Mesh used to create edges
  87476. * @param epsilon sum of angles in adjacency to check for edge
  87477. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87478. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87479. */
  87480. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87481. protected _prepareRessources(): void;
  87482. /** @hidden */
  87483. _rebuild(): void;
  87484. /**
  87485. * Releases the required resources for the edges renderer
  87486. */
  87487. dispose(): void;
  87488. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87489. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87490. /**
  87491. * Checks if the pair of p0 and p1 is en edge
  87492. * @param faceIndex
  87493. * @param edge
  87494. * @param faceNormals
  87495. * @param p0
  87496. * @param p1
  87497. * @private
  87498. */
  87499. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87500. /**
  87501. * push line into the position, normal and index buffer
  87502. * @protected
  87503. */
  87504. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87505. /**
  87506. * Generates lines edges from adjacencjes
  87507. * @private
  87508. */
  87509. _generateEdgesLines(): void;
  87510. /**
  87511. * Checks wether or not the edges renderer is ready to render.
  87512. * @return true if ready, otherwise false.
  87513. */
  87514. isReady(): boolean;
  87515. /**
  87516. * Renders the edges of the attached mesh,
  87517. */
  87518. render(): void;
  87519. }
  87520. /**
  87521. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87522. */
  87523. export class LineEdgesRenderer extends EdgesRenderer {
  87524. /**
  87525. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87526. * @param source LineMesh used to generate edges
  87527. * @param epsilon not important (specified angle for edge detection)
  87528. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87529. */
  87530. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87531. /**
  87532. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87533. */
  87534. _generateEdgesLines(): void;
  87535. }
  87536. }
  87537. declare module BABYLON {
  87538. /**
  87539. * This represents the object necessary to create a rendering group.
  87540. * This is exclusively used and created by the rendering manager.
  87541. * To modify the behavior, you use the available helpers in your scene or meshes.
  87542. * @hidden
  87543. */
  87544. export class RenderingGroup {
  87545. index: number;
  87546. private static _zeroVector;
  87547. private _scene;
  87548. private _opaqueSubMeshes;
  87549. private _transparentSubMeshes;
  87550. private _alphaTestSubMeshes;
  87551. private _depthOnlySubMeshes;
  87552. private _particleSystems;
  87553. private _spriteManagers;
  87554. private _opaqueSortCompareFn;
  87555. private _alphaTestSortCompareFn;
  87556. private _transparentSortCompareFn;
  87557. private _renderOpaque;
  87558. private _renderAlphaTest;
  87559. private _renderTransparent;
  87560. /** @hidden */
  87561. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87562. onBeforeTransparentRendering: () => void;
  87563. /**
  87564. * Set the opaque sort comparison function.
  87565. * If null the sub meshes will be render in the order they were created
  87566. */
  87567. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87568. /**
  87569. * Set the alpha test sort comparison function.
  87570. * If null the sub meshes will be render in the order they were created
  87571. */
  87572. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87573. /**
  87574. * Set the transparent sort comparison function.
  87575. * If null the sub meshes will be render in the order they were created
  87576. */
  87577. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87578. /**
  87579. * Creates a new rendering group.
  87580. * @param index The rendering group index
  87581. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87582. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87583. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87584. */
  87585. 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>);
  87586. /**
  87587. * Render all the sub meshes contained in the group.
  87588. * @param customRenderFunction Used to override the default render behaviour of the group.
  87589. * @returns true if rendered some submeshes.
  87590. */
  87591. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87592. /**
  87593. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87594. * @param subMeshes The submeshes to render
  87595. */
  87596. private renderOpaqueSorted;
  87597. /**
  87598. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87599. * @param subMeshes The submeshes to render
  87600. */
  87601. private renderAlphaTestSorted;
  87602. /**
  87603. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87604. * @param subMeshes The submeshes to render
  87605. */
  87606. private renderTransparentSorted;
  87607. /**
  87608. * Renders the submeshes in a specified order.
  87609. * @param subMeshes The submeshes to sort before render
  87610. * @param sortCompareFn The comparison function use to sort
  87611. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87612. * @param transparent Specifies to activate blending if true
  87613. */
  87614. private static renderSorted;
  87615. /**
  87616. * Renders the submeshes in the order they were dispatched (no sort applied).
  87617. * @param subMeshes The submeshes to render
  87618. */
  87619. private static renderUnsorted;
  87620. /**
  87621. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87622. * are rendered back to front if in the same alpha index.
  87623. *
  87624. * @param a The first submesh
  87625. * @param b The second submesh
  87626. * @returns The result of the comparison
  87627. */
  87628. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87629. /**
  87630. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87631. * are rendered back to front.
  87632. *
  87633. * @param a The first submesh
  87634. * @param b The second submesh
  87635. * @returns The result of the comparison
  87636. */
  87637. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87638. /**
  87639. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87640. * are rendered front to back (prevent overdraw).
  87641. *
  87642. * @param a The first submesh
  87643. * @param b The second submesh
  87644. * @returns The result of the comparison
  87645. */
  87646. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87647. /**
  87648. * Resets the different lists of submeshes to prepare a new frame.
  87649. */
  87650. prepare(): void;
  87651. dispose(): void;
  87652. /**
  87653. * Inserts the submesh in its correct queue depending on its material.
  87654. * @param subMesh The submesh to dispatch
  87655. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87656. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87657. */
  87658. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87659. dispatchSprites(spriteManager: ISpriteManager): void;
  87660. dispatchParticles(particleSystem: IParticleSystem): void;
  87661. private _renderParticles;
  87662. private _renderSprites;
  87663. }
  87664. }
  87665. declare module BABYLON {
  87666. /**
  87667. * Interface describing the different options available in the rendering manager
  87668. * regarding Auto Clear between groups.
  87669. */
  87670. export interface IRenderingManagerAutoClearSetup {
  87671. /**
  87672. * Defines whether or not autoclear is enable.
  87673. */
  87674. autoClear: boolean;
  87675. /**
  87676. * Defines whether or not to autoclear the depth buffer.
  87677. */
  87678. depth: boolean;
  87679. /**
  87680. * Defines whether or not to autoclear the stencil buffer.
  87681. */
  87682. stencil: boolean;
  87683. }
  87684. /**
  87685. * This class is used by the onRenderingGroupObservable
  87686. */
  87687. export class RenderingGroupInfo {
  87688. /**
  87689. * The Scene that being rendered
  87690. */
  87691. scene: Scene;
  87692. /**
  87693. * The camera currently used for the rendering pass
  87694. */
  87695. camera: Nullable<Camera>;
  87696. /**
  87697. * The ID of the renderingGroup being processed
  87698. */
  87699. renderingGroupId: number;
  87700. }
  87701. /**
  87702. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87703. * It is enable to manage the different groups as well as the different necessary sort functions.
  87704. * This should not be used directly aside of the few static configurations
  87705. */
  87706. export class RenderingManager {
  87707. /**
  87708. * The max id used for rendering groups (not included)
  87709. */
  87710. static MAX_RENDERINGGROUPS: number;
  87711. /**
  87712. * The min id used for rendering groups (included)
  87713. */
  87714. static MIN_RENDERINGGROUPS: number;
  87715. /**
  87716. * Used to globally prevent autoclearing scenes.
  87717. */
  87718. static AUTOCLEAR: boolean;
  87719. /**
  87720. * @hidden
  87721. */
  87722. _useSceneAutoClearSetup: boolean;
  87723. private _scene;
  87724. private _renderingGroups;
  87725. private _depthStencilBufferAlreadyCleaned;
  87726. private _autoClearDepthStencil;
  87727. private _customOpaqueSortCompareFn;
  87728. private _customAlphaTestSortCompareFn;
  87729. private _customTransparentSortCompareFn;
  87730. private _renderingGroupInfo;
  87731. /**
  87732. * Instantiates a new rendering group for a particular scene
  87733. * @param scene Defines the scene the groups belongs to
  87734. */
  87735. constructor(scene: Scene);
  87736. private _clearDepthStencilBuffer;
  87737. /**
  87738. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87739. * @hidden
  87740. */
  87741. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87742. /**
  87743. * Resets the different information of the group to prepare a new frame
  87744. * @hidden
  87745. */
  87746. reset(): void;
  87747. /**
  87748. * Dispose and release the group and its associated resources.
  87749. * @hidden
  87750. */
  87751. dispose(): void;
  87752. /**
  87753. * Clear the info related to rendering groups preventing retention points during dispose.
  87754. */
  87755. freeRenderingGroups(): void;
  87756. private _prepareRenderingGroup;
  87757. /**
  87758. * Add a sprite manager to the rendering manager in order to render it this frame.
  87759. * @param spriteManager Define the sprite manager to render
  87760. */
  87761. dispatchSprites(spriteManager: ISpriteManager): void;
  87762. /**
  87763. * Add a particle system to the rendering manager in order to render it this frame.
  87764. * @param particleSystem Define the particle system to render
  87765. */
  87766. dispatchParticles(particleSystem: IParticleSystem): void;
  87767. /**
  87768. * Add a submesh to the manager in order to render it this frame
  87769. * @param subMesh The submesh to dispatch
  87770. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87771. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87772. */
  87773. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87774. /**
  87775. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87776. * This allowed control for front to back rendering or reversly depending of the special needs.
  87777. *
  87778. * @param renderingGroupId The rendering group id corresponding to its index
  87779. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87780. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87781. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87782. */
  87783. 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;
  87784. /**
  87785. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87786. *
  87787. * @param renderingGroupId The rendering group id corresponding to its index
  87788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87789. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87790. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87791. */
  87792. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87793. /**
  87794. * Gets the current auto clear configuration for one rendering group of the rendering
  87795. * manager.
  87796. * @param index the rendering group index to get the information for
  87797. * @returns The auto clear setup for the requested rendering group
  87798. */
  87799. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87800. }
  87801. }
  87802. declare module BABYLON {
  87803. /**
  87804. * This Helps creating a texture that will be created from a camera in your scene.
  87805. * It is basically a dynamic texture that could be used to create special effects for instance.
  87806. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87807. */
  87808. export class RenderTargetTexture extends Texture {
  87809. isCube: boolean;
  87810. /**
  87811. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87812. */
  87813. static readonly REFRESHRATE_RENDER_ONCE: number;
  87814. /**
  87815. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87816. */
  87817. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87818. /**
  87819. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87820. * the central point of your effect and can save a lot of performances.
  87821. */
  87822. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87823. /**
  87824. * Use this predicate to dynamically define the list of mesh you want to render.
  87825. * If set, the renderList property will be overwritten.
  87826. */
  87827. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87828. private _renderList;
  87829. /**
  87830. * Use this list to define the list of mesh you want to render.
  87831. */
  87832. renderList: Nullable<Array<AbstractMesh>>;
  87833. private _hookArray;
  87834. /**
  87835. * Define if particles should be rendered in your texture.
  87836. */
  87837. renderParticles: boolean;
  87838. /**
  87839. * Define if sprites should be rendered in your texture.
  87840. */
  87841. renderSprites: boolean;
  87842. /**
  87843. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87844. */
  87845. coordinatesMode: number;
  87846. /**
  87847. * Define the camera used to render the texture.
  87848. */
  87849. activeCamera: Nullable<Camera>;
  87850. /**
  87851. * Override the render function of the texture with your own one.
  87852. */
  87853. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87854. /**
  87855. * Define if camera post processes should be use while rendering the texture.
  87856. */
  87857. useCameraPostProcesses: boolean;
  87858. /**
  87859. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87860. */
  87861. ignoreCameraViewport: boolean;
  87862. private _postProcessManager;
  87863. private _postProcesses;
  87864. private _resizeObserver;
  87865. /**
  87866. * An event triggered when the texture is unbind.
  87867. */
  87868. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87869. /**
  87870. * An event triggered when the texture is unbind.
  87871. */
  87872. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87873. private _onAfterUnbindObserver;
  87874. /**
  87875. * Set a after unbind callback in the texture.
  87876. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87877. */
  87878. onAfterUnbind: () => void;
  87879. /**
  87880. * An event triggered before rendering the texture
  87881. */
  87882. onBeforeRenderObservable: Observable<number>;
  87883. private _onBeforeRenderObserver;
  87884. /**
  87885. * Set a before render callback in the texture.
  87886. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87887. */
  87888. onBeforeRender: (faceIndex: number) => void;
  87889. /**
  87890. * An event triggered after rendering the texture
  87891. */
  87892. onAfterRenderObservable: Observable<number>;
  87893. private _onAfterRenderObserver;
  87894. /**
  87895. * Set a after render callback in the texture.
  87896. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87897. */
  87898. onAfterRender: (faceIndex: number) => void;
  87899. /**
  87900. * An event triggered after the texture clear
  87901. */
  87902. onClearObservable: Observable<Engine>;
  87903. private _onClearObserver;
  87904. /**
  87905. * Set a clear callback in the texture.
  87906. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87907. */
  87908. onClear: (Engine: Engine) => void;
  87909. /**
  87910. * An event triggered when the texture is resized.
  87911. */
  87912. onResizeObservable: Observable<RenderTargetTexture>;
  87913. /**
  87914. * Define the clear color of the Render Target if it should be different from the scene.
  87915. */
  87916. clearColor: Color4;
  87917. protected _size: number | {
  87918. width: number;
  87919. height: number;
  87920. };
  87921. protected _initialSizeParameter: number | {
  87922. width: number;
  87923. height: number;
  87924. } | {
  87925. ratio: number;
  87926. };
  87927. protected _sizeRatio: Nullable<number>;
  87928. /** @hidden */
  87929. _generateMipMaps: boolean;
  87930. protected _renderingManager: RenderingManager;
  87931. /** @hidden */
  87932. _waitingRenderList: string[];
  87933. protected _doNotChangeAspectRatio: boolean;
  87934. protected _currentRefreshId: number;
  87935. protected _refreshRate: number;
  87936. protected _textureMatrix: Matrix;
  87937. protected _samples: number;
  87938. protected _renderTargetOptions: RenderTargetCreationOptions;
  87939. /**
  87940. * Gets render target creation options that were used.
  87941. */
  87942. readonly renderTargetOptions: RenderTargetCreationOptions;
  87943. protected _engine: Engine;
  87944. protected _onRatioRescale(): void;
  87945. /**
  87946. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87947. * It must define where the camera used to render the texture is set
  87948. */
  87949. boundingBoxPosition: Vector3;
  87950. private _boundingBoxSize;
  87951. /**
  87952. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87953. * When defined, the cubemap will switch to local mode
  87954. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87955. * @example https://www.babylonjs-playground.com/#RNASML
  87956. */
  87957. boundingBoxSize: Vector3;
  87958. /**
  87959. * In case the RTT has been created with a depth texture, get the associated
  87960. * depth texture.
  87961. * Otherwise, return null.
  87962. */
  87963. depthStencilTexture: Nullable<InternalTexture>;
  87964. /**
  87965. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87966. * or used a shadow, depth texture...
  87967. * @param name The friendly name of the texture
  87968. * @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)
  87969. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87970. * @param generateMipMaps True if mip maps need to be generated after render.
  87971. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87972. * @param type The type of the buffer in the RTT (int, half float, float...)
  87973. * @param isCube True if a cube texture needs to be created
  87974. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87975. * @param generateDepthBuffer True to generate a depth buffer
  87976. * @param generateStencilBuffer True to generate a stencil buffer
  87977. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87978. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87979. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87980. */
  87981. constructor(name: string, size: number | {
  87982. width: number;
  87983. height: number;
  87984. } | {
  87985. ratio: number;
  87986. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87987. /**
  87988. * Creates a depth stencil texture.
  87989. * This is only available in WebGL 2 or with the depth texture extension available.
  87990. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87991. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87992. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87993. */
  87994. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87995. private _processSizeParameter;
  87996. /**
  87997. * Define the number of samples to use in case of MSAA.
  87998. * It defaults to one meaning no MSAA has been enabled.
  87999. */
  88000. samples: number;
  88001. /**
  88002. * Resets the refresh counter of the texture and start bak from scratch.
  88003. * Could be useful to regenerate the texture if it is setup to render only once.
  88004. */
  88005. resetRefreshCounter(): void;
  88006. /**
  88007. * Define the refresh rate of the texture or the rendering frequency.
  88008. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88009. */
  88010. refreshRate: number;
  88011. /**
  88012. * Adds a post process to the render target rendering passes.
  88013. * @param postProcess define the post process to add
  88014. */
  88015. addPostProcess(postProcess: PostProcess): void;
  88016. /**
  88017. * Clear all the post processes attached to the render target
  88018. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88019. */
  88020. clearPostProcesses(dispose?: boolean): void;
  88021. /**
  88022. * Remove one of the post process from the list of attached post processes to the texture
  88023. * @param postProcess define the post process to remove from the list
  88024. */
  88025. removePostProcess(postProcess: PostProcess): void;
  88026. /** @hidden */
  88027. _shouldRender(): boolean;
  88028. /**
  88029. * Gets the actual render size of the texture.
  88030. * @returns the width of the render size
  88031. */
  88032. getRenderSize(): number;
  88033. /**
  88034. * Gets the actual render width of the texture.
  88035. * @returns the width of the render size
  88036. */
  88037. getRenderWidth(): number;
  88038. /**
  88039. * Gets the actual render height of the texture.
  88040. * @returns the height of the render size
  88041. */
  88042. getRenderHeight(): number;
  88043. /**
  88044. * Get if the texture can be rescaled or not.
  88045. */
  88046. readonly canRescale: boolean;
  88047. /**
  88048. * Resize the texture using a ratio.
  88049. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88050. */
  88051. scale(ratio: number): void;
  88052. /**
  88053. * Get the texture reflection matrix used to rotate/transform the reflection.
  88054. * @returns the reflection matrix
  88055. */
  88056. getReflectionTextureMatrix(): Matrix;
  88057. /**
  88058. * Resize the texture to a new desired size.
  88059. * Be carrefull as it will recreate all the data in the new texture.
  88060. * @param size Define the new size. It can be:
  88061. * - a number for squared texture,
  88062. * - an object containing { width: number, height: number }
  88063. * - or an object containing a ratio { ratio: number }
  88064. */
  88065. resize(size: number | {
  88066. width: number;
  88067. height: number;
  88068. } | {
  88069. ratio: number;
  88070. }): void;
  88071. /**
  88072. * Renders all the objects from the render list into the texture.
  88073. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88074. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88075. */
  88076. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88077. private _bestReflectionRenderTargetDimension;
  88078. /**
  88079. * @hidden
  88080. * @param faceIndex face index to bind to if this is a cubetexture
  88081. */
  88082. _bindFrameBuffer(faceIndex?: number): void;
  88083. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88084. private renderToTarget;
  88085. /**
  88086. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88087. * This allowed control for front to back rendering or reversly depending of the special needs.
  88088. *
  88089. * @param renderingGroupId The rendering group id corresponding to its index
  88090. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88091. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88092. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88093. */
  88094. 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;
  88095. /**
  88096. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88097. *
  88098. * @param renderingGroupId The rendering group id corresponding to its index
  88099. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88100. */
  88101. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88102. /**
  88103. * Clones the texture.
  88104. * @returns the cloned texture
  88105. */
  88106. clone(): RenderTargetTexture;
  88107. /**
  88108. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88109. * @returns The JSON representation of the texture
  88110. */
  88111. serialize(): any;
  88112. /**
  88113. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88114. */
  88115. disposeFramebufferObjects(): void;
  88116. /**
  88117. * Dispose the texture and release its associated resources.
  88118. */
  88119. dispose(): void;
  88120. /** @hidden */
  88121. _rebuild(): void;
  88122. /**
  88123. * Clear the info related to rendering groups preventing retention point in material dispose.
  88124. */
  88125. freeRenderingGroups(): void;
  88126. /**
  88127. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88128. * @returns the view count
  88129. */
  88130. getViewCount(): number;
  88131. }
  88132. }
  88133. declare module BABYLON {
  88134. /**
  88135. * Options for compiling materials.
  88136. */
  88137. export interface IMaterialCompilationOptions {
  88138. /**
  88139. * Defines whether clip planes are enabled.
  88140. */
  88141. clipPlane: boolean;
  88142. /**
  88143. * Defines whether instances are enabled.
  88144. */
  88145. useInstances: boolean;
  88146. }
  88147. /**
  88148. * Base class for the main features of a material in Babylon.js
  88149. */
  88150. export class Material implements IAnimatable {
  88151. /**
  88152. * Returns the triangle fill mode
  88153. */
  88154. static readonly TriangleFillMode: number;
  88155. /**
  88156. * Returns the wireframe mode
  88157. */
  88158. static readonly WireFrameFillMode: number;
  88159. /**
  88160. * Returns the point fill mode
  88161. */
  88162. static readonly PointFillMode: number;
  88163. /**
  88164. * Returns the point list draw mode
  88165. */
  88166. static readonly PointListDrawMode: number;
  88167. /**
  88168. * Returns the line list draw mode
  88169. */
  88170. static readonly LineListDrawMode: number;
  88171. /**
  88172. * Returns the line loop draw mode
  88173. */
  88174. static readonly LineLoopDrawMode: number;
  88175. /**
  88176. * Returns the line strip draw mode
  88177. */
  88178. static readonly LineStripDrawMode: number;
  88179. /**
  88180. * Returns the triangle strip draw mode
  88181. */
  88182. static readonly TriangleStripDrawMode: number;
  88183. /**
  88184. * Returns the triangle fan draw mode
  88185. */
  88186. static readonly TriangleFanDrawMode: number;
  88187. /**
  88188. * Stores the clock-wise side orientation
  88189. */
  88190. static readonly ClockWiseSideOrientation: number;
  88191. /**
  88192. * Stores the counter clock-wise side orientation
  88193. */
  88194. static readonly CounterClockWiseSideOrientation: number;
  88195. /**
  88196. * The dirty texture flag value
  88197. */
  88198. static readonly TextureDirtyFlag: number;
  88199. /**
  88200. * The dirty light flag value
  88201. */
  88202. static readonly LightDirtyFlag: number;
  88203. /**
  88204. * The dirty fresnel flag value
  88205. */
  88206. static readonly FresnelDirtyFlag: number;
  88207. /**
  88208. * The dirty attribute flag value
  88209. */
  88210. static readonly AttributesDirtyFlag: number;
  88211. /**
  88212. * The dirty misc flag value
  88213. */
  88214. static readonly MiscDirtyFlag: number;
  88215. /**
  88216. * The all dirty flag value
  88217. */
  88218. static readonly AllDirtyFlag: number;
  88219. /**
  88220. * The ID of the material
  88221. */
  88222. id: string;
  88223. /**
  88224. * Gets or sets the unique id of the material
  88225. */
  88226. uniqueId: number;
  88227. /**
  88228. * The name of the material
  88229. */
  88230. name: string;
  88231. /**
  88232. * Gets or sets user defined metadata
  88233. */
  88234. metadata: any;
  88235. /**
  88236. * For internal use only. Please do not use.
  88237. */
  88238. reservedDataStore: any;
  88239. /**
  88240. * Specifies if the ready state should be checked on each call
  88241. */
  88242. checkReadyOnEveryCall: boolean;
  88243. /**
  88244. * Specifies if the ready state should be checked once
  88245. */
  88246. checkReadyOnlyOnce: boolean;
  88247. /**
  88248. * The state of the material
  88249. */
  88250. state: string;
  88251. /**
  88252. * The alpha value of the material
  88253. */
  88254. protected _alpha: number;
  88255. /**
  88256. * List of inspectable custom properties (used by the Inspector)
  88257. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88258. */
  88259. inspectableCustomProperties: IInspectable[];
  88260. /**
  88261. * Sets the alpha value of the material
  88262. */
  88263. /**
  88264. * Gets the alpha value of the material
  88265. */
  88266. alpha: number;
  88267. /**
  88268. * Specifies if back face culling is enabled
  88269. */
  88270. protected _backFaceCulling: boolean;
  88271. /**
  88272. * Sets the back-face culling state
  88273. */
  88274. /**
  88275. * Gets the back-face culling state
  88276. */
  88277. backFaceCulling: boolean;
  88278. /**
  88279. * Stores the value for side orientation
  88280. */
  88281. sideOrientation: number;
  88282. /**
  88283. * Callback triggered when the material is compiled
  88284. */
  88285. onCompiled: Nullable<(effect: Effect) => void>;
  88286. /**
  88287. * Callback triggered when an error occurs
  88288. */
  88289. onError: Nullable<(effect: Effect, errors: string) => void>;
  88290. /**
  88291. * Callback triggered to get the render target textures
  88292. */
  88293. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88294. /**
  88295. * Gets a boolean indicating that current material needs to register RTT
  88296. */
  88297. readonly hasRenderTargetTextures: boolean;
  88298. /**
  88299. * Specifies if the material should be serialized
  88300. */
  88301. doNotSerialize: boolean;
  88302. /**
  88303. * @hidden
  88304. */
  88305. _storeEffectOnSubMeshes: boolean;
  88306. /**
  88307. * Stores the animations for the material
  88308. */
  88309. animations: Nullable<Array<Animation>>;
  88310. /**
  88311. * An event triggered when the material is disposed
  88312. */
  88313. onDisposeObservable: Observable<Material>;
  88314. /**
  88315. * An observer which watches for dispose events
  88316. */
  88317. private _onDisposeObserver;
  88318. private _onUnBindObservable;
  88319. /**
  88320. * Called during a dispose event
  88321. */
  88322. onDispose: () => void;
  88323. private _onBindObservable;
  88324. /**
  88325. * An event triggered when the material is bound
  88326. */
  88327. readonly onBindObservable: Observable<AbstractMesh>;
  88328. /**
  88329. * An observer which watches for bind events
  88330. */
  88331. private _onBindObserver;
  88332. /**
  88333. * Called during a bind event
  88334. */
  88335. onBind: (Mesh: AbstractMesh) => void;
  88336. /**
  88337. * An event triggered when the material is unbound
  88338. */
  88339. readonly onUnBindObservable: Observable<Material>;
  88340. /**
  88341. * Stores the value of the alpha mode
  88342. */
  88343. private _alphaMode;
  88344. /**
  88345. * Sets the value of the alpha mode.
  88346. *
  88347. * | Value | Type | Description |
  88348. * | --- | --- | --- |
  88349. * | 0 | ALPHA_DISABLE | |
  88350. * | 1 | ALPHA_ADD | |
  88351. * | 2 | ALPHA_COMBINE | |
  88352. * | 3 | ALPHA_SUBTRACT | |
  88353. * | 4 | ALPHA_MULTIPLY | |
  88354. * | 5 | ALPHA_MAXIMIZED | |
  88355. * | 6 | ALPHA_ONEONE | |
  88356. * | 7 | ALPHA_PREMULTIPLIED | |
  88357. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88358. * | 9 | ALPHA_INTERPOLATE | |
  88359. * | 10 | ALPHA_SCREENMODE | |
  88360. *
  88361. */
  88362. /**
  88363. * Gets the value of the alpha mode
  88364. */
  88365. alphaMode: number;
  88366. /**
  88367. * Stores the state of the need depth pre-pass value
  88368. */
  88369. private _needDepthPrePass;
  88370. /**
  88371. * Sets the need depth pre-pass value
  88372. */
  88373. /**
  88374. * Gets the depth pre-pass value
  88375. */
  88376. needDepthPrePass: boolean;
  88377. /**
  88378. * Specifies if depth writing should be disabled
  88379. */
  88380. disableDepthWrite: boolean;
  88381. /**
  88382. * Specifies if depth writing should be forced
  88383. */
  88384. forceDepthWrite: boolean;
  88385. /**
  88386. * Specifies if there should be a separate pass for culling
  88387. */
  88388. separateCullingPass: boolean;
  88389. /**
  88390. * Stores the state specifing if fog should be enabled
  88391. */
  88392. private _fogEnabled;
  88393. /**
  88394. * Sets the state for enabling fog
  88395. */
  88396. /**
  88397. * Gets the value of the fog enabled state
  88398. */
  88399. fogEnabled: boolean;
  88400. /**
  88401. * Stores the size of points
  88402. */
  88403. pointSize: number;
  88404. /**
  88405. * Stores the z offset value
  88406. */
  88407. zOffset: number;
  88408. /**
  88409. * Gets a value specifying if wireframe mode is enabled
  88410. */
  88411. /**
  88412. * Sets the state of wireframe mode
  88413. */
  88414. wireframe: boolean;
  88415. /**
  88416. * Gets the value specifying if point clouds are enabled
  88417. */
  88418. /**
  88419. * Sets the state of point cloud mode
  88420. */
  88421. pointsCloud: boolean;
  88422. /**
  88423. * Gets the material fill mode
  88424. */
  88425. /**
  88426. * Sets the material fill mode
  88427. */
  88428. fillMode: number;
  88429. /**
  88430. * @hidden
  88431. * Stores the effects for the material
  88432. */
  88433. _effect: Nullable<Effect>;
  88434. /**
  88435. * @hidden
  88436. * Specifies if the material was previously ready
  88437. */
  88438. _wasPreviouslyReady: boolean;
  88439. /**
  88440. * Specifies if uniform buffers should be used
  88441. */
  88442. private _useUBO;
  88443. /**
  88444. * Stores a reference to the scene
  88445. */
  88446. private _scene;
  88447. /**
  88448. * Stores the fill mode state
  88449. */
  88450. private _fillMode;
  88451. /**
  88452. * Specifies if the depth write state should be cached
  88453. */
  88454. private _cachedDepthWriteState;
  88455. /**
  88456. * Stores the uniform buffer
  88457. */
  88458. protected _uniformBuffer: UniformBuffer;
  88459. /** @hidden */
  88460. _indexInSceneMaterialArray: number;
  88461. /** @hidden */
  88462. meshMap: Nullable<{
  88463. [id: string]: AbstractMesh | undefined;
  88464. }>;
  88465. /**
  88466. * Creates a material instance
  88467. * @param name defines the name of the material
  88468. * @param scene defines the scene to reference
  88469. * @param doNotAdd specifies if the material should be added to the scene
  88470. */
  88471. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88472. /**
  88473. * Returns a string representation of the current material
  88474. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88475. * @returns a string with material information
  88476. */
  88477. toString(fullDetails?: boolean): string;
  88478. /**
  88479. * Gets the class name of the material
  88480. * @returns a string with the class name of the material
  88481. */
  88482. getClassName(): string;
  88483. /**
  88484. * Specifies if updates for the material been locked
  88485. */
  88486. readonly isFrozen: boolean;
  88487. /**
  88488. * Locks updates for the material
  88489. */
  88490. freeze(): void;
  88491. /**
  88492. * Unlocks updates for the material
  88493. */
  88494. unfreeze(): void;
  88495. /**
  88496. * Specifies if the material is ready to be used
  88497. * @param mesh defines the mesh to check
  88498. * @param useInstances specifies if instances should be used
  88499. * @returns a boolean indicating if the material is ready to be used
  88500. */
  88501. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88502. /**
  88503. * Specifies that the submesh is ready to be used
  88504. * @param mesh defines the mesh to check
  88505. * @param subMesh defines which submesh to check
  88506. * @param useInstances specifies that instances should be used
  88507. * @returns a boolean indicating that the submesh is ready or not
  88508. */
  88509. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88510. /**
  88511. * Returns the material effect
  88512. * @returns the effect associated with the material
  88513. */
  88514. getEffect(): Nullable<Effect>;
  88515. /**
  88516. * Returns the current scene
  88517. * @returns a Scene
  88518. */
  88519. getScene(): Scene;
  88520. /**
  88521. * Specifies if the material will require alpha blending
  88522. * @returns a boolean specifying if alpha blending is needed
  88523. */
  88524. needAlphaBlending(): boolean;
  88525. /**
  88526. * Specifies if the mesh will require alpha blending
  88527. * @param mesh defines the mesh to check
  88528. * @returns a boolean specifying if alpha blending is needed for the mesh
  88529. */
  88530. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88531. /**
  88532. * Specifies if this material should be rendered in alpha test mode
  88533. * @returns a boolean specifying if an alpha test is needed.
  88534. */
  88535. needAlphaTesting(): boolean;
  88536. /**
  88537. * Gets the texture used for the alpha test
  88538. * @returns the texture to use for alpha testing
  88539. */
  88540. getAlphaTestTexture(): Nullable<BaseTexture>;
  88541. /**
  88542. * Marks the material to indicate that it needs to be re-calculated
  88543. */
  88544. markDirty(): void;
  88545. /** @hidden */
  88546. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88547. /**
  88548. * Binds the material to the mesh
  88549. * @param world defines the world transformation matrix
  88550. * @param mesh defines the mesh to bind the material to
  88551. */
  88552. bind(world: Matrix, mesh?: Mesh): void;
  88553. /**
  88554. * Binds the submesh to the material
  88555. * @param world defines the world transformation matrix
  88556. * @param mesh defines the mesh containing the submesh
  88557. * @param subMesh defines the submesh to bind the material to
  88558. */
  88559. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88560. /**
  88561. * Binds the world matrix to the material
  88562. * @param world defines the world transformation matrix
  88563. */
  88564. bindOnlyWorldMatrix(world: Matrix): void;
  88565. /**
  88566. * Binds the scene's uniform buffer to the effect.
  88567. * @param effect defines the effect to bind to the scene uniform buffer
  88568. * @param sceneUbo defines the uniform buffer storing scene data
  88569. */
  88570. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88571. /**
  88572. * Binds the view matrix to the effect
  88573. * @param effect defines the effect to bind the view matrix to
  88574. */
  88575. bindView(effect: Effect): void;
  88576. /**
  88577. * Binds the view projection matrix to the effect
  88578. * @param effect defines the effect to bind the view projection matrix to
  88579. */
  88580. bindViewProjection(effect: Effect): void;
  88581. /**
  88582. * Specifies if material alpha testing should be turned on for the mesh
  88583. * @param mesh defines the mesh to check
  88584. */
  88585. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88586. /**
  88587. * Processes to execute after binding the material to a mesh
  88588. * @param mesh defines the rendered mesh
  88589. */
  88590. protected _afterBind(mesh?: Mesh): void;
  88591. /**
  88592. * Unbinds the material from the mesh
  88593. */
  88594. unbind(): void;
  88595. /**
  88596. * Gets the active textures from the material
  88597. * @returns an array of textures
  88598. */
  88599. getActiveTextures(): BaseTexture[];
  88600. /**
  88601. * Specifies if the material uses a texture
  88602. * @param texture defines the texture to check against the material
  88603. * @returns a boolean specifying if the material uses the texture
  88604. */
  88605. hasTexture(texture: BaseTexture): boolean;
  88606. /**
  88607. * Makes a duplicate of the material, and gives it a new name
  88608. * @param name defines the new name for the duplicated material
  88609. * @returns the cloned material
  88610. */
  88611. clone(name: string): Nullable<Material>;
  88612. /**
  88613. * Gets the meshes bound to the material
  88614. * @returns an array of meshes bound to the material
  88615. */
  88616. getBindedMeshes(): AbstractMesh[];
  88617. /**
  88618. * Force shader compilation
  88619. * @param mesh defines the mesh associated with this material
  88620. * @param onCompiled defines a function to execute once the material is compiled
  88621. * @param options defines the options to configure the compilation
  88622. * @param onError defines a function to execute if the material fails compiling
  88623. */
  88624. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88625. /**
  88626. * Force shader compilation
  88627. * @param mesh defines the mesh that will use this material
  88628. * @param options defines additional options for compiling the shaders
  88629. * @returns a promise that resolves when the compilation completes
  88630. */
  88631. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88632. private static readonly _AllDirtyCallBack;
  88633. private static readonly _ImageProcessingDirtyCallBack;
  88634. private static readonly _TextureDirtyCallBack;
  88635. private static readonly _FresnelDirtyCallBack;
  88636. private static readonly _MiscDirtyCallBack;
  88637. private static readonly _LightsDirtyCallBack;
  88638. private static readonly _AttributeDirtyCallBack;
  88639. private static _FresnelAndMiscDirtyCallBack;
  88640. private static _TextureAndMiscDirtyCallBack;
  88641. private static readonly _DirtyCallbackArray;
  88642. private static readonly _RunDirtyCallBacks;
  88643. /**
  88644. * Marks a define in the material to indicate that it needs to be re-computed
  88645. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88646. */
  88647. markAsDirty(flag: number): void;
  88648. /**
  88649. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88650. * @param func defines a function which checks material defines against the submeshes
  88651. */
  88652. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88653. /**
  88654. * Indicates that we need to re-calculated for all submeshes
  88655. */
  88656. protected _markAllSubMeshesAsAllDirty(): void;
  88657. /**
  88658. * Indicates that image processing needs to be re-calculated for all submeshes
  88659. */
  88660. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88661. /**
  88662. * Indicates that textures need to be re-calculated for all submeshes
  88663. */
  88664. protected _markAllSubMeshesAsTexturesDirty(): void;
  88665. /**
  88666. * Indicates that fresnel needs to be re-calculated for all submeshes
  88667. */
  88668. protected _markAllSubMeshesAsFresnelDirty(): void;
  88669. /**
  88670. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88671. */
  88672. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88673. /**
  88674. * Indicates that lights need to be re-calculated for all submeshes
  88675. */
  88676. protected _markAllSubMeshesAsLightsDirty(): void;
  88677. /**
  88678. * Indicates that attributes need to be re-calculated for all submeshes
  88679. */
  88680. protected _markAllSubMeshesAsAttributesDirty(): void;
  88681. /**
  88682. * Indicates that misc needs to be re-calculated for all submeshes
  88683. */
  88684. protected _markAllSubMeshesAsMiscDirty(): void;
  88685. /**
  88686. * Indicates that textures and misc need to be re-calculated for all submeshes
  88687. */
  88688. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88689. /**
  88690. * Disposes the material
  88691. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88692. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88693. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88694. */
  88695. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88696. /** @hidden */
  88697. private releaseVertexArrayObject;
  88698. /**
  88699. * Serializes this material
  88700. * @returns the serialized material object
  88701. */
  88702. serialize(): any;
  88703. /**
  88704. * Creates a material from parsed material data
  88705. * @param parsedMaterial defines parsed material data
  88706. * @param scene defines the hosting scene
  88707. * @param rootUrl defines the root URL to use to load textures
  88708. * @returns a new material
  88709. */
  88710. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88711. }
  88712. }
  88713. declare module BABYLON {
  88714. /**
  88715. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88716. * separate meshes. This can be use to improve performances.
  88717. * @see http://doc.babylonjs.com/how_to/multi_materials
  88718. */
  88719. export class MultiMaterial extends Material {
  88720. private _subMaterials;
  88721. /**
  88722. * Gets or Sets the list of Materials used within the multi material.
  88723. * They need to be ordered according to the submeshes order in the associated mesh
  88724. */
  88725. subMaterials: Nullable<Material>[];
  88726. /**
  88727. * Function used to align with Node.getChildren()
  88728. * @returns the list of Materials used within the multi material
  88729. */
  88730. getChildren(): Nullable<Material>[];
  88731. /**
  88732. * Instantiates a new Multi Material
  88733. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88734. * separate meshes. This can be use to improve performances.
  88735. * @see http://doc.babylonjs.com/how_to/multi_materials
  88736. * @param name Define the name in the scene
  88737. * @param scene Define the scene the material belongs to
  88738. */
  88739. constructor(name: string, scene: Scene);
  88740. private _hookArray;
  88741. /**
  88742. * Get one of the submaterial by its index in the submaterials array
  88743. * @param index The index to look the sub material at
  88744. * @returns The Material if the index has been defined
  88745. */
  88746. getSubMaterial(index: number): Nullable<Material>;
  88747. /**
  88748. * Get the list of active textures for the whole sub materials list.
  88749. * @returns All the textures that will be used during the rendering
  88750. */
  88751. getActiveTextures(): BaseTexture[];
  88752. /**
  88753. * Gets the current class name of the material e.g. "MultiMaterial"
  88754. * Mainly use in serialization.
  88755. * @returns the class name
  88756. */
  88757. getClassName(): string;
  88758. /**
  88759. * Checks if the material is ready to render the requested sub mesh
  88760. * @param mesh Define the mesh the submesh belongs to
  88761. * @param subMesh Define the sub mesh to look readyness for
  88762. * @param useInstances Define whether or not the material is used with instances
  88763. * @returns true if ready, otherwise false
  88764. */
  88765. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88766. /**
  88767. * Clones the current material and its related sub materials
  88768. * @param name Define the name of the newly cloned material
  88769. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88770. * @returns the cloned material
  88771. */
  88772. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88773. /**
  88774. * Serializes the materials into a JSON representation.
  88775. * @returns the JSON representation
  88776. */
  88777. serialize(): any;
  88778. /**
  88779. * Dispose the material and release its associated resources
  88780. * @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)
  88781. * @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)
  88782. * @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)
  88783. */
  88784. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88785. /**
  88786. * Creates a MultiMaterial from parsed MultiMaterial data.
  88787. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88788. * @param scene defines the hosting scene
  88789. * @returns a new MultiMaterial
  88790. */
  88791. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88792. }
  88793. }
  88794. declare module BABYLON {
  88795. /**
  88796. * Base class for submeshes
  88797. */
  88798. export class BaseSubMesh {
  88799. /** @hidden */
  88800. _materialDefines: Nullable<MaterialDefines>;
  88801. /** @hidden */
  88802. _materialEffect: Nullable<Effect>;
  88803. /**
  88804. * Gets associated effect
  88805. */
  88806. readonly effect: Nullable<Effect>;
  88807. /**
  88808. * Sets associated effect (effect used to render this submesh)
  88809. * @param effect defines the effect to associate with
  88810. * @param defines defines the set of defines used to compile this effect
  88811. */
  88812. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88813. }
  88814. /**
  88815. * Defines a subdivision inside a mesh
  88816. */
  88817. export class SubMesh extends BaseSubMesh implements ICullable {
  88818. /** the material index to use */
  88819. materialIndex: number;
  88820. /** vertex index start */
  88821. verticesStart: number;
  88822. /** vertices count */
  88823. verticesCount: number;
  88824. /** index start */
  88825. indexStart: number;
  88826. /** indices count */
  88827. indexCount: number;
  88828. /** @hidden */
  88829. _linesIndexCount: number;
  88830. private _mesh;
  88831. private _renderingMesh;
  88832. private _boundingInfo;
  88833. private _linesIndexBuffer;
  88834. /** @hidden */
  88835. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88836. /** @hidden */
  88837. _trianglePlanes: Plane[];
  88838. /** @hidden */
  88839. _lastColliderTransformMatrix: Nullable<Matrix>;
  88840. /** @hidden */
  88841. _renderId: number;
  88842. /** @hidden */
  88843. _alphaIndex: number;
  88844. /** @hidden */
  88845. _distanceToCamera: number;
  88846. /** @hidden */
  88847. _id: number;
  88848. private _currentMaterial;
  88849. /**
  88850. * Add a new submesh to a mesh
  88851. * @param materialIndex defines the material index to use
  88852. * @param verticesStart defines vertex index start
  88853. * @param verticesCount defines vertices count
  88854. * @param indexStart defines index start
  88855. * @param indexCount defines indices count
  88856. * @param mesh defines the parent mesh
  88857. * @param renderingMesh defines an optional rendering mesh
  88858. * @param createBoundingBox defines if bounding box should be created for this submesh
  88859. * @returns the new submesh
  88860. */
  88861. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88862. /**
  88863. * Creates a new submesh
  88864. * @param materialIndex defines the material index to use
  88865. * @param verticesStart defines vertex index start
  88866. * @param verticesCount defines vertices count
  88867. * @param indexStart defines index start
  88868. * @param indexCount defines indices count
  88869. * @param mesh defines the parent mesh
  88870. * @param renderingMesh defines an optional rendering mesh
  88871. * @param createBoundingBox defines if bounding box should be created for this submesh
  88872. */
  88873. constructor(
  88874. /** the material index to use */
  88875. materialIndex: number,
  88876. /** vertex index start */
  88877. verticesStart: number,
  88878. /** vertices count */
  88879. verticesCount: number,
  88880. /** index start */
  88881. indexStart: number,
  88882. /** indices count */
  88883. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88884. /**
  88885. * Returns true if this submesh covers the entire parent mesh
  88886. * @ignorenaming
  88887. */
  88888. readonly IsGlobal: boolean;
  88889. /**
  88890. * Returns the submesh BoudingInfo object
  88891. * @returns current bounding info (or mesh's one if the submesh is global)
  88892. */
  88893. getBoundingInfo(): BoundingInfo;
  88894. /**
  88895. * Sets the submesh BoundingInfo
  88896. * @param boundingInfo defines the new bounding info to use
  88897. * @returns the SubMesh
  88898. */
  88899. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88900. /**
  88901. * Returns the mesh of the current submesh
  88902. * @return the parent mesh
  88903. */
  88904. getMesh(): AbstractMesh;
  88905. /**
  88906. * Returns the rendering mesh of the submesh
  88907. * @returns the rendering mesh (could be different from parent mesh)
  88908. */
  88909. getRenderingMesh(): Mesh;
  88910. /**
  88911. * Returns the submesh material
  88912. * @returns null or the current material
  88913. */
  88914. getMaterial(): Nullable<Material>;
  88915. /**
  88916. * Sets a new updated BoundingInfo object to the submesh
  88917. * @param data defines an optional position array to use to determine the bounding info
  88918. * @returns the SubMesh
  88919. */
  88920. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88921. /** @hidden */
  88922. _checkCollision(collider: Collider): boolean;
  88923. /**
  88924. * Updates the submesh BoundingInfo
  88925. * @param world defines the world matrix to use to update the bounding info
  88926. * @returns the submesh
  88927. */
  88928. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88929. /**
  88930. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88931. * @param frustumPlanes defines the frustum planes
  88932. * @returns true if the submesh is intersecting with the frustum
  88933. */
  88934. isInFrustum(frustumPlanes: Plane[]): boolean;
  88935. /**
  88936. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88937. * @param frustumPlanes defines the frustum planes
  88938. * @returns true if the submesh is inside the frustum
  88939. */
  88940. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88941. /**
  88942. * Renders the submesh
  88943. * @param enableAlphaMode defines if alpha needs to be used
  88944. * @returns the submesh
  88945. */
  88946. render(enableAlphaMode: boolean): SubMesh;
  88947. /**
  88948. * @hidden
  88949. */
  88950. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88951. /**
  88952. * Checks if the submesh intersects with a ray
  88953. * @param ray defines the ray to test
  88954. * @returns true is the passed ray intersects the submesh bounding box
  88955. */
  88956. canIntersects(ray: Ray): boolean;
  88957. /**
  88958. * Intersects current submesh with a ray
  88959. * @param ray defines the ray to test
  88960. * @param positions defines mesh's positions array
  88961. * @param indices defines mesh's indices array
  88962. * @param fastCheck defines if only bounding info should be used
  88963. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88964. * @returns intersection info or null if no intersection
  88965. */
  88966. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88967. /** @hidden */
  88968. private _intersectLines;
  88969. /** @hidden */
  88970. private _intersectUnIndexedLines;
  88971. /** @hidden */
  88972. private _intersectTriangles;
  88973. /** @hidden */
  88974. private _intersectUnIndexedTriangles;
  88975. /** @hidden */
  88976. _rebuild(): void;
  88977. /**
  88978. * Creates a new submesh from the passed mesh
  88979. * @param newMesh defines the new hosting mesh
  88980. * @param newRenderingMesh defines an optional rendering mesh
  88981. * @returns the new submesh
  88982. */
  88983. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88984. /**
  88985. * Release associated resources
  88986. */
  88987. dispose(): void;
  88988. /**
  88989. * Gets the class name
  88990. * @returns the string "SubMesh".
  88991. */
  88992. getClassName(): string;
  88993. /**
  88994. * Creates a new submesh from indices data
  88995. * @param materialIndex the index of the main mesh material
  88996. * @param startIndex the index where to start the copy in the mesh indices array
  88997. * @param indexCount the number of indices to copy then from the startIndex
  88998. * @param mesh the main mesh to create the submesh from
  88999. * @param renderingMesh the optional rendering mesh
  89000. * @returns a new submesh
  89001. */
  89002. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89003. }
  89004. }
  89005. declare module BABYLON {
  89006. /**
  89007. * Class used to represent data loading progression
  89008. */
  89009. export class SceneLoaderFlags {
  89010. private static _ForceFullSceneLoadingForIncremental;
  89011. private static _ShowLoadingScreen;
  89012. private static _CleanBoneMatrixWeights;
  89013. private static _loggingLevel;
  89014. /**
  89015. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89016. */
  89017. static ForceFullSceneLoadingForIncremental: boolean;
  89018. /**
  89019. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89020. */
  89021. static ShowLoadingScreen: boolean;
  89022. /**
  89023. * Defines the current logging level (while loading the scene)
  89024. * @ignorenaming
  89025. */
  89026. static loggingLevel: number;
  89027. /**
  89028. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89029. */
  89030. static CleanBoneMatrixWeights: boolean;
  89031. }
  89032. }
  89033. declare module BABYLON {
  89034. /**
  89035. * Class used to store geometry data (vertex buffers + index buffer)
  89036. */
  89037. export class Geometry implements IGetSetVerticesData {
  89038. /**
  89039. * Gets or sets the ID of the geometry
  89040. */
  89041. id: string;
  89042. /**
  89043. * Gets or sets the unique ID of the geometry
  89044. */
  89045. uniqueId: number;
  89046. /**
  89047. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89048. */
  89049. delayLoadState: number;
  89050. /**
  89051. * Gets the file containing the data to load when running in delay load state
  89052. */
  89053. delayLoadingFile: Nullable<string>;
  89054. /**
  89055. * Callback called when the geometry is updated
  89056. */
  89057. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89058. private _scene;
  89059. private _engine;
  89060. private _meshes;
  89061. private _totalVertices;
  89062. /** @hidden */
  89063. _indices: IndicesArray;
  89064. /** @hidden */
  89065. _vertexBuffers: {
  89066. [key: string]: VertexBuffer;
  89067. };
  89068. private _isDisposed;
  89069. private _extend;
  89070. private _boundingBias;
  89071. /** @hidden */
  89072. _delayInfo: Array<string>;
  89073. private _indexBuffer;
  89074. private _indexBufferIsUpdatable;
  89075. /** @hidden */
  89076. _boundingInfo: Nullable<BoundingInfo>;
  89077. /** @hidden */
  89078. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89079. /** @hidden */
  89080. _softwareSkinningFrameId: number;
  89081. private _vertexArrayObjects;
  89082. private _updatable;
  89083. /** @hidden */
  89084. _positions: Nullable<Vector3[]>;
  89085. /**
  89086. * 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
  89087. */
  89088. /**
  89089. * 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
  89090. */
  89091. boundingBias: Vector2;
  89092. /**
  89093. * Static function used to attach a new empty geometry to a mesh
  89094. * @param mesh defines the mesh to attach the geometry to
  89095. * @returns the new Geometry
  89096. */
  89097. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89098. /**
  89099. * Creates a new geometry
  89100. * @param id defines the unique ID
  89101. * @param scene defines the hosting scene
  89102. * @param vertexData defines the VertexData used to get geometry data
  89103. * @param updatable defines if geometry must be updatable (false by default)
  89104. * @param mesh defines the mesh that will be associated with the geometry
  89105. */
  89106. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89107. /**
  89108. * Gets the current extend of the geometry
  89109. */
  89110. readonly extend: {
  89111. minimum: Vector3;
  89112. maximum: Vector3;
  89113. };
  89114. /**
  89115. * Gets the hosting scene
  89116. * @returns the hosting Scene
  89117. */
  89118. getScene(): Scene;
  89119. /**
  89120. * Gets the hosting engine
  89121. * @returns the hosting Engine
  89122. */
  89123. getEngine(): Engine;
  89124. /**
  89125. * Defines if the geometry is ready to use
  89126. * @returns true if the geometry is ready to be used
  89127. */
  89128. isReady(): boolean;
  89129. /**
  89130. * Gets a value indicating that the geometry should not be serialized
  89131. */
  89132. readonly doNotSerialize: boolean;
  89133. /** @hidden */
  89134. _rebuild(): void;
  89135. /**
  89136. * Affects all geometry data in one call
  89137. * @param vertexData defines the geometry data
  89138. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89139. */
  89140. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89141. /**
  89142. * Set specific vertex data
  89143. * @param kind defines the data kind (Position, normal, etc...)
  89144. * @param data defines the vertex data to use
  89145. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89146. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89147. */
  89148. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89149. /**
  89150. * Removes a specific vertex data
  89151. * @param kind defines the data kind (Position, normal, etc...)
  89152. */
  89153. removeVerticesData(kind: string): void;
  89154. /**
  89155. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89156. * @param buffer defines the vertex buffer to use
  89157. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89158. */
  89159. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89160. /**
  89161. * Update a specific vertex buffer
  89162. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89163. * It will do nothing if the buffer is not updatable
  89164. * @param kind defines the data kind (Position, normal, etc...)
  89165. * @param data defines the data to use
  89166. * @param offset defines the offset in the target buffer where to store the data
  89167. * @param useBytes set to true if the offset is in bytes
  89168. */
  89169. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89170. /**
  89171. * Update a specific vertex buffer
  89172. * This function will create a new buffer if the current one is not updatable
  89173. * @param kind defines the data kind (Position, normal, etc...)
  89174. * @param data defines the data to use
  89175. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89176. */
  89177. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89178. private _updateBoundingInfo;
  89179. /** @hidden */
  89180. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89181. /**
  89182. * Gets total number of vertices
  89183. * @returns the total number of vertices
  89184. */
  89185. getTotalVertices(): number;
  89186. /**
  89187. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89188. * @param kind defines the data kind (Position, normal, etc...)
  89189. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89190. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89191. * @returns a float array containing vertex data
  89192. */
  89193. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89194. /**
  89195. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89196. * @param kind defines the data kind (Position, normal, etc...)
  89197. * @returns true if the vertex buffer with the specified kind is updatable
  89198. */
  89199. isVertexBufferUpdatable(kind: string): boolean;
  89200. /**
  89201. * Gets a specific vertex buffer
  89202. * @param kind defines the data kind (Position, normal, etc...)
  89203. * @returns a VertexBuffer
  89204. */
  89205. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89206. /**
  89207. * Returns all vertex buffers
  89208. * @return an object holding all vertex buffers indexed by kind
  89209. */
  89210. getVertexBuffers(): Nullable<{
  89211. [key: string]: VertexBuffer;
  89212. }>;
  89213. /**
  89214. * Gets a boolean indicating if specific vertex buffer is present
  89215. * @param kind defines the data kind (Position, normal, etc...)
  89216. * @returns true if data is present
  89217. */
  89218. isVerticesDataPresent(kind: string): boolean;
  89219. /**
  89220. * Gets a list of all attached data kinds (Position, normal, etc...)
  89221. * @returns a list of string containing all kinds
  89222. */
  89223. getVerticesDataKinds(): string[];
  89224. /**
  89225. * Update index buffer
  89226. * @param indices defines the indices to store in the index buffer
  89227. * @param offset defines the offset in the target buffer where to store the data
  89228. * @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)
  89229. */
  89230. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89231. /**
  89232. * Creates a new index buffer
  89233. * @param indices defines the indices to store in the index buffer
  89234. * @param totalVertices defines the total number of vertices (could be null)
  89235. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89236. */
  89237. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89238. /**
  89239. * Return the total number of indices
  89240. * @returns the total number of indices
  89241. */
  89242. getTotalIndices(): number;
  89243. /**
  89244. * Gets the index buffer array
  89245. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89246. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89247. * @returns the index buffer array
  89248. */
  89249. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89250. /**
  89251. * Gets the index buffer
  89252. * @return the index buffer
  89253. */
  89254. getIndexBuffer(): Nullable<DataBuffer>;
  89255. /** @hidden */
  89256. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89257. /**
  89258. * Release the associated resources for a specific mesh
  89259. * @param mesh defines the source mesh
  89260. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89261. */
  89262. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89263. /**
  89264. * Apply current geometry to a given mesh
  89265. * @param mesh defines the mesh to apply geometry to
  89266. */
  89267. applyToMesh(mesh: Mesh): void;
  89268. private _updateExtend;
  89269. private _applyToMesh;
  89270. private notifyUpdate;
  89271. /**
  89272. * Load the geometry if it was flagged as delay loaded
  89273. * @param scene defines the hosting scene
  89274. * @param onLoaded defines a callback called when the geometry is loaded
  89275. */
  89276. load(scene: Scene, onLoaded?: () => void): void;
  89277. private _queueLoad;
  89278. /**
  89279. * Invert the geometry to move from a right handed system to a left handed one.
  89280. */
  89281. toLeftHanded(): void;
  89282. /** @hidden */
  89283. _resetPointsArrayCache(): void;
  89284. /** @hidden */
  89285. _generatePointsArray(): boolean;
  89286. /**
  89287. * Gets a value indicating if the geometry is disposed
  89288. * @returns true if the geometry was disposed
  89289. */
  89290. isDisposed(): boolean;
  89291. private _disposeVertexArrayObjects;
  89292. /**
  89293. * Free all associated resources
  89294. */
  89295. dispose(): void;
  89296. /**
  89297. * Clone the current geometry into a new geometry
  89298. * @param id defines the unique ID of the new geometry
  89299. * @returns a new geometry object
  89300. */
  89301. copy(id: string): Geometry;
  89302. /**
  89303. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89304. * @return a JSON representation of the current geometry data (without the vertices data)
  89305. */
  89306. serialize(): any;
  89307. private toNumberArray;
  89308. /**
  89309. * Serialize all vertices data into a JSON oject
  89310. * @returns a JSON representation of the current geometry data
  89311. */
  89312. serializeVerticeData(): any;
  89313. /**
  89314. * Extracts a clone of a mesh geometry
  89315. * @param mesh defines the source mesh
  89316. * @param id defines the unique ID of the new geometry object
  89317. * @returns the new geometry object
  89318. */
  89319. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89320. /**
  89321. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89322. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89323. * Be aware Math.random() could cause collisions, but:
  89324. * "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"
  89325. * @returns a string containing a new GUID
  89326. */
  89327. static RandomId(): string;
  89328. /** @hidden */
  89329. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89330. private static _CleanMatricesWeights;
  89331. /**
  89332. * Create a new geometry from persisted data (Using .babylon file format)
  89333. * @param parsedVertexData defines the persisted data
  89334. * @param scene defines the hosting scene
  89335. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89336. * @returns the new geometry object
  89337. */
  89338. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89339. }
  89340. }
  89341. declare module BABYLON {
  89342. /**
  89343. * Define an interface for all classes that will get and set the data on vertices
  89344. */
  89345. export interface IGetSetVerticesData {
  89346. /**
  89347. * Gets a boolean indicating if specific vertex data is present
  89348. * @param kind defines the vertex data kind to use
  89349. * @returns true is data kind is present
  89350. */
  89351. isVerticesDataPresent(kind: string): boolean;
  89352. /**
  89353. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89354. * @param kind defines the data kind (Position, normal, etc...)
  89355. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89356. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89357. * @returns a float array containing vertex data
  89358. */
  89359. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89360. /**
  89361. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89362. * @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.
  89363. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89364. * @returns the indices array or an empty array if the mesh has no geometry
  89365. */
  89366. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89367. /**
  89368. * Set specific vertex data
  89369. * @param kind defines the data kind (Position, normal, etc...)
  89370. * @param data defines the vertex data to use
  89371. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89372. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89373. */
  89374. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89375. /**
  89376. * Update a specific associated vertex buffer
  89377. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89378. * - VertexBuffer.PositionKind
  89379. * - VertexBuffer.UVKind
  89380. * - VertexBuffer.UV2Kind
  89381. * - VertexBuffer.UV3Kind
  89382. * - VertexBuffer.UV4Kind
  89383. * - VertexBuffer.UV5Kind
  89384. * - VertexBuffer.UV6Kind
  89385. * - VertexBuffer.ColorKind
  89386. * - VertexBuffer.MatricesIndicesKind
  89387. * - VertexBuffer.MatricesIndicesExtraKind
  89388. * - VertexBuffer.MatricesWeightsKind
  89389. * - VertexBuffer.MatricesWeightsExtraKind
  89390. * @param data defines the data source
  89391. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89392. * @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)
  89393. */
  89394. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89395. /**
  89396. * Creates a new index buffer
  89397. * @param indices defines the indices to store in the index buffer
  89398. * @param totalVertices defines the total number of vertices (could be null)
  89399. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89400. */
  89401. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89402. }
  89403. /**
  89404. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89405. */
  89406. export class VertexData {
  89407. /**
  89408. * Mesh side orientation : usually the external or front surface
  89409. */
  89410. static readonly FRONTSIDE: number;
  89411. /**
  89412. * Mesh side orientation : usually the internal or back surface
  89413. */
  89414. static readonly BACKSIDE: number;
  89415. /**
  89416. * Mesh side orientation : both internal and external or front and back surfaces
  89417. */
  89418. static readonly DOUBLESIDE: number;
  89419. /**
  89420. * Mesh side orientation : by default, `FRONTSIDE`
  89421. */
  89422. static readonly DEFAULTSIDE: number;
  89423. /**
  89424. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89425. */
  89426. positions: Nullable<FloatArray>;
  89427. /**
  89428. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89429. */
  89430. normals: Nullable<FloatArray>;
  89431. /**
  89432. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89433. */
  89434. tangents: Nullable<FloatArray>;
  89435. /**
  89436. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89437. */
  89438. uvs: Nullable<FloatArray>;
  89439. /**
  89440. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89441. */
  89442. uvs2: Nullable<FloatArray>;
  89443. /**
  89444. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89445. */
  89446. uvs3: Nullable<FloatArray>;
  89447. /**
  89448. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89449. */
  89450. uvs4: Nullable<FloatArray>;
  89451. /**
  89452. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89453. */
  89454. uvs5: Nullable<FloatArray>;
  89455. /**
  89456. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89457. */
  89458. uvs6: Nullable<FloatArray>;
  89459. /**
  89460. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89461. */
  89462. colors: Nullable<FloatArray>;
  89463. /**
  89464. * 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).
  89465. */
  89466. matricesIndices: Nullable<FloatArray>;
  89467. /**
  89468. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89469. */
  89470. matricesWeights: Nullable<FloatArray>;
  89471. /**
  89472. * An array extending the number of possible indices
  89473. */
  89474. matricesIndicesExtra: Nullable<FloatArray>;
  89475. /**
  89476. * An array extending the number of possible weights when the number of indices is extended
  89477. */
  89478. matricesWeightsExtra: Nullable<FloatArray>;
  89479. /**
  89480. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89481. */
  89482. indices: Nullable<IndicesArray>;
  89483. /**
  89484. * Uses the passed data array to set the set the values for the specified kind of data
  89485. * @param data a linear array of floating numbers
  89486. * @param kind the type of data that is being set, eg positions, colors etc
  89487. */
  89488. set(data: FloatArray, kind: string): void;
  89489. /**
  89490. * Associates the vertexData to the passed Mesh.
  89491. * Sets it as updatable or not (default `false`)
  89492. * @param mesh the mesh the vertexData is applied to
  89493. * @param updatable when used and having the value true allows new data to update the vertexData
  89494. * @returns the VertexData
  89495. */
  89496. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89497. /**
  89498. * Associates the vertexData to the passed Geometry.
  89499. * Sets it as updatable or not (default `false`)
  89500. * @param geometry the geometry the vertexData is applied to
  89501. * @param updatable when used and having the value true allows new data to update the vertexData
  89502. * @returns VertexData
  89503. */
  89504. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89505. /**
  89506. * Updates the associated mesh
  89507. * @param mesh the mesh to be updated
  89508. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89509. * @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
  89510. * @returns VertexData
  89511. */
  89512. updateMesh(mesh: Mesh): VertexData;
  89513. /**
  89514. * Updates the associated geometry
  89515. * @param geometry the geometry to be updated
  89516. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89517. * @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
  89518. * @returns VertexData.
  89519. */
  89520. updateGeometry(geometry: Geometry): VertexData;
  89521. private _applyTo;
  89522. private _update;
  89523. /**
  89524. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89525. * @param matrix the transforming matrix
  89526. * @returns the VertexData
  89527. */
  89528. transform(matrix: Matrix): VertexData;
  89529. /**
  89530. * Merges the passed VertexData into the current one
  89531. * @param other the VertexData to be merged into the current one
  89532. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89533. * @returns the modified VertexData
  89534. */
  89535. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89536. private _mergeElement;
  89537. private _validate;
  89538. /**
  89539. * Serializes the VertexData
  89540. * @returns a serialized object
  89541. */
  89542. serialize(): any;
  89543. /**
  89544. * Extracts the vertexData from a mesh
  89545. * @param mesh the mesh from which to extract the VertexData
  89546. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89547. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89548. * @returns the object VertexData associated to the passed mesh
  89549. */
  89550. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89551. /**
  89552. * Extracts the vertexData from the geometry
  89553. * @param geometry the geometry from which to extract the VertexData
  89554. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89555. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89556. * @returns the object VertexData associated to the passed mesh
  89557. */
  89558. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89559. private static _ExtractFrom;
  89560. /**
  89561. * Creates the VertexData for a Ribbon
  89562. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89563. * * pathArray array of paths, each of which an array of successive Vector3
  89564. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89565. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89566. * * 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
  89567. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89568. * * 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)
  89569. * * 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)
  89570. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89571. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89572. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89573. * @returns the VertexData of the ribbon
  89574. */
  89575. static CreateRibbon(options: {
  89576. pathArray: Vector3[][];
  89577. closeArray?: boolean;
  89578. closePath?: boolean;
  89579. offset?: number;
  89580. sideOrientation?: number;
  89581. frontUVs?: Vector4;
  89582. backUVs?: Vector4;
  89583. invertUV?: boolean;
  89584. uvs?: Vector2[];
  89585. colors?: Color4[];
  89586. }): VertexData;
  89587. /**
  89588. * Creates the VertexData for a box
  89589. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89590. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89591. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89592. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89593. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89594. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89595. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89597. * * 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)
  89598. * * 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)
  89599. * @returns the VertexData of the box
  89600. */
  89601. static CreateBox(options: {
  89602. size?: number;
  89603. width?: number;
  89604. height?: number;
  89605. depth?: number;
  89606. faceUV?: Vector4[];
  89607. faceColors?: Color4[];
  89608. sideOrientation?: number;
  89609. frontUVs?: Vector4;
  89610. backUVs?: Vector4;
  89611. }): VertexData;
  89612. /**
  89613. * Creates the VertexData for a tiled box
  89614. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89615. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89616. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89617. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89618. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89619. * @returns the VertexData of the box
  89620. */
  89621. static CreateTiledBox(options: {
  89622. pattern?: number;
  89623. width?: number;
  89624. height?: number;
  89625. depth?: number;
  89626. tileSize?: number;
  89627. tileWidth?: number;
  89628. tileHeight?: number;
  89629. alignHorizontal?: number;
  89630. alignVertical?: number;
  89631. faceUV?: Vector4[];
  89632. faceColors?: Color4[];
  89633. sideOrientation?: number;
  89634. }): VertexData;
  89635. /**
  89636. * Creates the VertexData for a tiled plane
  89637. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89638. * * pattern a limited pattern arrangement depending on the number
  89639. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89640. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89641. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89642. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89643. * * 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)
  89644. * * 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)
  89645. * @returns the VertexData of the tiled plane
  89646. */
  89647. static CreateTiledPlane(options: {
  89648. pattern?: number;
  89649. tileSize?: number;
  89650. tileWidth?: number;
  89651. tileHeight?: number;
  89652. size?: number;
  89653. width?: number;
  89654. height?: number;
  89655. alignHorizontal?: number;
  89656. alignVertical?: number;
  89657. sideOrientation?: number;
  89658. frontUVs?: Vector4;
  89659. backUVs?: Vector4;
  89660. }): VertexData;
  89661. /**
  89662. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89663. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89664. * * segments sets the number of horizontal strips optional, default 32
  89665. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89666. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89667. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89668. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89669. * * 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
  89670. * * 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
  89671. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89672. * * 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)
  89673. * * 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)
  89674. * @returns the VertexData of the ellipsoid
  89675. */
  89676. static CreateSphere(options: {
  89677. segments?: number;
  89678. diameter?: number;
  89679. diameterX?: number;
  89680. diameterY?: number;
  89681. diameterZ?: number;
  89682. arc?: number;
  89683. slice?: number;
  89684. sideOrientation?: number;
  89685. frontUVs?: Vector4;
  89686. backUVs?: Vector4;
  89687. }): VertexData;
  89688. /**
  89689. * Creates the VertexData for a cylinder, cone or prism
  89690. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89691. * * height sets the height (y direction) of the cylinder, optional, default 2
  89692. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89693. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89694. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89695. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89696. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89697. * * 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
  89698. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89699. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89700. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89701. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89702. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89703. * * 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)
  89704. * * 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)
  89705. * @returns the VertexData of the cylinder, cone or prism
  89706. */
  89707. static CreateCylinder(options: {
  89708. height?: number;
  89709. diameterTop?: number;
  89710. diameterBottom?: number;
  89711. diameter?: number;
  89712. tessellation?: number;
  89713. subdivisions?: number;
  89714. arc?: number;
  89715. faceColors?: Color4[];
  89716. faceUV?: Vector4[];
  89717. hasRings?: boolean;
  89718. enclose?: boolean;
  89719. sideOrientation?: number;
  89720. frontUVs?: Vector4;
  89721. backUVs?: Vector4;
  89722. }): VertexData;
  89723. /**
  89724. * Creates the VertexData for a torus
  89725. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89726. * * diameter the diameter of the torus, optional default 1
  89727. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89728. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89729. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89730. * * 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)
  89731. * * 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)
  89732. * @returns the VertexData of the torus
  89733. */
  89734. static CreateTorus(options: {
  89735. diameter?: number;
  89736. thickness?: number;
  89737. tessellation?: number;
  89738. sideOrientation?: number;
  89739. frontUVs?: Vector4;
  89740. backUVs?: Vector4;
  89741. }): VertexData;
  89742. /**
  89743. * Creates the VertexData of the LineSystem
  89744. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89745. * - lines an array of lines, each line being an array of successive Vector3
  89746. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89747. * @returns the VertexData of the LineSystem
  89748. */
  89749. static CreateLineSystem(options: {
  89750. lines: Vector3[][];
  89751. colors?: Nullable<Color4[][]>;
  89752. }): VertexData;
  89753. /**
  89754. * Create the VertexData for a DashedLines
  89755. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89756. * - points an array successive Vector3
  89757. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89758. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89759. * - dashNb the intended total number of dashes, optional, default 200
  89760. * @returns the VertexData for the DashedLines
  89761. */
  89762. static CreateDashedLines(options: {
  89763. points: Vector3[];
  89764. dashSize?: number;
  89765. gapSize?: number;
  89766. dashNb?: number;
  89767. }): VertexData;
  89768. /**
  89769. * Creates the VertexData for a Ground
  89770. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89771. * - width the width (x direction) of the ground, optional, default 1
  89772. * - height the height (z direction) of the ground, optional, default 1
  89773. * - subdivisions the number of subdivisions per side, optional, default 1
  89774. * @returns the VertexData of the Ground
  89775. */
  89776. static CreateGround(options: {
  89777. width?: number;
  89778. height?: number;
  89779. subdivisions?: number;
  89780. subdivisionsX?: number;
  89781. subdivisionsY?: number;
  89782. }): VertexData;
  89783. /**
  89784. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89785. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89786. * * xmin the ground minimum X coordinate, optional, default -1
  89787. * * zmin the ground minimum Z coordinate, optional, default -1
  89788. * * xmax the ground maximum X coordinate, optional, default 1
  89789. * * zmax the ground maximum Z coordinate, optional, default 1
  89790. * * 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}
  89791. * * 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}
  89792. * @returns the VertexData of the TiledGround
  89793. */
  89794. static CreateTiledGround(options: {
  89795. xmin: number;
  89796. zmin: number;
  89797. xmax: number;
  89798. zmax: number;
  89799. subdivisions?: {
  89800. w: number;
  89801. h: number;
  89802. };
  89803. precision?: {
  89804. w: number;
  89805. h: number;
  89806. };
  89807. }): VertexData;
  89808. /**
  89809. * Creates the VertexData of the Ground designed from a heightmap
  89810. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89811. * * width the width (x direction) of the ground
  89812. * * height the height (z direction) of the ground
  89813. * * subdivisions the number of subdivisions per side
  89814. * * minHeight the minimum altitude on the ground, optional, default 0
  89815. * * maxHeight the maximum altitude on the ground, optional default 1
  89816. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89817. * * buffer the array holding the image color data
  89818. * * bufferWidth the width of image
  89819. * * bufferHeight the height of image
  89820. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89821. * @returns the VertexData of the Ground designed from a heightmap
  89822. */
  89823. static CreateGroundFromHeightMap(options: {
  89824. width: number;
  89825. height: number;
  89826. subdivisions: number;
  89827. minHeight: number;
  89828. maxHeight: number;
  89829. colorFilter: Color3;
  89830. buffer: Uint8Array;
  89831. bufferWidth: number;
  89832. bufferHeight: number;
  89833. alphaFilter: number;
  89834. }): VertexData;
  89835. /**
  89836. * Creates the VertexData for a Plane
  89837. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89838. * * size sets the width and height of the plane to the value of size, optional default 1
  89839. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89840. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89841. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89842. * * 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)
  89843. * * 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)
  89844. * @returns the VertexData of the box
  89845. */
  89846. static CreatePlane(options: {
  89847. size?: number;
  89848. width?: number;
  89849. height?: number;
  89850. sideOrientation?: number;
  89851. frontUVs?: Vector4;
  89852. backUVs?: Vector4;
  89853. }): VertexData;
  89854. /**
  89855. * Creates the VertexData of the Disc or regular Polygon
  89856. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89857. * * radius the radius of the disc, optional default 0.5
  89858. * * tessellation the number of polygon sides, optional, default 64
  89859. * * 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
  89860. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89861. * * 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)
  89862. * * 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)
  89863. * @returns the VertexData of the box
  89864. */
  89865. static CreateDisc(options: {
  89866. radius?: number;
  89867. tessellation?: number;
  89868. arc?: number;
  89869. sideOrientation?: number;
  89870. frontUVs?: Vector4;
  89871. backUVs?: Vector4;
  89872. }): VertexData;
  89873. /**
  89874. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89875. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89876. * @param polygon a mesh built from polygonTriangulation.build()
  89877. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89878. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89879. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89880. * @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)
  89881. * @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)
  89882. * @returns the VertexData of the Polygon
  89883. */
  89884. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89885. /**
  89886. * Creates the VertexData of the IcoSphere
  89887. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89888. * * radius the radius of the IcoSphere, optional default 1
  89889. * * radiusX allows stretching in the x direction, optional, default radius
  89890. * * radiusY allows stretching in the y direction, optional, default radius
  89891. * * radiusZ allows stretching in the z direction, optional, default radius
  89892. * * flat when true creates a flat shaded mesh, optional, default true
  89893. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89894. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89895. * * 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)
  89896. * * 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)
  89897. * @returns the VertexData of the IcoSphere
  89898. */
  89899. static CreateIcoSphere(options: {
  89900. radius?: number;
  89901. radiusX?: number;
  89902. radiusY?: number;
  89903. radiusZ?: number;
  89904. flat?: boolean;
  89905. subdivisions?: number;
  89906. sideOrientation?: number;
  89907. frontUVs?: Vector4;
  89908. backUVs?: Vector4;
  89909. }): VertexData;
  89910. /**
  89911. * Creates the VertexData for a Polyhedron
  89912. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89913. * * type provided types are:
  89914. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89915. * * 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)
  89916. * * size the size of the IcoSphere, optional default 1
  89917. * * sizeX allows stretching in the x direction, optional, default size
  89918. * * sizeY allows stretching in the y direction, optional, default size
  89919. * * sizeZ allows stretching in the z direction, optional, default size
  89920. * * 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
  89921. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89922. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89923. * * flat when true creates a flat shaded mesh, optional, default true
  89924. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89926. * * 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)
  89927. * * 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)
  89928. * @returns the VertexData of the Polyhedron
  89929. */
  89930. static CreatePolyhedron(options: {
  89931. type?: number;
  89932. size?: number;
  89933. sizeX?: number;
  89934. sizeY?: number;
  89935. sizeZ?: number;
  89936. custom?: any;
  89937. faceUV?: Vector4[];
  89938. faceColors?: Color4[];
  89939. flat?: boolean;
  89940. sideOrientation?: number;
  89941. frontUVs?: Vector4;
  89942. backUVs?: Vector4;
  89943. }): VertexData;
  89944. /**
  89945. * Creates the VertexData for a TorusKnot
  89946. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89947. * * radius the radius of the torus knot, optional, default 2
  89948. * * tube the thickness of the tube, optional, default 0.5
  89949. * * radialSegments the number of sides on each tube segments, optional, default 32
  89950. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89951. * * p the number of windings around the z axis, optional, default 2
  89952. * * q the number of windings around the x axis, optional, default 3
  89953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89954. * * 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)
  89955. * * 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)
  89956. * @returns the VertexData of the Torus Knot
  89957. */
  89958. static CreateTorusKnot(options: {
  89959. radius?: number;
  89960. tube?: number;
  89961. radialSegments?: number;
  89962. tubularSegments?: number;
  89963. p?: number;
  89964. q?: number;
  89965. sideOrientation?: number;
  89966. frontUVs?: Vector4;
  89967. backUVs?: Vector4;
  89968. }): VertexData;
  89969. /**
  89970. * Compute normals for given positions and indices
  89971. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89972. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89973. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89974. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89975. * * facetNormals : optional array of facet normals (vector3)
  89976. * * facetPositions : optional array of facet positions (vector3)
  89977. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89978. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89979. * * bInfo : optional bounding info, required for facetPartitioning computation
  89980. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89981. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89982. * * useRightHandedSystem: optional boolean to for right handed system computation
  89983. * * depthSort : optional boolean to enable the facet depth sort computation
  89984. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89985. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89986. */
  89987. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89988. facetNormals?: any;
  89989. facetPositions?: any;
  89990. facetPartitioning?: any;
  89991. ratio?: number;
  89992. bInfo?: any;
  89993. bbSize?: Vector3;
  89994. subDiv?: any;
  89995. useRightHandedSystem?: boolean;
  89996. depthSort?: boolean;
  89997. distanceTo?: Vector3;
  89998. depthSortedFacets?: any;
  89999. }): void;
  90000. /** @hidden */
  90001. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90002. /**
  90003. * Applies VertexData created from the imported parameters to the geometry
  90004. * @param parsedVertexData the parsed data from an imported file
  90005. * @param geometry the geometry to apply the VertexData to
  90006. */
  90007. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90008. }
  90009. }
  90010. declare module BABYLON {
  90011. /**
  90012. * Defines a target to use with MorphTargetManager
  90013. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90014. */
  90015. export class MorphTarget implements IAnimatable {
  90016. /** defines the name of the target */
  90017. name: string;
  90018. /**
  90019. * Gets or sets the list of animations
  90020. */
  90021. animations: Animation[];
  90022. private _scene;
  90023. private _positions;
  90024. private _normals;
  90025. private _tangents;
  90026. private _uvs;
  90027. private _influence;
  90028. private _uniqueId;
  90029. /**
  90030. * Observable raised when the influence changes
  90031. */
  90032. onInfluenceChanged: Observable<boolean>;
  90033. /** @hidden */
  90034. _onDataLayoutChanged: Observable<void>;
  90035. /**
  90036. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90037. */
  90038. influence: number;
  90039. /**
  90040. * Gets or sets the id of the morph Target
  90041. */
  90042. id: string;
  90043. private _animationPropertiesOverride;
  90044. /**
  90045. * Gets or sets the animation properties override
  90046. */
  90047. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90048. /**
  90049. * Creates a new MorphTarget
  90050. * @param name defines the name of the target
  90051. * @param influence defines the influence to use
  90052. * @param scene defines the scene the morphtarget belongs to
  90053. */
  90054. constructor(
  90055. /** defines the name of the target */
  90056. name: string, influence?: number, scene?: Nullable<Scene>);
  90057. /**
  90058. * Gets the unique ID of this manager
  90059. */
  90060. readonly uniqueId: number;
  90061. /**
  90062. * Gets a boolean defining if the target contains position data
  90063. */
  90064. readonly hasPositions: boolean;
  90065. /**
  90066. * Gets a boolean defining if the target contains normal data
  90067. */
  90068. readonly hasNormals: boolean;
  90069. /**
  90070. * Gets a boolean defining if the target contains tangent data
  90071. */
  90072. readonly hasTangents: boolean;
  90073. /**
  90074. * Gets a boolean defining if the target contains texture coordinates data
  90075. */
  90076. readonly hasUVs: boolean;
  90077. /**
  90078. * Affects position data to this target
  90079. * @param data defines the position data to use
  90080. */
  90081. setPositions(data: Nullable<FloatArray>): void;
  90082. /**
  90083. * Gets the position data stored in this target
  90084. * @returns a FloatArray containing the position data (or null if not present)
  90085. */
  90086. getPositions(): Nullable<FloatArray>;
  90087. /**
  90088. * Affects normal data to this target
  90089. * @param data defines the normal data to use
  90090. */
  90091. setNormals(data: Nullable<FloatArray>): void;
  90092. /**
  90093. * Gets the normal data stored in this target
  90094. * @returns a FloatArray containing the normal data (or null if not present)
  90095. */
  90096. getNormals(): Nullable<FloatArray>;
  90097. /**
  90098. * Affects tangent data to this target
  90099. * @param data defines the tangent data to use
  90100. */
  90101. setTangents(data: Nullable<FloatArray>): void;
  90102. /**
  90103. * Gets the tangent data stored in this target
  90104. * @returns a FloatArray containing the tangent data (or null if not present)
  90105. */
  90106. getTangents(): Nullable<FloatArray>;
  90107. /**
  90108. * Affects texture coordinates data to this target
  90109. * @param data defines the texture coordinates data to use
  90110. */
  90111. setUVs(data: Nullable<FloatArray>): void;
  90112. /**
  90113. * Gets the texture coordinates data stored in this target
  90114. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90115. */
  90116. getUVs(): Nullable<FloatArray>;
  90117. /**
  90118. * Clone the current target
  90119. * @returns a new MorphTarget
  90120. */
  90121. clone(): MorphTarget;
  90122. /**
  90123. * Serializes the current target into a Serialization object
  90124. * @returns the serialized object
  90125. */
  90126. serialize(): any;
  90127. /**
  90128. * Returns the string "MorphTarget"
  90129. * @returns "MorphTarget"
  90130. */
  90131. getClassName(): string;
  90132. /**
  90133. * Creates a new target from serialized data
  90134. * @param serializationObject defines the serialized data to use
  90135. * @returns a new MorphTarget
  90136. */
  90137. static Parse(serializationObject: any): MorphTarget;
  90138. /**
  90139. * Creates a MorphTarget from mesh data
  90140. * @param mesh defines the source mesh
  90141. * @param name defines the name to use for the new target
  90142. * @param influence defines the influence to attach to the target
  90143. * @returns a new MorphTarget
  90144. */
  90145. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90146. }
  90147. }
  90148. declare module BABYLON {
  90149. /**
  90150. * This class is used to deform meshes using morphing between different targets
  90151. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90152. */
  90153. export class MorphTargetManager {
  90154. private _targets;
  90155. private _targetInfluenceChangedObservers;
  90156. private _targetDataLayoutChangedObservers;
  90157. private _activeTargets;
  90158. private _scene;
  90159. private _influences;
  90160. private _supportsNormals;
  90161. private _supportsTangents;
  90162. private _supportsUVs;
  90163. private _vertexCount;
  90164. private _uniqueId;
  90165. private _tempInfluences;
  90166. /**
  90167. * Gets or sets a boolean indicating if normals must be morphed
  90168. */
  90169. enableNormalMorphing: boolean;
  90170. /**
  90171. * Gets or sets a boolean indicating if tangents must be morphed
  90172. */
  90173. enableTangentMorphing: boolean;
  90174. /**
  90175. * Gets or sets a boolean indicating if UV must be morphed
  90176. */
  90177. enableUVMorphing: boolean;
  90178. /**
  90179. * Creates a new MorphTargetManager
  90180. * @param scene defines the current scene
  90181. */
  90182. constructor(scene?: Nullable<Scene>);
  90183. /**
  90184. * Gets the unique ID of this manager
  90185. */
  90186. readonly uniqueId: number;
  90187. /**
  90188. * Gets the number of vertices handled by this manager
  90189. */
  90190. readonly vertexCount: number;
  90191. /**
  90192. * Gets a boolean indicating if this manager supports morphing of normals
  90193. */
  90194. readonly supportsNormals: boolean;
  90195. /**
  90196. * Gets a boolean indicating if this manager supports morphing of tangents
  90197. */
  90198. readonly supportsTangents: boolean;
  90199. /**
  90200. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90201. */
  90202. readonly supportsUVs: boolean;
  90203. /**
  90204. * Gets the number of targets stored in this manager
  90205. */
  90206. readonly numTargets: number;
  90207. /**
  90208. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90209. */
  90210. readonly numInfluencers: number;
  90211. /**
  90212. * Gets the list of influences (one per target)
  90213. */
  90214. readonly influences: Float32Array;
  90215. /**
  90216. * Gets the active target at specified index. An active target is a target with an influence > 0
  90217. * @param index defines the index to check
  90218. * @returns the requested target
  90219. */
  90220. getActiveTarget(index: number): MorphTarget;
  90221. /**
  90222. * Gets the target at specified index
  90223. * @param index defines the index to check
  90224. * @returns the requested target
  90225. */
  90226. getTarget(index: number): MorphTarget;
  90227. /**
  90228. * Add a new target to this manager
  90229. * @param target defines the target to add
  90230. */
  90231. addTarget(target: MorphTarget): void;
  90232. /**
  90233. * Removes a target from the manager
  90234. * @param target defines the target to remove
  90235. */
  90236. removeTarget(target: MorphTarget): void;
  90237. /**
  90238. * Clone the current manager
  90239. * @returns a new MorphTargetManager
  90240. */
  90241. clone(): MorphTargetManager;
  90242. /**
  90243. * Serializes the current manager into a Serialization object
  90244. * @returns the serialized object
  90245. */
  90246. serialize(): any;
  90247. private _syncActiveTargets;
  90248. /**
  90249. * Syncrhonize the targets with all the meshes using this morph target manager
  90250. */
  90251. synchronize(): void;
  90252. /**
  90253. * Creates a new MorphTargetManager from serialized data
  90254. * @param serializationObject defines the serialized data
  90255. * @param scene defines the hosting scene
  90256. * @returns the new MorphTargetManager
  90257. */
  90258. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90259. }
  90260. }
  90261. declare module BABYLON {
  90262. /**
  90263. * Class used to represent a specific level of detail of a mesh
  90264. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90265. */
  90266. export class MeshLODLevel {
  90267. /** Defines the distance where this level should start being displayed */
  90268. distance: number;
  90269. /** Defines the mesh to use to render this level */
  90270. mesh: Nullable<Mesh>;
  90271. /**
  90272. * Creates a new LOD level
  90273. * @param distance defines the distance where this level should star being displayed
  90274. * @param mesh defines the mesh to use to render this level
  90275. */
  90276. constructor(
  90277. /** Defines the distance where this level should start being displayed */
  90278. distance: number,
  90279. /** Defines the mesh to use to render this level */
  90280. mesh: Nullable<Mesh>);
  90281. }
  90282. }
  90283. declare module BABYLON {
  90284. /**
  90285. * Mesh representing the gorund
  90286. */
  90287. export class GroundMesh extends Mesh {
  90288. /** If octree should be generated */
  90289. generateOctree: boolean;
  90290. private _heightQuads;
  90291. /** @hidden */
  90292. _subdivisionsX: number;
  90293. /** @hidden */
  90294. _subdivisionsY: number;
  90295. /** @hidden */
  90296. _width: number;
  90297. /** @hidden */
  90298. _height: number;
  90299. /** @hidden */
  90300. _minX: number;
  90301. /** @hidden */
  90302. _maxX: number;
  90303. /** @hidden */
  90304. _minZ: number;
  90305. /** @hidden */
  90306. _maxZ: number;
  90307. constructor(name: string, scene: Scene);
  90308. /**
  90309. * "GroundMesh"
  90310. * @returns "GroundMesh"
  90311. */
  90312. getClassName(): string;
  90313. /**
  90314. * The minimum of x and y subdivisions
  90315. */
  90316. readonly subdivisions: number;
  90317. /**
  90318. * X subdivisions
  90319. */
  90320. readonly subdivisionsX: number;
  90321. /**
  90322. * Y subdivisions
  90323. */
  90324. readonly subdivisionsY: number;
  90325. /**
  90326. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90327. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90328. * @param chunksCount the number of subdivisions for x and y
  90329. * @param octreeBlocksSize (Default: 32)
  90330. */
  90331. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90332. /**
  90333. * Returns a height (y) value in the Worl system :
  90334. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90335. * @param x x coordinate
  90336. * @param z z coordinate
  90337. * @returns the ground y position if (x, z) are outside the ground surface.
  90338. */
  90339. getHeightAtCoordinates(x: number, z: number): number;
  90340. /**
  90341. * Returns a normalized vector (Vector3) orthogonal to the ground
  90342. * at the ground coordinates (x, z) expressed in the World system.
  90343. * @param x x coordinate
  90344. * @param z z coordinate
  90345. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90346. */
  90347. getNormalAtCoordinates(x: number, z: number): Vector3;
  90348. /**
  90349. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90350. * at the ground coordinates (x, z) expressed in the World system.
  90351. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90352. * @param x x coordinate
  90353. * @param z z coordinate
  90354. * @param ref vector to store the result
  90355. * @returns the GroundMesh.
  90356. */
  90357. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90358. /**
  90359. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90360. * if the ground has been updated.
  90361. * This can be used in the render loop.
  90362. * @returns the GroundMesh.
  90363. */
  90364. updateCoordinateHeights(): GroundMesh;
  90365. private _getFacetAt;
  90366. private _initHeightQuads;
  90367. private _computeHeightQuads;
  90368. /**
  90369. * Serializes this ground mesh
  90370. * @param serializationObject object to write serialization to
  90371. */
  90372. serialize(serializationObject: any): void;
  90373. /**
  90374. * Parses a serialized ground mesh
  90375. * @param parsedMesh the serialized mesh
  90376. * @param scene the scene to create the ground mesh in
  90377. * @returns the created ground mesh
  90378. */
  90379. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90380. }
  90381. }
  90382. declare module BABYLON {
  90383. /**
  90384. * Interface for Physics-Joint data
  90385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90386. */
  90387. export interface PhysicsJointData {
  90388. /**
  90389. * The main pivot of the joint
  90390. */
  90391. mainPivot?: Vector3;
  90392. /**
  90393. * The connected pivot of the joint
  90394. */
  90395. connectedPivot?: Vector3;
  90396. /**
  90397. * The main axis of the joint
  90398. */
  90399. mainAxis?: Vector3;
  90400. /**
  90401. * The connected axis of the joint
  90402. */
  90403. connectedAxis?: Vector3;
  90404. /**
  90405. * The collision of the joint
  90406. */
  90407. collision?: boolean;
  90408. /**
  90409. * Native Oimo/Cannon/Energy data
  90410. */
  90411. nativeParams?: any;
  90412. }
  90413. /**
  90414. * This is a holder class for the physics joint created by the physics plugin
  90415. * It holds a set of functions to control the underlying joint
  90416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90417. */
  90418. export class PhysicsJoint {
  90419. /**
  90420. * The type of the physics joint
  90421. */
  90422. type: number;
  90423. /**
  90424. * The data for the physics joint
  90425. */
  90426. jointData: PhysicsJointData;
  90427. private _physicsJoint;
  90428. protected _physicsPlugin: IPhysicsEnginePlugin;
  90429. /**
  90430. * Initializes the physics joint
  90431. * @param type The type of the physics joint
  90432. * @param jointData The data for the physics joint
  90433. */
  90434. constructor(
  90435. /**
  90436. * The type of the physics joint
  90437. */
  90438. type: number,
  90439. /**
  90440. * The data for the physics joint
  90441. */
  90442. jointData: PhysicsJointData);
  90443. /**
  90444. * Gets the physics joint
  90445. */
  90446. /**
  90447. * Sets the physics joint
  90448. */
  90449. physicsJoint: any;
  90450. /**
  90451. * Sets the physics plugin
  90452. */
  90453. physicsPlugin: IPhysicsEnginePlugin;
  90454. /**
  90455. * Execute a function that is physics-plugin specific.
  90456. * @param {Function} func the function that will be executed.
  90457. * It accepts two parameters: the physics world and the physics joint
  90458. */
  90459. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90460. /**
  90461. * Distance-Joint type
  90462. */
  90463. static DistanceJoint: number;
  90464. /**
  90465. * Hinge-Joint type
  90466. */
  90467. static HingeJoint: number;
  90468. /**
  90469. * Ball-and-Socket joint type
  90470. */
  90471. static BallAndSocketJoint: number;
  90472. /**
  90473. * Wheel-Joint type
  90474. */
  90475. static WheelJoint: number;
  90476. /**
  90477. * Slider-Joint type
  90478. */
  90479. static SliderJoint: number;
  90480. /**
  90481. * Prismatic-Joint type
  90482. */
  90483. static PrismaticJoint: number;
  90484. /**
  90485. * Universal-Joint type
  90486. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90487. */
  90488. static UniversalJoint: number;
  90489. /**
  90490. * Hinge-Joint 2 type
  90491. */
  90492. static Hinge2Joint: number;
  90493. /**
  90494. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90495. */
  90496. static PointToPointJoint: number;
  90497. /**
  90498. * Spring-Joint type
  90499. */
  90500. static SpringJoint: number;
  90501. /**
  90502. * Lock-Joint type
  90503. */
  90504. static LockJoint: number;
  90505. }
  90506. /**
  90507. * A class representing a physics distance joint
  90508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90509. */
  90510. export class DistanceJoint extends PhysicsJoint {
  90511. /**
  90512. *
  90513. * @param jointData The data for the Distance-Joint
  90514. */
  90515. constructor(jointData: DistanceJointData);
  90516. /**
  90517. * Update the predefined distance.
  90518. * @param maxDistance The maximum preferred distance
  90519. * @param minDistance The minimum preferred distance
  90520. */
  90521. updateDistance(maxDistance: number, minDistance?: number): void;
  90522. }
  90523. /**
  90524. * Represents a Motor-Enabled Joint
  90525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90526. */
  90527. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90528. /**
  90529. * Initializes the Motor-Enabled Joint
  90530. * @param type The type of the joint
  90531. * @param jointData The physica joint data for the joint
  90532. */
  90533. constructor(type: number, jointData: PhysicsJointData);
  90534. /**
  90535. * Set the motor values.
  90536. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90537. * @param force the force to apply
  90538. * @param maxForce max force for this motor.
  90539. */
  90540. setMotor(force?: number, maxForce?: number): void;
  90541. /**
  90542. * Set the motor's limits.
  90543. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90544. * @param upperLimit The upper limit of the motor
  90545. * @param lowerLimit The lower limit of the motor
  90546. */
  90547. setLimit(upperLimit: number, lowerLimit?: number): void;
  90548. }
  90549. /**
  90550. * This class represents a single physics Hinge-Joint
  90551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90552. */
  90553. export class HingeJoint extends MotorEnabledJoint {
  90554. /**
  90555. * Initializes the Hinge-Joint
  90556. * @param jointData The joint data for the Hinge-Joint
  90557. */
  90558. constructor(jointData: PhysicsJointData);
  90559. /**
  90560. * Set the motor values.
  90561. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90562. * @param {number} force the force to apply
  90563. * @param {number} maxForce max force for this motor.
  90564. */
  90565. setMotor(force?: number, maxForce?: number): void;
  90566. /**
  90567. * Set the motor's limits.
  90568. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90569. * @param upperLimit The upper limit of the motor
  90570. * @param lowerLimit The lower limit of the motor
  90571. */
  90572. setLimit(upperLimit: number, lowerLimit?: number): void;
  90573. }
  90574. /**
  90575. * This class represents a dual hinge physics joint (same as wheel joint)
  90576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90577. */
  90578. export class Hinge2Joint extends MotorEnabledJoint {
  90579. /**
  90580. * Initializes the Hinge2-Joint
  90581. * @param jointData The joint data for the Hinge2-Joint
  90582. */
  90583. constructor(jointData: PhysicsJointData);
  90584. /**
  90585. * Set the motor values.
  90586. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90587. * @param {number} targetSpeed the speed the motor is to reach
  90588. * @param {number} maxForce max force for this motor.
  90589. * @param {motorIndex} the motor's index, 0 or 1.
  90590. */
  90591. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90592. /**
  90593. * Set the motor limits.
  90594. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90595. * @param {number} upperLimit the upper limit
  90596. * @param {number} lowerLimit lower limit
  90597. * @param {motorIndex} the motor's index, 0 or 1.
  90598. */
  90599. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90600. }
  90601. /**
  90602. * Interface for a motor enabled joint
  90603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90604. */
  90605. export interface IMotorEnabledJoint {
  90606. /**
  90607. * Physics joint
  90608. */
  90609. physicsJoint: any;
  90610. /**
  90611. * Sets the motor of the motor-enabled joint
  90612. * @param force The force of the motor
  90613. * @param maxForce The maximum force of the motor
  90614. * @param motorIndex The index of the motor
  90615. */
  90616. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90617. /**
  90618. * Sets the limit of the motor
  90619. * @param upperLimit The upper limit of the motor
  90620. * @param lowerLimit The lower limit of the motor
  90621. * @param motorIndex The index of the motor
  90622. */
  90623. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90624. }
  90625. /**
  90626. * Joint data for a Distance-Joint
  90627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90628. */
  90629. export interface DistanceJointData extends PhysicsJointData {
  90630. /**
  90631. * Max distance the 2 joint objects can be apart
  90632. */
  90633. maxDistance: number;
  90634. }
  90635. /**
  90636. * Joint data from a spring joint
  90637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90638. */
  90639. export interface SpringJointData extends PhysicsJointData {
  90640. /**
  90641. * Length of the spring
  90642. */
  90643. length: number;
  90644. /**
  90645. * Stiffness of the spring
  90646. */
  90647. stiffness: number;
  90648. /**
  90649. * Damping of the spring
  90650. */
  90651. damping: number;
  90652. /** this callback will be called when applying the force to the impostors. */
  90653. forceApplicationCallback: () => void;
  90654. }
  90655. }
  90656. declare module BABYLON {
  90657. /**
  90658. * Holds the data for the raycast result
  90659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90660. */
  90661. export class PhysicsRaycastResult {
  90662. private _hasHit;
  90663. private _hitDistance;
  90664. private _hitNormalWorld;
  90665. private _hitPointWorld;
  90666. private _rayFromWorld;
  90667. private _rayToWorld;
  90668. /**
  90669. * Gets if there was a hit
  90670. */
  90671. readonly hasHit: boolean;
  90672. /**
  90673. * Gets the distance from the hit
  90674. */
  90675. readonly hitDistance: number;
  90676. /**
  90677. * Gets the hit normal/direction in the world
  90678. */
  90679. readonly hitNormalWorld: Vector3;
  90680. /**
  90681. * Gets the hit point in the world
  90682. */
  90683. readonly hitPointWorld: Vector3;
  90684. /**
  90685. * Gets the ray "start point" of the ray in the world
  90686. */
  90687. readonly rayFromWorld: Vector3;
  90688. /**
  90689. * Gets the ray "end point" of the ray in the world
  90690. */
  90691. readonly rayToWorld: Vector3;
  90692. /**
  90693. * Sets the hit data (normal & point in world space)
  90694. * @param hitNormalWorld defines the normal in world space
  90695. * @param hitPointWorld defines the point in world space
  90696. */
  90697. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90698. /**
  90699. * Sets the distance from the start point to the hit point
  90700. * @param distance
  90701. */
  90702. setHitDistance(distance: number): void;
  90703. /**
  90704. * Calculates the distance manually
  90705. */
  90706. calculateHitDistance(): void;
  90707. /**
  90708. * Resets all the values to default
  90709. * @param from The from point on world space
  90710. * @param to The to point on world space
  90711. */
  90712. reset(from?: Vector3, to?: Vector3): void;
  90713. }
  90714. /**
  90715. * Interface for the size containing width and height
  90716. */
  90717. interface IXYZ {
  90718. /**
  90719. * X
  90720. */
  90721. x: number;
  90722. /**
  90723. * Y
  90724. */
  90725. y: number;
  90726. /**
  90727. * Z
  90728. */
  90729. z: number;
  90730. }
  90731. }
  90732. declare module BABYLON {
  90733. /**
  90734. * Interface used to describe a physics joint
  90735. */
  90736. export interface PhysicsImpostorJoint {
  90737. /** Defines the main impostor to which the joint is linked */
  90738. mainImpostor: PhysicsImpostor;
  90739. /** Defines the impostor that is connected to the main impostor using this joint */
  90740. connectedImpostor: PhysicsImpostor;
  90741. /** Defines the joint itself */
  90742. joint: PhysicsJoint;
  90743. }
  90744. /** @hidden */
  90745. export interface IPhysicsEnginePlugin {
  90746. world: any;
  90747. name: string;
  90748. setGravity(gravity: Vector3): void;
  90749. setTimeStep(timeStep: number): void;
  90750. getTimeStep(): number;
  90751. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90752. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90753. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90754. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90755. removePhysicsBody(impostor: PhysicsImpostor): void;
  90756. generateJoint(joint: PhysicsImpostorJoint): void;
  90757. removeJoint(joint: PhysicsImpostorJoint): void;
  90758. isSupported(): boolean;
  90759. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90760. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90761. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90762. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90763. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90764. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90765. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90766. getBodyMass(impostor: PhysicsImpostor): number;
  90767. getBodyFriction(impostor: PhysicsImpostor): number;
  90768. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90769. getBodyRestitution(impostor: PhysicsImpostor): number;
  90770. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90771. getBodyPressure?(impostor: PhysicsImpostor): number;
  90772. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90773. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90774. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90775. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90776. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90777. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90778. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90779. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90780. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90781. sleepBody(impostor: PhysicsImpostor): void;
  90782. wakeUpBody(impostor: PhysicsImpostor): void;
  90783. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90784. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90785. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90786. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90787. getRadius(impostor: PhysicsImpostor): number;
  90788. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90789. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90790. dispose(): void;
  90791. }
  90792. /**
  90793. * Interface used to define a physics engine
  90794. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90795. */
  90796. export interface IPhysicsEngine {
  90797. /**
  90798. * Gets the gravity vector used by the simulation
  90799. */
  90800. gravity: Vector3;
  90801. /**
  90802. * Sets the gravity vector used by the simulation
  90803. * @param gravity defines the gravity vector to use
  90804. */
  90805. setGravity(gravity: Vector3): void;
  90806. /**
  90807. * Set the time step of the physics engine.
  90808. * Default is 1/60.
  90809. * To slow it down, enter 1/600 for example.
  90810. * To speed it up, 1/30
  90811. * @param newTimeStep the new timestep to apply to this world.
  90812. */
  90813. setTimeStep(newTimeStep: number): void;
  90814. /**
  90815. * Get the time step of the physics engine.
  90816. * @returns the current time step
  90817. */
  90818. getTimeStep(): number;
  90819. /**
  90820. * Release all resources
  90821. */
  90822. dispose(): void;
  90823. /**
  90824. * Gets the name of the current physics plugin
  90825. * @returns the name of the plugin
  90826. */
  90827. getPhysicsPluginName(): string;
  90828. /**
  90829. * Adding a new impostor for the impostor tracking.
  90830. * This will be done by the impostor itself.
  90831. * @param impostor the impostor to add
  90832. */
  90833. addImpostor(impostor: PhysicsImpostor): void;
  90834. /**
  90835. * Remove an impostor from the engine.
  90836. * This impostor and its mesh will not longer be updated by the physics engine.
  90837. * @param impostor the impostor to remove
  90838. */
  90839. removeImpostor(impostor: PhysicsImpostor): void;
  90840. /**
  90841. * Add a joint to the physics engine
  90842. * @param mainImpostor defines the main impostor to which the joint is added.
  90843. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90844. * @param joint defines the joint that will connect both impostors.
  90845. */
  90846. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90847. /**
  90848. * Removes a joint from the simulation
  90849. * @param mainImpostor defines the impostor used with the joint
  90850. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90851. * @param joint defines the joint to remove
  90852. */
  90853. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90854. /**
  90855. * Gets the current plugin used to run the simulation
  90856. * @returns current plugin
  90857. */
  90858. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90859. /**
  90860. * Gets the list of physic impostors
  90861. * @returns an array of PhysicsImpostor
  90862. */
  90863. getImpostors(): Array<PhysicsImpostor>;
  90864. /**
  90865. * Gets the impostor for a physics enabled object
  90866. * @param object defines the object impersonated by the impostor
  90867. * @returns the PhysicsImpostor or null if not found
  90868. */
  90869. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90870. /**
  90871. * Gets the impostor for a physics body object
  90872. * @param body defines physics body used by the impostor
  90873. * @returns the PhysicsImpostor or null if not found
  90874. */
  90875. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90876. /**
  90877. * Does a raycast in the physics world
  90878. * @param from when should the ray start?
  90879. * @param to when should the ray end?
  90880. * @returns PhysicsRaycastResult
  90881. */
  90882. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90883. /**
  90884. * Called by the scene. No need to call it.
  90885. * @param delta defines the timespam between frames
  90886. */
  90887. _step(delta: number): void;
  90888. }
  90889. }
  90890. declare module BABYLON {
  90891. /**
  90892. * The interface for the physics imposter parameters
  90893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90894. */
  90895. export interface PhysicsImpostorParameters {
  90896. /**
  90897. * The mass of the physics imposter
  90898. */
  90899. mass: number;
  90900. /**
  90901. * The friction of the physics imposter
  90902. */
  90903. friction?: number;
  90904. /**
  90905. * The coefficient of restitution of the physics imposter
  90906. */
  90907. restitution?: number;
  90908. /**
  90909. * The native options of the physics imposter
  90910. */
  90911. nativeOptions?: any;
  90912. /**
  90913. * Specifies if the parent should be ignored
  90914. */
  90915. ignoreParent?: boolean;
  90916. /**
  90917. * Specifies if bi-directional transformations should be disabled
  90918. */
  90919. disableBidirectionalTransformation?: boolean;
  90920. /**
  90921. * The pressure inside the physics imposter, soft object only
  90922. */
  90923. pressure?: number;
  90924. /**
  90925. * The stiffness the physics imposter, soft object only
  90926. */
  90927. stiffness?: number;
  90928. /**
  90929. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90930. */
  90931. velocityIterations?: number;
  90932. /**
  90933. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90934. */
  90935. positionIterations?: number;
  90936. /**
  90937. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90938. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90939. * Add to fix multiple points
  90940. */
  90941. fixedPoints?: number;
  90942. /**
  90943. * The collision margin around a soft object
  90944. */
  90945. margin?: number;
  90946. /**
  90947. * The collision margin around a soft object
  90948. */
  90949. damping?: number;
  90950. /**
  90951. * The path for a rope based on an extrusion
  90952. */
  90953. path?: any;
  90954. /**
  90955. * The shape of an extrusion used for a rope based on an extrusion
  90956. */
  90957. shape?: any;
  90958. }
  90959. /**
  90960. * Interface for a physics-enabled object
  90961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90962. */
  90963. export interface IPhysicsEnabledObject {
  90964. /**
  90965. * The position of the physics-enabled object
  90966. */
  90967. position: Vector3;
  90968. /**
  90969. * The rotation of the physics-enabled object
  90970. */
  90971. rotationQuaternion: Nullable<Quaternion>;
  90972. /**
  90973. * The scale of the physics-enabled object
  90974. */
  90975. scaling: Vector3;
  90976. /**
  90977. * The rotation of the physics-enabled object
  90978. */
  90979. rotation?: Vector3;
  90980. /**
  90981. * The parent of the physics-enabled object
  90982. */
  90983. parent?: any;
  90984. /**
  90985. * The bounding info of the physics-enabled object
  90986. * @returns The bounding info of the physics-enabled object
  90987. */
  90988. getBoundingInfo(): BoundingInfo;
  90989. /**
  90990. * Computes the world matrix
  90991. * @param force Specifies if the world matrix should be computed by force
  90992. * @returns A world matrix
  90993. */
  90994. computeWorldMatrix(force: boolean): Matrix;
  90995. /**
  90996. * Gets the world matrix
  90997. * @returns A world matrix
  90998. */
  90999. getWorldMatrix?(): Matrix;
  91000. /**
  91001. * Gets the child meshes
  91002. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91003. * @returns An array of abstract meshes
  91004. */
  91005. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91006. /**
  91007. * Gets the vertex data
  91008. * @param kind The type of vertex data
  91009. * @returns A nullable array of numbers, or a float32 array
  91010. */
  91011. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91012. /**
  91013. * Gets the indices from the mesh
  91014. * @returns A nullable array of index arrays
  91015. */
  91016. getIndices?(): Nullable<IndicesArray>;
  91017. /**
  91018. * Gets the scene from the mesh
  91019. * @returns the indices array or null
  91020. */
  91021. getScene?(): Scene;
  91022. /**
  91023. * Gets the absolute position from the mesh
  91024. * @returns the absolute position
  91025. */
  91026. getAbsolutePosition(): Vector3;
  91027. /**
  91028. * Gets the absolute pivot point from the mesh
  91029. * @returns the absolute pivot point
  91030. */
  91031. getAbsolutePivotPoint(): Vector3;
  91032. /**
  91033. * Rotates the mesh
  91034. * @param axis The axis of rotation
  91035. * @param amount The amount of rotation
  91036. * @param space The space of the rotation
  91037. * @returns The rotation transform node
  91038. */
  91039. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91040. /**
  91041. * Translates the mesh
  91042. * @param axis The axis of translation
  91043. * @param distance The distance of translation
  91044. * @param space The space of the translation
  91045. * @returns The transform node
  91046. */
  91047. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91048. /**
  91049. * Sets the absolute position of the mesh
  91050. * @param absolutePosition The absolute position of the mesh
  91051. * @returns The transform node
  91052. */
  91053. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91054. /**
  91055. * Gets the class name of the mesh
  91056. * @returns The class name
  91057. */
  91058. getClassName(): string;
  91059. }
  91060. /**
  91061. * Represents a physics imposter
  91062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91063. */
  91064. export class PhysicsImpostor {
  91065. /**
  91066. * The physics-enabled object used as the physics imposter
  91067. */
  91068. object: IPhysicsEnabledObject;
  91069. /**
  91070. * The type of the physics imposter
  91071. */
  91072. type: number;
  91073. private _options;
  91074. private _scene?;
  91075. /**
  91076. * The default object size of the imposter
  91077. */
  91078. static DEFAULT_OBJECT_SIZE: Vector3;
  91079. /**
  91080. * The identity quaternion of the imposter
  91081. */
  91082. static IDENTITY_QUATERNION: Quaternion;
  91083. /** @hidden */
  91084. _pluginData: any;
  91085. private _physicsEngine;
  91086. private _physicsBody;
  91087. private _bodyUpdateRequired;
  91088. private _onBeforePhysicsStepCallbacks;
  91089. private _onAfterPhysicsStepCallbacks;
  91090. /** @hidden */
  91091. _onPhysicsCollideCallbacks: Array<{
  91092. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91093. otherImpostors: Array<PhysicsImpostor>;
  91094. }>;
  91095. private _deltaPosition;
  91096. private _deltaRotation;
  91097. private _deltaRotationConjugated;
  91098. /** @hidden */
  91099. _isFromLine: boolean;
  91100. private _parent;
  91101. private _isDisposed;
  91102. private static _tmpVecs;
  91103. private static _tmpQuat;
  91104. /**
  91105. * Specifies if the physics imposter is disposed
  91106. */
  91107. readonly isDisposed: boolean;
  91108. /**
  91109. * Gets the mass of the physics imposter
  91110. */
  91111. mass: number;
  91112. /**
  91113. * Gets the coefficient of friction
  91114. */
  91115. /**
  91116. * Sets the coefficient of friction
  91117. */
  91118. friction: number;
  91119. /**
  91120. * Gets the coefficient of restitution
  91121. */
  91122. /**
  91123. * Sets the coefficient of restitution
  91124. */
  91125. restitution: number;
  91126. /**
  91127. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91128. */
  91129. /**
  91130. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91131. */
  91132. pressure: number;
  91133. /**
  91134. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91135. */
  91136. /**
  91137. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91138. */
  91139. stiffness: number;
  91140. /**
  91141. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91142. */
  91143. /**
  91144. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91145. */
  91146. velocityIterations: number;
  91147. /**
  91148. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91149. */
  91150. /**
  91151. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91152. */
  91153. positionIterations: number;
  91154. /**
  91155. * The unique id of the physics imposter
  91156. * set by the physics engine when adding this impostor to the array
  91157. */
  91158. uniqueId: number;
  91159. /**
  91160. * @hidden
  91161. */
  91162. soft: boolean;
  91163. /**
  91164. * @hidden
  91165. */
  91166. segments: number;
  91167. private _joints;
  91168. /**
  91169. * Initializes the physics imposter
  91170. * @param object The physics-enabled object used as the physics imposter
  91171. * @param type The type of the physics imposter
  91172. * @param _options The options for the physics imposter
  91173. * @param _scene The Babylon scene
  91174. */
  91175. constructor(
  91176. /**
  91177. * The physics-enabled object used as the physics imposter
  91178. */
  91179. object: IPhysicsEnabledObject,
  91180. /**
  91181. * The type of the physics imposter
  91182. */
  91183. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91184. /**
  91185. * This function will completly initialize this impostor.
  91186. * It will create a new body - but only if this mesh has no parent.
  91187. * If it has, this impostor will not be used other than to define the impostor
  91188. * of the child mesh.
  91189. * @hidden
  91190. */
  91191. _init(): void;
  91192. private _getPhysicsParent;
  91193. /**
  91194. * Should a new body be generated.
  91195. * @returns boolean specifying if body initialization is required
  91196. */
  91197. isBodyInitRequired(): boolean;
  91198. /**
  91199. * Sets the updated scaling
  91200. * @param updated Specifies if the scaling is updated
  91201. */
  91202. setScalingUpdated(): void;
  91203. /**
  91204. * Force a regeneration of this or the parent's impostor's body.
  91205. * Use under cautious - This will remove all joints already implemented.
  91206. */
  91207. forceUpdate(): void;
  91208. /**
  91209. * Gets the body that holds this impostor. Either its own, or its parent.
  91210. */
  91211. /**
  91212. * Set the physics body. Used mainly by the physics engine/plugin
  91213. */
  91214. physicsBody: any;
  91215. /**
  91216. * Get the parent of the physics imposter
  91217. * @returns Physics imposter or null
  91218. */
  91219. /**
  91220. * Sets the parent of the physics imposter
  91221. */
  91222. parent: Nullable<PhysicsImpostor>;
  91223. /**
  91224. * Resets the update flags
  91225. */
  91226. resetUpdateFlags(): void;
  91227. /**
  91228. * Gets the object extend size
  91229. * @returns the object extend size
  91230. */
  91231. getObjectExtendSize(): Vector3;
  91232. /**
  91233. * Gets the object center
  91234. * @returns The object center
  91235. */
  91236. getObjectCenter(): Vector3;
  91237. /**
  91238. * Get a specific parametes from the options parameter
  91239. * @param paramName The object parameter name
  91240. * @returns The object parameter
  91241. */
  91242. getParam(paramName: string): any;
  91243. /**
  91244. * Sets a specific parameter in the options given to the physics plugin
  91245. * @param paramName The parameter name
  91246. * @param value The value of the parameter
  91247. */
  91248. setParam(paramName: string, value: number): void;
  91249. /**
  91250. * Specifically change the body's mass option. Won't recreate the physics body object
  91251. * @param mass The mass of the physics imposter
  91252. */
  91253. setMass(mass: number): void;
  91254. /**
  91255. * Gets the linear velocity
  91256. * @returns linear velocity or null
  91257. */
  91258. getLinearVelocity(): Nullable<Vector3>;
  91259. /**
  91260. * Sets the linear velocity
  91261. * @param velocity linear velocity or null
  91262. */
  91263. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91264. /**
  91265. * Gets the angular velocity
  91266. * @returns angular velocity or null
  91267. */
  91268. getAngularVelocity(): Nullable<Vector3>;
  91269. /**
  91270. * Sets the angular velocity
  91271. * @param velocity The velocity or null
  91272. */
  91273. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91274. /**
  91275. * Execute a function with the physics plugin native code
  91276. * Provide a function the will have two variables - the world object and the physics body object
  91277. * @param func The function to execute with the physics plugin native code
  91278. */
  91279. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91280. /**
  91281. * Register a function that will be executed before the physics world is stepping forward
  91282. * @param func The function to execute before the physics world is stepped forward
  91283. */
  91284. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91285. /**
  91286. * Unregister a function that will be executed before the physics world is stepping forward
  91287. * @param func The function to execute before the physics world is stepped forward
  91288. */
  91289. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91290. /**
  91291. * Register a function that will be executed after the physics step
  91292. * @param func The function to execute after physics step
  91293. */
  91294. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91295. /**
  91296. * Unregisters a function that will be executed after the physics step
  91297. * @param func The function to execute after physics step
  91298. */
  91299. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91300. /**
  91301. * register a function that will be executed when this impostor collides against a different body
  91302. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91303. * @param func Callback that is executed on collision
  91304. */
  91305. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91306. /**
  91307. * Unregisters the physics imposter on contact
  91308. * @param collideAgainst The physics object to collide against
  91309. * @param func Callback to execute on collision
  91310. */
  91311. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91312. private _tmpQuat;
  91313. private _tmpQuat2;
  91314. /**
  91315. * Get the parent rotation
  91316. * @returns The parent rotation
  91317. */
  91318. getParentsRotation(): Quaternion;
  91319. /**
  91320. * this function is executed by the physics engine.
  91321. */
  91322. beforeStep: () => void;
  91323. /**
  91324. * this function is executed by the physics engine
  91325. */
  91326. afterStep: () => void;
  91327. /**
  91328. * Legacy collision detection event support
  91329. */
  91330. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91331. /**
  91332. * event and body object due to cannon's event-based architecture.
  91333. */
  91334. onCollide: (e: {
  91335. body: any;
  91336. }) => void;
  91337. /**
  91338. * Apply a force
  91339. * @param force The force to apply
  91340. * @param contactPoint The contact point for the force
  91341. * @returns The physics imposter
  91342. */
  91343. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91344. /**
  91345. * Apply an impulse
  91346. * @param force The impulse force
  91347. * @param contactPoint The contact point for the impulse force
  91348. * @returns The physics imposter
  91349. */
  91350. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91351. /**
  91352. * A help function to create a joint
  91353. * @param otherImpostor A physics imposter used to create a joint
  91354. * @param jointType The type of joint
  91355. * @param jointData The data for the joint
  91356. * @returns The physics imposter
  91357. */
  91358. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91359. /**
  91360. * Add a joint to this impostor with a different impostor
  91361. * @param otherImpostor A physics imposter used to add a joint
  91362. * @param joint The joint to add
  91363. * @returns The physics imposter
  91364. */
  91365. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91366. /**
  91367. * Add an anchor to a cloth impostor
  91368. * @param otherImpostor rigid impostor to anchor to
  91369. * @param width ratio across width from 0 to 1
  91370. * @param height ratio up height from 0 to 1
  91371. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91372. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91373. * @returns impostor the soft imposter
  91374. */
  91375. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91376. /**
  91377. * Add a hook to a rope impostor
  91378. * @param otherImpostor rigid impostor to anchor to
  91379. * @param length ratio across rope from 0 to 1
  91380. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91381. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91382. * @returns impostor the rope imposter
  91383. */
  91384. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91385. /**
  91386. * Will keep this body still, in a sleep mode.
  91387. * @returns the physics imposter
  91388. */
  91389. sleep(): PhysicsImpostor;
  91390. /**
  91391. * Wake the body up.
  91392. * @returns The physics imposter
  91393. */
  91394. wakeUp(): PhysicsImpostor;
  91395. /**
  91396. * Clones the physics imposter
  91397. * @param newObject The physics imposter clones to this physics-enabled object
  91398. * @returns A nullable physics imposter
  91399. */
  91400. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91401. /**
  91402. * Disposes the physics imposter
  91403. */
  91404. dispose(): void;
  91405. /**
  91406. * Sets the delta position
  91407. * @param position The delta position amount
  91408. */
  91409. setDeltaPosition(position: Vector3): void;
  91410. /**
  91411. * Sets the delta rotation
  91412. * @param rotation The delta rotation amount
  91413. */
  91414. setDeltaRotation(rotation: Quaternion): void;
  91415. /**
  91416. * Gets the box size of the physics imposter and stores the result in the input parameter
  91417. * @param result Stores the box size
  91418. * @returns The physics imposter
  91419. */
  91420. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91421. /**
  91422. * Gets the radius of the physics imposter
  91423. * @returns Radius of the physics imposter
  91424. */
  91425. getRadius(): number;
  91426. /**
  91427. * Sync a bone with this impostor
  91428. * @param bone The bone to sync to the impostor.
  91429. * @param boneMesh The mesh that the bone is influencing.
  91430. * @param jointPivot The pivot of the joint / bone in local space.
  91431. * @param distToJoint Optional distance from the impostor to the joint.
  91432. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91433. */
  91434. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91435. /**
  91436. * Sync impostor to a bone
  91437. * @param bone The bone that the impostor will be synced to.
  91438. * @param boneMesh The mesh that the bone is influencing.
  91439. * @param jointPivot The pivot of the joint / bone in local space.
  91440. * @param distToJoint Optional distance from the impostor to the joint.
  91441. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91442. * @param boneAxis Optional vector3 axis the bone is aligned with
  91443. */
  91444. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91445. /**
  91446. * No-Imposter type
  91447. */
  91448. static NoImpostor: number;
  91449. /**
  91450. * Sphere-Imposter type
  91451. */
  91452. static SphereImpostor: number;
  91453. /**
  91454. * Box-Imposter type
  91455. */
  91456. static BoxImpostor: number;
  91457. /**
  91458. * Plane-Imposter type
  91459. */
  91460. static PlaneImpostor: number;
  91461. /**
  91462. * Mesh-imposter type
  91463. */
  91464. static MeshImpostor: number;
  91465. /**
  91466. * Capsule-Impostor type (Ammo.js plugin only)
  91467. */
  91468. static CapsuleImpostor: number;
  91469. /**
  91470. * Cylinder-Imposter type
  91471. */
  91472. static CylinderImpostor: number;
  91473. /**
  91474. * Particle-Imposter type
  91475. */
  91476. static ParticleImpostor: number;
  91477. /**
  91478. * Heightmap-Imposter type
  91479. */
  91480. static HeightmapImpostor: number;
  91481. /**
  91482. * ConvexHull-Impostor type (Ammo.js plugin only)
  91483. */
  91484. static ConvexHullImpostor: number;
  91485. /**
  91486. * Rope-Imposter type
  91487. */
  91488. static RopeImpostor: number;
  91489. /**
  91490. * Cloth-Imposter type
  91491. */
  91492. static ClothImpostor: number;
  91493. /**
  91494. * Softbody-Imposter type
  91495. */
  91496. static SoftbodyImpostor: number;
  91497. }
  91498. }
  91499. declare module BABYLON {
  91500. /**
  91501. * @hidden
  91502. **/
  91503. export class _CreationDataStorage {
  91504. closePath?: boolean;
  91505. closeArray?: boolean;
  91506. idx: number[];
  91507. dashSize: number;
  91508. gapSize: number;
  91509. path3D: Path3D;
  91510. pathArray: Vector3[][];
  91511. arc: number;
  91512. radius: number;
  91513. cap: number;
  91514. tessellation: number;
  91515. }
  91516. /**
  91517. * @hidden
  91518. **/
  91519. class _InstanceDataStorage {
  91520. visibleInstances: any;
  91521. batchCache: _InstancesBatch;
  91522. instancesBufferSize: number;
  91523. instancesBuffer: Nullable<Buffer>;
  91524. instancesData: Float32Array;
  91525. overridenInstanceCount: number;
  91526. isFrozen: boolean;
  91527. previousBatch: Nullable<_InstancesBatch>;
  91528. hardwareInstancedRendering: boolean;
  91529. sideOrientation: number;
  91530. }
  91531. /**
  91532. * @hidden
  91533. **/
  91534. export class _InstancesBatch {
  91535. mustReturn: boolean;
  91536. visibleInstances: Nullable<InstancedMesh[]>[];
  91537. renderSelf: boolean[];
  91538. hardwareInstancedRendering: boolean[];
  91539. }
  91540. /**
  91541. * Class used to represent renderable models
  91542. */
  91543. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91544. /**
  91545. * Mesh side orientation : usually the external or front surface
  91546. */
  91547. static readonly FRONTSIDE: number;
  91548. /**
  91549. * Mesh side orientation : usually the internal or back surface
  91550. */
  91551. static readonly BACKSIDE: number;
  91552. /**
  91553. * Mesh side orientation : both internal and external or front and back surfaces
  91554. */
  91555. static readonly DOUBLESIDE: number;
  91556. /**
  91557. * Mesh side orientation : by default, `FRONTSIDE`
  91558. */
  91559. static readonly DEFAULTSIDE: number;
  91560. /**
  91561. * Mesh cap setting : no cap
  91562. */
  91563. static readonly NO_CAP: number;
  91564. /**
  91565. * Mesh cap setting : one cap at the beginning of the mesh
  91566. */
  91567. static readonly CAP_START: number;
  91568. /**
  91569. * Mesh cap setting : one cap at the end of the mesh
  91570. */
  91571. static readonly CAP_END: number;
  91572. /**
  91573. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91574. */
  91575. static readonly CAP_ALL: number;
  91576. /**
  91577. * Mesh pattern setting : no flip or rotate
  91578. */
  91579. static readonly NO_FLIP: number;
  91580. /**
  91581. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91582. */
  91583. static readonly FLIP_TILE: number;
  91584. /**
  91585. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91586. */
  91587. static readonly ROTATE_TILE: number;
  91588. /**
  91589. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91590. */
  91591. static readonly FLIP_ROW: number;
  91592. /**
  91593. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91594. */
  91595. static readonly ROTATE_ROW: number;
  91596. /**
  91597. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91598. */
  91599. static readonly FLIP_N_ROTATE_TILE: number;
  91600. /**
  91601. * Mesh pattern setting : rotate pattern and rotate
  91602. */
  91603. static readonly FLIP_N_ROTATE_ROW: number;
  91604. /**
  91605. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91606. */
  91607. static readonly CENTER: number;
  91608. /**
  91609. * Mesh tile positioning : part tiles on left
  91610. */
  91611. static readonly LEFT: number;
  91612. /**
  91613. * Mesh tile positioning : part tiles on right
  91614. */
  91615. static readonly RIGHT: number;
  91616. /**
  91617. * Mesh tile positioning : part tiles on top
  91618. */
  91619. static readonly TOP: number;
  91620. /**
  91621. * Mesh tile positioning : part tiles on bottom
  91622. */
  91623. static readonly BOTTOM: number;
  91624. /**
  91625. * Gets the default side orientation.
  91626. * @param orientation the orientation to value to attempt to get
  91627. * @returns the default orientation
  91628. * @hidden
  91629. */
  91630. static _GetDefaultSideOrientation(orientation?: number): number;
  91631. private _internalMeshDataInfo;
  91632. /**
  91633. * An event triggered before rendering the mesh
  91634. */
  91635. readonly onBeforeRenderObservable: Observable<Mesh>;
  91636. /**
  91637. * An event triggered before binding the mesh
  91638. */
  91639. readonly onBeforeBindObservable: Observable<Mesh>;
  91640. /**
  91641. * An event triggered after rendering the mesh
  91642. */
  91643. readonly onAfterRenderObservable: Observable<Mesh>;
  91644. /**
  91645. * An event triggered before drawing the mesh
  91646. */
  91647. readonly onBeforeDrawObservable: Observable<Mesh>;
  91648. private _onBeforeDrawObserver;
  91649. /**
  91650. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91651. */
  91652. onBeforeDraw: () => void;
  91653. readonly hasInstances: boolean;
  91654. /**
  91655. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91656. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91657. */
  91658. delayLoadState: number;
  91659. /**
  91660. * Gets the list of instances created from this mesh
  91661. * it is not supposed to be modified manually.
  91662. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91663. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91664. */
  91665. instances: InstancedMesh[];
  91666. /**
  91667. * Gets the file containing delay loading data for this mesh
  91668. */
  91669. delayLoadingFile: string;
  91670. /** @hidden */
  91671. _binaryInfo: any;
  91672. /**
  91673. * User defined function used to change how LOD level selection is done
  91674. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91675. */
  91676. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91677. /**
  91678. * Gets or sets the morph target manager
  91679. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91680. */
  91681. morphTargetManager: Nullable<MorphTargetManager>;
  91682. /** @hidden */
  91683. _creationDataStorage: Nullable<_CreationDataStorage>;
  91684. /** @hidden */
  91685. _geometry: Nullable<Geometry>;
  91686. /** @hidden */
  91687. _delayInfo: Array<string>;
  91688. /** @hidden */
  91689. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91690. /** @hidden */
  91691. _instanceDataStorage: _InstanceDataStorage;
  91692. private _effectiveMaterial;
  91693. /** @hidden */
  91694. _shouldGenerateFlatShading: boolean;
  91695. /** @hidden */
  91696. _originalBuilderSideOrientation: number;
  91697. /**
  91698. * Use this property to change the original side orientation defined at construction time
  91699. */
  91700. overrideMaterialSideOrientation: Nullable<number>;
  91701. /**
  91702. * Gets the source mesh (the one used to clone this one from)
  91703. */
  91704. readonly source: Nullable<Mesh>;
  91705. /**
  91706. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91707. */
  91708. isUnIndexed: boolean;
  91709. /**
  91710. * @constructor
  91711. * @param name The value used by scene.getMeshByName() to do a lookup.
  91712. * @param scene The scene to add this mesh to.
  91713. * @param parent The parent of this mesh, if it has one
  91714. * @param source An optional Mesh from which geometry is shared, cloned.
  91715. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91716. * When false, achieved by calling a clone(), also passing False.
  91717. * This will make creation of children, recursive.
  91718. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91719. */
  91720. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91721. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91722. doNotInstantiate: boolean;
  91723. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91724. /**
  91725. * Gets the class name
  91726. * @returns the string "Mesh".
  91727. */
  91728. getClassName(): string;
  91729. /** @hidden */
  91730. readonly _isMesh: boolean;
  91731. /**
  91732. * Returns a description of this mesh
  91733. * @param fullDetails define if full details about this mesh must be used
  91734. * @returns a descriptive string representing this mesh
  91735. */
  91736. toString(fullDetails?: boolean): string;
  91737. /** @hidden */
  91738. _unBindEffect(): void;
  91739. /**
  91740. * Gets a boolean indicating if this mesh has LOD
  91741. */
  91742. readonly hasLODLevels: boolean;
  91743. /**
  91744. * Gets the list of MeshLODLevel associated with the current mesh
  91745. * @returns an array of MeshLODLevel
  91746. */
  91747. getLODLevels(): MeshLODLevel[];
  91748. private _sortLODLevels;
  91749. /**
  91750. * Add a mesh as LOD level triggered at the given distance.
  91751. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91752. * @param distance The distance from the center of the object to show this level
  91753. * @param mesh The mesh to be added as LOD level (can be null)
  91754. * @return This mesh (for chaining)
  91755. */
  91756. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91757. /**
  91758. * Returns the LOD level mesh at the passed distance or null if not found.
  91759. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91760. * @param distance The distance from the center of the object to show this level
  91761. * @returns a Mesh or `null`
  91762. */
  91763. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91764. /**
  91765. * Remove a mesh from the LOD array
  91766. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91767. * @param mesh defines the mesh to be removed
  91768. * @return This mesh (for chaining)
  91769. */
  91770. removeLODLevel(mesh: Mesh): Mesh;
  91771. /**
  91772. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91773. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91774. * @param camera defines the camera to use to compute distance
  91775. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91776. * @return This mesh (for chaining)
  91777. */
  91778. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91779. /**
  91780. * Gets the mesh internal Geometry object
  91781. */
  91782. readonly geometry: Nullable<Geometry>;
  91783. /**
  91784. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91785. * @returns the total number of vertices
  91786. */
  91787. getTotalVertices(): number;
  91788. /**
  91789. * Returns the content of an associated vertex buffer
  91790. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91791. * - VertexBuffer.PositionKind
  91792. * - VertexBuffer.UVKind
  91793. * - VertexBuffer.UV2Kind
  91794. * - VertexBuffer.UV3Kind
  91795. * - VertexBuffer.UV4Kind
  91796. * - VertexBuffer.UV5Kind
  91797. * - VertexBuffer.UV6Kind
  91798. * - VertexBuffer.ColorKind
  91799. * - VertexBuffer.MatricesIndicesKind
  91800. * - VertexBuffer.MatricesIndicesExtraKind
  91801. * - VertexBuffer.MatricesWeightsKind
  91802. * - VertexBuffer.MatricesWeightsExtraKind
  91803. * @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
  91804. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91805. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91806. */
  91807. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91808. /**
  91809. * Returns the mesh VertexBuffer object from the requested `kind`
  91810. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91811. * - VertexBuffer.PositionKind
  91812. * - VertexBuffer.NormalKind
  91813. * - VertexBuffer.UVKind
  91814. * - VertexBuffer.UV2Kind
  91815. * - VertexBuffer.UV3Kind
  91816. * - VertexBuffer.UV4Kind
  91817. * - VertexBuffer.UV5Kind
  91818. * - VertexBuffer.UV6Kind
  91819. * - VertexBuffer.ColorKind
  91820. * - VertexBuffer.MatricesIndicesKind
  91821. * - VertexBuffer.MatricesIndicesExtraKind
  91822. * - VertexBuffer.MatricesWeightsKind
  91823. * - VertexBuffer.MatricesWeightsExtraKind
  91824. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91825. */
  91826. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91827. /**
  91828. * Tests if a specific vertex buffer is associated with this mesh
  91829. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91830. * - VertexBuffer.PositionKind
  91831. * - VertexBuffer.NormalKind
  91832. * - VertexBuffer.UVKind
  91833. * - VertexBuffer.UV2Kind
  91834. * - VertexBuffer.UV3Kind
  91835. * - VertexBuffer.UV4Kind
  91836. * - VertexBuffer.UV5Kind
  91837. * - VertexBuffer.UV6Kind
  91838. * - VertexBuffer.ColorKind
  91839. * - VertexBuffer.MatricesIndicesKind
  91840. * - VertexBuffer.MatricesIndicesExtraKind
  91841. * - VertexBuffer.MatricesWeightsKind
  91842. * - VertexBuffer.MatricesWeightsExtraKind
  91843. * @returns a boolean
  91844. */
  91845. isVerticesDataPresent(kind: string): boolean;
  91846. /**
  91847. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91848. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91849. * - VertexBuffer.PositionKind
  91850. * - VertexBuffer.UVKind
  91851. * - VertexBuffer.UV2Kind
  91852. * - VertexBuffer.UV3Kind
  91853. * - VertexBuffer.UV4Kind
  91854. * - VertexBuffer.UV5Kind
  91855. * - VertexBuffer.UV6Kind
  91856. * - VertexBuffer.ColorKind
  91857. * - VertexBuffer.MatricesIndicesKind
  91858. * - VertexBuffer.MatricesIndicesExtraKind
  91859. * - VertexBuffer.MatricesWeightsKind
  91860. * - VertexBuffer.MatricesWeightsExtraKind
  91861. * @returns a boolean
  91862. */
  91863. isVertexBufferUpdatable(kind: string): boolean;
  91864. /**
  91865. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91866. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91867. * - VertexBuffer.PositionKind
  91868. * - VertexBuffer.NormalKind
  91869. * - VertexBuffer.UVKind
  91870. * - VertexBuffer.UV2Kind
  91871. * - VertexBuffer.UV3Kind
  91872. * - VertexBuffer.UV4Kind
  91873. * - VertexBuffer.UV5Kind
  91874. * - VertexBuffer.UV6Kind
  91875. * - VertexBuffer.ColorKind
  91876. * - VertexBuffer.MatricesIndicesKind
  91877. * - VertexBuffer.MatricesIndicesExtraKind
  91878. * - VertexBuffer.MatricesWeightsKind
  91879. * - VertexBuffer.MatricesWeightsExtraKind
  91880. * @returns an array of strings
  91881. */
  91882. getVerticesDataKinds(): string[];
  91883. /**
  91884. * Returns a positive integer : the total number of indices in this mesh geometry.
  91885. * @returns the numner of indices or zero if the mesh has no geometry.
  91886. */
  91887. getTotalIndices(): number;
  91888. /**
  91889. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91890. * @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.
  91891. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91892. * @returns the indices array or an empty array if the mesh has no geometry
  91893. */
  91894. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91895. readonly isBlocked: boolean;
  91896. /**
  91897. * Determine if the current mesh is ready to be rendered
  91898. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91899. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91900. * @returns true if all associated assets are ready (material, textures, shaders)
  91901. */
  91902. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91903. /**
  91904. * 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.
  91905. */
  91906. readonly areNormalsFrozen: boolean;
  91907. /**
  91908. * 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.
  91909. * @returns the current mesh
  91910. */
  91911. freezeNormals(): Mesh;
  91912. /**
  91913. * 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
  91914. * @returns the current mesh
  91915. */
  91916. unfreezeNormals(): Mesh;
  91917. /**
  91918. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91919. */
  91920. overridenInstanceCount: number;
  91921. /** @hidden */
  91922. _preActivate(): Mesh;
  91923. /** @hidden */
  91924. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91925. /** @hidden */
  91926. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91927. /**
  91928. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91929. * This means the mesh underlying bounding box and sphere are recomputed.
  91930. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91931. * @returns the current mesh
  91932. */
  91933. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91934. /** @hidden */
  91935. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91936. /**
  91937. * This function will subdivide the mesh into multiple submeshes
  91938. * @param count defines the expected number of submeshes
  91939. */
  91940. subdivide(count: number): void;
  91941. /**
  91942. * Copy a FloatArray into a specific associated vertex buffer
  91943. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91944. * - VertexBuffer.PositionKind
  91945. * - VertexBuffer.UVKind
  91946. * - VertexBuffer.UV2Kind
  91947. * - VertexBuffer.UV3Kind
  91948. * - VertexBuffer.UV4Kind
  91949. * - VertexBuffer.UV5Kind
  91950. * - VertexBuffer.UV6Kind
  91951. * - VertexBuffer.ColorKind
  91952. * - VertexBuffer.MatricesIndicesKind
  91953. * - VertexBuffer.MatricesIndicesExtraKind
  91954. * - VertexBuffer.MatricesWeightsKind
  91955. * - VertexBuffer.MatricesWeightsExtraKind
  91956. * @param data defines the data source
  91957. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91958. * @param stride defines the data stride size (can be null)
  91959. * @returns the current mesh
  91960. */
  91961. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91962. /**
  91963. * Delete a vertex buffer associated with this mesh
  91964. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  91965. * - VertexBuffer.PositionKind
  91966. * - VertexBuffer.UVKind
  91967. * - VertexBuffer.UV2Kind
  91968. * - VertexBuffer.UV3Kind
  91969. * - VertexBuffer.UV4Kind
  91970. * - VertexBuffer.UV5Kind
  91971. * - VertexBuffer.UV6Kind
  91972. * - VertexBuffer.ColorKind
  91973. * - VertexBuffer.MatricesIndicesKind
  91974. * - VertexBuffer.MatricesIndicesExtraKind
  91975. * - VertexBuffer.MatricesWeightsKind
  91976. * - VertexBuffer.MatricesWeightsExtraKind
  91977. */
  91978. removeVerticesData(kind: string): void;
  91979. /**
  91980. * Flags an associated vertex buffer as updatable
  91981. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91982. * - VertexBuffer.PositionKind
  91983. * - VertexBuffer.UVKind
  91984. * - VertexBuffer.UV2Kind
  91985. * - VertexBuffer.UV3Kind
  91986. * - VertexBuffer.UV4Kind
  91987. * - VertexBuffer.UV5Kind
  91988. * - VertexBuffer.UV6Kind
  91989. * - VertexBuffer.ColorKind
  91990. * - VertexBuffer.MatricesIndicesKind
  91991. * - VertexBuffer.MatricesIndicesExtraKind
  91992. * - VertexBuffer.MatricesWeightsKind
  91993. * - VertexBuffer.MatricesWeightsExtraKind
  91994. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91995. */
  91996. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91997. /**
  91998. * Sets the mesh global Vertex Buffer
  91999. * @param buffer defines the buffer to use
  92000. * @returns the current mesh
  92001. */
  92002. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92003. /**
  92004. * Update a specific associated vertex buffer
  92005. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92006. * - VertexBuffer.PositionKind
  92007. * - VertexBuffer.UVKind
  92008. * - VertexBuffer.UV2Kind
  92009. * - VertexBuffer.UV3Kind
  92010. * - VertexBuffer.UV4Kind
  92011. * - VertexBuffer.UV5Kind
  92012. * - VertexBuffer.UV6Kind
  92013. * - VertexBuffer.ColorKind
  92014. * - VertexBuffer.MatricesIndicesKind
  92015. * - VertexBuffer.MatricesIndicesExtraKind
  92016. * - VertexBuffer.MatricesWeightsKind
  92017. * - VertexBuffer.MatricesWeightsExtraKind
  92018. * @param data defines the data source
  92019. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92020. * @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)
  92021. * @returns the current mesh
  92022. */
  92023. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92024. /**
  92025. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92026. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92027. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92028. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92029. * @returns the current mesh
  92030. */
  92031. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92032. /**
  92033. * Creates a un-shared specific occurence of the geometry for the mesh.
  92034. * @returns the current mesh
  92035. */
  92036. makeGeometryUnique(): Mesh;
  92037. /**
  92038. * Set the index buffer of this mesh
  92039. * @param indices defines the source data
  92040. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92041. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92042. * @returns the current mesh
  92043. */
  92044. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92045. /**
  92046. * Update the current index buffer
  92047. * @param indices defines the source data
  92048. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92049. * @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)
  92050. * @returns the current mesh
  92051. */
  92052. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92053. /**
  92054. * Invert the geometry to move from a right handed system to a left handed one.
  92055. * @returns the current mesh
  92056. */
  92057. toLeftHanded(): Mesh;
  92058. /** @hidden */
  92059. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92060. /** @hidden */
  92061. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92062. /**
  92063. * Registers for this mesh a javascript function called just before the rendering process
  92064. * @param func defines the function to call before rendering this mesh
  92065. * @returns the current mesh
  92066. */
  92067. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92068. /**
  92069. * Disposes a previously registered javascript function called before the rendering
  92070. * @param func defines the function to remove
  92071. * @returns the current mesh
  92072. */
  92073. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92074. /**
  92075. * Registers for this mesh a javascript function called just after the rendering is complete
  92076. * @param func defines the function to call after rendering this mesh
  92077. * @returns the current mesh
  92078. */
  92079. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92080. /**
  92081. * Disposes a previously registered javascript function called after the rendering.
  92082. * @param func defines the function to remove
  92083. * @returns the current mesh
  92084. */
  92085. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92086. /** @hidden */
  92087. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  92088. /** @hidden */
  92089. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92090. /** @hidden */
  92091. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92092. /** @hidden */
  92093. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92094. /** @hidden */
  92095. _rebuild(): void;
  92096. /** @hidden */
  92097. _freeze(): void;
  92098. /** @hidden */
  92099. _unFreeze(): void;
  92100. /**
  92101. * 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
  92102. * @param subMesh defines the subMesh to render
  92103. * @param enableAlphaMode defines if alpha mode can be changed
  92104. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92105. * @returns the current mesh
  92106. */
  92107. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92108. private _onBeforeDraw;
  92109. /**
  92110. * Renormalize the mesh and patch it up if there are no weights
  92111. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92112. * However in the case of zero weights then we set just a single influence to 1.
  92113. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92114. */
  92115. cleanMatrixWeights(): void;
  92116. private normalizeSkinFourWeights;
  92117. private normalizeSkinWeightsAndExtra;
  92118. /**
  92119. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92120. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92121. * the user know there was an issue with importing the mesh
  92122. * @returns a validation object with skinned, valid and report string
  92123. */
  92124. validateSkinning(): {
  92125. skinned: boolean;
  92126. valid: boolean;
  92127. report: string;
  92128. };
  92129. /** @hidden */
  92130. _checkDelayState(): Mesh;
  92131. private _queueLoad;
  92132. /**
  92133. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92134. * A mesh is in the frustum if its bounding box intersects the frustum
  92135. * @param frustumPlanes defines the frustum to test
  92136. * @returns true if the mesh is in the frustum planes
  92137. */
  92138. isInFrustum(frustumPlanes: Plane[]): boolean;
  92139. /**
  92140. * Sets the mesh material by the material or multiMaterial `id` property
  92141. * @param id is a string identifying the material or the multiMaterial
  92142. * @returns the current mesh
  92143. */
  92144. setMaterialByID(id: string): Mesh;
  92145. /**
  92146. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92147. * @returns an array of IAnimatable
  92148. */
  92149. getAnimatables(): IAnimatable[];
  92150. /**
  92151. * Modifies the mesh geometry according to the passed transformation matrix.
  92152. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92153. * The mesh normals are modified using the same transformation.
  92154. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92155. * @param transform defines the transform matrix to use
  92156. * @see http://doc.babylonjs.com/resources/baking_transformations
  92157. * @returns the current mesh
  92158. */
  92159. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92160. /**
  92161. * Modifies the mesh geometry according to its own current World Matrix.
  92162. * The mesh World Matrix is then reset.
  92163. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92164. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92165. * @see http://doc.babylonjs.com/resources/baking_transformations
  92166. * @returns the current mesh
  92167. */
  92168. bakeCurrentTransformIntoVertices(): Mesh;
  92169. /** @hidden */
  92170. readonly _positions: Nullable<Vector3[]>;
  92171. /** @hidden */
  92172. _resetPointsArrayCache(): Mesh;
  92173. /** @hidden */
  92174. _generatePointsArray(): boolean;
  92175. /**
  92176. * Returns a new Mesh object generated from the current mesh properties.
  92177. * This method must not get confused with createInstance()
  92178. * @param name is a string, the name given to the new mesh
  92179. * @param newParent can be any Node object (default `null`)
  92180. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92181. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92182. * @returns a new mesh
  92183. */
  92184. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92185. /**
  92186. * Releases resources associated with this mesh.
  92187. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92188. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92189. */
  92190. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92191. /** @hidden */
  92192. _disposeInstanceSpecificData(): void;
  92193. /**
  92194. * Modifies the mesh geometry according to a displacement map.
  92195. * 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.
  92196. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92197. * @param url is a string, the URL from the image file is to be downloaded.
  92198. * @param minHeight is the lower limit of the displacement.
  92199. * @param maxHeight is the upper limit of the displacement.
  92200. * @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.
  92201. * @param uvOffset is an optional vector2 used to offset UV.
  92202. * @param uvScale is an optional vector2 used to scale UV.
  92203. * @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.
  92204. * @returns the Mesh.
  92205. */
  92206. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92207. /**
  92208. * Modifies the mesh geometry according to a displacementMap buffer.
  92209. * 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.
  92210. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92211. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92212. * @param heightMapWidth is the width of the buffer image.
  92213. * @param heightMapHeight is the height of the buffer image.
  92214. * @param minHeight is the lower limit of the displacement.
  92215. * @param maxHeight is the upper limit of the displacement.
  92216. * @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.
  92217. * @param uvOffset is an optional vector2 used to offset UV.
  92218. * @param uvScale is an optional vector2 used to scale UV.
  92219. * @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.
  92220. * @returns the Mesh.
  92221. */
  92222. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92223. /**
  92224. * Modify the mesh to get a flat shading rendering.
  92225. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92226. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92227. * @returns current mesh
  92228. */
  92229. convertToFlatShadedMesh(): Mesh;
  92230. /**
  92231. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92232. * In other words, more vertices, no more indices and a single bigger VBO.
  92233. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92234. * @returns current mesh
  92235. */
  92236. convertToUnIndexedMesh(): Mesh;
  92237. /**
  92238. * Inverses facet orientations.
  92239. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92240. * @param flipNormals will also inverts the normals
  92241. * @returns current mesh
  92242. */
  92243. flipFaces(flipNormals?: boolean): Mesh;
  92244. /**
  92245. * Increase the number of facets and hence vertices in a mesh
  92246. * Vertex normals are interpolated from existing vertex normals
  92247. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92248. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92249. */
  92250. increaseVertices(numberPerEdge: number): void;
  92251. /**
  92252. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92253. * This will undo any application of covertToFlatShadedMesh
  92254. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92255. */
  92256. forceSharedVertices(): void;
  92257. /** @hidden */
  92258. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92259. /** @hidden */
  92260. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92261. /**
  92262. * Creates a new InstancedMesh object from the mesh model.
  92263. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92264. * @param name defines the name of the new instance
  92265. * @returns a new InstancedMesh
  92266. */
  92267. createInstance(name: string): InstancedMesh;
  92268. /**
  92269. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92270. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92271. * @returns the current mesh
  92272. */
  92273. synchronizeInstances(): Mesh;
  92274. /**
  92275. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92276. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92277. * This should be used together with the simplification to avoid disappearing triangles.
  92278. * @param successCallback an optional success callback to be called after the optimization finished.
  92279. * @returns the current mesh
  92280. */
  92281. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92282. /**
  92283. * Serialize current mesh
  92284. * @param serializationObject defines the object which will receive the serialization data
  92285. */
  92286. serialize(serializationObject: any): void;
  92287. /** @hidden */
  92288. _syncGeometryWithMorphTargetManager(): void;
  92289. /** @hidden */
  92290. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92291. /**
  92292. * Returns a new Mesh object parsed from the source provided.
  92293. * @param parsedMesh is the source
  92294. * @param scene defines the hosting scene
  92295. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92296. * @returns a new Mesh
  92297. */
  92298. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92299. /**
  92300. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92301. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92302. * @param name defines the name of the mesh to create
  92303. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92304. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92305. * @param closePath creates a seam between the first and the last points of each path of the path array
  92306. * @param offset is taken in account only if the `pathArray` is containing a single path
  92307. * @param scene defines the hosting scene
  92308. * @param updatable defines if the mesh must be flagged as updatable
  92309. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92310. * @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)
  92311. * @returns a new Mesh
  92312. */
  92313. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92314. /**
  92315. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92316. * @param name defines the name of the mesh to create
  92317. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92318. * @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
  92319. * @param scene defines the hosting scene
  92320. * @param updatable defines if the mesh must be flagged as updatable
  92321. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92322. * @returns a new Mesh
  92323. */
  92324. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92325. /**
  92326. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92327. * @param name defines the name of the mesh to create
  92328. * @param size sets the size (float) of each box side (default 1)
  92329. * @param scene defines the hosting scene
  92330. * @param updatable defines if the mesh must be flagged as updatable
  92331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92332. * @returns a new Mesh
  92333. */
  92334. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92335. /**
  92336. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92337. * @param name defines the name of the mesh to create
  92338. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92339. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92340. * @param scene defines the hosting scene
  92341. * @param updatable defines if the mesh must be flagged as updatable
  92342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92343. * @returns a new Mesh
  92344. */
  92345. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92346. /**
  92347. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92348. * @param name defines the name of the mesh to create
  92349. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92350. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92351. * @param scene defines the hosting scene
  92352. * @returns a new Mesh
  92353. */
  92354. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92355. /**
  92356. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92357. * @param name defines the name of the mesh to create
  92358. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92359. * @param diameterTop set the top cap diameter (floats, default 1)
  92360. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92361. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92362. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92363. * @param scene defines the hosting scene
  92364. * @param updatable defines if the mesh must be flagged as updatable
  92365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92366. * @returns a new Mesh
  92367. */
  92368. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92369. /**
  92370. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92371. * @param name defines the name of the mesh to create
  92372. * @param diameter sets the diameter size (float) of the torus (default 1)
  92373. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92374. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92375. * @param scene defines the hosting scene
  92376. * @param updatable defines if the mesh must be flagged as updatable
  92377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92378. * @returns a new Mesh
  92379. */
  92380. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92381. /**
  92382. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92383. * @param name defines the name of the mesh to create
  92384. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92385. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92386. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92387. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92388. * @param p the number of windings on X axis (positive integers, default 2)
  92389. * @param q the number of windings on Y axis (positive integers, default 3)
  92390. * @param scene defines the hosting scene
  92391. * @param updatable defines if the mesh must be flagged as updatable
  92392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92393. * @returns a new Mesh
  92394. */
  92395. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92396. /**
  92397. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92398. * @param name defines the name of the mesh to create
  92399. * @param points is an array successive Vector3
  92400. * @param scene defines the hosting scene
  92401. * @param updatable defines if the mesh must be flagged as updatable
  92402. * @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).
  92403. * @returns a new Mesh
  92404. */
  92405. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92406. /**
  92407. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92408. * @param name defines the name of the mesh to create
  92409. * @param points is an array successive Vector3
  92410. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92411. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92412. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92413. * @param scene defines the hosting scene
  92414. * @param updatable defines if the mesh must be flagged as updatable
  92415. * @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)
  92416. * @returns a new Mesh
  92417. */
  92418. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92419. /**
  92420. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92421. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92422. * 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.
  92423. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92424. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92425. * Remember you can only change the shape positions, not their number when updating a polygon.
  92426. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92427. * @param name defines the name of the mesh to create
  92428. * @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
  92429. * @param scene defines the hosting scene
  92430. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92431. * @param updatable defines if the mesh must be flagged as updatable
  92432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92433. * @param earcutInjection can be used to inject your own earcut reference
  92434. * @returns a new Mesh
  92435. */
  92436. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92437. /**
  92438. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92440. * @param name defines the name of the mesh to create
  92441. * @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
  92442. * @param depth defines the height of extrusion
  92443. * @param scene defines the hosting scene
  92444. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92445. * @param updatable defines if the mesh must be flagged as updatable
  92446. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92447. * @param earcutInjection can be used to inject your own earcut reference
  92448. * @returns a new Mesh
  92449. */
  92450. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92451. /**
  92452. * Creates an extruded shape mesh.
  92453. * 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
  92454. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92455. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92456. * @param name defines the name of the mesh to create
  92457. * @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
  92458. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92459. * @param scale is the value to scale the shape
  92460. * @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
  92461. * @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
  92462. * @param scene defines the hosting scene
  92463. * @param updatable defines if the mesh must be flagged as updatable
  92464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92465. * @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)
  92466. * @returns a new Mesh
  92467. */
  92468. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92469. /**
  92470. * Creates an custom extruded shape mesh.
  92471. * The custom extrusion is a parametric shape.
  92472. * It has no predefined shape. Its final shape will depend on the input parameters.
  92473. * Please consider using the same method from the MeshBuilder class instead
  92474. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92475. * @param name defines the name of the mesh to create
  92476. * @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
  92477. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92478. * @param scaleFunction is a custom Javascript function called on each path point
  92479. * @param rotationFunction is a custom Javascript function called on each path point
  92480. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92481. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92482. * @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
  92483. * @param scene defines the hosting scene
  92484. * @param updatable defines if the mesh must be flagged as updatable
  92485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92486. * @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)
  92487. * @returns a new Mesh
  92488. */
  92489. 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;
  92490. /**
  92491. * Creates lathe mesh.
  92492. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92493. * Please consider using the same method from the MeshBuilder class instead
  92494. * @param name defines the name of the mesh to create
  92495. * @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
  92496. * @param radius is the radius value of the lathe
  92497. * @param tessellation is the side number of the lathe.
  92498. * @param scene defines the hosting scene
  92499. * @param updatable defines if the mesh must be flagged as updatable
  92500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92501. * @returns a new Mesh
  92502. */
  92503. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92504. /**
  92505. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92506. * @param name defines the name of the mesh to create
  92507. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92508. * @param scene defines the hosting scene
  92509. * @param updatable defines if the mesh must be flagged as updatable
  92510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92511. * @returns a new Mesh
  92512. */
  92513. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92514. /**
  92515. * Creates a ground mesh.
  92516. * Please consider using the same method from the MeshBuilder class instead
  92517. * @param name defines the name of the mesh to create
  92518. * @param width set the width of the ground
  92519. * @param height set the height of the ground
  92520. * @param subdivisions sets the number of subdivisions per side
  92521. * @param scene defines the hosting scene
  92522. * @param updatable defines if the mesh must be flagged as updatable
  92523. * @returns a new Mesh
  92524. */
  92525. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92526. /**
  92527. * Creates a tiled ground mesh.
  92528. * Please consider using the same method from the MeshBuilder class instead
  92529. * @param name defines the name of the mesh to create
  92530. * @param xmin set the ground minimum X coordinate
  92531. * @param zmin set the ground minimum Y coordinate
  92532. * @param xmax set the ground maximum X coordinate
  92533. * @param zmax set the ground maximum Z coordinate
  92534. * @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
  92535. * @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
  92536. * @param scene defines the hosting scene
  92537. * @param updatable defines if the mesh must be flagged as updatable
  92538. * @returns a new Mesh
  92539. */
  92540. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92541. w: number;
  92542. h: number;
  92543. }, precision: {
  92544. w: number;
  92545. h: number;
  92546. }, scene: Scene, updatable?: boolean): Mesh;
  92547. /**
  92548. * Creates a ground mesh from a height map.
  92549. * Please consider using the same method from the MeshBuilder class instead
  92550. * @see http://doc.babylonjs.com/babylon101/height_map
  92551. * @param name defines the name of the mesh to create
  92552. * @param url sets the URL of the height map image resource
  92553. * @param width set the ground width size
  92554. * @param height set the ground height size
  92555. * @param subdivisions sets the number of subdivision per side
  92556. * @param minHeight is the minimum altitude on the ground
  92557. * @param maxHeight is the maximum altitude on the ground
  92558. * @param scene defines the hosting scene
  92559. * @param updatable defines if the mesh must be flagged as updatable
  92560. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92561. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92562. * @returns a new Mesh
  92563. */
  92564. 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;
  92565. /**
  92566. * Creates a tube mesh.
  92567. * The tube is a parametric shape.
  92568. * It has no predefined shape. Its final shape will depend on the input parameters.
  92569. * Please consider using the same method from the MeshBuilder class instead
  92570. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92571. * @param name defines the name of the mesh to create
  92572. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92573. * @param radius sets the tube radius size
  92574. * @param tessellation is the number of sides on the tubular surface
  92575. * @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
  92576. * @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
  92577. * @param scene defines the hosting scene
  92578. * @param updatable defines if the mesh must be flagged as updatable
  92579. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92580. * @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)
  92581. * @returns a new Mesh
  92582. */
  92583. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92584. (i: number, distance: number): number;
  92585. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92586. /**
  92587. * Creates a polyhedron mesh.
  92588. * Please consider using the same method from the MeshBuilder class instead.
  92589. * * 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
  92590. * * The parameter `size` (positive float, default 1) sets the polygon size
  92591. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92592. * * 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`
  92593. * * 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
  92594. * * 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)`)
  92595. * * 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
  92596. * * 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
  92597. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92598. * * If you create a double-sided mesh, you can choose what parts of 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
  92599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92600. * @param name defines the name of the mesh to create
  92601. * @param options defines the options used to create the mesh
  92602. * @param scene defines the hosting scene
  92603. * @returns a new Mesh
  92604. */
  92605. static CreatePolyhedron(name: string, options: {
  92606. type?: number;
  92607. size?: number;
  92608. sizeX?: number;
  92609. sizeY?: number;
  92610. sizeZ?: number;
  92611. custom?: any;
  92612. faceUV?: Vector4[];
  92613. faceColors?: Color4[];
  92614. updatable?: boolean;
  92615. sideOrientation?: number;
  92616. }, scene: Scene): Mesh;
  92617. /**
  92618. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92619. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92620. * * 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`)
  92621. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92622. * * 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
  92623. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92624. * * If you create a double-sided mesh, you can choose what parts of 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
  92625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92626. * @param name defines the name of the mesh
  92627. * @param options defines the options used to create the mesh
  92628. * @param scene defines the hosting scene
  92629. * @returns a new Mesh
  92630. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92631. */
  92632. static CreateIcoSphere(name: string, options: {
  92633. radius?: number;
  92634. flat?: boolean;
  92635. subdivisions?: number;
  92636. sideOrientation?: number;
  92637. updatable?: boolean;
  92638. }, scene: Scene): Mesh;
  92639. /**
  92640. * Creates a decal mesh.
  92641. * Please consider using the same method from the MeshBuilder class instead.
  92642. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92643. * @param name defines the name of the mesh
  92644. * @param sourceMesh defines the mesh receiving the decal
  92645. * @param position sets the position of the decal in world coordinates
  92646. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92647. * @param size sets the decal scaling
  92648. * @param angle sets the angle to rotate the decal
  92649. * @returns a new Mesh
  92650. */
  92651. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92652. /**
  92653. * Prepare internal position array for software CPU skinning
  92654. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92655. */
  92656. setPositionsForCPUSkinning(): Float32Array;
  92657. /**
  92658. * Prepare internal normal array for software CPU skinning
  92659. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92660. */
  92661. setNormalsForCPUSkinning(): Float32Array;
  92662. /**
  92663. * Updates the vertex buffer by applying transformation from the bones
  92664. * @param skeleton defines the skeleton to apply to current mesh
  92665. * @returns the current mesh
  92666. */
  92667. applySkeleton(skeleton: Skeleton): Mesh;
  92668. /**
  92669. * 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
  92670. * @param meshes defines the list of meshes to scan
  92671. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92672. */
  92673. static MinMax(meshes: AbstractMesh[]): {
  92674. min: Vector3;
  92675. max: Vector3;
  92676. };
  92677. /**
  92678. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92679. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92680. * @returns a vector3
  92681. */
  92682. static Center(meshesOrMinMaxVector: {
  92683. min: Vector3;
  92684. max: Vector3;
  92685. } | AbstractMesh[]): Vector3;
  92686. /**
  92687. * Merge the array of meshes into a single mesh for performance reasons.
  92688. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92689. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92690. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92691. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92692. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92693. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92694. * @returns a new mesh
  92695. */
  92696. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92697. /** @hidden */
  92698. addInstance(instance: InstancedMesh): void;
  92699. /** @hidden */
  92700. removeInstance(instance: InstancedMesh): void;
  92701. }
  92702. }
  92703. declare module BABYLON {
  92704. /**
  92705. * This is the base class of all the camera used in the application.
  92706. * @see http://doc.babylonjs.com/features/cameras
  92707. */
  92708. export class Camera extends Node {
  92709. /** @hidden */
  92710. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92711. /**
  92712. * This is the default projection mode used by the cameras.
  92713. * It helps recreating a feeling of perspective and better appreciate depth.
  92714. * This is the best way to simulate real life cameras.
  92715. */
  92716. static readonly PERSPECTIVE_CAMERA: number;
  92717. /**
  92718. * This helps creating camera with an orthographic mode.
  92719. * 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.
  92720. */
  92721. static readonly ORTHOGRAPHIC_CAMERA: number;
  92722. /**
  92723. * This is the default FOV mode for perspective cameras.
  92724. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92725. */
  92726. static readonly FOVMODE_VERTICAL_FIXED: number;
  92727. /**
  92728. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92729. */
  92730. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92731. /**
  92732. * This specifies ther is no need for a camera rig.
  92733. * Basically only one eye is rendered corresponding to the camera.
  92734. */
  92735. static readonly RIG_MODE_NONE: number;
  92736. /**
  92737. * Simulates a camera Rig with one blue eye and one red eye.
  92738. * This can be use with 3d blue and red glasses.
  92739. */
  92740. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92741. /**
  92742. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92743. */
  92744. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92745. /**
  92746. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92747. */
  92748. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92749. /**
  92750. * Defines that both eyes of the camera will be rendered over under each other.
  92751. */
  92752. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92753. /**
  92754. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92755. */
  92756. static readonly RIG_MODE_VR: number;
  92757. /**
  92758. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92759. */
  92760. static readonly RIG_MODE_WEBVR: number;
  92761. /**
  92762. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92763. */
  92764. static readonly RIG_MODE_CUSTOM: number;
  92765. /**
  92766. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92767. */
  92768. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92769. /**
  92770. * Define the input manager associated with the camera.
  92771. */
  92772. inputs: CameraInputsManager<Camera>;
  92773. /** @hidden */
  92774. _position: Vector3;
  92775. /**
  92776. * Define the current local position of the camera in the scene
  92777. */
  92778. position: Vector3;
  92779. /**
  92780. * The vector the camera should consider as up.
  92781. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92782. */
  92783. upVector: Vector3;
  92784. /**
  92785. * Define the current limit on the left side for an orthographic camera
  92786. * In scene unit
  92787. */
  92788. orthoLeft: Nullable<number>;
  92789. /**
  92790. * Define the current limit on the right side for an orthographic camera
  92791. * In scene unit
  92792. */
  92793. orthoRight: Nullable<number>;
  92794. /**
  92795. * Define the current limit on the bottom side for an orthographic camera
  92796. * In scene unit
  92797. */
  92798. orthoBottom: Nullable<number>;
  92799. /**
  92800. * Define the current limit on the top side for an orthographic camera
  92801. * In scene unit
  92802. */
  92803. orthoTop: Nullable<number>;
  92804. /**
  92805. * Field Of View is set in Radians. (default is 0.8)
  92806. */
  92807. fov: number;
  92808. /**
  92809. * Define the minimum distance the camera can see from.
  92810. * This is important to note that the depth buffer are not infinite and the closer it starts
  92811. * the more your scene might encounter depth fighting issue.
  92812. */
  92813. minZ: number;
  92814. /**
  92815. * Define the maximum distance the camera can see to.
  92816. * This is important to note that the depth buffer are not infinite and the further it end
  92817. * the more your scene might encounter depth fighting issue.
  92818. */
  92819. maxZ: number;
  92820. /**
  92821. * Define the default inertia of the camera.
  92822. * This helps giving a smooth feeling to the camera movement.
  92823. */
  92824. inertia: number;
  92825. /**
  92826. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92827. */
  92828. mode: number;
  92829. /**
  92830. * Define wether the camera is intermediate.
  92831. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92832. */
  92833. isIntermediate: boolean;
  92834. /**
  92835. * Define the viewport of the camera.
  92836. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92837. */
  92838. viewport: Viewport;
  92839. /**
  92840. * Restricts the camera to viewing objects with the same layerMask.
  92841. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92842. */
  92843. layerMask: number;
  92844. /**
  92845. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92846. */
  92847. fovMode: number;
  92848. /**
  92849. * Rig mode of the camera.
  92850. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92851. * This is normally controlled byt the camera themselves as internal use.
  92852. */
  92853. cameraRigMode: number;
  92854. /**
  92855. * Defines the distance between both "eyes" in case of a RIG
  92856. */
  92857. interaxialDistance: number;
  92858. /**
  92859. * Defines if stereoscopic rendering is done side by side or over under.
  92860. */
  92861. isStereoscopicSideBySide: boolean;
  92862. /**
  92863. * 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
  92864. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92865. * else in the scene. (Eg. security camera)
  92866. *
  92867. * 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)
  92868. */
  92869. customRenderTargets: RenderTargetTexture[];
  92870. /**
  92871. * When set, the camera will render to this render target instead of the default canvas
  92872. *
  92873. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92874. */
  92875. outputRenderTarget: Nullable<RenderTargetTexture>;
  92876. /**
  92877. * Observable triggered when the camera view matrix has changed.
  92878. */
  92879. onViewMatrixChangedObservable: Observable<Camera>;
  92880. /**
  92881. * Observable triggered when the camera Projection matrix has changed.
  92882. */
  92883. onProjectionMatrixChangedObservable: Observable<Camera>;
  92884. /**
  92885. * Observable triggered when the inputs have been processed.
  92886. */
  92887. onAfterCheckInputsObservable: Observable<Camera>;
  92888. /**
  92889. * Observable triggered when reset has been called and applied to the camera.
  92890. */
  92891. onRestoreStateObservable: Observable<Camera>;
  92892. /** @hidden */
  92893. _cameraRigParams: any;
  92894. /** @hidden */
  92895. _rigCameras: Camera[];
  92896. /** @hidden */
  92897. _rigPostProcess: Nullable<PostProcess>;
  92898. protected _webvrViewMatrix: Matrix;
  92899. /** @hidden */
  92900. _skipRendering: boolean;
  92901. /** @hidden */
  92902. _projectionMatrix: Matrix;
  92903. /** @hidden */
  92904. _postProcesses: Nullable<PostProcess>[];
  92905. /** @hidden */
  92906. _activeMeshes: SmartArray<AbstractMesh>;
  92907. protected _globalPosition: Vector3;
  92908. /** @hidden */
  92909. _computedViewMatrix: Matrix;
  92910. private _doNotComputeProjectionMatrix;
  92911. private _transformMatrix;
  92912. private _frustumPlanes;
  92913. private _refreshFrustumPlanes;
  92914. private _storedFov;
  92915. private _stateStored;
  92916. /**
  92917. * Instantiates a new camera object.
  92918. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92919. * @see http://doc.babylonjs.com/features/cameras
  92920. * @param name Defines the name of the camera in the scene
  92921. * @param position Defines the position of the camera
  92922. * @param scene Defines the scene the camera belongs too
  92923. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92924. */
  92925. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92926. /**
  92927. * Store current camera state (fov, position, etc..)
  92928. * @returns the camera
  92929. */
  92930. storeState(): Camera;
  92931. /**
  92932. * Restores the camera state values if it has been stored. You must call storeState() first
  92933. */
  92934. protected _restoreStateValues(): boolean;
  92935. /**
  92936. * Restored camera state. You must call storeState() first.
  92937. * @returns true if restored and false otherwise
  92938. */
  92939. restoreState(): boolean;
  92940. /**
  92941. * Gets the class name of the camera.
  92942. * @returns the class name
  92943. */
  92944. getClassName(): string;
  92945. /** @hidden */
  92946. readonly _isCamera: boolean;
  92947. /**
  92948. * Gets a string representation of the camera useful for debug purpose.
  92949. * @param fullDetails Defines that a more verboe level of logging is required
  92950. * @returns the string representation
  92951. */
  92952. toString(fullDetails?: boolean): string;
  92953. /**
  92954. * Gets the current world space position of the camera.
  92955. */
  92956. readonly globalPosition: Vector3;
  92957. /**
  92958. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92959. * @returns the active meshe list
  92960. */
  92961. getActiveMeshes(): SmartArray<AbstractMesh>;
  92962. /**
  92963. * Check wether a mesh is part of the current active mesh list of the camera
  92964. * @param mesh Defines the mesh to check
  92965. * @returns true if active, false otherwise
  92966. */
  92967. isActiveMesh(mesh: Mesh): boolean;
  92968. /**
  92969. * Is this camera ready to be used/rendered
  92970. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92971. * @return true if the camera is ready
  92972. */
  92973. isReady(completeCheck?: boolean): boolean;
  92974. /** @hidden */
  92975. _initCache(): void;
  92976. /** @hidden */
  92977. _updateCache(ignoreParentClass?: boolean): void;
  92978. /** @hidden */
  92979. _isSynchronized(): boolean;
  92980. /** @hidden */
  92981. _isSynchronizedViewMatrix(): boolean;
  92982. /** @hidden */
  92983. _isSynchronizedProjectionMatrix(): boolean;
  92984. /**
  92985. * Attach the input controls to a specific dom element to get the input from.
  92986. * @param element Defines the element the controls should be listened from
  92987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92988. */
  92989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92990. /**
  92991. * Detach the current controls from the specified dom element.
  92992. * @param element Defines the element to stop listening the inputs from
  92993. */
  92994. detachControl(element: HTMLElement): void;
  92995. /**
  92996. * Update the camera state according to the different inputs gathered during the frame.
  92997. */
  92998. update(): void;
  92999. /** @hidden */
  93000. _checkInputs(): void;
  93001. /** @hidden */
  93002. readonly rigCameras: Camera[];
  93003. /**
  93004. * Gets the post process used by the rig cameras
  93005. */
  93006. readonly rigPostProcess: Nullable<PostProcess>;
  93007. /**
  93008. * Internal, gets the first post proces.
  93009. * @returns the first post process to be run on this camera.
  93010. */
  93011. _getFirstPostProcess(): Nullable<PostProcess>;
  93012. private _cascadePostProcessesToRigCams;
  93013. /**
  93014. * Attach a post process to the camera.
  93015. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93016. * @param postProcess The post process to attach to the camera
  93017. * @param insertAt The position of the post process in case several of them are in use in the scene
  93018. * @returns the position the post process has been inserted at
  93019. */
  93020. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93021. /**
  93022. * Detach a post process to the camera.
  93023. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93024. * @param postProcess The post process to detach from the camera
  93025. */
  93026. detachPostProcess(postProcess: PostProcess): void;
  93027. /**
  93028. * Gets the current world matrix of the camera
  93029. */
  93030. getWorldMatrix(): Matrix;
  93031. /** @hidden */
  93032. _getViewMatrix(): Matrix;
  93033. /**
  93034. * Gets the current view matrix of the camera.
  93035. * @param force forces the camera to recompute the matrix without looking at the cached state
  93036. * @returns the view matrix
  93037. */
  93038. getViewMatrix(force?: boolean): Matrix;
  93039. /**
  93040. * Freeze the projection matrix.
  93041. * It will prevent the cache check of the camera projection compute and can speed up perf
  93042. * if no parameter of the camera are meant to change
  93043. * @param projection Defines manually a projection if necessary
  93044. */
  93045. freezeProjectionMatrix(projection?: Matrix): void;
  93046. /**
  93047. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93048. */
  93049. unfreezeProjectionMatrix(): void;
  93050. /**
  93051. * Gets the current projection matrix of the camera.
  93052. * @param force forces the camera to recompute the matrix without looking at the cached state
  93053. * @returns the projection matrix
  93054. */
  93055. getProjectionMatrix(force?: boolean): Matrix;
  93056. /**
  93057. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93058. * @returns a Matrix
  93059. */
  93060. getTransformationMatrix(): Matrix;
  93061. private _updateFrustumPlanes;
  93062. /**
  93063. * Checks if a cullable object (mesh...) is in the camera frustum
  93064. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93065. * @param target The object to check
  93066. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93067. * @returns true if the object is in frustum otherwise false
  93068. */
  93069. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93070. /**
  93071. * Checks if a cullable object (mesh...) is in the camera frustum
  93072. * Unlike isInFrustum this cheks the full bounding box
  93073. * @param target The object to check
  93074. * @returns true if the object is in frustum otherwise false
  93075. */
  93076. isCompletelyInFrustum(target: ICullable): boolean;
  93077. /**
  93078. * Gets a ray in the forward direction from the camera.
  93079. * @param length Defines the length of the ray to create
  93080. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93081. * @param origin Defines the start point of the ray which defaults to the camera position
  93082. * @returns the forward ray
  93083. */
  93084. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93085. /**
  93086. * Releases resources associated with this node.
  93087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93089. */
  93090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93091. /** @hidden */
  93092. _isLeftCamera: boolean;
  93093. /**
  93094. * Gets the left camera of a rig setup in case of Rigged Camera
  93095. */
  93096. readonly isLeftCamera: boolean;
  93097. /** @hidden */
  93098. _isRightCamera: boolean;
  93099. /**
  93100. * Gets the right camera of a rig setup in case of Rigged Camera
  93101. */
  93102. readonly isRightCamera: boolean;
  93103. /**
  93104. * Gets the left camera of a rig setup in case of Rigged Camera
  93105. */
  93106. readonly leftCamera: Nullable<FreeCamera>;
  93107. /**
  93108. * Gets the right camera of a rig setup in case of Rigged Camera
  93109. */
  93110. readonly rightCamera: Nullable<FreeCamera>;
  93111. /**
  93112. * Gets the left camera target of a rig setup in case of Rigged Camera
  93113. * @returns the target position
  93114. */
  93115. getLeftTarget(): Nullable<Vector3>;
  93116. /**
  93117. * Gets the right camera target of a rig setup in case of Rigged Camera
  93118. * @returns the target position
  93119. */
  93120. getRightTarget(): Nullable<Vector3>;
  93121. /**
  93122. * @hidden
  93123. */
  93124. setCameraRigMode(mode: number, rigParams: any): void;
  93125. /** @hidden */
  93126. static _setStereoscopicRigMode(camera: Camera): void;
  93127. /** @hidden */
  93128. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93129. /** @hidden */
  93130. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93131. /** @hidden */
  93132. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93133. /** @hidden */
  93134. _getVRProjectionMatrix(): Matrix;
  93135. protected _updateCameraRotationMatrix(): void;
  93136. protected _updateWebVRCameraRotationMatrix(): void;
  93137. /**
  93138. * This function MUST be overwritten by the different WebVR cameras available.
  93139. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93140. * @hidden
  93141. */
  93142. _getWebVRProjectionMatrix(): Matrix;
  93143. /**
  93144. * This function MUST be overwritten by the different WebVR cameras available.
  93145. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93146. * @hidden
  93147. */
  93148. _getWebVRViewMatrix(): Matrix;
  93149. /** @hidden */
  93150. setCameraRigParameter(name: string, value: any): void;
  93151. /**
  93152. * needs to be overridden by children so sub has required properties to be copied
  93153. * @hidden
  93154. */
  93155. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93156. /**
  93157. * May need to be overridden by children
  93158. * @hidden
  93159. */
  93160. _updateRigCameras(): void;
  93161. /** @hidden */
  93162. _setupInputs(): void;
  93163. /**
  93164. * Serialiaze the camera setup to a json represention
  93165. * @returns the JSON representation
  93166. */
  93167. serialize(): any;
  93168. /**
  93169. * Clones the current camera.
  93170. * @param name The cloned camera name
  93171. * @returns the cloned camera
  93172. */
  93173. clone(name: string): Camera;
  93174. /**
  93175. * Gets the direction of the camera relative to a given local axis.
  93176. * @param localAxis Defines the reference axis to provide a relative direction.
  93177. * @return the direction
  93178. */
  93179. getDirection(localAxis: Vector3): Vector3;
  93180. /**
  93181. * Returns the current camera absolute rotation
  93182. */
  93183. readonly absoluteRotation: Quaternion;
  93184. /**
  93185. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93186. * @param localAxis Defines the reference axis to provide a relative direction.
  93187. * @param result Defines the vector to store the result in
  93188. */
  93189. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93190. /**
  93191. * Gets a camera constructor for a given camera type
  93192. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93193. * @param name The name of the camera the result will be able to instantiate
  93194. * @param scene The scene the result will construct the camera in
  93195. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93196. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93197. * @returns a factory method to construc the camera
  93198. */
  93199. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93200. /**
  93201. * Compute the world matrix of the camera.
  93202. * @returns the camera world matrix
  93203. */
  93204. computeWorldMatrix(): Matrix;
  93205. /**
  93206. * Parse a JSON and creates the camera from the parsed information
  93207. * @param parsedCamera The JSON to parse
  93208. * @param scene The scene to instantiate the camera in
  93209. * @returns the newly constructed camera
  93210. */
  93211. static Parse(parsedCamera: any, scene: Scene): Camera;
  93212. }
  93213. }
  93214. declare module BABYLON {
  93215. /**
  93216. * Class containing static functions to help procedurally build meshes
  93217. */
  93218. export class DiscBuilder {
  93219. /**
  93220. * Creates a plane polygonal mesh. By default, this is a disc
  93221. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93222. * * 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
  93223. * * 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
  93224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93227. * @param name defines the name of the mesh
  93228. * @param options defines the options used to create the mesh
  93229. * @param scene defines the hosting scene
  93230. * @returns the plane polygonal mesh
  93231. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93232. */
  93233. static CreateDisc(name: string, options: {
  93234. radius?: number;
  93235. tessellation?: number;
  93236. arc?: number;
  93237. updatable?: boolean;
  93238. sideOrientation?: number;
  93239. frontUVs?: Vector4;
  93240. backUVs?: Vector4;
  93241. }, scene?: Nullable<Scene>): Mesh;
  93242. }
  93243. }
  93244. declare module BABYLON {
  93245. /**
  93246. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93247. *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.
  93248. * The SPS is also a particle system. It provides some methods to manage the particles.
  93249. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93250. *
  93251. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93252. */
  93253. export class SolidParticleSystem implements IDisposable {
  93254. /**
  93255. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93256. * Example : var p = SPS.particles[i];
  93257. */
  93258. particles: SolidParticle[];
  93259. /**
  93260. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93261. */
  93262. nbParticles: number;
  93263. /**
  93264. * If the particles must ever face the camera (default false). Useful for planar particles.
  93265. */
  93266. billboard: boolean;
  93267. /**
  93268. * Recompute normals when adding a shape
  93269. */
  93270. recomputeNormals: boolean;
  93271. /**
  93272. * This a counter ofr your own usage. It's not set by any SPS functions.
  93273. */
  93274. counter: number;
  93275. /**
  93276. * The SPS name. This name is also given to the underlying mesh.
  93277. */
  93278. name: string;
  93279. /**
  93280. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93281. */
  93282. mesh: Mesh;
  93283. /**
  93284. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93285. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93286. */
  93287. vars: any;
  93288. /**
  93289. * This array is populated when the SPS is set as 'pickable'.
  93290. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93291. * Each element of this array is an object `{idx: int, faceId: int}`.
  93292. * `idx` is the picked particle index in the `SPS.particles` array
  93293. * `faceId` is the picked face index counted within this particle.
  93294. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93295. */
  93296. pickedParticles: {
  93297. idx: number;
  93298. faceId: number;
  93299. }[];
  93300. /**
  93301. * This array is populated when `enableDepthSort` is set to true.
  93302. * Each element of this array is an instance of the class DepthSortedParticle.
  93303. */
  93304. depthSortedParticles: DepthSortedParticle[];
  93305. /**
  93306. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93307. * @hidden
  93308. */
  93309. _bSphereOnly: boolean;
  93310. /**
  93311. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93312. * @hidden
  93313. */
  93314. _bSphereRadiusFactor: number;
  93315. private _scene;
  93316. private _positions;
  93317. private _indices;
  93318. private _normals;
  93319. private _colors;
  93320. private _uvs;
  93321. private _indices32;
  93322. private _positions32;
  93323. private _normals32;
  93324. private _fixedNormal32;
  93325. private _colors32;
  93326. private _uvs32;
  93327. private _index;
  93328. private _updatable;
  93329. private _pickable;
  93330. private _isVisibilityBoxLocked;
  93331. private _alwaysVisible;
  93332. private _depthSort;
  93333. private _expandable;
  93334. private _shapeCounter;
  93335. private _copy;
  93336. private _color;
  93337. private _computeParticleColor;
  93338. private _computeParticleTexture;
  93339. private _computeParticleRotation;
  93340. private _computeParticleVertex;
  93341. private _computeBoundingBox;
  93342. private _depthSortParticles;
  93343. private _camera;
  93344. private _mustUnrotateFixedNormals;
  93345. private _particlesIntersect;
  93346. private _needs32Bits;
  93347. private _isNotBuilt;
  93348. /**
  93349. * Creates a SPS (Solid Particle System) object.
  93350. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93351. * @param scene (Scene) is the scene in which the SPS is added.
  93352. * @param options defines the options of the sps e.g.
  93353. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93354. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93355. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93356. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93357. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93358. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93359. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93360. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93361. */
  93362. constructor(name: string, scene: Scene, options?: {
  93363. updatable?: boolean;
  93364. isPickable?: boolean;
  93365. enableDepthSort?: boolean;
  93366. particleIntersection?: boolean;
  93367. boundingSphereOnly?: boolean;
  93368. bSphereRadiusFactor?: number;
  93369. expandable?: boolean;
  93370. });
  93371. /**
  93372. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93373. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93374. * @returns the created mesh
  93375. */
  93376. buildMesh(): Mesh;
  93377. /**
  93378. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93379. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93380. * Thus the particles generated from `digest()` have their property `position` set yet.
  93381. * @param mesh ( Mesh ) is the mesh to be digested
  93382. * @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
  93383. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93384. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93385. * @returns the current SPS
  93386. */
  93387. digest(mesh: Mesh, options?: {
  93388. facetNb?: number;
  93389. number?: number;
  93390. delta?: number;
  93391. }): SolidParticleSystem;
  93392. private _unrotateFixedNormals;
  93393. private _resetCopy;
  93394. private _meshBuilder;
  93395. private _posToShape;
  93396. private _uvsToShapeUV;
  93397. private _addParticle;
  93398. /**
  93399. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93400. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93401. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93402. * @param nb (positive integer) the number of particles to be created from this model
  93403. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93404. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93405. * @returns the number of shapes in the system
  93406. */
  93407. addShape(mesh: Mesh, nb: number, options?: {
  93408. positionFunction?: any;
  93409. vertexFunction?: any;
  93410. }): number;
  93411. private _rebuildParticle;
  93412. /**
  93413. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93414. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  93415. * @returns the SPS.
  93416. */
  93417. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93418. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93419. * Returns an array with the removed particles.
  93420. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  93421. * The SPS can't be empty so at least one particle needs to remain in place.
  93422. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93423. * @param start index of the first particle to remove
  93424. * @param end index of the last particle to remove (included)
  93425. * @returns an array populated with the removed particles
  93426. */
  93427. removeParticles(start: number, end: number): SolidParticle[];
  93428. /**
  93429. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93430. * This method calls `updateParticle()` for each particle of the SPS.
  93431. * For an animated SPS, it is usually called within the render loop.
  93432. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  93433. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93434. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93435. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93436. * @returns the SPS.
  93437. */
  93438. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93439. /**
  93440. * Disposes the SPS.
  93441. */
  93442. dispose(): void;
  93443. /**
  93444. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93445. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93446. * @returns the SPS.
  93447. */
  93448. refreshVisibleSize(): SolidParticleSystem;
  93449. /**
  93450. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93451. * @param size the size (float) of the visibility box
  93452. * note : this doesn't lock the SPS mesh bounding box.
  93453. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93454. */
  93455. setVisibilityBox(size: number): void;
  93456. /**
  93457. * Gets whether the SPS as always visible or not
  93458. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93459. */
  93460. /**
  93461. * Sets the SPS as always visible or not
  93462. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93463. */
  93464. isAlwaysVisible: boolean;
  93465. /**
  93466. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93467. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93468. */
  93469. /**
  93470. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93471. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93472. */
  93473. isVisibilityBoxLocked: boolean;
  93474. /**
  93475. * Tells to `setParticles()` to compute the particle rotations or not.
  93476. * Default value : true. The SPS is faster when it's set to false.
  93477. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93478. */
  93479. /**
  93480. * Gets if `setParticles()` computes the particle rotations or not.
  93481. * Default value : true. The SPS is faster when it's set to false.
  93482. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93483. */
  93484. computeParticleRotation: boolean;
  93485. /**
  93486. * Tells to `setParticles()` to compute the particle colors or not.
  93487. * Default value : true. The SPS is faster when it's set to false.
  93488. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93489. */
  93490. /**
  93491. * Gets if `setParticles()` computes the particle colors or not.
  93492. * Default value : true. The SPS is faster when it's set to false.
  93493. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93494. */
  93495. computeParticleColor: boolean;
  93496. /**
  93497. * Gets if `setParticles()` computes the particle textures or not.
  93498. * Default value : true. The SPS is faster when it's set to false.
  93499. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  93500. */
  93501. computeParticleTexture: boolean;
  93502. /**
  93503. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  93504. * Default value : false. The SPS is faster when it's set to false.
  93505. * Note : the particle custom vertex positions aren't stored values.
  93506. */
  93507. /**
  93508. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93509. * Default value : false. The SPS is faster when it's set to false.
  93510. * Note : the particle custom vertex positions aren't stored values.
  93511. */
  93512. computeParticleVertex: boolean;
  93513. /**
  93514. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93515. */
  93516. /**
  93517. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  93518. */
  93519. computeBoundingBox: boolean;
  93520. /**
  93521. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  93522. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93523. * Default : `true`
  93524. */
  93525. /**
  93526. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  93527. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93528. * Default : `true`
  93529. */
  93530. depthSortParticles: boolean;
  93531. /**
  93532. * Gets if the SPS is created as expandable at construction time.
  93533. * Default : `false`
  93534. */
  93535. readonly expandable: boolean;
  93536. /**
  93537. * This function does nothing. It may be overwritten to set all the particle first values.
  93538. * The SPS doesn't call this function, you may have to call it by your own.
  93539. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93540. */
  93541. initParticles(): void;
  93542. /**
  93543. * This function does nothing. It may be overwritten to recycle a particle.
  93544. * The SPS doesn't call this function, you may have to call it by your own.
  93545. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93546. * @param particle The particle to recycle
  93547. * @returns the recycled particle
  93548. */
  93549. recycleParticle(particle: SolidParticle): SolidParticle;
  93550. /**
  93551. * Updates a particle : this function should be overwritten by the user.
  93552. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  93553. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93554. * @example : just set a particle position or velocity and recycle conditions
  93555. * @param particle The particle to update
  93556. * @returns the updated particle
  93557. */
  93558. updateParticle(particle: SolidParticle): SolidParticle;
  93559. /**
  93560. * Updates a vertex of a particle : it can be overwritten by the user.
  93561. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  93562. * @param particle the current particle
  93563. * @param vertex the current index of the current particle
  93564. * @param pt the index of the current vertex in the particle shape
  93565. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93566. * @example : just set a vertex particle position
  93567. * @returns the updated vertex
  93568. */
  93569. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93570. /**
  93571. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93572. * This does nothing and may be overwritten by the user.
  93573. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93574. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93575. * @param update the boolean update value actually passed to setParticles()
  93576. */
  93577. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93578. /**
  93579. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93580. * This will be passed three parameters.
  93581. * This does nothing and may be overwritten by the user.
  93582. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93583. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93584. * @param update the boolean update value actually passed to setParticles()
  93585. */
  93586. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93587. }
  93588. }
  93589. declare module BABYLON {
  93590. /**
  93591. * Represents one particle of a solid particle system.
  93592. */
  93593. export class SolidParticle {
  93594. /**
  93595. * particle global index
  93596. */
  93597. idx: number;
  93598. /**
  93599. * The color of the particle
  93600. */
  93601. color: Nullable<Color4>;
  93602. /**
  93603. * The world space position of the particle.
  93604. */
  93605. position: Vector3;
  93606. /**
  93607. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93608. */
  93609. rotation: Vector3;
  93610. /**
  93611. * The world space rotation quaternion of the particle.
  93612. */
  93613. rotationQuaternion: Nullable<Quaternion>;
  93614. /**
  93615. * The scaling of the particle.
  93616. */
  93617. scaling: Vector3;
  93618. /**
  93619. * The uvs of the particle.
  93620. */
  93621. uvs: Vector4;
  93622. /**
  93623. * The current speed of the particle.
  93624. */
  93625. velocity: Vector3;
  93626. /**
  93627. * The pivot point in the particle local space.
  93628. */
  93629. pivot: Vector3;
  93630. /**
  93631. * Must the particle be translated from its pivot point in its local space ?
  93632. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93633. * Default : false
  93634. */
  93635. translateFromPivot: boolean;
  93636. /**
  93637. * Is the particle active or not ?
  93638. */
  93639. alive: boolean;
  93640. /**
  93641. * Is the particle visible or not ?
  93642. */
  93643. isVisible: boolean;
  93644. /**
  93645. * Index of this particle in the global "positions" array (Internal use)
  93646. * @hidden
  93647. */
  93648. _pos: number;
  93649. /**
  93650. * @hidden Index of this particle in the global "indices" array (Internal use)
  93651. */
  93652. _ind: number;
  93653. /**
  93654. * @hidden ModelShape of this particle (Internal use)
  93655. */
  93656. _model: ModelShape;
  93657. /**
  93658. * ModelShape id of this particle
  93659. */
  93660. shapeId: number;
  93661. /**
  93662. * Index of the particle in its shape id
  93663. */
  93664. idxInShape: number;
  93665. /**
  93666. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93667. */
  93668. _modelBoundingInfo: BoundingInfo;
  93669. /**
  93670. * @hidden Particle BoundingInfo object (Internal use)
  93671. */
  93672. _boundingInfo: BoundingInfo;
  93673. /**
  93674. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93675. */
  93676. _sps: SolidParticleSystem;
  93677. /**
  93678. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93679. */
  93680. _stillInvisible: boolean;
  93681. /**
  93682. * @hidden Last computed particle rotation matrix
  93683. */
  93684. _rotationMatrix: number[];
  93685. /**
  93686. * Parent particle Id, if any.
  93687. * Default null.
  93688. */
  93689. parentId: Nullable<number>;
  93690. /**
  93691. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93692. * The possible values are :
  93693. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93694. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93695. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93696. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93697. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93698. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93699. * */
  93700. cullingStrategy: number;
  93701. /**
  93702. * @hidden Internal global position in the SPS.
  93703. */
  93704. _globalPosition: Vector3;
  93705. /**
  93706. * Creates a Solid Particle object.
  93707. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93708. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  93709. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93710. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93711. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93712. * @param shapeId (integer) is the model shape identifier in the SPS.
  93713. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93714. * @param sps defines the sps it is associated to
  93715. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93716. */
  93717. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93718. /**
  93719. * Legacy support, changed scale to scaling
  93720. */
  93721. /**
  93722. * Legacy support, changed scale to scaling
  93723. */
  93724. scale: Vector3;
  93725. /**
  93726. * Legacy support, changed quaternion to rotationQuaternion
  93727. */
  93728. /**
  93729. * Legacy support, changed quaternion to rotationQuaternion
  93730. */
  93731. quaternion: Nullable<Quaternion>;
  93732. /**
  93733. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93734. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93735. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93736. * @returns true if it intersects
  93737. */
  93738. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93739. /**
  93740. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93741. * A particle is in the frustum if its bounding box intersects the frustum
  93742. * @param frustumPlanes defines the frustum to test
  93743. * @returns true if the particle is in the frustum planes
  93744. */
  93745. isInFrustum(frustumPlanes: Plane[]): boolean;
  93746. /**
  93747. * get the rotation matrix of the particle
  93748. * @hidden
  93749. */
  93750. getRotationMatrix(m: Matrix): void;
  93751. }
  93752. /**
  93753. * Represents the shape of the model used by one particle of a solid particle system.
  93754. * SPS internal tool, don't use it manually.
  93755. */
  93756. export class ModelShape {
  93757. /**
  93758. * The shape id
  93759. * @hidden
  93760. */
  93761. shapeID: number;
  93762. /**
  93763. * flat array of model positions (internal use)
  93764. * @hidden
  93765. */
  93766. _shape: Vector3[];
  93767. /**
  93768. * flat array of model UVs (internal use)
  93769. * @hidden
  93770. */
  93771. _shapeUV: number[];
  93772. /**
  93773. * color array of the model
  93774. * @hidden
  93775. */
  93776. _shapeColors: number[];
  93777. /**
  93778. * indices array of the model
  93779. * @hidden
  93780. */
  93781. _indices: number[];
  93782. /**
  93783. * normals array of the model
  93784. * @hidden
  93785. */
  93786. _normals: number[];
  93787. /**
  93788. * length of the shape in the model indices array (internal use)
  93789. * @hidden
  93790. */
  93791. _indicesLength: number;
  93792. /**
  93793. * Custom position function (internal use)
  93794. * @hidden
  93795. */
  93796. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  93797. /**
  93798. * Custom vertex function (internal use)
  93799. * @hidden
  93800. */
  93801. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  93802. /**
  93803. * 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.
  93804. * SPS internal tool, don't use it manually.
  93805. * @hidden
  93806. */
  93807. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  93808. }
  93809. /**
  93810. * Represents a Depth Sorted Particle in the solid particle system.
  93811. */
  93812. export class DepthSortedParticle {
  93813. /**
  93814. * Index of the particle in the "indices" array
  93815. */
  93816. ind: number;
  93817. /**
  93818. * Length of the particle shape in the "indices" array
  93819. */
  93820. indicesLength: number;
  93821. /**
  93822. * Squared distance from the particle to the camera
  93823. */
  93824. sqDistance: number;
  93825. }
  93826. }
  93827. declare module BABYLON {
  93828. /**
  93829. * @hidden
  93830. */
  93831. export class _MeshCollisionData {
  93832. _checkCollisions: boolean;
  93833. _collisionMask: number;
  93834. _collisionGroup: number;
  93835. _collider: Nullable<Collider>;
  93836. _oldPositionForCollisions: Vector3;
  93837. _diffPositionForCollisions: Vector3;
  93838. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  93839. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  93840. }
  93841. }
  93842. declare module BABYLON {
  93843. /** @hidden */
  93844. class _FacetDataStorage {
  93845. facetPositions: Vector3[];
  93846. facetNormals: Vector3[];
  93847. facetPartitioning: number[][];
  93848. facetNb: number;
  93849. partitioningSubdivisions: number;
  93850. partitioningBBoxRatio: number;
  93851. facetDataEnabled: boolean;
  93852. facetParameters: any;
  93853. bbSize: Vector3;
  93854. subDiv: {
  93855. max: number;
  93856. X: number;
  93857. Y: number;
  93858. Z: number;
  93859. };
  93860. facetDepthSort: boolean;
  93861. facetDepthSortEnabled: boolean;
  93862. depthSortedIndices: IndicesArray;
  93863. depthSortedFacets: {
  93864. ind: number;
  93865. sqDistance: number;
  93866. }[];
  93867. facetDepthSortFunction: (f1: {
  93868. ind: number;
  93869. sqDistance: number;
  93870. }, f2: {
  93871. ind: number;
  93872. sqDistance: number;
  93873. }) => number;
  93874. facetDepthSortFrom: Vector3;
  93875. facetDepthSortOrigin: Vector3;
  93876. invertedMatrix: Matrix;
  93877. }
  93878. /**
  93879. * @hidden
  93880. **/
  93881. class _InternalAbstractMeshDataInfo {
  93882. _hasVertexAlpha: boolean;
  93883. _useVertexColors: boolean;
  93884. _numBoneInfluencers: number;
  93885. _applyFog: boolean;
  93886. _receiveShadows: boolean;
  93887. _facetData: _FacetDataStorage;
  93888. _visibility: number;
  93889. _skeleton: Nullable<Skeleton>;
  93890. _layerMask: number;
  93891. _computeBonesUsingShaders: boolean;
  93892. _isActive: boolean;
  93893. _onlyForInstances: boolean;
  93894. _isActiveIntermediate: boolean;
  93895. _onlyForInstancesIntermediate: boolean;
  93896. _actAsRegularMesh: boolean;
  93897. }
  93898. /**
  93899. * Class used to store all common mesh properties
  93900. */
  93901. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93902. /** No occlusion */
  93903. static OCCLUSION_TYPE_NONE: number;
  93904. /** Occlusion set to optimisitic */
  93905. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93906. /** Occlusion set to strict */
  93907. static OCCLUSION_TYPE_STRICT: number;
  93908. /** Use an accurante occlusion algorithm */
  93909. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93910. /** Use a conservative occlusion algorithm */
  93911. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93912. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93913. * Test order :
  93914. * Is the bounding sphere outside the frustum ?
  93915. * If not, are the bounding box vertices outside the frustum ?
  93916. * It not, then the cullable object is in the frustum.
  93917. */
  93918. static readonly CULLINGSTRATEGY_STANDARD: number;
  93919. /** Culling strategy : Bounding Sphere Only.
  93920. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93921. * It's also less accurate than the standard because some not visible objects can still be selected.
  93922. * Test : is the bounding sphere outside the frustum ?
  93923. * If not, then the cullable object is in the frustum.
  93924. */
  93925. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93926. /** Culling strategy : Optimistic Inclusion.
  93927. * This in an inclusion test first, then the standard exclusion test.
  93928. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93929. * 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.
  93930. * Anyway, it's as accurate as the standard strategy.
  93931. * Test :
  93932. * Is the cullable object bounding sphere center in the frustum ?
  93933. * If not, apply the default culling strategy.
  93934. */
  93935. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93936. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93937. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93938. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93939. * 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.
  93940. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93941. * Test :
  93942. * Is the cullable object bounding sphere center in the frustum ?
  93943. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93944. */
  93945. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93946. /**
  93947. * No billboard
  93948. */
  93949. static readonly BILLBOARDMODE_NONE: number;
  93950. /** Billboard on X axis */
  93951. static readonly BILLBOARDMODE_X: number;
  93952. /** Billboard on Y axis */
  93953. static readonly BILLBOARDMODE_Y: number;
  93954. /** Billboard on Z axis */
  93955. static readonly BILLBOARDMODE_Z: number;
  93956. /** Billboard on all axes */
  93957. static readonly BILLBOARDMODE_ALL: number;
  93958. /** Billboard on using position instead of orientation */
  93959. static readonly BILLBOARDMODE_USE_POSITION: number;
  93960. /** @hidden */
  93961. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93962. /**
  93963. * The culling strategy to use to check whether the mesh must be rendered or not.
  93964. * This value can be changed at any time and will be used on the next render mesh selection.
  93965. * The possible values are :
  93966. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93967. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93968. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93969. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93970. * Please read each static variable documentation to get details about the culling process.
  93971. * */
  93972. cullingStrategy: number;
  93973. /**
  93974. * Gets the number of facets in the mesh
  93975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93976. */
  93977. readonly facetNb: number;
  93978. /**
  93979. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93981. */
  93982. partitioningSubdivisions: number;
  93983. /**
  93984. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93985. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93987. */
  93988. partitioningBBoxRatio: number;
  93989. /**
  93990. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93991. * Works only for updatable meshes.
  93992. * Doesn't work with multi-materials
  93993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93994. */
  93995. mustDepthSortFacets: boolean;
  93996. /**
  93997. * The location (Vector3) where the facet depth sort must be computed from.
  93998. * By default, the active camera position.
  93999. * Used only when facet depth sort is enabled
  94000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94001. */
  94002. facetDepthSortFrom: Vector3;
  94003. /**
  94004. * gets a boolean indicating if facetData is enabled
  94005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94006. */
  94007. readonly isFacetDataEnabled: boolean;
  94008. /** @hidden */
  94009. _updateNonUniformScalingState(value: boolean): boolean;
  94010. /**
  94011. * An event triggered when this mesh collides with another one
  94012. */
  94013. onCollideObservable: Observable<AbstractMesh>;
  94014. /** Set a function to call when this mesh collides with another one */
  94015. onCollide: () => void;
  94016. /**
  94017. * An event triggered when the collision's position changes
  94018. */
  94019. onCollisionPositionChangeObservable: Observable<Vector3>;
  94020. /** Set a function to call when the collision's position changes */
  94021. onCollisionPositionChange: () => void;
  94022. /**
  94023. * An event triggered when material is changed
  94024. */
  94025. onMaterialChangedObservable: Observable<AbstractMesh>;
  94026. /**
  94027. * Gets or sets the orientation for POV movement & rotation
  94028. */
  94029. definedFacingForward: boolean;
  94030. /** @hidden */
  94031. _occlusionQuery: Nullable<WebGLQuery>;
  94032. /** @hidden */
  94033. _renderingGroup: Nullable<RenderingGroup>;
  94034. /**
  94035. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94036. */
  94037. /**
  94038. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94039. */
  94040. visibility: number;
  94041. /** Gets or sets the alpha index used to sort transparent meshes
  94042. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94043. */
  94044. alphaIndex: number;
  94045. /**
  94046. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94047. */
  94048. isVisible: boolean;
  94049. /**
  94050. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94051. */
  94052. isPickable: boolean;
  94053. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94054. showSubMeshesBoundingBox: boolean;
  94055. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94056. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94057. */
  94058. isBlocker: boolean;
  94059. /**
  94060. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94061. */
  94062. enablePointerMoveEvents: boolean;
  94063. /**
  94064. * Specifies the rendering group id for this mesh (0 by default)
  94065. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94066. */
  94067. renderingGroupId: number;
  94068. private _material;
  94069. /** Gets or sets current material */
  94070. material: Nullable<Material>;
  94071. /**
  94072. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94073. * @see http://doc.babylonjs.com/babylon101/shadows
  94074. */
  94075. receiveShadows: boolean;
  94076. /** Defines color to use when rendering outline */
  94077. outlineColor: Color3;
  94078. /** Define width to use when rendering outline */
  94079. outlineWidth: number;
  94080. /** Defines color to use when rendering overlay */
  94081. overlayColor: Color3;
  94082. /** Defines alpha to use when rendering overlay */
  94083. overlayAlpha: number;
  94084. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94085. hasVertexAlpha: boolean;
  94086. /** 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) */
  94087. useVertexColors: boolean;
  94088. /**
  94089. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94090. */
  94091. computeBonesUsingShaders: boolean;
  94092. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94093. numBoneInfluencers: number;
  94094. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94095. applyFog: boolean;
  94096. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94097. useOctreeForRenderingSelection: boolean;
  94098. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94099. useOctreeForPicking: boolean;
  94100. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94101. useOctreeForCollisions: boolean;
  94102. /**
  94103. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94104. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94105. */
  94106. layerMask: number;
  94107. /**
  94108. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94109. */
  94110. alwaysSelectAsActiveMesh: boolean;
  94111. /**
  94112. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94113. */
  94114. doNotSyncBoundingInfo: boolean;
  94115. /**
  94116. * Gets or sets the current action manager
  94117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94118. */
  94119. actionManager: Nullable<AbstractActionManager>;
  94120. private _meshCollisionData;
  94121. /**
  94122. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94123. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94124. */
  94125. ellipsoid: Vector3;
  94126. /**
  94127. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94129. */
  94130. ellipsoidOffset: Vector3;
  94131. /**
  94132. * Gets or sets a collision mask used to mask collisions (default is -1).
  94133. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94134. */
  94135. collisionMask: number;
  94136. /**
  94137. * Gets or sets the current collision group mask (-1 by default).
  94138. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94139. */
  94140. collisionGroup: number;
  94141. /**
  94142. * Defines edge width used when edgesRenderer is enabled
  94143. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94144. */
  94145. edgesWidth: number;
  94146. /**
  94147. * Defines edge color used when edgesRenderer is enabled
  94148. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94149. */
  94150. edgesColor: Color4;
  94151. /** @hidden */
  94152. _edgesRenderer: Nullable<IEdgesRenderer>;
  94153. /** @hidden */
  94154. _masterMesh: Nullable<AbstractMesh>;
  94155. /** @hidden */
  94156. _boundingInfo: Nullable<BoundingInfo>;
  94157. /** @hidden */
  94158. _renderId: number;
  94159. /**
  94160. * Gets or sets the list of subMeshes
  94161. * @see http://doc.babylonjs.com/how_to/multi_materials
  94162. */
  94163. subMeshes: SubMesh[];
  94164. /** @hidden */
  94165. _intersectionsInProgress: AbstractMesh[];
  94166. /** @hidden */
  94167. _unIndexed: boolean;
  94168. /** @hidden */
  94169. _lightSources: Light[];
  94170. /** Gets the list of lights affecting that mesh */
  94171. readonly lightSources: Light[];
  94172. /** @hidden */
  94173. readonly _positions: Nullable<Vector3[]>;
  94174. /** @hidden */
  94175. _waitingData: {
  94176. lods: Nullable<any>;
  94177. actions: Nullable<any>;
  94178. freezeWorldMatrix: Nullable<boolean>;
  94179. };
  94180. /** @hidden */
  94181. _bonesTransformMatrices: Nullable<Float32Array>;
  94182. /** @hidden */
  94183. _transformMatrixTexture: Nullable<RawTexture>;
  94184. /**
  94185. * Gets or sets a skeleton to apply skining transformations
  94186. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94187. */
  94188. skeleton: Nullable<Skeleton>;
  94189. /**
  94190. * An event triggered when the mesh is rebuilt.
  94191. */
  94192. onRebuildObservable: Observable<AbstractMesh>;
  94193. /**
  94194. * Creates a new AbstractMesh
  94195. * @param name defines the name of the mesh
  94196. * @param scene defines the hosting scene
  94197. */
  94198. constructor(name: string, scene?: Nullable<Scene>);
  94199. /**
  94200. * Returns the string "AbstractMesh"
  94201. * @returns "AbstractMesh"
  94202. */
  94203. getClassName(): string;
  94204. /**
  94205. * Gets a string representation of the current mesh
  94206. * @param fullDetails defines a boolean indicating if full details must be included
  94207. * @returns a string representation of the current mesh
  94208. */
  94209. toString(fullDetails?: boolean): string;
  94210. /**
  94211. * @hidden
  94212. */
  94213. protected _getEffectiveParent(): Nullable<Node>;
  94214. /** @hidden */
  94215. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94216. /** @hidden */
  94217. _rebuild(): void;
  94218. /** @hidden */
  94219. _resyncLightSources(): void;
  94220. /** @hidden */
  94221. _resyncLighSource(light: Light): void;
  94222. /** @hidden */
  94223. _unBindEffect(): void;
  94224. /** @hidden */
  94225. _removeLightSource(light: Light, dispose: boolean): void;
  94226. private _markSubMeshesAsDirty;
  94227. /** @hidden */
  94228. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94229. /** @hidden */
  94230. _markSubMeshesAsAttributesDirty(): void;
  94231. /** @hidden */
  94232. _markSubMeshesAsMiscDirty(): void;
  94233. /**
  94234. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94235. */
  94236. scaling: Vector3;
  94237. /**
  94238. * Returns true if the mesh is blocked. Implemented by child classes
  94239. */
  94240. readonly isBlocked: boolean;
  94241. /**
  94242. * Returns the mesh itself by default. Implemented by child classes
  94243. * @param camera defines the camera to use to pick the right LOD level
  94244. * @returns the currentAbstractMesh
  94245. */
  94246. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94247. /**
  94248. * Returns 0 by default. Implemented by child classes
  94249. * @returns an integer
  94250. */
  94251. getTotalVertices(): number;
  94252. /**
  94253. * Returns a positive integer : the total number of indices in this mesh geometry.
  94254. * @returns the numner of indices or zero if the mesh has no geometry.
  94255. */
  94256. getTotalIndices(): number;
  94257. /**
  94258. * Returns null by default. Implemented by child classes
  94259. * @returns null
  94260. */
  94261. getIndices(): Nullable<IndicesArray>;
  94262. /**
  94263. * Returns the array of the requested vertex data kind. Implemented by child classes
  94264. * @param kind defines the vertex data kind to use
  94265. * @returns null
  94266. */
  94267. getVerticesData(kind: string): Nullable<FloatArray>;
  94268. /**
  94269. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94270. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94271. * Note that a new underlying VertexBuffer object is created each call.
  94272. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94273. * @param kind defines vertex data kind:
  94274. * * VertexBuffer.PositionKind
  94275. * * VertexBuffer.UVKind
  94276. * * VertexBuffer.UV2Kind
  94277. * * VertexBuffer.UV3Kind
  94278. * * VertexBuffer.UV4Kind
  94279. * * VertexBuffer.UV5Kind
  94280. * * VertexBuffer.UV6Kind
  94281. * * VertexBuffer.ColorKind
  94282. * * VertexBuffer.MatricesIndicesKind
  94283. * * VertexBuffer.MatricesIndicesExtraKind
  94284. * * VertexBuffer.MatricesWeightsKind
  94285. * * VertexBuffer.MatricesWeightsExtraKind
  94286. * @param data defines the data source
  94287. * @param updatable defines if the data must be flagged as updatable (or static)
  94288. * @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
  94289. * @returns the current mesh
  94290. */
  94291. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94292. /**
  94293. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94294. * If the mesh has no geometry, it is simply returned as it is.
  94295. * @param kind defines vertex data kind:
  94296. * * VertexBuffer.PositionKind
  94297. * * VertexBuffer.UVKind
  94298. * * VertexBuffer.UV2Kind
  94299. * * VertexBuffer.UV3Kind
  94300. * * VertexBuffer.UV4Kind
  94301. * * VertexBuffer.UV5Kind
  94302. * * VertexBuffer.UV6Kind
  94303. * * VertexBuffer.ColorKind
  94304. * * VertexBuffer.MatricesIndicesKind
  94305. * * VertexBuffer.MatricesIndicesExtraKind
  94306. * * VertexBuffer.MatricesWeightsKind
  94307. * * VertexBuffer.MatricesWeightsExtraKind
  94308. * @param data defines the data source
  94309. * @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
  94310. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94311. * @returns the current mesh
  94312. */
  94313. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94314. /**
  94315. * Sets the mesh indices,
  94316. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94317. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94318. * @param totalVertices Defines the total number of vertices
  94319. * @returns the current mesh
  94320. */
  94321. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94322. /**
  94323. * Gets a boolean indicating if specific vertex data is present
  94324. * @param kind defines the vertex data kind to use
  94325. * @returns true is data kind is present
  94326. */
  94327. isVerticesDataPresent(kind: string): boolean;
  94328. /**
  94329. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94330. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94331. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94332. * @returns a BoundingInfo
  94333. */
  94334. getBoundingInfo(): BoundingInfo;
  94335. /**
  94336. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94337. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94338. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94339. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94340. * @returns the current mesh
  94341. */
  94342. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94343. /**
  94344. * Overwrite the current bounding info
  94345. * @param boundingInfo defines the new bounding info
  94346. * @returns the current mesh
  94347. */
  94348. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94349. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94350. readonly useBones: boolean;
  94351. /** @hidden */
  94352. _preActivate(): void;
  94353. /** @hidden */
  94354. _preActivateForIntermediateRendering(renderId: number): void;
  94355. /** @hidden */
  94356. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94357. /** @hidden */
  94358. _postActivate(): void;
  94359. /** @hidden */
  94360. _freeze(): void;
  94361. /** @hidden */
  94362. _unFreeze(): void;
  94363. /**
  94364. * Gets the current world matrix
  94365. * @returns a Matrix
  94366. */
  94367. getWorldMatrix(): Matrix;
  94368. /** @hidden */
  94369. _getWorldMatrixDeterminant(): number;
  94370. /**
  94371. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94372. */
  94373. readonly isAnInstance: boolean;
  94374. /**
  94375. * Gets a boolean indicating if this mesh has instances
  94376. */
  94377. readonly hasInstances: boolean;
  94378. /**
  94379. * Perform relative position change from the point of view of behind the front of the mesh.
  94380. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94381. * Supports definition of mesh facing forward or backward
  94382. * @param amountRight defines the distance on the right axis
  94383. * @param amountUp defines the distance on the up axis
  94384. * @param amountForward defines the distance on the forward axis
  94385. * @returns the current mesh
  94386. */
  94387. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94388. /**
  94389. * Calculate relative position change from the point of view of behind the front of the mesh.
  94390. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94391. * Supports definition of mesh facing forward or backward
  94392. * @param amountRight defines the distance on the right axis
  94393. * @param amountUp defines the distance on the up axis
  94394. * @param amountForward defines the distance on the forward axis
  94395. * @returns the new displacement vector
  94396. */
  94397. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94398. /**
  94399. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94400. * Supports definition of mesh facing forward or backward
  94401. * @param flipBack defines the flip
  94402. * @param twirlClockwise defines the twirl
  94403. * @param tiltRight defines the tilt
  94404. * @returns the current mesh
  94405. */
  94406. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94407. /**
  94408. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94409. * Supports definition of mesh facing forward or backward.
  94410. * @param flipBack defines the flip
  94411. * @param twirlClockwise defines the twirl
  94412. * @param tiltRight defines the tilt
  94413. * @returns the new rotation vector
  94414. */
  94415. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94416. /**
  94417. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94418. * This means the mesh underlying bounding box and sphere are recomputed.
  94419. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94420. * @returns the current mesh
  94421. */
  94422. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94423. /** @hidden */
  94424. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94425. /** @hidden */
  94426. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94427. /** @hidden */
  94428. _updateBoundingInfo(): AbstractMesh;
  94429. /** @hidden */
  94430. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94431. /** @hidden */
  94432. protected _afterComputeWorldMatrix(): void;
  94433. /** @hidden */
  94434. readonly _effectiveMesh: AbstractMesh;
  94435. /**
  94436. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94437. * A mesh is in the frustum if its bounding box intersects the frustum
  94438. * @param frustumPlanes defines the frustum to test
  94439. * @returns true if the mesh is in the frustum planes
  94440. */
  94441. isInFrustum(frustumPlanes: Plane[]): boolean;
  94442. /**
  94443. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94444. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94445. * @param frustumPlanes defines the frustum to test
  94446. * @returns true if the mesh is completely in the frustum planes
  94447. */
  94448. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94449. /**
  94450. * True if the mesh intersects another mesh or a SolidParticle object
  94451. * @param mesh defines a target mesh or SolidParticle to test
  94452. * @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)
  94453. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94454. * @returns true if there is an intersection
  94455. */
  94456. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94457. /**
  94458. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94459. * @param point defines the point to test
  94460. * @returns true if there is an intersection
  94461. */
  94462. intersectsPoint(point: Vector3): boolean;
  94463. /**
  94464. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94466. */
  94467. checkCollisions: boolean;
  94468. /**
  94469. * Gets Collider object used to compute collisions (not physics)
  94470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94471. */
  94472. readonly collider: Nullable<Collider>;
  94473. /**
  94474. * Move the mesh using collision engine
  94475. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94476. * @param displacement defines the requested displacement vector
  94477. * @returns the current mesh
  94478. */
  94479. moveWithCollisions(displacement: Vector3): AbstractMesh;
  94480. private _onCollisionPositionChange;
  94481. /** @hidden */
  94482. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  94483. /** @hidden */
  94484. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  94485. /** @hidden */
  94486. _checkCollision(collider: Collider): AbstractMesh;
  94487. /** @hidden */
  94488. _generatePointsArray(): boolean;
  94489. /**
  94490. * Checks if the passed Ray intersects with the mesh
  94491. * @param ray defines the ray to use
  94492. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  94493. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94494. * @returns the picking info
  94495. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  94496. */
  94497. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  94498. /**
  94499. * Clones the current mesh
  94500. * @param name defines the mesh name
  94501. * @param newParent defines the new mesh parent
  94502. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  94503. * @returns the new mesh
  94504. */
  94505. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  94506. /**
  94507. * Disposes all the submeshes of the current meshnp
  94508. * @returns the current mesh
  94509. */
  94510. releaseSubMeshes(): AbstractMesh;
  94511. /**
  94512. * Releases resources associated with this abstract mesh.
  94513. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94514. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94515. */
  94516. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94517. /**
  94518. * Adds the passed mesh as a child to the current mesh
  94519. * @param mesh defines the child mesh
  94520. * @returns the current mesh
  94521. */
  94522. addChild(mesh: AbstractMesh): AbstractMesh;
  94523. /**
  94524. * Removes the passed mesh from the current mesh children list
  94525. * @param mesh defines the child mesh
  94526. * @returns the current mesh
  94527. */
  94528. removeChild(mesh: AbstractMesh): AbstractMesh;
  94529. /** @hidden */
  94530. private _initFacetData;
  94531. /**
  94532. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  94533. * This method can be called within the render loop.
  94534. * 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
  94535. * @returns the current mesh
  94536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94537. */
  94538. updateFacetData(): AbstractMesh;
  94539. /**
  94540. * Returns the facetLocalNormals array.
  94541. * The normals are expressed in the mesh local spac
  94542. * @returns an array of Vector3
  94543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94544. */
  94545. getFacetLocalNormals(): Vector3[];
  94546. /**
  94547. * Returns the facetLocalPositions array.
  94548. * The facet positions are expressed in the mesh local space
  94549. * @returns an array of Vector3
  94550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94551. */
  94552. getFacetLocalPositions(): Vector3[];
  94553. /**
  94554. * Returns the facetLocalPartioning array
  94555. * @returns an array of array of numbers
  94556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94557. */
  94558. getFacetLocalPartitioning(): number[][];
  94559. /**
  94560. * Returns the i-th facet position in the world system.
  94561. * This method allocates a new Vector3 per call
  94562. * @param i defines the facet index
  94563. * @returns a new Vector3
  94564. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94565. */
  94566. getFacetPosition(i: number): Vector3;
  94567. /**
  94568. * Sets the reference Vector3 with the i-th facet position in the world system
  94569. * @param i defines the facet index
  94570. * @param ref defines the target vector
  94571. * @returns the current mesh
  94572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94573. */
  94574. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94575. /**
  94576. * Returns the i-th facet normal in the world system.
  94577. * This method allocates a new Vector3 per call
  94578. * @param i defines the facet index
  94579. * @returns a new Vector3
  94580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94581. */
  94582. getFacetNormal(i: number): Vector3;
  94583. /**
  94584. * Sets the reference Vector3 with the i-th facet normal in the world system
  94585. * @param i defines the facet index
  94586. * @param ref defines the target vector
  94587. * @returns the current mesh
  94588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94589. */
  94590. getFacetNormalToRef(i: number, ref: Vector3): this;
  94591. /**
  94592. * 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)
  94593. * @param x defines x coordinate
  94594. * @param y defines y coordinate
  94595. * @param z defines z coordinate
  94596. * @returns the array of facet indexes
  94597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94598. */
  94599. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94600. /**
  94601. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94602. * @param projected sets as the (x,y,z) world projection on the facet
  94603. * @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
  94604. * @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
  94605. * @param x defines x coordinate
  94606. * @param y defines y coordinate
  94607. * @param z defines z coordinate
  94608. * @returns the face index if found (or null instead)
  94609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94610. */
  94611. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94612. /**
  94613. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94614. * @param projected sets as the (x,y,z) local projection on the facet
  94615. * @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
  94616. * @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
  94617. * @param x defines x coordinate
  94618. * @param y defines y coordinate
  94619. * @param z defines z coordinate
  94620. * @returns the face index if found (or null instead)
  94621. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94622. */
  94623. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94624. /**
  94625. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94626. * @returns the parameters
  94627. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94628. */
  94629. getFacetDataParameters(): any;
  94630. /**
  94631. * Disables the feature FacetData and frees the related memory
  94632. * @returns the current mesh
  94633. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94634. */
  94635. disableFacetData(): AbstractMesh;
  94636. /**
  94637. * Updates the AbstractMesh indices array
  94638. * @param indices defines the data source
  94639. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94640. * @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)
  94641. * @returns the current mesh
  94642. */
  94643. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94644. /**
  94645. * Creates new normals data for the mesh
  94646. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94647. * @returns the current mesh
  94648. */
  94649. createNormals(updatable: boolean): AbstractMesh;
  94650. /**
  94651. * Align the mesh with a normal
  94652. * @param normal defines the normal to use
  94653. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94654. * @returns the current mesh
  94655. */
  94656. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94657. /** @hidden */
  94658. _checkOcclusionQuery(): boolean;
  94659. /**
  94660. * Disables the mesh edge rendering mode
  94661. * @returns the currentAbstractMesh
  94662. */
  94663. disableEdgesRendering(): AbstractMesh;
  94664. /**
  94665. * Enables the edge rendering mode on the mesh.
  94666. * This mode makes the mesh edges visible
  94667. * @param epsilon defines the maximal distance between two angles to detect a face
  94668. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94669. * @returns the currentAbstractMesh
  94670. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94671. */
  94672. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94673. }
  94674. }
  94675. declare module BABYLON {
  94676. /**
  94677. * Interface used to define ActionEvent
  94678. */
  94679. export interface IActionEvent {
  94680. /** The mesh or sprite that triggered the action */
  94681. source: any;
  94682. /** The X mouse cursor position at the time of the event */
  94683. pointerX: number;
  94684. /** The Y mouse cursor position at the time of the event */
  94685. pointerY: number;
  94686. /** The mesh that is currently pointed at (can be null) */
  94687. meshUnderPointer: Nullable<AbstractMesh>;
  94688. /** the original (browser) event that triggered the ActionEvent */
  94689. sourceEvent?: any;
  94690. /** additional data for the event */
  94691. additionalData?: any;
  94692. }
  94693. /**
  94694. * ActionEvent is the event being sent when an action is triggered.
  94695. */
  94696. export class ActionEvent implements IActionEvent {
  94697. /** The mesh or sprite that triggered the action */
  94698. source: any;
  94699. /** The X mouse cursor position at the time of the event */
  94700. pointerX: number;
  94701. /** The Y mouse cursor position at the time of the event */
  94702. pointerY: number;
  94703. /** The mesh that is currently pointed at (can be null) */
  94704. meshUnderPointer: Nullable<AbstractMesh>;
  94705. /** the original (browser) event that triggered the ActionEvent */
  94706. sourceEvent?: any;
  94707. /** additional data for the event */
  94708. additionalData?: any;
  94709. /**
  94710. * Creates a new ActionEvent
  94711. * @param source The mesh or sprite that triggered the action
  94712. * @param pointerX The X mouse cursor position at the time of the event
  94713. * @param pointerY The Y mouse cursor position at the time of the event
  94714. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94715. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94716. * @param additionalData additional data for the event
  94717. */
  94718. constructor(
  94719. /** The mesh or sprite that triggered the action */
  94720. source: any,
  94721. /** The X mouse cursor position at the time of the event */
  94722. pointerX: number,
  94723. /** The Y mouse cursor position at the time of the event */
  94724. pointerY: number,
  94725. /** The mesh that is currently pointed at (can be null) */
  94726. meshUnderPointer: Nullable<AbstractMesh>,
  94727. /** the original (browser) event that triggered the ActionEvent */
  94728. sourceEvent?: any,
  94729. /** additional data for the event */
  94730. additionalData?: any);
  94731. /**
  94732. * Helper function to auto-create an ActionEvent from a source mesh.
  94733. * @param source The source mesh that triggered the event
  94734. * @param evt The original (browser) event
  94735. * @param additionalData additional data for the event
  94736. * @returns the new ActionEvent
  94737. */
  94738. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94739. /**
  94740. * Helper function to auto-create an ActionEvent from a source sprite
  94741. * @param source The source sprite that triggered the event
  94742. * @param scene Scene associated with the sprite
  94743. * @param evt The original (browser) event
  94744. * @param additionalData additional data for the event
  94745. * @returns the new ActionEvent
  94746. */
  94747. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94748. /**
  94749. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94750. * @param scene the scene where the event occurred
  94751. * @param evt The original (browser) event
  94752. * @returns the new ActionEvent
  94753. */
  94754. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  94755. /**
  94756. * Helper function to auto-create an ActionEvent from a primitive
  94757. * @param prim defines the target primitive
  94758. * @param pointerPos defines the pointer position
  94759. * @param evt The original (browser) event
  94760. * @param additionalData additional data for the event
  94761. * @returns the new ActionEvent
  94762. */
  94763. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  94764. }
  94765. }
  94766. declare module BABYLON {
  94767. /**
  94768. * Abstract class used to decouple action Manager from scene and meshes.
  94769. * Do not instantiate.
  94770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94771. */
  94772. export abstract class AbstractActionManager implements IDisposable {
  94773. /** Gets the list of active triggers */
  94774. static Triggers: {
  94775. [key: string]: number;
  94776. };
  94777. /** Gets the cursor to use when hovering items */
  94778. hoverCursor: string;
  94779. /** Gets the list of actions */
  94780. actions: IAction[];
  94781. /**
  94782. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  94783. */
  94784. isRecursive: boolean;
  94785. /**
  94786. * Releases all associated resources
  94787. */
  94788. abstract dispose(): void;
  94789. /**
  94790. * Does this action manager has pointer triggers
  94791. */
  94792. abstract readonly hasPointerTriggers: boolean;
  94793. /**
  94794. * Does this action manager has pick triggers
  94795. */
  94796. abstract readonly hasPickTriggers: boolean;
  94797. /**
  94798. * Process a specific trigger
  94799. * @param trigger defines the trigger to process
  94800. * @param evt defines the event details to be processed
  94801. */
  94802. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  94803. /**
  94804. * Does this action manager handles actions of any of the given triggers
  94805. * @param triggers defines the triggers to be tested
  94806. * @return a boolean indicating whether one (or more) of the triggers is handled
  94807. */
  94808. abstract hasSpecificTriggers(triggers: number[]): boolean;
  94809. /**
  94810. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94811. * speed.
  94812. * @param triggerA defines the trigger to be tested
  94813. * @param triggerB defines the trigger to be tested
  94814. * @return a boolean indicating whether one (or more) of the triggers is handled
  94815. */
  94816. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94817. /**
  94818. * Does this action manager handles actions of a given trigger
  94819. * @param trigger defines the trigger to be tested
  94820. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94821. * @return whether the trigger is handled
  94822. */
  94823. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94824. /**
  94825. * Serialize this manager to a JSON object
  94826. * @param name defines the property name to store this manager
  94827. * @returns a JSON representation of this manager
  94828. */
  94829. abstract serialize(name: string): any;
  94830. /**
  94831. * Registers an action to this action manager
  94832. * @param action defines the action to be registered
  94833. * @return the action amended (prepared) after registration
  94834. */
  94835. abstract registerAction(action: IAction): Nullable<IAction>;
  94836. /**
  94837. * Unregisters an action to this action manager
  94838. * @param action defines the action to be unregistered
  94839. * @return a boolean indicating whether the action has been unregistered
  94840. */
  94841. abstract unregisterAction(action: IAction): Boolean;
  94842. /**
  94843. * Does exist one action manager with at least one trigger
  94844. **/
  94845. static readonly HasTriggers: boolean;
  94846. /**
  94847. * Does exist one action manager with at least one pick trigger
  94848. **/
  94849. static readonly HasPickTriggers: boolean;
  94850. /**
  94851. * Does exist one action manager that handles actions of a given trigger
  94852. * @param trigger defines the trigger to be tested
  94853. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  94854. **/
  94855. static HasSpecificTrigger(trigger: number): boolean;
  94856. }
  94857. }
  94858. declare module BABYLON {
  94859. /**
  94860. * Defines how a node can be built from a string name.
  94861. */
  94862. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  94863. /**
  94864. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  94865. */
  94866. export class Node implements IBehaviorAware<Node> {
  94867. /** @hidden */
  94868. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  94869. private static _NodeConstructors;
  94870. /**
  94871. * Add a new node constructor
  94872. * @param type defines the type name of the node to construct
  94873. * @param constructorFunc defines the constructor function
  94874. */
  94875. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  94876. /**
  94877. * Returns a node constructor based on type name
  94878. * @param type defines the type name
  94879. * @param name defines the new node name
  94880. * @param scene defines the hosting scene
  94881. * @param options defines optional options to transmit to constructors
  94882. * @returns the new constructor or null
  94883. */
  94884. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  94885. /**
  94886. * Gets or sets the name of the node
  94887. */
  94888. name: string;
  94889. /**
  94890. * Gets or sets the id of the node
  94891. */
  94892. id: string;
  94893. /**
  94894. * Gets or sets the unique id of the node
  94895. */
  94896. uniqueId: number;
  94897. /**
  94898. * Gets or sets a string used to store user defined state for the node
  94899. */
  94900. state: string;
  94901. /**
  94902. * Gets or sets an object used to store user defined information for the node
  94903. */
  94904. metadata: any;
  94905. /**
  94906. * For internal use only. Please do not use.
  94907. */
  94908. reservedDataStore: any;
  94909. /**
  94910. * List of inspectable custom properties (used by the Inspector)
  94911. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94912. */
  94913. inspectableCustomProperties: IInspectable[];
  94914. private _doNotSerialize;
  94915. /**
  94916. * Gets or sets a boolean used to define if the node must be serialized
  94917. */
  94918. doNotSerialize: boolean;
  94919. /** @hidden */
  94920. _isDisposed: boolean;
  94921. /**
  94922. * Gets a list of Animations associated with the node
  94923. */
  94924. animations: Animation[];
  94925. protected _ranges: {
  94926. [name: string]: Nullable<AnimationRange>;
  94927. };
  94928. /**
  94929. * Callback raised when the node is ready to be used
  94930. */
  94931. onReady: Nullable<(node: Node) => void>;
  94932. private _isEnabled;
  94933. private _isParentEnabled;
  94934. private _isReady;
  94935. /** @hidden */
  94936. _currentRenderId: number;
  94937. private _parentUpdateId;
  94938. /** @hidden */
  94939. _childUpdateId: number;
  94940. /** @hidden */
  94941. _waitingParentId: Nullable<string>;
  94942. /** @hidden */
  94943. _scene: Scene;
  94944. /** @hidden */
  94945. _cache: any;
  94946. private _parentNode;
  94947. private _children;
  94948. /** @hidden */
  94949. _worldMatrix: Matrix;
  94950. /** @hidden */
  94951. _worldMatrixDeterminant: number;
  94952. /** @hidden */
  94953. _worldMatrixDeterminantIsDirty: boolean;
  94954. /** @hidden */
  94955. private _sceneRootNodesIndex;
  94956. /**
  94957. * Gets a boolean indicating if the node has been disposed
  94958. * @returns true if the node was disposed
  94959. */
  94960. isDisposed(): boolean;
  94961. /**
  94962. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94963. * @see https://doc.babylonjs.com/how_to/parenting
  94964. */
  94965. parent: Nullable<Node>;
  94966. /** @hidden */
  94967. _addToSceneRootNodes(): void;
  94968. /** @hidden */
  94969. _removeFromSceneRootNodes(): void;
  94970. private _animationPropertiesOverride;
  94971. /**
  94972. * Gets or sets the animation properties override
  94973. */
  94974. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94975. /**
  94976. * Gets a string idenfifying the name of the class
  94977. * @returns "Node" string
  94978. */
  94979. getClassName(): string;
  94980. /** @hidden */
  94981. readonly _isNode: boolean;
  94982. /**
  94983. * An event triggered when the mesh is disposed
  94984. */
  94985. onDisposeObservable: Observable<Node>;
  94986. private _onDisposeObserver;
  94987. /**
  94988. * Sets a callback that will be raised when the node will be disposed
  94989. */
  94990. onDispose: () => void;
  94991. /**
  94992. * Creates a new Node
  94993. * @param name the name and id to be given to this node
  94994. * @param scene the scene this node will be added to
  94995. */
  94996. constructor(name: string, scene?: Nullable<Scene>);
  94997. /**
  94998. * Gets the scene of the node
  94999. * @returns a scene
  95000. */
  95001. getScene(): Scene;
  95002. /**
  95003. * Gets the engine of the node
  95004. * @returns a Engine
  95005. */
  95006. getEngine(): Engine;
  95007. private _behaviors;
  95008. /**
  95009. * Attach a behavior to the node
  95010. * @see http://doc.babylonjs.com/features/behaviour
  95011. * @param behavior defines the behavior to attach
  95012. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95013. * @returns the current Node
  95014. */
  95015. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95016. /**
  95017. * Remove an attached behavior
  95018. * @see http://doc.babylonjs.com/features/behaviour
  95019. * @param behavior defines the behavior to attach
  95020. * @returns the current Node
  95021. */
  95022. removeBehavior(behavior: Behavior<Node>): Node;
  95023. /**
  95024. * Gets the list of attached behaviors
  95025. * @see http://doc.babylonjs.com/features/behaviour
  95026. */
  95027. readonly behaviors: Behavior<Node>[];
  95028. /**
  95029. * Gets an attached behavior by name
  95030. * @param name defines the name of the behavior to look for
  95031. * @see http://doc.babylonjs.com/features/behaviour
  95032. * @returns null if behavior was not found else the requested behavior
  95033. */
  95034. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95035. /**
  95036. * Returns the latest update of the World matrix
  95037. * @returns a Matrix
  95038. */
  95039. getWorldMatrix(): Matrix;
  95040. /** @hidden */
  95041. _getWorldMatrixDeterminant(): number;
  95042. /**
  95043. * Returns directly the latest state of the mesh World matrix.
  95044. * A Matrix is returned.
  95045. */
  95046. readonly worldMatrixFromCache: Matrix;
  95047. /** @hidden */
  95048. _initCache(): void;
  95049. /** @hidden */
  95050. updateCache(force?: boolean): void;
  95051. /** @hidden */
  95052. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95053. /** @hidden */
  95054. _updateCache(ignoreParentClass?: boolean): void;
  95055. /** @hidden */
  95056. _isSynchronized(): boolean;
  95057. /** @hidden */
  95058. _markSyncedWithParent(): void;
  95059. /** @hidden */
  95060. isSynchronizedWithParent(): boolean;
  95061. /** @hidden */
  95062. isSynchronized(): boolean;
  95063. /**
  95064. * Is this node ready to be used/rendered
  95065. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95066. * @return true if the node is ready
  95067. */
  95068. isReady(completeCheck?: boolean): boolean;
  95069. /**
  95070. * Is this node enabled?
  95071. * 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
  95072. * @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
  95073. * @return whether this node (and its parent) is enabled
  95074. */
  95075. isEnabled(checkAncestors?: boolean): boolean;
  95076. /** @hidden */
  95077. protected _syncParentEnabledState(): void;
  95078. /**
  95079. * Set the enabled state of this node
  95080. * @param value defines the new enabled state
  95081. */
  95082. setEnabled(value: boolean): void;
  95083. /**
  95084. * Is this node a descendant of the given node?
  95085. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95086. * @param ancestor defines the parent node to inspect
  95087. * @returns a boolean indicating if this node is a descendant of the given node
  95088. */
  95089. isDescendantOf(ancestor: Node): boolean;
  95090. /** @hidden */
  95091. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95092. /**
  95093. * Will return all nodes that have this node as ascendant
  95094. * @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
  95095. * @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
  95096. * @return all children nodes of all types
  95097. */
  95098. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95099. /**
  95100. * Get all child-meshes of this node
  95101. * @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)
  95102. * @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
  95103. * @returns an array of AbstractMesh
  95104. */
  95105. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95106. /**
  95107. * Get all direct children of this node
  95108. * @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
  95109. * @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)
  95110. * @returns an array of Node
  95111. */
  95112. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95113. /** @hidden */
  95114. _setReady(state: boolean): void;
  95115. /**
  95116. * Get an animation by name
  95117. * @param name defines the name of the animation to look for
  95118. * @returns null if not found else the requested animation
  95119. */
  95120. getAnimationByName(name: string): Nullable<Animation>;
  95121. /**
  95122. * Creates an animation range for this node
  95123. * @param name defines the name of the range
  95124. * @param from defines the starting key
  95125. * @param to defines the end key
  95126. */
  95127. createAnimationRange(name: string, from: number, to: number): void;
  95128. /**
  95129. * Delete a specific animation range
  95130. * @param name defines the name of the range to delete
  95131. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95132. */
  95133. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95134. /**
  95135. * Get an animation range by name
  95136. * @param name defines the name of the animation range to look for
  95137. * @returns null if not found else the requested animation range
  95138. */
  95139. getAnimationRange(name: string): Nullable<AnimationRange>;
  95140. /**
  95141. * Gets the list of all animation ranges defined on this node
  95142. * @returns an array
  95143. */
  95144. getAnimationRanges(): Nullable<AnimationRange>[];
  95145. /**
  95146. * Will start the animation sequence
  95147. * @param name defines the range frames for animation sequence
  95148. * @param loop defines if the animation should loop (false by default)
  95149. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95150. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95151. * @returns the object created for this animation. If range does not exist, it will return null
  95152. */
  95153. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95154. /**
  95155. * Serialize animation ranges into a JSON compatible object
  95156. * @returns serialization object
  95157. */
  95158. serializeAnimationRanges(): any;
  95159. /**
  95160. * Computes the world matrix of the node
  95161. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95162. * @returns the world matrix
  95163. */
  95164. computeWorldMatrix(force?: boolean): Matrix;
  95165. /**
  95166. * Releases resources associated with this node.
  95167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95169. */
  95170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95171. /**
  95172. * Parse animation range data from a serialization object and store them into a given node
  95173. * @param node defines where to store the animation ranges
  95174. * @param parsedNode defines the serialization object to read data from
  95175. * @param scene defines the hosting scene
  95176. */
  95177. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95178. /**
  95179. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95180. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95181. * @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
  95182. * @returns the new bounding vectors
  95183. */
  95184. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95185. min: Vector3;
  95186. max: Vector3;
  95187. };
  95188. }
  95189. }
  95190. declare module BABYLON {
  95191. /**
  95192. * @hidden
  95193. */
  95194. export class _IAnimationState {
  95195. key: number;
  95196. repeatCount: number;
  95197. workValue?: any;
  95198. loopMode?: number;
  95199. offsetValue?: any;
  95200. highLimitValue?: any;
  95201. }
  95202. /**
  95203. * Class used to store any kind of animation
  95204. */
  95205. export class Animation {
  95206. /**Name of the animation */
  95207. name: string;
  95208. /**Property to animate */
  95209. targetProperty: string;
  95210. /**The frames per second of the animation */
  95211. framePerSecond: number;
  95212. /**The data type of the animation */
  95213. dataType: number;
  95214. /**The loop mode of the animation */
  95215. loopMode?: number | undefined;
  95216. /**Specifies if blending should be enabled */
  95217. enableBlending?: boolean | undefined;
  95218. /**
  95219. * Use matrix interpolation instead of using direct key value when animating matrices
  95220. */
  95221. static AllowMatricesInterpolation: boolean;
  95222. /**
  95223. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95224. */
  95225. static AllowMatrixDecomposeForInterpolation: boolean;
  95226. /**
  95227. * Stores the key frames of the animation
  95228. */
  95229. private _keys;
  95230. /**
  95231. * Stores the easing function of the animation
  95232. */
  95233. private _easingFunction;
  95234. /**
  95235. * @hidden Internal use only
  95236. */
  95237. _runtimeAnimations: RuntimeAnimation[];
  95238. /**
  95239. * The set of event that will be linked to this animation
  95240. */
  95241. private _events;
  95242. /**
  95243. * Stores an array of target property paths
  95244. */
  95245. targetPropertyPath: string[];
  95246. /**
  95247. * Stores the blending speed of the animation
  95248. */
  95249. blendingSpeed: number;
  95250. /**
  95251. * Stores the animation ranges for the animation
  95252. */
  95253. private _ranges;
  95254. /**
  95255. * @hidden Internal use
  95256. */
  95257. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95258. /**
  95259. * Sets up an animation
  95260. * @param property The property to animate
  95261. * @param animationType The animation type to apply
  95262. * @param framePerSecond The frames per second of the animation
  95263. * @param easingFunction The easing function used in the animation
  95264. * @returns The created animation
  95265. */
  95266. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95267. /**
  95268. * Create and start an animation on a node
  95269. * @param name defines the name of the global animation that will be run on all nodes
  95270. * @param node defines the root node where the animation will take place
  95271. * @param targetProperty defines property to animate
  95272. * @param framePerSecond defines the number of frame per second yo use
  95273. * @param totalFrame defines the number of frames in total
  95274. * @param from defines the initial value
  95275. * @param to defines the final value
  95276. * @param loopMode defines which loop mode you want to use (off by default)
  95277. * @param easingFunction defines the easing function to use (linear by default)
  95278. * @param onAnimationEnd defines the callback to call when animation end
  95279. * @returns the animatable created for this animation
  95280. */
  95281. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95282. /**
  95283. * Create and start an animation on a node and its descendants
  95284. * @param name defines the name of the global animation that will be run on all nodes
  95285. * @param node defines the root node where the animation will take place
  95286. * @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
  95287. * @param targetProperty defines property to animate
  95288. * @param framePerSecond defines the number of frame per second to use
  95289. * @param totalFrame defines the number of frames in total
  95290. * @param from defines the initial value
  95291. * @param to defines the final value
  95292. * @param loopMode defines which loop mode you want to use (off by default)
  95293. * @param easingFunction defines the easing function to use (linear by default)
  95294. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95295. * @returns the list of animatables created for all nodes
  95296. * @example https://www.babylonjs-playground.com/#MH0VLI
  95297. */
  95298. 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[]>;
  95299. /**
  95300. * Creates a new animation, merges it with the existing animations and starts it
  95301. * @param name Name of the animation
  95302. * @param node Node which contains the scene that begins the animations
  95303. * @param targetProperty Specifies which property to animate
  95304. * @param framePerSecond The frames per second of the animation
  95305. * @param totalFrame The total number of frames
  95306. * @param from The frame at the beginning of the animation
  95307. * @param to The frame at the end of the animation
  95308. * @param loopMode Specifies the loop mode of the animation
  95309. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95310. * @param onAnimationEnd Callback to run once the animation is complete
  95311. * @returns Nullable animation
  95312. */
  95313. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95314. /**
  95315. * Transition property of an host to the target Value
  95316. * @param property The property to transition
  95317. * @param targetValue The target Value of the property
  95318. * @param host The object where the property to animate belongs
  95319. * @param scene Scene used to run the animation
  95320. * @param frameRate Framerate (in frame/s) to use
  95321. * @param transition The transition type we want to use
  95322. * @param duration The duration of the animation, in milliseconds
  95323. * @param onAnimationEnd Callback trigger at the end of the animation
  95324. * @returns Nullable animation
  95325. */
  95326. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95327. /**
  95328. * Return the array of runtime animations currently using this animation
  95329. */
  95330. readonly runtimeAnimations: RuntimeAnimation[];
  95331. /**
  95332. * Specifies if any of the runtime animations are currently running
  95333. */
  95334. readonly hasRunningRuntimeAnimations: boolean;
  95335. /**
  95336. * Initializes the animation
  95337. * @param name Name of the animation
  95338. * @param targetProperty Property to animate
  95339. * @param framePerSecond The frames per second of the animation
  95340. * @param dataType The data type of the animation
  95341. * @param loopMode The loop mode of the animation
  95342. * @param enableBlending Specifies if blending should be enabled
  95343. */
  95344. constructor(
  95345. /**Name of the animation */
  95346. name: string,
  95347. /**Property to animate */
  95348. targetProperty: string,
  95349. /**The frames per second of the animation */
  95350. framePerSecond: number,
  95351. /**The data type of the animation */
  95352. dataType: number,
  95353. /**The loop mode of the animation */
  95354. loopMode?: number | undefined,
  95355. /**Specifies if blending should be enabled */
  95356. enableBlending?: boolean | undefined);
  95357. /**
  95358. * Converts the animation to a string
  95359. * @param fullDetails support for multiple levels of logging within scene loading
  95360. * @returns String form of the animation
  95361. */
  95362. toString(fullDetails?: boolean): string;
  95363. /**
  95364. * Add an event to this animation
  95365. * @param event Event to add
  95366. */
  95367. addEvent(event: AnimationEvent): void;
  95368. /**
  95369. * Remove all events found at the given frame
  95370. * @param frame The frame to remove events from
  95371. */
  95372. removeEvents(frame: number): void;
  95373. /**
  95374. * Retrieves all the events from the animation
  95375. * @returns Events from the animation
  95376. */
  95377. getEvents(): AnimationEvent[];
  95378. /**
  95379. * Creates an animation range
  95380. * @param name Name of the animation range
  95381. * @param from Starting frame of the animation range
  95382. * @param to Ending frame of the animation
  95383. */
  95384. createRange(name: string, from: number, to: number): void;
  95385. /**
  95386. * Deletes an animation range by name
  95387. * @param name Name of the animation range to delete
  95388. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95389. */
  95390. deleteRange(name: string, deleteFrames?: boolean): void;
  95391. /**
  95392. * Gets the animation range by name, or null if not defined
  95393. * @param name Name of the animation range
  95394. * @returns Nullable animation range
  95395. */
  95396. getRange(name: string): Nullable<AnimationRange>;
  95397. /**
  95398. * Gets the key frames from the animation
  95399. * @returns The key frames of the animation
  95400. */
  95401. getKeys(): Array<IAnimationKey>;
  95402. /**
  95403. * Gets the highest frame rate of the animation
  95404. * @returns Highest frame rate of the animation
  95405. */
  95406. getHighestFrame(): number;
  95407. /**
  95408. * Gets the easing function of the animation
  95409. * @returns Easing function of the animation
  95410. */
  95411. getEasingFunction(): IEasingFunction;
  95412. /**
  95413. * Sets the easing function of the animation
  95414. * @param easingFunction A custom mathematical formula for animation
  95415. */
  95416. setEasingFunction(easingFunction: EasingFunction): void;
  95417. /**
  95418. * Interpolates a scalar linearly
  95419. * @param startValue Start value of the animation curve
  95420. * @param endValue End value of the animation curve
  95421. * @param gradient Scalar amount to interpolate
  95422. * @returns Interpolated scalar value
  95423. */
  95424. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95425. /**
  95426. * Interpolates a scalar cubically
  95427. * @param startValue Start value of the animation curve
  95428. * @param outTangent End tangent of the animation
  95429. * @param endValue End value of the animation curve
  95430. * @param inTangent Start tangent of the animation curve
  95431. * @param gradient Scalar amount to interpolate
  95432. * @returns Interpolated scalar value
  95433. */
  95434. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95435. /**
  95436. * Interpolates a quaternion using a spherical linear interpolation
  95437. * @param startValue Start value of the animation curve
  95438. * @param endValue End value of the animation curve
  95439. * @param gradient Scalar amount to interpolate
  95440. * @returns Interpolated quaternion value
  95441. */
  95442. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95443. /**
  95444. * Interpolates a quaternion cubically
  95445. * @param startValue Start value of the animation curve
  95446. * @param outTangent End tangent of the animation curve
  95447. * @param endValue End value of the animation curve
  95448. * @param inTangent Start tangent of the animation curve
  95449. * @param gradient Scalar amount to interpolate
  95450. * @returns Interpolated quaternion value
  95451. */
  95452. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95453. /**
  95454. * Interpolates a Vector3 linearl
  95455. * @param startValue Start value of the animation curve
  95456. * @param endValue End value of the animation curve
  95457. * @param gradient Scalar amount to interpolate
  95458. * @returns Interpolated scalar value
  95459. */
  95460. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95461. /**
  95462. * Interpolates a Vector3 cubically
  95463. * @param startValue Start value of the animation curve
  95464. * @param outTangent End tangent of the animation
  95465. * @param endValue End value of the animation curve
  95466. * @param inTangent Start tangent of the animation curve
  95467. * @param gradient Scalar amount to interpolate
  95468. * @returns InterpolatedVector3 value
  95469. */
  95470. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95471. /**
  95472. * Interpolates a Vector2 linearly
  95473. * @param startValue Start value of the animation curve
  95474. * @param endValue End value of the animation curve
  95475. * @param gradient Scalar amount to interpolate
  95476. * @returns Interpolated Vector2 value
  95477. */
  95478. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  95479. /**
  95480. * Interpolates a Vector2 cubically
  95481. * @param startValue Start value of the animation curve
  95482. * @param outTangent End tangent of the animation
  95483. * @param endValue End value of the animation curve
  95484. * @param inTangent Start tangent of the animation curve
  95485. * @param gradient Scalar amount to interpolate
  95486. * @returns Interpolated Vector2 value
  95487. */
  95488. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  95489. /**
  95490. * Interpolates a size linearly
  95491. * @param startValue Start value of the animation curve
  95492. * @param endValue End value of the animation curve
  95493. * @param gradient Scalar amount to interpolate
  95494. * @returns Interpolated Size value
  95495. */
  95496. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  95497. /**
  95498. * Interpolates a Color3 linearly
  95499. * @param startValue Start value of the animation curve
  95500. * @param endValue End value of the animation curve
  95501. * @param gradient Scalar amount to interpolate
  95502. * @returns Interpolated Color3 value
  95503. */
  95504. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  95505. /**
  95506. * Interpolates a Color4 linearly
  95507. * @param startValue Start value of the animation curve
  95508. * @param endValue End value of the animation curve
  95509. * @param gradient Scalar amount to interpolate
  95510. * @returns Interpolated Color3 value
  95511. */
  95512. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  95513. /**
  95514. * @hidden Internal use only
  95515. */
  95516. _getKeyValue(value: any): any;
  95517. /**
  95518. * @hidden Internal use only
  95519. */
  95520. _interpolate(currentFrame: number, state: _IAnimationState): any;
  95521. /**
  95522. * Defines the function to use to interpolate matrices
  95523. * @param startValue defines the start matrix
  95524. * @param endValue defines the end matrix
  95525. * @param gradient defines the gradient between both matrices
  95526. * @param result defines an optional target matrix where to store the interpolation
  95527. * @returns the interpolated matrix
  95528. */
  95529. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  95530. /**
  95531. * Makes a copy of the animation
  95532. * @returns Cloned animation
  95533. */
  95534. clone(): Animation;
  95535. /**
  95536. * Sets the key frames of the animation
  95537. * @param values The animation key frames to set
  95538. */
  95539. setKeys(values: Array<IAnimationKey>): void;
  95540. /**
  95541. * Serializes the animation to an object
  95542. * @returns Serialized object
  95543. */
  95544. serialize(): any;
  95545. /**
  95546. * Float animation type
  95547. */
  95548. static readonly ANIMATIONTYPE_FLOAT: number;
  95549. /**
  95550. * Vector3 animation type
  95551. */
  95552. static readonly ANIMATIONTYPE_VECTOR3: number;
  95553. /**
  95554. * Quaternion animation type
  95555. */
  95556. static readonly ANIMATIONTYPE_QUATERNION: number;
  95557. /**
  95558. * Matrix animation type
  95559. */
  95560. static readonly ANIMATIONTYPE_MATRIX: number;
  95561. /**
  95562. * Color3 animation type
  95563. */
  95564. static readonly ANIMATIONTYPE_COLOR3: number;
  95565. /**
  95566. * Color3 animation type
  95567. */
  95568. static readonly ANIMATIONTYPE_COLOR4: number;
  95569. /**
  95570. * Vector2 animation type
  95571. */
  95572. static readonly ANIMATIONTYPE_VECTOR2: number;
  95573. /**
  95574. * Size animation type
  95575. */
  95576. static readonly ANIMATIONTYPE_SIZE: number;
  95577. /**
  95578. * Relative Loop Mode
  95579. */
  95580. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95581. /**
  95582. * Cycle Loop Mode
  95583. */
  95584. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95585. /**
  95586. * Constant Loop Mode
  95587. */
  95588. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95589. /** @hidden */
  95590. static _UniversalLerp(left: any, right: any, amount: number): any;
  95591. /**
  95592. * Parses an animation object and creates an animation
  95593. * @param parsedAnimation Parsed animation object
  95594. * @returns Animation object
  95595. */
  95596. static Parse(parsedAnimation: any): Animation;
  95597. /**
  95598. * Appends the serialized animations from the source animations
  95599. * @param source Source containing the animations
  95600. * @param destination Target to store the animations
  95601. */
  95602. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95603. }
  95604. }
  95605. declare module BABYLON {
  95606. /**
  95607. * Interface containing an array of animations
  95608. */
  95609. export interface IAnimatable {
  95610. /**
  95611. * Array of animations
  95612. */
  95613. animations: Nullable<Array<Animation>>;
  95614. }
  95615. }
  95616. declare module BABYLON {
  95617. /**
  95618. * This represents all the required information to add a fresnel effect on a material:
  95619. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95620. */
  95621. export class FresnelParameters {
  95622. private _isEnabled;
  95623. /**
  95624. * Define if the fresnel effect is enable or not.
  95625. */
  95626. isEnabled: boolean;
  95627. /**
  95628. * Define the color used on edges (grazing angle)
  95629. */
  95630. leftColor: Color3;
  95631. /**
  95632. * Define the color used on center
  95633. */
  95634. rightColor: Color3;
  95635. /**
  95636. * Define bias applied to computed fresnel term
  95637. */
  95638. bias: number;
  95639. /**
  95640. * Defined the power exponent applied to fresnel term
  95641. */
  95642. power: number;
  95643. /**
  95644. * Clones the current fresnel and its valuues
  95645. * @returns a clone fresnel configuration
  95646. */
  95647. clone(): FresnelParameters;
  95648. /**
  95649. * Serializes the current fresnel parameters to a JSON representation.
  95650. * @return the JSON serialization
  95651. */
  95652. serialize(): any;
  95653. /**
  95654. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95655. * @param parsedFresnelParameters Define the JSON representation
  95656. * @returns the parsed parameters
  95657. */
  95658. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95659. }
  95660. }
  95661. declare module BABYLON {
  95662. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95663. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95664. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95665. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95666. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95667. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95668. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95669. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95670. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95671. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95672. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95673. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95674. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95675. /**
  95676. * Decorator used to define property that can be serialized as reference to a camera
  95677. * @param sourceName defines the name of the property to decorate
  95678. */
  95679. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95680. /**
  95681. * Class used to help serialization objects
  95682. */
  95683. export class SerializationHelper {
  95684. /** @hidden */
  95685. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95686. /** @hidden */
  95687. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95688. /** @hidden */
  95689. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95690. /** @hidden */
  95691. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95692. /**
  95693. * Appends the serialized animations from the source animations
  95694. * @param source Source containing the animations
  95695. * @param destination Target to store the animations
  95696. */
  95697. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95698. /**
  95699. * Static function used to serialized a specific entity
  95700. * @param entity defines the entity to serialize
  95701. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95702. * @returns a JSON compatible object representing the serialization of the entity
  95703. */
  95704. static Serialize<T>(entity: T, serializationObject?: any): any;
  95705. /**
  95706. * Creates a new entity from a serialization data object
  95707. * @param creationFunction defines a function used to instanciated the new entity
  95708. * @param source defines the source serialization data
  95709. * @param scene defines the hosting scene
  95710. * @param rootUrl defines the root url for resources
  95711. * @returns a new entity
  95712. */
  95713. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95714. /**
  95715. * Clones an object
  95716. * @param creationFunction defines the function used to instanciate the new object
  95717. * @param source defines the source object
  95718. * @returns the cloned object
  95719. */
  95720. static Clone<T>(creationFunction: () => T, source: T): T;
  95721. /**
  95722. * Instanciates a new object based on a source one (some data will be shared between both object)
  95723. * @param creationFunction defines the function used to instanciate the new object
  95724. * @param source defines the source object
  95725. * @returns the new object
  95726. */
  95727. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95728. }
  95729. }
  95730. declare module BABYLON {
  95731. /**
  95732. * Class used to manipulate GUIDs
  95733. */
  95734. export class GUID {
  95735. /**
  95736. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95737. * Be aware Math.random() could cause collisions, but:
  95738. * "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"
  95739. * @returns a pseudo random id
  95740. */
  95741. static RandomId(): string;
  95742. }
  95743. }
  95744. declare module BABYLON {
  95745. /**
  95746. * Base class of all the textures in babylon.
  95747. * It groups all the common properties the materials, post process, lights... might need
  95748. * in order to make a correct use of the texture.
  95749. */
  95750. export class BaseTexture implements IAnimatable {
  95751. /**
  95752. * Default anisotropic filtering level for the application.
  95753. * It is set to 4 as a good tradeoff between perf and quality.
  95754. */
  95755. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  95756. /**
  95757. * Gets or sets the unique id of the texture
  95758. */
  95759. uniqueId: number;
  95760. /**
  95761. * Define the name of the texture.
  95762. */
  95763. name: string;
  95764. /**
  95765. * Gets or sets an object used to store user defined information.
  95766. */
  95767. metadata: any;
  95768. /**
  95769. * For internal use only. Please do not use.
  95770. */
  95771. reservedDataStore: any;
  95772. private _hasAlpha;
  95773. /**
  95774. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  95775. */
  95776. hasAlpha: boolean;
  95777. /**
  95778. * Defines if the alpha value should be determined via the rgb values.
  95779. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  95780. */
  95781. getAlphaFromRGB: boolean;
  95782. /**
  95783. * Intensity or strength of the texture.
  95784. * It is commonly used by materials to fine tune the intensity of the texture
  95785. */
  95786. level: number;
  95787. /**
  95788. * Define the UV chanel to use starting from 0 and defaulting to 0.
  95789. * This is part of the texture as textures usually maps to one uv set.
  95790. */
  95791. coordinatesIndex: number;
  95792. private _coordinatesMode;
  95793. /**
  95794. * How a texture is mapped.
  95795. *
  95796. * | Value | Type | Description |
  95797. * | ----- | ----------------------------------- | ----------- |
  95798. * | 0 | EXPLICIT_MODE | |
  95799. * | 1 | SPHERICAL_MODE | |
  95800. * | 2 | PLANAR_MODE | |
  95801. * | 3 | CUBIC_MODE | |
  95802. * | 4 | PROJECTION_MODE | |
  95803. * | 5 | SKYBOX_MODE | |
  95804. * | 6 | INVCUBIC_MODE | |
  95805. * | 7 | EQUIRECTANGULAR_MODE | |
  95806. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  95807. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  95808. */
  95809. coordinatesMode: number;
  95810. /**
  95811. * | Value | Type | Description |
  95812. * | ----- | ------------------ | ----------- |
  95813. * | 0 | CLAMP_ADDRESSMODE | |
  95814. * | 1 | WRAP_ADDRESSMODE | |
  95815. * | 2 | MIRROR_ADDRESSMODE | |
  95816. */
  95817. wrapU: number;
  95818. /**
  95819. * | Value | Type | Description |
  95820. * | ----- | ------------------ | ----------- |
  95821. * | 0 | CLAMP_ADDRESSMODE | |
  95822. * | 1 | WRAP_ADDRESSMODE | |
  95823. * | 2 | MIRROR_ADDRESSMODE | |
  95824. */
  95825. wrapV: number;
  95826. /**
  95827. * | Value | Type | Description |
  95828. * | ----- | ------------------ | ----------- |
  95829. * | 0 | CLAMP_ADDRESSMODE | |
  95830. * | 1 | WRAP_ADDRESSMODE | |
  95831. * | 2 | MIRROR_ADDRESSMODE | |
  95832. */
  95833. wrapR: number;
  95834. /**
  95835. * With compliant hardware and browser (supporting anisotropic filtering)
  95836. * this defines the level of anisotropic filtering in the texture.
  95837. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  95838. */
  95839. anisotropicFilteringLevel: number;
  95840. /**
  95841. * Define if the texture is a cube texture or if false a 2d texture.
  95842. */
  95843. isCube: boolean;
  95844. /**
  95845. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  95846. */
  95847. is3D: boolean;
  95848. /**
  95849. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  95850. */
  95851. is2DArray: boolean;
  95852. /**
  95853. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  95854. * HDR texture are usually stored in linear space.
  95855. * This only impacts the PBR and Background materials
  95856. */
  95857. gammaSpace: boolean;
  95858. /**
  95859. * Gets or sets whether or not the texture contains RGBD data.
  95860. */
  95861. isRGBD: boolean;
  95862. /**
  95863. * Is Z inverted in the texture (useful in a cube texture).
  95864. */
  95865. invertZ: boolean;
  95866. /**
  95867. * Are mip maps generated for this texture or not.
  95868. */
  95869. readonly noMipmap: boolean;
  95870. /**
  95871. * @hidden
  95872. */
  95873. lodLevelInAlpha: boolean;
  95874. /**
  95875. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95876. */
  95877. lodGenerationOffset: number;
  95878. /**
  95879. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95880. */
  95881. lodGenerationScale: number;
  95882. /**
  95883. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95884. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95885. * average roughness values.
  95886. */
  95887. linearSpecularLOD: boolean;
  95888. /**
  95889. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95890. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95891. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95892. */
  95893. irradianceTexture: Nullable<BaseTexture>;
  95894. /**
  95895. * Define if the texture is a render target.
  95896. */
  95897. isRenderTarget: boolean;
  95898. /**
  95899. * Define the unique id of the texture in the scene.
  95900. */
  95901. readonly uid: string;
  95902. /**
  95903. * Return a string representation of the texture.
  95904. * @returns the texture as a string
  95905. */
  95906. toString(): string;
  95907. /**
  95908. * Get the class name of the texture.
  95909. * @returns "BaseTexture"
  95910. */
  95911. getClassName(): string;
  95912. /**
  95913. * Define the list of animation attached to the texture.
  95914. */
  95915. animations: Animation[];
  95916. /**
  95917. * An event triggered when the texture is disposed.
  95918. */
  95919. onDisposeObservable: Observable<BaseTexture>;
  95920. private _onDisposeObserver;
  95921. /**
  95922. * Callback triggered when the texture has been disposed.
  95923. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95924. */
  95925. onDispose: () => void;
  95926. /**
  95927. * Define the current state of the loading sequence when in delayed load mode.
  95928. */
  95929. delayLoadState: number;
  95930. private _scene;
  95931. /** @hidden */
  95932. _texture: Nullable<InternalTexture>;
  95933. private _uid;
  95934. /**
  95935. * Define if the texture is preventinga material to render or not.
  95936. * If not and the texture is not ready, the engine will use a default black texture instead.
  95937. */
  95938. readonly isBlocking: boolean;
  95939. /**
  95940. * Instantiates a new BaseTexture.
  95941. * Base class of all the textures in babylon.
  95942. * It groups all the common properties the materials, post process, lights... might need
  95943. * in order to make a correct use of the texture.
  95944. * @param scene Define the scene the texture blongs to
  95945. */
  95946. constructor(scene: Nullable<Scene>);
  95947. /**
  95948. * Get the scene the texture belongs to.
  95949. * @returns the scene or null if undefined
  95950. */
  95951. getScene(): Nullable<Scene>;
  95952. /**
  95953. * Get the texture transform matrix used to offset tile the texture for istance.
  95954. * @returns the transformation matrix
  95955. */
  95956. getTextureMatrix(): Matrix;
  95957. /**
  95958. * Get the texture reflection matrix used to rotate/transform the reflection.
  95959. * @returns the reflection matrix
  95960. */
  95961. getReflectionTextureMatrix(): Matrix;
  95962. /**
  95963. * Get the underlying lower level texture from Babylon.
  95964. * @returns the insternal texture
  95965. */
  95966. getInternalTexture(): Nullable<InternalTexture>;
  95967. /**
  95968. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95969. * @returns true if ready or not blocking
  95970. */
  95971. isReadyOrNotBlocking(): boolean;
  95972. /**
  95973. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95974. * @returns true if fully ready
  95975. */
  95976. isReady(): boolean;
  95977. private _cachedSize;
  95978. /**
  95979. * Get the size of the texture.
  95980. * @returns the texture size.
  95981. */
  95982. getSize(): ISize;
  95983. /**
  95984. * Get the base size of the texture.
  95985. * It can be different from the size if the texture has been resized for POT for instance
  95986. * @returns the base size
  95987. */
  95988. getBaseSize(): ISize;
  95989. /**
  95990. * Update the sampling mode of the texture.
  95991. * Default is Trilinear mode.
  95992. *
  95993. * | Value | Type | Description |
  95994. * | ----- | ------------------ | ----------- |
  95995. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95996. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95997. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95998. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95999. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96000. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96001. * | 7 | NEAREST_LINEAR | |
  96002. * | 8 | NEAREST_NEAREST | |
  96003. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96004. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96005. * | 11 | LINEAR_LINEAR | |
  96006. * | 12 | LINEAR_NEAREST | |
  96007. *
  96008. * > _mag_: magnification filter (close to the viewer)
  96009. * > _min_: minification filter (far from the viewer)
  96010. * > _mip_: filter used between mip map levels
  96011. *@param samplingMode Define the new sampling mode of the texture
  96012. */
  96013. updateSamplingMode(samplingMode: number): void;
  96014. /**
  96015. * Scales the texture if is `canRescale()`
  96016. * @param ratio the resize factor we want to use to rescale
  96017. */
  96018. scale(ratio: number): void;
  96019. /**
  96020. * Get if the texture can rescale.
  96021. */
  96022. readonly canRescale: boolean;
  96023. /** @hidden */
  96024. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96025. /** @hidden */
  96026. _rebuild(): void;
  96027. /**
  96028. * Triggers the load sequence in delayed load mode.
  96029. */
  96030. delayLoad(): void;
  96031. /**
  96032. * Clones the texture.
  96033. * @returns the cloned texture
  96034. */
  96035. clone(): Nullable<BaseTexture>;
  96036. /**
  96037. * Get the texture underlying type (INT, FLOAT...)
  96038. */
  96039. readonly textureType: number;
  96040. /**
  96041. * Get the texture underlying format (RGB, RGBA...)
  96042. */
  96043. readonly textureFormat: number;
  96044. /**
  96045. * Indicates that textures need to be re-calculated for all materials
  96046. */
  96047. protected _markAllSubMeshesAsTexturesDirty(): void;
  96048. /**
  96049. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96050. * This will returns an RGBA array buffer containing either in values (0-255) or
  96051. * float values (0-1) depending of the underlying buffer type.
  96052. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96053. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96054. * @param buffer defines a user defined buffer to fill with data (can be null)
  96055. * @returns The Array buffer containing the pixels data.
  96056. */
  96057. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96058. /**
  96059. * Release and destroy the underlying lower level texture aka internalTexture.
  96060. */
  96061. releaseInternalTexture(): void;
  96062. /** @hidden */
  96063. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96064. /** @hidden */
  96065. readonly _lodTextureMid: Nullable<BaseTexture>;
  96066. /** @hidden */
  96067. readonly _lodTextureLow: Nullable<BaseTexture>;
  96068. /**
  96069. * Dispose the texture and release its associated resources.
  96070. */
  96071. dispose(): void;
  96072. /**
  96073. * Serialize the texture into a JSON representation that can be parsed later on.
  96074. * @returns the JSON representation of the texture
  96075. */
  96076. serialize(): any;
  96077. /**
  96078. * Helper function to be called back once a list of texture contains only ready textures.
  96079. * @param textures Define the list of textures to wait for
  96080. * @param callback Define the callback triggered once the entire list will be ready
  96081. */
  96082. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96083. }
  96084. }
  96085. declare module BABYLON {
  96086. /**
  96087. * Options to be used when creating an effect.
  96088. */
  96089. export interface IEffectCreationOptions {
  96090. /**
  96091. * Atrributes that will be used in the shader.
  96092. */
  96093. attributes: string[];
  96094. /**
  96095. * Uniform varible names that will be set in the shader.
  96096. */
  96097. uniformsNames: string[];
  96098. /**
  96099. * Uniform buffer varible names that will be set in the shader.
  96100. */
  96101. uniformBuffersNames: string[];
  96102. /**
  96103. * Sampler texture variable names that will be set in the shader.
  96104. */
  96105. samplers: string[];
  96106. /**
  96107. * Define statements that will be set in the shader.
  96108. */
  96109. defines: any;
  96110. /**
  96111. * Possible fallbacks for this effect to improve performance when needed.
  96112. */
  96113. fallbacks: Nullable<IEffectFallbacks>;
  96114. /**
  96115. * Callback that will be called when the shader is compiled.
  96116. */
  96117. onCompiled: Nullable<(effect: Effect) => void>;
  96118. /**
  96119. * Callback that will be called if an error occurs during shader compilation.
  96120. */
  96121. onError: Nullable<(effect: Effect, errors: string) => void>;
  96122. /**
  96123. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96124. */
  96125. indexParameters?: any;
  96126. /**
  96127. * Max number of lights that can be used in the shader.
  96128. */
  96129. maxSimultaneousLights?: number;
  96130. /**
  96131. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96132. */
  96133. transformFeedbackVaryings?: Nullable<string[]>;
  96134. }
  96135. /**
  96136. * Effect containing vertex and fragment shader that can be executed on an object.
  96137. */
  96138. export class Effect implements IDisposable {
  96139. /**
  96140. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96141. */
  96142. static ShadersRepository: string;
  96143. /**
  96144. * Name of the effect.
  96145. */
  96146. name: any;
  96147. /**
  96148. * String container all the define statements that should be set on the shader.
  96149. */
  96150. defines: string;
  96151. /**
  96152. * Callback that will be called when the shader is compiled.
  96153. */
  96154. onCompiled: Nullable<(effect: Effect) => void>;
  96155. /**
  96156. * Callback that will be called if an error occurs during shader compilation.
  96157. */
  96158. onError: Nullable<(effect: Effect, errors: string) => void>;
  96159. /**
  96160. * Callback that will be called when effect is bound.
  96161. */
  96162. onBind: Nullable<(effect: Effect) => void>;
  96163. /**
  96164. * Unique ID of the effect.
  96165. */
  96166. uniqueId: number;
  96167. /**
  96168. * Observable that will be called when the shader is compiled.
  96169. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96170. */
  96171. onCompileObservable: Observable<Effect>;
  96172. /**
  96173. * Observable that will be called if an error occurs during shader compilation.
  96174. */
  96175. onErrorObservable: Observable<Effect>;
  96176. /** @hidden */
  96177. _onBindObservable: Nullable<Observable<Effect>>;
  96178. /**
  96179. * Observable that will be called when effect is bound.
  96180. */
  96181. readonly onBindObservable: Observable<Effect>;
  96182. /** @hidden */
  96183. _bonesComputationForcedToCPU: boolean;
  96184. private static _uniqueIdSeed;
  96185. private _engine;
  96186. private _uniformBuffersNames;
  96187. private _uniformsNames;
  96188. private _samplerList;
  96189. private _samplers;
  96190. private _isReady;
  96191. private _compilationError;
  96192. private _allFallbacksProcessed;
  96193. private _attributesNames;
  96194. private _attributes;
  96195. private _uniforms;
  96196. /**
  96197. * Key for the effect.
  96198. * @hidden
  96199. */
  96200. _key: string;
  96201. private _indexParameters;
  96202. private _fallbacks;
  96203. private _vertexSourceCode;
  96204. private _fragmentSourceCode;
  96205. private _vertexSourceCodeOverride;
  96206. private _fragmentSourceCodeOverride;
  96207. private _transformFeedbackVaryings;
  96208. /**
  96209. * Compiled shader to webGL program.
  96210. * @hidden
  96211. */
  96212. _pipelineContext: Nullable<IPipelineContext>;
  96213. private _valueCache;
  96214. private static _baseCache;
  96215. /**
  96216. * Instantiates an effect.
  96217. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96218. * @param baseName Name of the effect.
  96219. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96220. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96221. * @param samplers List of sampler variables that will be passed to the shader.
  96222. * @param engine Engine to be used to render the effect
  96223. * @param defines Define statements to be added to the shader.
  96224. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96225. * @param onCompiled Callback that will be called when the shader is compiled.
  96226. * @param onError Callback that will be called if an error occurs during shader compilation.
  96227. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96228. */
  96229. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  96230. private _useFinalCode;
  96231. /**
  96232. * Unique key for this effect
  96233. */
  96234. readonly key: string;
  96235. /**
  96236. * If the effect has been compiled and prepared.
  96237. * @returns if the effect is compiled and prepared.
  96238. */
  96239. isReady(): boolean;
  96240. private _isReadyInternal;
  96241. /**
  96242. * The engine the effect was initialized with.
  96243. * @returns the engine.
  96244. */
  96245. getEngine(): Engine;
  96246. /**
  96247. * The pipeline context for this effect
  96248. * @returns the associated pipeline context
  96249. */
  96250. getPipelineContext(): Nullable<IPipelineContext>;
  96251. /**
  96252. * The set of names of attribute variables for the shader.
  96253. * @returns An array of attribute names.
  96254. */
  96255. getAttributesNames(): string[];
  96256. /**
  96257. * Returns the attribute at the given index.
  96258. * @param index The index of the attribute.
  96259. * @returns The location of the attribute.
  96260. */
  96261. getAttributeLocation(index: number): number;
  96262. /**
  96263. * Returns the attribute based on the name of the variable.
  96264. * @param name of the attribute to look up.
  96265. * @returns the attribute location.
  96266. */
  96267. getAttributeLocationByName(name: string): number;
  96268. /**
  96269. * The number of attributes.
  96270. * @returns the numnber of attributes.
  96271. */
  96272. getAttributesCount(): number;
  96273. /**
  96274. * Gets the index of a uniform variable.
  96275. * @param uniformName of the uniform to look up.
  96276. * @returns the index.
  96277. */
  96278. getUniformIndex(uniformName: string): number;
  96279. /**
  96280. * Returns the attribute based on the name of the variable.
  96281. * @param uniformName of the uniform to look up.
  96282. * @returns the location of the uniform.
  96283. */
  96284. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96285. /**
  96286. * Returns an array of sampler variable names
  96287. * @returns The array of sampler variable neames.
  96288. */
  96289. getSamplers(): string[];
  96290. /**
  96291. * The error from the last compilation.
  96292. * @returns the error string.
  96293. */
  96294. getCompilationError(): string;
  96295. /**
  96296. * Gets a boolean indicating that all fallbacks were used during compilation
  96297. * @returns true if all fallbacks were used
  96298. */
  96299. allFallbacksProcessed(): boolean;
  96300. /**
  96301. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96302. * @param func The callback to be used.
  96303. */
  96304. executeWhenCompiled(func: (effect: Effect) => void): void;
  96305. private _checkIsReady;
  96306. private _loadShader;
  96307. /**
  96308. * Recompiles the webGL program
  96309. * @param vertexSourceCode The source code for the vertex shader.
  96310. * @param fragmentSourceCode The source code for the fragment shader.
  96311. * @param onCompiled Callback called when completed.
  96312. * @param onError Callback called on error.
  96313. * @hidden
  96314. */
  96315. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96316. /**
  96317. * Prepares the effect
  96318. * @hidden
  96319. */
  96320. _prepareEffect(): void;
  96321. private _processCompilationErrors;
  96322. /**
  96323. * Checks if the effect is supported. (Must be called after compilation)
  96324. */
  96325. readonly isSupported: boolean;
  96326. /**
  96327. * Binds a texture to the engine to be used as output of the shader.
  96328. * @param channel Name of the output variable.
  96329. * @param texture Texture to bind.
  96330. * @hidden
  96331. */
  96332. _bindTexture(channel: string, texture: InternalTexture): void;
  96333. /**
  96334. * Sets a texture on the engine to be used in the shader.
  96335. * @param channel Name of the sampler variable.
  96336. * @param texture Texture to set.
  96337. */
  96338. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96339. /**
  96340. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96341. * @param channel Name of the sampler variable.
  96342. * @param texture Texture to set.
  96343. */
  96344. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96345. /**
  96346. * Sets an array of textures on the engine to be used in the shader.
  96347. * @param channel Name of the variable.
  96348. * @param textures Textures to set.
  96349. */
  96350. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96351. /**
  96352. * 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)
  96353. * @param channel Name of the sampler variable.
  96354. * @param postProcess Post process to get the input texture from.
  96355. */
  96356. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96357. /**
  96358. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96359. * 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)
  96360. * @param channel Name of the sampler variable.
  96361. * @param postProcess Post process to get the output texture from.
  96362. */
  96363. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96364. /** @hidden */
  96365. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96366. /** @hidden */
  96367. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96368. /** @hidden */
  96369. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96370. /** @hidden */
  96371. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96372. /**
  96373. * Binds a buffer to a uniform.
  96374. * @param buffer Buffer to bind.
  96375. * @param name Name of the uniform variable to bind to.
  96376. */
  96377. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96378. /**
  96379. * Binds block to a uniform.
  96380. * @param blockName Name of the block to bind.
  96381. * @param index Index to bind.
  96382. */
  96383. bindUniformBlock(blockName: string, index: number): void;
  96384. /**
  96385. * Sets an interger value on a uniform variable.
  96386. * @param uniformName Name of the variable.
  96387. * @param value Value to be set.
  96388. * @returns this effect.
  96389. */
  96390. setInt(uniformName: string, value: number): Effect;
  96391. /**
  96392. * Sets an int array on a uniform variable.
  96393. * @param uniformName Name of the variable.
  96394. * @param array array to be set.
  96395. * @returns this effect.
  96396. */
  96397. setIntArray(uniformName: string, array: Int32Array): Effect;
  96398. /**
  96399. * 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)
  96400. * @param uniformName Name of the variable.
  96401. * @param array array to be set.
  96402. * @returns this effect.
  96403. */
  96404. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96405. /**
  96406. * 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)
  96407. * @param uniformName Name of the variable.
  96408. * @param array array to be set.
  96409. * @returns this effect.
  96410. */
  96411. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96412. /**
  96413. * 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)
  96414. * @param uniformName Name of the variable.
  96415. * @param array array to be set.
  96416. * @returns this effect.
  96417. */
  96418. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96419. /**
  96420. * Sets an float array on a uniform variable.
  96421. * @param uniformName Name of the variable.
  96422. * @param array array to be set.
  96423. * @returns this effect.
  96424. */
  96425. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96426. /**
  96427. * 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)
  96428. * @param uniformName Name of the variable.
  96429. * @param array array to be set.
  96430. * @returns this effect.
  96431. */
  96432. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96433. /**
  96434. * 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)
  96435. * @param uniformName Name of the variable.
  96436. * @param array array to be set.
  96437. * @returns this effect.
  96438. */
  96439. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96440. /**
  96441. * 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)
  96442. * @param uniformName Name of the variable.
  96443. * @param array array to be set.
  96444. * @returns this effect.
  96445. */
  96446. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96447. /**
  96448. * Sets an array on a uniform variable.
  96449. * @param uniformName Name of the variable.
  96450. * @param array array to be set.
  96451. * @returns this effect.
  96452. */
  96453. setArray(uniformName: string, array: number[]): Effect;
  96454. /**
  96455. * 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)
  96456. * @param uniformName Name of the variable.
  96457. * @param array array to be set.
  96458. * @returns this effect.
  96459. */
  96460. setArray2(uniformName: string, array: number[]): Effect;
  96461. /**
  96462. * 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)
  96463. * @param uniformName Name of the variable.
  96464. * @param array array to be set.
  96465. * @returns this effect.
  96466. */
  96467. setArray3(uniformName: string, array: number[]): Effect;
  96468. /**
  96469. * 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)
  96470. * @param uniformName Name of the variable.
  96471. * @param array array to be set.
  96472. * @returns this effect.
  96473. */
  96474. setArray4(uniformName: string, array: number[]): Effect;
  96475. /**
  96476. * Sets matrices on a uniform variable.
  96477. * @param uniformName Name of the variable.
  96478. * @param matrices matrices to be set.
  96479. * @returns this effect.
  96480. */
  96481. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  96482. /**
  96483. * Sets matrix on a uniform variable.
  96484. * @param uniformName Name of the variable.
  96485. * @param matrix matrix to be set.
  96486. * @returns this effect.
  96487. */
  96488. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  96489. /**
  96490. * 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)
  96491. * @param uniformName Name of the variable.
  96492. * @param matrix matrix to be set.
  96493. * @returns this effect.
  96494. */
  96495. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  96496. /**
  96497. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  96498. * @param uniformName Name of the variable.
  96499. * @param matrix matrix to be set.
  96500. * @returns this effect.
  96501. */
  96502. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  96503. /**
  96504. * Sets a float on a uniform variable.
  96505. * @param uniformName Name of the variable.
  96506. * @param value value to be set.
  96507. * @returns this effect.
  96508. */
  96509. setFloat(uniformName: string, value: number): Effect;
  96510. /**
  96511. * Sets a boolean on a uniform variable.
  96512. * @param uniformName Name of the variable.
  96513. * @param bool value to be set.
  96514. * @returns this effect.
  96515. */
  96516. setBool(uniformName: string, bool: boolean): Effect;
  96517. /**
  96518. * Sets a Vector2 on a uniform variable.
  96519. * @param uniformName Name of the variable.
  96520. * @param vector2 vector2 to be set.
  96521. * @returns this effect.
  96522. */
  96523. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  96524. /**
  96525. * Sets a float2 on a uniform variable.
  96526. * @param uniformName Name of the variable.
  96527. * @param x First float in float2.
  96528. * @param y Second float in float2.
  96529. * @returns this effect.
  96530. */
  96531. setFloat2(uniformName: string, x: number, y: number): Effect;
  96532. /**
  96533. * Sets a Vector3 on a uniform variable.
  96534. * @param uniformName Name of the variable.
  96535. * @param vector3 Value to be set.
  96536. * @returns this effect.
  96537. */
  96538. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  96539. /**
  96540. * Sets a float3 on a uniform variable.
  96541. * @param uniformName Name of the variable.
  96542. * @param x First float in float3.
  96543. * @param y Second float in float3.
  96544. * @param z Third float in float3.
  96545. * @returns this effect.
  96546. */
  96547. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  96548. /**
  96549. * Sets a Vector4 on a uniform variable.
  96550. * @param uniformName Name of the variable.
  96551. * @param vector4 Value to be set.
  96552. * @returns this effect.
  96553. */
  96554. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  96555. /**
  96556. * Sets a float4 on a uniform variable.
  96557. * @param uniformName Name of the variable.
  96558. * @param x First float in float4.
  96559. * @param y Second float in float4.
  96560. * @param z Third float in float4.
  96561. * @param w Fourth float in float4.
  96562. * @returns this effect.
  96563. */
  96564. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  96565. /**
  96566. * Sets a Color3 on a uniform variable.
  96567. * @param uniformName Name of the variable.
  96568. * @param color3 Value to be set.
  96569. * @returns this effect.
  96570. */
  96571. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96572. /**
  96573. * Sets a Color4 on a uniform variable.
  96574. * @param uniformName Name of the variable.
  96575. * @param color3 Value to be set.
  96576. * @param alpha Alpha value to be set.
  96577. * @returns this effect.
  96578. */
  96579. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96580. /**
  96581. * Sets a Color4 on a uniform variable
  96582. * @param uniformName defines the name of the variable
  96583. * @param color4 defines the value to be set
  96584. * @returns this effect.
  96585. */
  96586. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96587. /** Release all associated resources */
  96588. dispose(): void;
  96589. /**
  96590. * This function will add a new shader to the shader store
  96591. * @param name the name of the shader
  96592. * @param pixelShader optional pixel shader content
  96593. * @param vertexShader optional vertex shader content
  96594. */
  96595. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96596. /**
  96597. * Store of each shader (The can be looked up using effect.key)
  96598. */
  96599. static ShadersStore: {
  96600. [key: string]: string;
  96601. };
  96602. /**
  96603. * Store of each included file for a shader (The can be looked up using effect.key)
  96604. */
  96605. static IncludesShadersStore: {
  96606. [key: string]: string;
  96607. };
  96608. /**
  96609. * Resets the cache of effects.
  96610. */
  96611. static ResetCache(): void;
  96612. }
  96613. }
  96614. declare module BABYLON {
  96615. /**
  96616. * Interface used to describe the capabilities of the engine relatively to the current browser
  96617. */
  96618. export interface EngineCapabilities {
  96619. /** Maximum textures units per fragment shader */
  96620. maxTexturesImageUnits: number;
  96621. /** Maximum texture units per vertex shader */
  96622. maxVertexTextureImageUnits: number;
  96623. /** Maximum textures units in the entire pipeline */
  96624. maxCombinedTexturesImageUnits: number;
  96625. /** Maximum texture size */
  96626. maxTextureSize: number;
  96627. /** Maximum cube texture size */
  96628. maxCubemapTextureSize: number;
  96629. /** Maximum render texture size */
  96630. maxRenderTextureSize: number;
  96631. /** Maximum number of vertex attributes */
  96632. maxVertexAttribs: number;
  96633. /** Maximum number of varyings */
  96634. maxVaryingVectors: number;
  96635. /** Maximum number of uniforms per vertex shader */
  96636. maxVertexUniformVectors: number;
  96637. /** Maximum number of uniforms per fragment shader */
  96638. maxFragmentUniformVectors: number;
  96639. /** Defines if standard derivates (dx/dy) are supported */
  96640. standardDerivatives: boolean;
  96641. /** Defines if s3tc texture compression is supported */
  96642. s3tc?: WEBGL_compressed_texture_s3tc;
  96643. /** Defines if pvrtc texture compression is supported */
  96644. pvrtc: any;
  96645. /** Defines if etc1 texture compression is supported */
  96646. etc1: any;
  96647. /** Defines if etc2 texture compression is supported */
  96648. etc2: any;
  96649. /** Defines if astc texture compression is supported */
  96650. astc: any;
  96651. /** Defines if float textures are supported */
  96652. textureFloat: boolean;
  96653. /** Defines if vertex array objects are supported */
  96654. vertexArrayObject: boolean;
  96655. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96656. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  96657. /** Gets the maximum level of anisotropy supported */
  96658. maxAnisotropy: number;
  96659. /** Defines if instancing is supported */
  96660. instancedArrays: boolean;
  96661. /** Defines if 32 bits indices are supported */
  96662. uintIndices: boolean;
  96663. /** Defines if high precision shaders are supported */
  96664. highPrecisionShaderSupported: boolean;
  96665. /** Defines if depth reading in the fragment shader is supported */
  96666. fragmentDepthSupported: boolean;
  96667. /** Defines if float texture linear filtering is supported*/
  96668. textureFloatLinearFiltering: boolean;
  96669. /** Defines if rendering to float textures is supported */
  96670. textureFloatRender: boolean;
  96671. /** Defines if half float textures are supported*/
  96672. textureHalfFloat: boolean;
  96673. /** Defines if half float texture linear filtering is supported*/
  96674. textureHalfFloatLinearFiltering: boolean;
  96675. /** Defines if rendering to half float textures is supported */
  96676. textureHalfFloatRender: boolean;
  96677. /** Defines if textureLOD shader command is supported */
  96678. textureLOD: boolean;
  96679. /** Defines if draw buffers extension is supported */
  96680. drawBuffersExtension: boolean;
  96681. /** Defines if depth textures are supported */
  96682. depthTextureExtension: boolean;
  96683. /** Defines if float color buffer are supported */
  96684. colorBufferFloat: boolean;
  96685. /** Gets disjoint timer query extension (null if not supported) */
  96686. timerQuery?: EXT_disjoint_timer_query;
  96687. /** Defines if timestamp can be used with timer query */
  96688. canUseTimestampForTimerQuery: boolean;
  96689. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96690. multiview?: any;
  96691. /** Function used to let the system compiles shaders in background */
  96692. parallelShaderCompile?: {
  96693. COMPLETION_STATUS_KHR: number;
  96694. };
  96695. /** Max number of texture samples for MSAA */
  96696. maxMSAASamples: number;
  96697. /** Defines if the blend min max extension is supported */
  96698. blendMinMax: boolean;
  96699. }
  96700. }
  96701. declare module BABYLON {
  96702. /**
  96703. * @hidden
  96704. **/
  96705. export class DepthCullingState {
  96706. private _isDepthTestDirty;
  96707. private _isDepthMaskDirty;
  96708. private _isDepthFuncDirty;
  96709. private _isCullFaceDirty;
  96710. private _isCullDirty;
  96711. private _isZOffsetDirty;
  96712. private _isFrontFaceDirty;
  96713. private _depthTest;
  96714. private _depthMask;
  96715. private _depthFunc;
  96716. private _cull;
  96717. private _cullFace;
  96718. private _zOffset;
  96719. private _frontFace;
  96720. /**
  96721. * Initializes the state.
  96722. */
  96723. constructor();
  96724. readonly isDirty: boolean;
  96725. zOffset: number;
  96726. cullFace: Nullable<number>;
  96727. cull: Nullable<boolean>;
  96728. depthFunc: Nullable<number>;
  96729. depthMask: boolean;
  96730. depthTest: boolean;
  96731. frontFace: Nullable<number>;
  96732. reset(): void;
  96733. apply(gl: WebGLRenderingContext): void;
  96734. }
  96735. }
  96736. declare module BABYLON {
  96737. /**
  96738. * @hidden
  96739. **/
  96740. export class StencilState {
  96741. /** 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 */
  96742. static readonly ALWAYS: number;
  96743. /** Passed to stencilOperation to specify that stencil value must be kept */
  96744. static readonly KEEP: number;
  96745. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96746. static readonly REPLACE: number;
  96747. private _isStencilTestDirty;
  96748. private _isStencilMaskDirty;
  96749. private _isStencilFuncDirty;
  96750. private _isStencilOpDirty;
  96751. private _stencilTest;
  96752. private _stencilMask;
  96753. private _stencilFunc;
  96754. private _stencilFuncRef;
  96755. private _stencilFuncMask;
  96756. private _stencilOpStencilFail;
  96757. private _stencilOpDepthFail;
  96758. private _stencilOpStencilDepthPass;
  96759. readonly isDirty: boolean;
  96760. stencilFunc: number;
  96761. stencilFuncRef: number;
  96762. stencilFuncMask: number;
  96763. stencilOpStencilFail: number;
  96764. stencilOpDepthFail: number;
  96765. stencilOpStencilDepthPass: number;
  96766. stencilMask: number;
  96767. stencilTest: boolean;
  96768. constructor();
  96769. reset(): void;
  96770. apply(gl: WebGLRenderingContext): void;
  96771. }
  96772. }
  96773. declare module BABYLON {
  96774. /**
  96775. * @hidden
  96776. **/
  96777. export class AlphaState {
  96778. private _isAlphaBlendDirty;
  96779. private _isBlendFunctionParametersDirty;
  96780. private _isBlendEquationParametersDirty;
  96781. private _isBlendConstantsDirty;
  96782. private _alphaBlend;
  96783. private _blendFunctionParameters;
  96784. private _blendEquationParameters;
  96785. private _blendConstants;
  96786. /**
  96787. * Initializes the state.
  96788. */
  96789. constructor();
  96790. readonly isDirty: boolean;
  96791. alphaBlend: boolean;
  96792. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  96793. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  96794. setAlphaEquationParameters(rgb: number, alpha: number): void;
  96795. reset(): void;
  96796. apply(gl: WebGLRenderingContext): void;
  96797. }
  96798. }
  96799. declare module BABYLON {
  96800. /** @hidden */
  96801. export class WebGL2ShaderProcessor implements IShaderProcessor {
  96802. attributeProcessor(attribute: string): string;
  96803. varyingProcessor(varying: string, isFragment: boolean): string;
  96804. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  96805. }
  96806. }
  96807. declare module BABYLON {
  96808. /**
  96809. * Interface for attribute information associated with buffer instanciation
  96810. */
  96811. export interface InstancingAttributeInfo {
  96812. /**
  96813. * Index/offset of the attribute in the vertex shader
  96814. */
  96815. index: number;
  96816. /**
  96817. * size of the attribute, 1, 2, 3 or 4
  96818. */
  96819. attributeSize: number;
  96820. /**
  96821. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  96822. * default is FLOAT
  96823. */
  96824. attributeType: number;
  96825. /**
  96826. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  96827. */
  96828. normalized: boolean;
  96829. /**
  96830. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  96831. */
  96832. offset: number;
  96833. /**
  96834. * Name of the GLSL attribute, for debugging purpose only
  96835. */
  96836. attributeName: string;
  96837. }
  96838. }
  96839. declare module BABYLON {
  96840. interface ThinEngine {
  96841. /**
  96842. * Update a video texture
  96843. * @param texture defines the texture to update
  96844. * @param video defines the video element to use
  96845. * @param invertY defines if data must be stored with Y axis inverted
  96846. */
  96847. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96848. }
  96849. }
  96850. declare module BABYLON {
  96851. /**
  96852. * Settings for finer control over video usage
  96853. */
  96854. export interface VideoTextureSettings {
  96855. /**
  96856. * Applies `autoplay` to video, if specified
  96857. */
  96858. autoPlay?: boolean;
  96859. /**
  96860. * Applies `loop` to video, if specified
  96861. */
  96862. loop?: boolean;
  96863. /**
  96864. * Automatically updates internal texture from video at every frame in the render loop
  96865. */
  96866. autoUpdateTexture: boolean;
  96867. /**
  96868. * Image src displayed during the video loading or until the user interacts with the video.
  96869. */
  96870. poster?: string;
  96871. }
  96872. /**
  96873. * If you want to display a video in your scene, this is the special texture for that.
  96874. * This special texture works similar to other textures, with the exception of a few parameters.
  96875. * @see https://doc.babylonjs.com/how_to/video_texture
  96876. */
  96877. export class VideoTexture extends Texture {
  96878. /**
  96879. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96880. */
  96881. readonly autoUpdateTexture: boolean;
  96882. /**
  96883. * The video instance used by the texture internally
  96884. */
  96885. readonly video: HTMLVideoElement;
  96886. private _onUserActionRequestedObservable;
  96887. /**
  96888. * Event triggerd when a dom action is required by the user to play the video.
  96889. * This happens due to recent changes in browser policies preventing video to auto start.
  96890. */
  96891. readonly onUserActionRequestedObservable: Observable<Texture>;
  96892. private _generateMipMaps;
  96893. private _engine;
  96894. private _stillImageCaptured;
  96895. private _displayingPosterTexture;
  96896. private _settings;
  96897. private _createInternalTextureOnEvent;
  96898. private _frameId;
  96899. /**
  96900. * Creates a video texture.
  96901. * If you want to display a video in your scene, this is the special texture for that.
  96902. * This special texture works similar to other textures, with the exception of a few parameters.
  96903. * @see https://doc.babylonjs.com/how_to/video_texture
  96904. * @param name optional name, will detect from video source, if not defined
  96905. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96906. * @param scene is obviously the current scene.
  96907. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96908. * @param invertY is false by default but can be used to invert video on Y axis
  96909. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96910. * @param settings allows finer control over video usage
  96911. */
  96912. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96913. private _getName;
  96914. private _getVideo;
  96915. private _createInternalTexture;
  96916. private reset;
  96917. /**
  96918. * @hidden Internal method to initiate `update`.
  96919. */
  96920. _rebuild(): void;
  96921. /**
  96922. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96923. */
  96924. update(): void;
  96925. /**
  96926. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96927. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96928. */
  96929. updateTexture(isVisible: boolean): void;
  96930. protected _updateInternalTexture: () => void;
  96931. /**
  96932. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96933. * @param url New url.
  96934. */
  96935. updateURL(url: string): void;
  96936. /**
  96937. * Dispose the texture and release its associated resources.
  96938. */
  96939. dispose(): void;
  96940. /**
  96941. * Creates a video texture straight from a stream.
  96942. * @param scene Define the scene the texture should be created in
  96943. * @param stream Define the stream the texture should be created from
  96944. * @returns The created video texture as a promise
  96945. */
  96946. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96947. /**
  96948. * Creates a video texture straight from your WebCam video feed.
  96949. * @param scene Define the scene the texture should be created in
  96950. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96951. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96952. * @returns The created video texture as a promise
  96953. */
  96954. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96955. minWidth: number;
  96956. maxWidth: number;
  96957. minHeight: number;
  96958. maxHeight: number;
  96959. deviceId: string;
  96960. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96961. /**
  96962. * Creates a video texture straight from your WebCam video feed.
  96963. * @param scene Define the scene the texture should be created in
  96964. * @param onReady Define a callback to triggered once the texture will be ready
  96965. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96966. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96967. */
  96968. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96969. minWidth: number;
  96970. maxWidth: number;
  96971. minHeight: number;
  96972. maxHeight: number;
  96973. deviceId: string;
  96974. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96975. }
  96976. }
  96977. declare module BABYLON {
  96978. /**
  96979. * Defines the interface used by objects working like Scene
  96980. * @hidden
  96981. */
  96982. interface ISceneLike {
  96983. _addPendingData(data: any): void;
  96984. _removePendingData(data: any): void;
  96985. offlineProvider: IOfflineProvider;
  96986. }
  96987. /** Interface defining initialization parameters for Engine class */
  96988. export interface EngineOptions extends WebGLContextAttributes {
  96989. /**
  96990. * Defines if the engine should no exceed a specified device ratio
  96991. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96992. */
  96993. limitDeviceRatio?: number;
  96994. /**
  96995. * Defines if webvr should be enabled automatically
  96996. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96997. */
  96998. autoEnableWebVR?: boolean;
  96999. /**
  97000. * Defines if webgl2 should be turned off even if supported
  97001. * @see http://doc.babylonjs.com/features/webgl2
  97002. */
  97003. disableWebGL2Support?: boolean;
  97004. /**
  97005. * Defines if webaudio should be initialized as well
  97006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97007. */
  97008. audioEngine?: boolean;
  97009. /**
  97010. * Defines if animations should run using a deterministic lock step
  97011. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97012. */
  97013. deterministicLockstep?: boolean;
  97014. /** Defines the maximum steps to use with deterministic lock step mode */
  97015. lockstepMaxSteps?: number;
  97016. /**
  97017. * Defines that engine should ignore context lost events
  97018. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97019. */
  97020. doNotHandleContextLost?: boolean;
  97021. /**
  97022. * Defines that engine should ignore modifying touch action attribute and style
  97023. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97024. */
  97025. doNotHandleTouchAction?: boolean;
  97026. /**
  97027. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97028. */
  97029. useHighPrecisionFloats?: boolean;
  97030. }
  97031. /**
  97032. * The base engine class (root of all engines)
  97033. */
  97034. export class ThinEngine {
  97035. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97036. static ExceptionList: ({
  97037. key: string;
  97038. capture: string;
  97039. captureConstraint: number;
  97040. targets: string[];
  97041. } | {
  97042. key: string;
  97043. capture: null;
  97044. captureConstraint: null;
  97045. targets: string[];
  97046. })[];
  97047. /** @hidden */
  97048. static _TextureLoaders: IInternalTextureLoader[];
  97049. /**
  97050. * Returns the current npm package of the sdk
  97051. */
  97052. static readonly NpmPackage: string;
  97053. /**
  97054. * Returns the current version of the framework
  97055. */
  97056. static readonly Version: string;
  97057. /**
  97058. * Returns a string describing the current engine
  97059. */
  97060. readonly description: string;
  97061. /**
  97062. * Gets or sets the epsilon value used by collision engine
  97063. */
  97064. static CollisionsEpsilon: number;
  97065. /**
  97066. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97067. */
  97068. static ShadersRepository: string;
  97069. /** @hidden */
  97070. _shaderProcessor: IShaderProcessor;
  97071. /**
  97072. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97073. */
  97074. forcePOTTextures: boolean;
  97075. /**
  97076. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97077. */
  97078. isFullscreen: boolean;
  97079. /**
  97080. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97081. */
  97082. cullBackFaces: boolean;
  97083. /**
  97084. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97085. */
  97086. renderEvenInBackground: boolean;
  97087. /**
  97088. * Gets or sets a boolean indicating that cache can be kept between frames
  97089. */
  97090. preventCacheWipeBetweenFrames: boolean;
  97091. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97092. validateShaderPrograms: boolean;
  97093. /**
  97094. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97095. */
  97096. disableUniformBuffers: boolean;
  97097. /** @hidden */
  97098. _uniformBuffers: UniformBuffer[];
  97099. /**
  97100. * Gets a boolean indicating that the engine supports uniform buffers
  97101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97102. */
  97103. readonly supportsUniformBuffers: boolean;
  97104. /** @hidden */
  97105. _gl: WebGLRenderingContext;
  97106. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97107. protected _windowIsBackground: boolean;
  97108. protected _webGLVersion: number;
  97109. protected _creationOptions: EngineOptions;
  97110. protected _highPrecisionShadersAllowed: boolean;
  97111. /** @hidden */
  97112. readonly _shouldUseHighPrecisionShader: boolean;
  97113. /**
  97114. * Gets a boolean indicating that only power of 2 textures are supported
  97115. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97116. */
  97117. readonly needPOTTextures: boolean;
  97118. /** @hidden */
  97119. _badOS: boolean;
  97120. /** @hidden */
  97121. _badDesktopOS: boolean;
  97122. private _hardwareScalingLevel;
  97123. /** @hidden */
  97124. _caps: EngineCapabilities;
  97125. private _isStencilEnable;
  97126. protected _colorWrite: boolean;
  97127. private _glVersion;
  97128. private _glRenderer;
  97129. private _glVendor;
  97130. /** @hidden */
  97131. _videoTextureSupported: boolean;
  97132. protected _renderingQueueLaunched: boolean;
  97133. protected _activeRenderLoops: (() => void)[];
  97134. /**
  97135. * Observable signaled when a context lost event is raised
  97136. */
  97137. onContextLostObservable: Observable<ThinEngine>;
  97138. /**
  97139. * Observable signaled when a context restored event is raised
  97140. */
  97141. onContextRestoredObservable: Observable<ThinEngine>;
  97142. private _onContextLost;
  97143. private _onContextRestored;
  97144. protected _contextWasLost: boolean;
  97145. /** @hidden */
  97146. _doNotHandleContextLost: boolean;
  97147. /**
  97148. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97149. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97150. */
  97151. doNotHandleContextLost: boolean;
  97152. /**
  97153. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97154. */
  97155. disableVertexArrayObjects: boolean;
  97156. /** @hidden */
  97157. protected _depthCullingState: DepthCullingState;
  97158. /** @hidden */
  97159. protected _stencilState: StencilState;
  97160. /** @hidden */
  97161. protected _alphaState: AlphaState;
  97162. /** @hidden */
  97163. _internalTexturesCache: InternalTexture[];
  97164. /** @hidden */
  97165. protected _activeChannel: number;
  97166. private _currentTextureChannel;
  97167. /** @hidden */
  97168. protected _boundTexturesCache: {
  97169. [key: string]: Nullable<InternalTexture>;
  97170. };
  97171. /** @hidden */
  97172. protected _currentEffect: Nullable<Effect>;
  97173. /** @hidden */
  97174. protected _currentProgram: Nullable<WebGLProgram>;
  97175. private _compiledEffects;
  97176. private _vertexAttribArraysEnabled;
  97177. /** @hidden */
  97178. protected _cachedViewport: Nullable<IViewportLike>;
  97179. private _cachedVertexArrayObject;
  97180. /** @hidden */
  97181. protected _cachedVertexBuffers: any;
  97182. /** @hidden */
  97183. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97184. /** @hidden */
  97185. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97186. /** @hidden */
  97187. _currentRenderTarget: Nullable<InternalTexture>;
  97188. private _uintIndicesCurrentlySet;
  97189. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97190. /** @hidden */
  97191. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97192. private _currentBufferPointers;
  97193. private _currentInstanceLocations;
  97194. private _currentInstanceBuffers;
  97195. private _textureUnits;
  97196. /** @hidden */
  97197. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97198. /** @hidden */
  97199. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97200. /** @hidden */
  97201. _boundRenderFunction: any;
  97202. private _vaoRecordInProgress;
  97203. private _mustWipeVertexAttributes;
  97204. private _emptyTexture;
  97205. private _emptyCubeTexture;
  97206. private _emptyTexture3D;
  97207. private _emptyTexture2DArray;
  97208. /** @hidden */
  97209. _frameHandler: number;
  97210. private _nextFreeTextureSlots;
  97211. private _maxSimultaneousTextures;
  97212. private _activeRequests;
  97213. protected _texturesSupported: string[];
  97214. /** @hidden */
  97215. _textureFormatInUse: Nullable<string>;
  97216. protected readonly _supportsHardwareTextureRescaling: boolean;
  97217. /**
  97218. * Gets the list of texture formats supported
  97219. */
  97220. readonly texturesSupported: Array<string>;
  97221. /**
  97222. * Gets the list of texture formats in use
  97223. */
  97224. readonly textureFormatInUse: Nullable<string>;
  97225. /**
  97226. * Gets the current viewport
  97227. */
  97228. readonly currentViewport: Nullable<IViewportLike>;
  97229. /**
  97230. * Gets the default empty texture
  97231. */
  97232. readonly emptyTexture: InternalTexture;
  97233. /**
  97234. * Gets the default empty 3D texture
  97235. */
  97236. readonly emptyTexture3D: InternalTexture;
  97237. /**
  97238. * Gets the default empty 2D array texture
  97239. */
  97240. readonly emptyTexture2DArray: InternalTexture;
  97241. /**
  97242. * Gets the default empty cube texture
  97243. */
  97244. readonly emptyCubeTexture: InternalTexture;
  97245. /**
  97246. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97247. */
  97248. readonly premultipliedAlpha: boolean;
  97249. /**
  97250. * Observable event triggered before each texture is initialized
  97251. */
  97252. onBeforeTextureInitObservable: Observable<Texture>;
  97253. /**
  97254. * Creates a new engine
  97255. * @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
  97256. * @param antialias defines enable antialiasing (default: false)
  97257. * @param options defines further options to be sent to the getContext() function
  97258. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97259. */
  97260. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97261. private _rebuildInternalTextures;
  97262. private _rebuildEffects;
  97263. /**
  97264. * Gets a boolean indicating if all created effects are ready
  97265. * @returns true if all effects are ready
  97266. */
  97267. areAllEffectsReady(): boolean;
  97268. protected _rebuildBuffers(): void;
  97269. private _initGLContext;
  97270. /**
  97271. * Gets version of the current webGL context
  97272. */
  97273. readonly webGLVersion: number;
  97274. /**
  97275. * Gets a string idenfifying the name of the class
  97276. * @returns "Engine" string
  97277. */
  97278. getClassName(): string;
  97279. /**
  97280. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97281. */
  97282. readonly isStencilEnable: boolean;
  97283. /** @hidden */
  97284. _prepareWorkingCanvas(): void;
  97285. /**
  97286. * Reset the texture cache to empty state
  97287. */
  97288. resetTextureCache(): void;
  97289. /**
  97290. * Gets an object containing information about the current webGL context
  97291. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97292. */
  97293. getGlInfo(): {
  97294. vendor: string;
  97295. renderer: string;
  97296. version: string;
  97297. };
  97298. /**
  97299. * Defines the hardware scaling level.
  97300. * By default the hardware scaling level is computed from the window device ratio.
  97301. * 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.
  97302. * @param level defines the level to use
  97303. */
  97304. setHardwareScalingLevel(level: number): void;
  97305. /**
  97306. * Gets the current hardware scaling level.
  97307. * By default the hardware scaling level is computed from the window device ratio.
  97308. * 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.
  97309. * @returns a number indicating the current hardware scaling level
  97310. */
  97311. getHardwareScalingLevel(): number;
  97312. /**
  97313. * Gets the list of loaded textures
  97314. * @returns an array containing all loaded textures
  97315. */
  97316. getLoadedTexturesCache(): InternalTexture[];
  97317. /**
  97318. * Gets the object containing all engine capabilities
  97319. * @returns the EngineCapabilities object
  97320. */
  97321. getCaps(): EngineCapabilities;
  97322. /**
  97323. * stop executing a render loop function and remove it from the execution array
  97324. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97325. */
  97326. stopRenderLoop(renderFunction?: () => void): void;
  97327. /** @hidden */
  97328. _renderLoop(): void;
  97329. /**
  97330. * Gets the HTML canvas attached with the current webGL context
  97331. * @returns a HTML canvas
  97332. */
  97333. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97334. /**
  97335. * Gets host window
  97336. * @returns the host window object
  97337. */
  97338. getHostWindow(): Nullable<Window>;
  97339. /**
  97340. * Gets the current render width
  97341. * @param useScreen defines if screen size must be used (or the current render target if any)
  97342. * @returns a number defining the current render width
  97343. */
  97344. getRenderWidth(useScreen?: boolean): number;
  97345. /**
  97346. * Gets the current render height
  97347. * @param useScreen defines if screen size must be used (or the current render target if any)
  97348. * @returns a number defining the current render height
  97349. */
  97350. getRenderHeight(useScreen?: boolean): number;
  97351. /**
  97352. * Can be used to override the current requestAnimationFrame requester.
  97353. * @hidden
  97354. */
  97355. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97356. /**
  97357. * Register and execute a render loop. The engine can have more than one render function
  97358. * @param renderFunction defines the function to continuously execute
  97359. */
  97360. runRenderLoop(renderFunction: () => void): void;
  97361. /**
  97362. * Clear the current render buffer or the current render target (if any is set up)
  97363. * @param color defines the color to use
  97364. * @param backBuffer defines if the back buffer must be cleared
  97365. * @param depth defines if the depth buffer must be cleared
  97366. * @param stencil defines if the stencil buffer must be cleared
  97367. */
  97368. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97369. private _viewportCached;
  97370. /** @hidden */
  97371. _viewport(x: number, y: number, width: number, height: number): void;
  97372. /**
  97373. * Set the WebGL's viewport
  97374. * @param viewport defines the viewport element to be used
  97375. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97376. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97377. */
  97378. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97379. /**
  97380. * Begin a new frame
  97381. */
  97382. beginFrame(): void;
  97383. /**
  97384. * Enf the current frame
  97385. */
  97386. endFrame(): void;
  97387. /**
  97388. * Resize the view according to the canvas' size
  97389. */
  97390. resize(): void;
  97391. /**
  97392. * Force a specific size of the canvas
  97393. * @param width defines the new canvas' width
  97394. * @param height defines the new canvas' height
  97395. */
  97396. setSize(width: number, height: number): void;
  97397. /**
  97398. * Binds the frame buffer to the specified texture.
  97399. * @param texture The texture to render to or null for the default canvas
  97400. * @param faceIndex The face of the texture to render to in case of cube texture
  97401. * @param requiredWidth The width of the target to render to
  97402. * @param requiredHeight The height of the target to render to
  97403. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97404. * @param depthStencilTexture The depth stencil texture to use to render
  97405. * @param lodLevel defines le lod level to bind to the frame buffer
  97406. */
  97407. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97408. /** @hidden */
  97409. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97410. /**
  97411. * Unbind the current render target texture from the webGL context
  97412. * @param texture defines the render target texture to unbind
  97413. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97414. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97415. */
  97416. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97417. /**
  97418. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97419. */
  97420. flushFramebuffer(): void;
  97421. /**
  97422. * Unbind the current render target and bind the default framebuffer
  97423. */
  97424. restoreDefaultFramebuffer(): void;
  97425. /** @hidden */
  97426. protected _resetVertexBufferBinding(): void;
  97427. /**
  97428. * Creates a vertex buffer
  97429. * @param data the data for the vertex buffer
  97430. * @returns the new WebGL static buffer
  97431. */
  97432. createVertexBuffer(data: DataArray): DataBuffer;
  97433. private _createVertexBuffer;
  97434. /**
  97435. * Creates a dynamic vertex buffer
  97436. * @param data the data for the dynamic vertex buffer
  97437. * @returns the new WebGL dynamic buffer
  97438. */
  97439. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97440. protected _resetIndexBufferBinding(): void;
  97441. /**
  97442. * Creates a new index buffer
  97443. * @param indices defines the content of the index buffer
  97444. * @param updatable defines if the index buffer must be updatable
  97445. * @returns a new webGL buffer
  97446. */
  97447. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97448. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97449. /**
  97450. * Bind a webGL buffer to the webGL context
  97451. * @param buffer defines the buffer to bind
  97452. */
  97453. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97454. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97455. private bindBuffer;
  97456. /**
  97457. * update the bound buffer with the given data
  97458. * @param data defines the data to update
  97459. */
  97460. updateArrayBuffer(data: Float32Array): void;
  97461. private _vertexAttribPointer;
  97462. private _bindIndexBufferWithCache;
  97463. private _bindVertexBuffersAttributes;
  97464. /**
  97465. * Records a vertex array object
  97466. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97467. * @param vertexBuffers defines the list of vertex buffers to store
  97468. * @param indexBuffer defines the index buffer to store
  97469. * @param effect defines the effect to store
  97470. * @returns the new vertex array object
  97471. */
  97472. recordVertexArrayObject(vertexBuffers: {
  97473. [key: string]: VertexBuffer;
  97474. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97475. /**
  97476. * Bind a specific vertex array object
  97477. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97478. * @param vertexArrayObject defines the vertex array object to bind
  97479. * @param indexBuffer defines the index buffer to bind
  97480. */
  97481. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  97482. /**
  97483. * Bind webGl buffers directly to the webGL context
  97484. * @param vertexBuffer defines the vertex buffer to bind
  97485. * @param indexBuffer defines the index buffer to bind
  97486. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  97487. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  97488. * @param effect defines the effect associated with the vertex buffer
  97489. */
  97490. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  97491. private _unbindVertexArrayObject;
  97492. /**
  97493. * Bind a list of vertex buffers to the webGL context
  97494. * @param vertexBuffers defines the list of vertex buffers to bind
  97495. * @param indexBuffer defines the index buffer to bind
  97496. * @param effect defines the effect associated with the vertex buffers
  97497. */
  97498. bindBuffers(vertexBuffers: {
  97499. [key: string]: Nullable<VertexBuffer>;
  97500. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  97501. /**
  97502. * Unbind all instance attributes
  97503. */
  97504. unbindInstanceAttributes(): void;
  97505. /**
  97506. * Release and free the memory of a vertex array object
  97507. * @param vao defines the vertex array object to delete
  97508. */
  97509. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  97510. /** @hidden */
  97511. _releaseBuffer(buffer: DataBuffer): boolean;
  97512. protected _deleteBuffer(buffer: DataBuffer): void;
  97513. /**
  97514. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  97515. * @param instancesBuffer defines the webGL buffer to update and bind
  97516. * @param data defines the data to store in the buffer
  97517. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  97518. */
  97519. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  97520. /**
  97521. * Apply all cached states (depth, culling, stencil and alpha)
  97522. */
  97523. applyStates(): void;
  97524. /**
  97525. * Send a draw order
  97526. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97527. * @param indexStart defines the starting index
  97528. * @param indexCount defines the number of index to draw
  97529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97530. */
  97531. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97532. /**
  97533. * Draw a list of points
  97534. * @param verticesStart defines the index of first vertex to draw
  97535. * @param verticesCount defines the count of vertices to draw
  97536. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97537. */
  97538. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97539. /**
  97540. * Draw a list of unindexed primitives
  97541. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97542. * @param verticesStart defines the index of first vertex to draw
  97543. * @param verticesCount defines the count of vertices to draw
  97544. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97545. */
  97546. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97547. /**
  97548. * Draw a list of indexed primitives
  97549. * @param fillMode defines the primitive to use
  97550. * @param indexStart defines the starting index
  97551. * @param indexCount defines the number of index to draw
  97552. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97553. */
  97554. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97555. /**
  97556. * Draw a list of unindexed primitives
  97557. * @param fillMode defines the primitive to use
  97558. * @param verticesStart defines the index of first vertex to draw
  97559. * @param verticesCount defines the count of vertices to draw
  97560. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97561. */
  97562. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97563. private _drawMode;
  97564. /** @hidden */
  97565. protected _reportDrawCall(): void;
  97566. /** @hidden */
  97567. _releaseEffect(effect: Effect): void;
  97568. /** @hidden */
  97569. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97570. /**
  97571. * Create a new effect (used to store vertex/fragment shaders)
  97572. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97573. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97574. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97575. * @param samplers defines an array of string used to represent textures
  97576. * @param defines defines the string containing the defines to use to compile the shaders
  97577. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97578. * @param onCompiled defines a function to call when the effect creation is successful
  97579. * @param onError defines a function to call when the effect creation has failed
  97580. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97581. * @returns the new Effect
  97582. */
  97583. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  97584. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97585. private _compileShader;
  97586. private _compileRawShader;
  97587. /**
  97588. * Directly creates a webGL program
  97589. * @param pipelineContext defines the pipeline context to attach to
  97590. * @param vertexCode defines the vertex shader code to use
  97591. * @param fragmentCode defines the fragment shader code to use
  97592. * @param context defines the webGL context to use (if not set, the current one will be used)
  97593. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97594. * @returns the new webGL program
  97595. */
  97596. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97597. /**
  97598. * Creates a webGL program
  97599. * @param pipelineContext defines the pipeline context to attach to
  97600. * @param vertexCode defines the vertex shader code to use
  97601. * @param fragmentCode defines the fragment shader code to use
  97602. * @param defines defines the string containing the defines to use to compile the shaders
  97603. * @param context defines the webGL context to use (if not set, the current one will be used)
  97604. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97605. * @returns the new webGL program
  97606. */
  97607. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97608. /**
  97609. * Creates a new pipeline context
  97610. * @returns the new pipeline
  97611. */
  97612. createPipelineContext(): IPipelineContext;
  97613. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97614. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97615. /** @hidden */
  97616. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97617. /** @hidden */
  97618. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97619. /** @hidden */
  97620. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97621. /**
  97622. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97623. * @param pipelineContext defines the pipeline context to use
  97624. * @param uniformsNames defines the list of uniform names
  97625. * @returns an array of webGL uniform locations
  97626. */
  97627. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97628. /**
  97629. * Gets the lsit of active attributes for a given webGL program
  97630. * @param pipelineContext defines the pipeline context to use
  97631. * @param attributesNames defines the list of attribute names to get
  97632. * @returns an array of indices indicating the offset of each attribute
  97633. */
  97634. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97635. /**
  97636. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97637. * @param effect defines the effect to activate
  97638. */
  97639. enableEffect(effect: Nullable<Effect>): void;
  97640. /**
  97641. * Set the value of an uniform to a number (int)
  97642. * @param uniform defines the webGL uniform location where to store the value
  97643. * @param value defines the int number to store
  97644. */
  97645. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97646. /**
  97647. * Set the value of an uniform to an array of int32
  97648. * @param uniform defines the webGL uniform location where to store the value
  97649. * @param array defines the array of int32 to store
  97650. */
  97651. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97652. /**
  97653. * Set the value of an uniform to an array of int32 (stored as vec2)
  97654. * @param uniform defines the webGL uniform location where to store the value
  97655. * @param array defines the array of int32 to store
  97656. */
  97657. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97658. /**
  97659. * Set the value of an uniform to an array of int32 (stored as vec3)
  97660. * @param uniform defines the webGL uniform location where to store the value
  97661. * @param array defines the array of int32 to store
  97662. */
  97663. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97664. /**
  97665. * Set the value of an uniform to an array of int32 (stored as vec4)
  97666. * @param uniform defines the webGL uniform location where to store the value
  97667. * @param array defines the array of int32 to store
  97668. */
  97669. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97670. /**
  97671. * Set the value of an uniform to an array of number
  97672. * @param uniform defines the webGL uniform location where to store the value
  97673. * @param array defines the array of number to store
  97674. */
  97675. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97676. /**
  97677. * Set the value of an uniform to an array of number (stored as vec2)
  97678. * @param uniform defines the webGL uniform location where to store the value
  97679. * @param array defines the array of number to store
  97680. */
  97681. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97682. /**
  97683. * Set the value of an uniform to an array of number (stored as vec3)
  97684. * @param uniform defines the webGL uniform location where to store the value
  97685. * @param array defines the array of number to store
  97686. */
  97687. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97688. /**
  97689. * Set the value of an uniform to an array of number (stored as vec4)
  97690. * @param uniform defines the webGL uniform location where to store the value
  97691. * @param array defines the array of number to store
  97692. */
  97693. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97694. /**
  97695. * Set the value of an uniform to an array of float32 (stored as matrices)
  97696. * @param uniform defines the webGL uniform location where to store the value
  97697. * @param matrices defines the array of float32 to store
  97698. */
  97699. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97700. /**
  97701. * Set the value of an uniform to a matrix (3x3)
  97702. * @param uniform defines the webGL uniform location where to store the value
  97703. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97704. */
  97705. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97706. /**
  97707. * Set the value of an uniform to a matrix (2x2)
  97708. * @param uniform defines the webGL uniform location where to store the value
  97709. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97710. */
  97711. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97712. /**
  97713. * Set the value of an uniform to a number (float)
  97714. * @param uniform defines the webGL uniform location where to store the value
  97715. * @param value defines the float number to store
  97716. */
  97717. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97718. /**
  97719. * Set the value of an uniform to a vec2
  97720. * @param uniform defines the webGL uniform location where to store the value
  97721. * @param x defines the 1st component of the value
  97722. * @param y defines the 2nd component of the value
  97723. */
  97724. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97725. /**
  97726. * Set the value of an uniform to a vec3
  97727. * @param uniform defines the webGL uniform location where to store the value
  97728. * @param x defines the 1st component of the value
  97729. * @param y defines the 2nd component of the value
  97730. * @param z defines the 3rd component of the value
  97731. */
  97732. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97733. /**
  97734. * Set the value of an uniform to a vec4
  97735. * @param uniform defines the webGL uniform location where to store the value
  97736. * @param x defines the 1st component of the value
  97737. * @param y defines the 2nd component of the value
  97738. * @param z defines the 3rd component of the value
  97739. * @param w defines the 4th component of the value
  97740. */
  97741. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97742. /**
  97743. * Gets the depth culling state manager
  97744. */
  97745. readonly depthCullingState: DepthCullingState;
  97746. /**
  97747. * Gets the alpha state manager
  97748. */
  97749. readonly alphaState: AlphaState;
  97750. /**
  97751. * Gets the stencil state manager
  97752. */
  97753. readonly stencilState: StencilState;
  97754. /**
  97755. * Clears the list of texture accessible through engine.
  97756. * This can help preventing texture load conflict due to name collision.
  97757. */
  97758. clearInternalTexturesCache(): void;
  97759. /**
  97760. * Force the entire cache to be cleared
  97761. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97762. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97763. */
  97764. wipeCaches(bruteForce?: boolean): void;
  97765. /** @hidden */
  97766. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97767. min: number;
  97768. mag: number;
  97769. };
  97770. /** @hidden */
  97771. _createTexture(): WebGLTexture;
  97772. /**
  97773. * Usually called from Texture.ts.
  97774. * Passed information to create a WebGLTexture
  97775. * @param urlArg defines a value which contains one of the following:
  97776. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97777. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97778. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97779. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97780. * @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)
  97781. * @param scene needed for loading to the correct scene
  97782. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97783. * @param onLoad optional callback to be called upon successful completion
  97784. * @param onError optional callback to be called upon failure
  97785. * @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
  97786. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97787. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97788. * @param forcedExtension defines the extension to use to pick the right loader
  97789. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97790. * @param mimeType defines an optional mime type
  97791. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97792. */
  97793. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  97794. /**
  97795. * @hidden
  97796. */
  97797. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97798. /**
  97799. * Creates a raw texture
  97800. * @param data defines the data to store in the texture
  97801. * @param width defines the width of the texture
  97802. * @param height defines the height of the texture
  97803. * @param format defines the format of the data
  97804. * @param generateMipMaps defines if the engine should generate the mip levels
  97805. * @param invertY defines if data must be stored with Y axis inverted
  97806. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97807. * @param compression defines the compression used (null by default)
  97808. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  97809. * @returns the raw texture inside an InternalTexture
  97810. */
  97811. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  97812. /**
  97813. * Creates a new raw cube texture
  97814. * @param data defines the array of data to use to create each face
  97815. * @param size defines the size of the textures
  97816. * @param format defines the format of the data
  97817. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  97818. * @param generateMipMaps defines if the engine should generate the mip levels
  97819. * @param invertY defines if data must be stored with Y axis inverted
  97820. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97821. * @param compression defines the compression used (null by default)
  97822. * @returns the cube texture as an InternalTexture
  97823. */
  97824. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  97825. /**
  97826. * Creates a new raw 3D texture
  97827. * @param data defines the data used to create the texture
  97828. * @param width defines the width of the texture
  97829. * @param height defines the height of the texture
  97830. * @param depth defines the depth of the texture
  97831. * @param format defines the format of the texture
  97832. * @param generateMipMaps defines if the engine must generate mip levels
  97833. * @param invertY defines if data must be stored with Y axis inverted
  97834. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97835. * @param compression defines the compressed used (can be null)
  97836. * @param textureType defines the compressed used (can be null)
  97837. * @returns a new raw 3D texture (stored in an InternalTexture)
  97838. */
  97839. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97840. /**
  97841. * Creates a new raw 2D array texture
  97842. * @param data defines the data used to create the texture
  97843. * @param width defines the width of the texture
  97844. * @param height defines the height of the texture
  97845. * @param depth defines the number of layers of the texture
  97846. * @param format defines the format of the texture
  97847. * @param generateMipMaps defines if the engine must generate mip levels
  97848. * @param invertY defines if data must be stored with Y axis inverted
  97849. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97850. * @param compression defines the compressed used (can be null)
  97851. * @param textureType defines the compressed used (can be null)
  97852. * @returns a new raw 2D array texture (stored in an InternalTexture)
  97853. */
  97854. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97855. private _unpackFlipYCached;
  97856. /**
  97857. * In case you are sharing the context with other applications, it might
  97858. * be interested to not cache the unpack flip y state to ensure a consistent
  97859. * value would be set.
  97860. */
  97861. enableUnpackFlipYCached: boolean;
  97862. /** @hidden */
  97863. _unpackFlipY(value: boolean): void;
  97864. /** @hidden */
  97865. _getUnpackAlignement(): number;
  97866. /**
  97867. * Update the sampling mode of a given texture
  97868. * @param samplingMode defines the required sampling mode
  97869. * @param texture defines the texture to update
  97870. */
  97871. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97872. /** @hidden */
  97873. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97874. width: number;
  97875. height: number;
  97876. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97877. /** @hidden */
  97878. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97879. /** @hidden */
  97880. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97881. /** @hidden */
  97882. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97883. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97884. private _prepareWebGLTexture;
  97885. /** @hidden */
  97886. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97887. /** @hidden */
  97888. _releaseFramebufferObjects(texture: InternalTexture): void;
  97889. /** @hidden */
  97890. _releaseTexture(texture: InternalTexture): void;
  97891. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97892. protected _setProgram(program: WebGLProgram): void;
  97893. protected _boundUniforms: {
  97894. [key: number]: WebGLUniformLocation;
  97895. };
  97896. /**
  97897. * Binds an effect to the webGL context
  97898. * @param effect defines the effect to bind
  97899. */
  97900. bindSamplers(effect: Effect): void;
  97901. private _activateCurrentTexture;
  97902. /** @hidden */
  97903. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97904. /** @hidden */
  97905. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97906. /**
  97907. * Unbind all textures from the webGL context
  97908. */
  97909. unbindAllTextures(): void;
  97910. /**
  97911. * Sets a texture to the according uniform.
  97912. * @param channel The texture channel
  97913. * @param uniform The uniform to set
  97914. * @param texture The texture to apply
  97915. */
  97916. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97917. private _bindSamplerUniformToChannel;
  97918. private _getTextureWrapMode;
  97919. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97920. /**
  97921. * Sets an array of texture to the webGL context
  97922. * @param channel defines the channel where the texture array must be set
  97923. * @param uniform defines the associated uniform location
  97924. * @param textures defines the array of textures to bind
  97925. */
  97926. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97927. /** @hidden */
  97928. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97929. private _setTextureParameterFloat;
  97930. private _setTextureParameterInteger;
  97931. /**
  97932. * Unbind all vertex attributes from the webGL context
  97933. */
  97934. unbindAllAttributes(): void;
  97935. /**
  97936. * 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
  97937. */
  97938. releaseEffects(): void;
  97939. /**
  97940. * Dispose and release all associated resources
  97941. */
  97942. dispose(): void;
  97943. /**
  97944. * Attach a new callback raised when context lost event is fired
  97945. * @param callback defines the callback to call
  97946. */
  97947. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97948. /**
  97949. * Attach a new callback raised when context restored event is fired
  97950. * @param callback defines the callback to call
  97951. */
  97952. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97953. /**
  97954. * Get the current error code of the webGL context
  97955. * @returns the error code
  97956. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97957. */
  97958. getError(): number;
  97959. private _canRenderToFloatFramebuffer;
  97960. private _canRenderToHalfFloatFramebuffer;
  97961. private _canRenderToFramebuffer;
  97962. /** @hidden */
  97963. _getWebGLTextureType(type: number): number;
  97964. /** @hidden */
  97965. _getInternalFormat(format: number): number;
  97966. /** @hidden */
  97967. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97968. /** @hidden */
  97969. _getRGBAMultiSampleBufferFormat(type: number): number;
  97970. /** @hidden */
  97971. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  97972. /**
  97973. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97974. * @returns true if the engine can be created
  97975. * @ignorenaming
  97976. */
  97977. static isSupported(): boolean;
  97978. /**
  97979. * Find the next highest power of two.
  97980. * @param x Number to start search from.
  97981. * @return Next highest power of two.
  97982. */
  97983. static CeilingPOT(x: number): number;
  97984. /**
  97985. * Find the next lowest power of two.
  97986. * @param x Number to start search from.
  97987. * @return Next lowest power of two.
  97988. */
  97989. static FloorPOT(x: number): number;
  97990. /**
  97991. * Find the nearest power of two.
  97992. * @param x Number to start search from.
  97993. * @return Next nearest power of two.
  97994. */
  97995. static NearestPOT(x: number): number;
  97996. /**
  97997. * Get the closest exponent of two
  97998. * @param value defines the value to approximate
  97999. * @param max defines the maximum value to return
  98000. * @param mode defines how to define the closest value
  98001. * @returns closest exponent of two of the given value
  98002. */
  98003. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98004. /**
  98005. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98006. * @param func - the function to be called
  98007. * @param requester - the object that will request the next frame. Falls back to window.
  98008. * @returns frame number
  98009. */
  98010. static QueueNewFrame(func: () => void, requester?: any): number;
  98011. }
  98012. }
  98013. declare module BABYLON {
  98014. /**
  98015. * Class representing spherical harmonics coefficients to the 3rd degree
  98016. */
  98017. export class SphericalHarmonics {
  98018. /**
  98019. * Defines whether or not the harmonics have been prescaled for rendering.
  98020. */
  98021. preScaled: boolean;
  98022. /**
  98023. * The l0,0 coefficients of the spherical harmonics
  98024. */
  98025. l00: Vector3;
  98026. /**
  98027. * The l1,-1 coefficients of the spherical harmonics
  98028. */
  98029. l1_1: Vector3;
  98030. /**
  98031. * The l1,0 coefficients of the spherical harmonics
  98032. */
  98033. l10: Vector3;
  98034. /**
  98035. * The l1,1 coefficients of the spherical harmonics
  98036. */
  98037. l11: Vector3;
  98038. /**
  98039. * The l2,-2 coefficients of the spherical harmonics
  98040. */
  98041. l2_2: Vector3;
  98042. /**
  98043. * The l2,-1 coefficients of the spherical harmonics
  98044. */
  98045. l2_1: Vector3;
  98046. /**
  98047. * The l2,0 coefficients of the spherical harmonics
  98048. */
  98049. l20: Vector3;
  98050. /**
  98051. * The l2,1 coefficients of the spherical harmonics
  98052. */
  98053. l21: Vector3;
  98054. /**
  98055. * The l2,2 coefficients of the spherical harmonics
  98056. */
  98057. l22: Vector3;
  98058. /**
  98059. * Adds a light to the spherical harmonics
  98060. * @param direction the direction of the light
  98061. * @param color the color of the light
  98062. * @param deltaSolidAngle the delta solid angle of the light
  98063. */
  98064. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98065. /**
  98066. * Scales the spherical harmonics by the given amount
  98067. * @param scale the amount to scale
  98068. */
  98069. scaleInPlace(scale: number): void;
  98070. /**
  98071. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98072. *
  98073. * ```
  98074. * E_lm = A_l * L_lm
  98075. * ```
  98076. *
  98077. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98078. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98079. * the scaling factors are given in equation 9.
  98080. */
  98081. convertIncidentRadianceToIrradiance(): void;
  98082. /**
  98083. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98084. *
  98085. * ```
  98086. * L = (1/pi) * E * rho
  98087. * ```
  98088. *
  98089. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98090. */
  98091. convertIrradianceToLambertianRadiance(): void;
  98092. /**
  98093. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98094. * required operations at run time.
  98095. *
  98096. * This is simply done by scaling back the SH with Ylm constants parameter.
  98097. * The trigonometric part being applied by the shader at run time.
  98098. */
  98099. preScaleForRendering(): void;
  98100. /**
  98101. * Constructs a spherical harmonics from an array.
  98102. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98103. * @returns the spherical harmonics
  98104. */
  98105. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98106. /**
  98107. * Gets the spherical harmonics from polynomial
  98108. * @param polynomial the spherical polynomial
  98109. * @returns the spherical harmonics
  98110. */
  98111. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98112. }
  98113. /**
  98114. * Class representing spherical polynomial coefficients to the 3rd degree
  98115. */
  98116. export class SphericalPolynomial {
  98117. private _harmonics;
  98118. /**
  98119. * The spherical harmonics used to create the polynomials.
  98120. */
  98121. readonly preScaledHarmonics: SphericalHarmonics;
  98122. /**
  98123. * The x coefficients of the spherical polynomial
  98124. */
  98125. x: Vector3;
  98126. /**
  98127. * The y coefficients of the spherical polynomial
  98128. */
  98129. y: Vector3;
  98130. /**
  98131. * The z coefficients of the spherical polynomial
  98132. */
  98133. z: Vector3;
  98134. /**
  98135. * The xx coefficients of the spherical polynomial
  98136. */
  98137. xx: Vector3;
  98138. /**
  98139. * The yy coefficients of the spherical polynomial
  98140. */
  98141. yy: Vector3;
  98142. /**
  98143. * The zz coefficients of the spherical polynomial
  98144. */
  98145. zz: Vector3;
  98146. /**
  98147. * The xy coefficients of the spherical polynomial
  98148. */
  98149. xy: Vector3;
  98150. /**
  98151. * The yz coefficients of the spherical polynomial
  98152. */
  98153. yz: Vector3;
  98154. /**
  98155. * The zx coefficients of the spherical polynomial
  98156. */
  98157. zx: Vector3;
  98158. /**
  98159. * Adds an ambient color to the spherical polynomial
  98160. * @param color the color to add
  98161. */
  98162. addAmbient(color: Color3): void;
  98163. /**
  98164. * Scales the spherical polynomial by the given amount
  98165. * @param scale the amount to scale
  98166. */
  98167. scaleInPlace(scale: number): void;
  98168. /**
  98169. * Gets the spherical polynomial from harmonics
  98170. * @param harmonics the spherical harmonics
  98171. * @returns the spherical polynomial
  98172. */
  98173. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98174. /**
  98175. * Constructs a spherical polynomial from an array.
  98176. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98177. * @returns the spherical polynomial
  98178. */
  98179. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98180. }
  98181. }
  98182. declare module BABYLON {
  98183. /**
  98184. * Defines the source of the internal texture
  98185. */
  98186. export enum InternalTextureSource {
  98187. /**
  98188. * The source of the texture data is unknown
  98189. */
  98190. Unknown = 0,
  98191. /**
  98192. * Texture data comes from an URL
  98193. */
  98194. Url = 1,
  98195. /**
  98196. * Texture data is only used for temporary storage
  98197. */
  98198. Temp = 2,
  98199. /**
  98200. * Texture data comes from raw data (ArrayBuffer)
  98201. */
  98202. Raw = 3,
  98203. /**
  98204. * Texture content is dynamic (video or dynamic texture)
  98205. */
  98206. Dynamic = 4,
  98207. /**
  98208. * Texture content is generated by rendering to it
  98209. */
  98210. RenderTarget = 5,
  98211. /**
  98212. * Texture content is part of a multi render target process
  98213. */
  98214. MultiRenderTarget = 6,
  98215. /**
  98216. * Texture data comes from a cube data file
  98217. */
  98218. Cube = 7,
  98219. /**
  98220. * Texture data comes from a raw cube data
  98221. */
  98222. CubeRaw = 8,
  98223. /**
  98224. * Texture data come from a prefiltered cube data file
  98225. */
  98226. CubePrefiltered = 9,
  98227. /**
  98228. * Texture content is raw 3D data
  98229. */
  98230. Raw3D = 10,
  98231. /**
  98232. * Texture content is raw 2D array data
  98233. */
  98234. Raw2DArray = 11,
  98235. /**
  98236. * Texture content is a depth texture
  98237. */
  98238. Depth = 12,
  98239. /**
  98240. * Texture data comes from a raw cube data encoded with RGBD
  98241. */
  98242. CubeRawRGBD = 13
  98243. }
  98244. /**
  98245. * Class used to store data associated with WebGL texture data for the engine
  98246. * This class should not be used directly
  98247. */
  98248. export class InternalTexture {
  98249. /** @hidden */
  98250. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98251. /**
  98252. * Defines if the texture is ready
  98253. */
  98254. isReady: boolean;
  98255. /**
  98256. * Defines if the texture is a cube texture
  98257. */
  98258. isCube: boolean;
  98259. /**
  98260. * Defines if the texture contains 3D data
  98261. */
  98262. is3D: boolean;
  98263. /**
  98264. * Defines if the texture contains 2D array data
  98265. */
  98266. is2DArray: boolean;
  98267. /**
  98268. * Defines if the texture contains multiview data
  98269. */
  98270. isMultiview: boolean;
  98271. /**
  98272. * Gets the URL used to load this texture
  98273. */
  98274. url: string;
  98275. /**
  98276. * Gets the sampling mode of the texture
  98277. */
  98278. samplingMode: number;
  98279. /**
  98280. * Gets a boolean indicating if the texture needs mipmaps generation
  98281. */
  98282. generateMipMaps: boolean;
  98283. /**
  98284. * Gets the number of samples used by the texture (WebGL2+ only)
  98285. */
  98286. samples: number;
  98287. /**
  98288. * Gets the type of the texture (int, float...)
  98289. */
  98290. type: number;
  98291. /**
  98292. * Gets the format of the texture (RGB, RGBA...)
  98293. */
  98294. format: number;
  98295. /**
  98296. * Observable called when the texture is loaded
  98297. */
  98298. onLoadedObservable: Observable<InternalTexture>;
  98299. /**
  98300. * Gets the width of the texture
  98301. */
  98302. width: number;
  98303. /**
  98304. * Gets the height of the texture
  98305. */
  98306. height: number;
  98307. /**
  98308. * Gets the depth of the texture
  98309. */
  98310. depth: number;
  98311. /**
  98312. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98313. */
  98314. baseWidth: number;
  98315. /**
  98316. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98317. */
  98318. baseHeight: number;
  98319. /**
  98320. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98321. */
  98322. baseDepth: number;
  98323. /**
  98324. * Gets a boolean indicating if the texture is inverted on Y axis
  98325. */
  98326. invertY: boolean;
  98327. /** @hidden */
  98328. _invertVScale: boolean;
  98329. /** @hidden */
  98330. _associatedChannel: number;
  98331. /** @hidden */
  98332. _source: InternalTextureSource;
  98333. /** @hidden */
  98334. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98335. /** @hidden */
  98336. _bufferView: Nullable<ArrayBufferView>;
  98337. /** @hidden */
  98338. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98339. /** @hidden */
  98340. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98341. /** @hidden */
  98342. _size: number;
  98343. /** @hidden */
  98344. _extension: string;
  98345. /** @hidden */
  98346. _files: Nullable<string[]>;
  98347. /** @hidden */
  98348. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98349. /** @hidden */
  98350. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98351. /** @hidden */
  98352. _framebuffer: Nullable<WebGLFramebuffer>;
  98353. /** @hidden */
  98354. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98355. /** @hidden */
  98356. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98357. /** @hidden */
  98358. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98359. /** @hidden */
  98360. _attachments: Nullable<number[]>;
  98361. /** @hidden */
  98362. _cachedCoordinatesMode: Nullable<number>;
  98363. /** @hidden */
  98364. _cachedWrapU: Nullable<number>;
  98365. /** @hidden */
  98366. _cachedWrapV: Nullable<number>;
  98367. /** @hidden */
  98368. _cachedWrapR: Nullable<number>;
  98369. /** @hidden */
  98370. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98371. /** @hidden */
  98372. _isDisabled: boolean;
  98373. /** @hidden */
  98374. _compression: Nullable<string>;
  98375. /** @hidden */
  98376. _generateStencilBuffer: boolean;
  98377. /** @hidden */
  98378. _generateDepthBuffer: boolean;
  98379. /** @hidden */
  98380. _comparisonFunction: number;
  98381. /** @hidden */
  98382. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98383. /** @hidden */
  98384. _lodGenerationScale: number;
  98385. /** @hidden */
  98386. _lodGenerationOffset: number;
  98387. /** @hidden */
  98388. _colorTextureArray: Nullable<WebGLTexture>;
  98389. /** @hidden */
  98390. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98391. /** @hidden */
  98392. _lodTextureHigh: Nullable<BaseTexture>;
  98393. /** @hidden */
  98394. _lodTextureMid: Nullable<BaseTexture>;
  98395. /** @hidden */
  98396. _lodTextureLow: Nullable<BaseTexture>;
  98397. /** @hidden */
  98398. _isRGBD: boolean;
  98399. /** @hidden */
  98400. _linearSpecularLOD: boolean;
  98401. /** @hidden */
  98402. _irradianceTexture: Nullable<BaseTexture>;
  98403. /** @hidden */
  98404. _webGLTexture: Nullable<WebGLTexture>;
  98405. /** @hidden */
  98406. _references: number;
  98407. private _engine;
  98408. /**
  98409. * Gets the Engine the texture belongs to.
  98410. * @returns The babylon engine
  98411. */
  98412. getEngine(): ThinEngine;
  98413. /**
  98414. * Gets the data source type of the texture
  98415. */
  98416. readonly source: InternalTextureSource;
  98417. /**
  98418. * Creates a new InternalTexture
  98419. * @param engine defines the engine to use
  98420. * @param source defines the type of data that will be used
  98421. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98422. */
  98423. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98424. /**
  98425. * Increments the number of references (ie. the number of Texture that point to it)
  98426. */
  98427. incrementReferences(): void;
  98428. /**
  98429. * Change the size of the texture (not the size of the content)
  98430. * @param width defines the new width
  98431. * @param height defines the new height
  98432. * @param depth defines the new depth (1 by default)
  98433. */
  98434. updateSize(width: int, height: int, depth?: int): void;
  98435. /** @hidden */
  98436. _rebuild(): void;
  98437. /** @hidden */
  98438. _swapAndDie(target: InternalTexture): void;
  98439. /**
  98440. * Dispose the current allocated resources
  98441. */
  98442. dispose(): void;
  98443. }
  98444. }
  98445. declare module BABYLON {
  98446. /**
  98447. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98449. */
  98450. export class Analyser {
  98451. /**
  98452. * Gets or sets the smoothing
  98453. * @ignorenaming
  98454. */
  98455. SMOOTHING: number;
  98456. /**
  98457. * Gets or sets the FFT table size
  98458. * @ignorenaming
  98459. */
  98460. FFT_SIZE: number;
  98461. /**
  98462. * Gets or sets the bar graph amplitude
  98463. * @ignorenaming
  98464. */
  98465. BARGRAPHAMPLITUDE: number;
  98466. /**
  98467. * Gets or sets the position of the debug canvas
  98468. * @ignorenaming
  98469. */
  98470. DEBUGCANVASPOS: {
  98471. x: number;
  98472. y: number;
  98473. };
  98474. /**
  98475. * Gets or sets the debug canvas size
  98476. * @ignorenaming
  98477. */
  98478. DEBUGCANVASSIZE: {
  98479. width: number;
  98480. height: number;
  98481. };
  98482. private _byteFreqs;
  98483. private _byteTime;
  98484. private _floatFreqs;
  98485. private _webAudioAnalyser;
  98486. private _debugCanvas;
  98487. private _debugCanvasContext;
  98488. private _scene;
  98489. private _registerFunc;
  98490. private _audioEngine;
  98491. /**
  98492. * Creates a new analyser
  98493. * @param scene defines hosting scene
  98494. */
  98495. constructor(scene: Scene);
  98496. /**
  98497. * Get the number of data values you will have to play with for the visualization
  98498. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98499. * @returns a number
  98500. */
  98501. getFrequencyBinCount(): number;
  98502. /**
  98503. * Gets the current frequency data as a byte array
  98504. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98505. * @returns a Uint8Array
  98506. */
  98507. getByteFrequencyData(): Uint8Array;
  98508. /**
  98509. * Gets the current waveform as a byte array
  98510. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  98511. * @returns a Uint8Array
  98512. */
  98513. getByteTimeDomainData(): Uint8Array;
  98514. /**
  98515. * Gets the current frequency data as a float array
  98516. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98517. * @returns a Float32Array
  98518. */
  98519. getFloatFrequencyData(): Float32Array;
  98520. /**
  98521. * Renders the debug canvas
  98522. */
  98523. drawDebugCanvas(): void;
  98524. /**
  98525. * Stops rendering the debug canvas and removes it
  98526. */
  98527. stopDebugCanvas(): void;
  98528. /**
  98529. * Connects two audio nodes
  98530. * @param inputAudioNode defines first node to connect
  98531. * @param outputAudioNode defines second node to connect
  98532. */
  98533. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  98534. /**
  98535. * Releases all associated resources
  98536. */
  98537. dispose(): void;
  98538. }
  98539. }
  98540. declare module BABYLON {
  98541. /**
  98542. * This represents an audio engine and it is responsible
  98543. * to play, synchronize and analyse sounds throughout the application.
  98544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98545. */
  98546. export interface IAudioEngine extends IDisposable {
  98547. /**
  98548. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98549. */
  98550. readonly canUseWebAudio: boolean;
  98551. /**
  98552. * Gets the current AudioContext if available.
  98553. */
  98554. readonly audioContext: Nullable<AudioContext>;
  98555. /**
  98556. * The master gain node defines the global audio volume of your audio engine.
  98557. */
  98558. readonly masterGain: GainNode;
  98559. /**
  98560. * Gets whether or not mp3 are supported by your browser.
  98561. */
  98562. readonly isMP3supported: boolean;
  98563. /**
  98564. * Gets whether or not ogg are supported by your browser.
  98565. */
  98566. readonly isOGGsupported: boolean;
  98567. /**
  98568. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98569. * @ignoreNaming
  98570. */
  98571. WarnedWebAudioUnsupported: boolean;
  98572. /**
  98573. * Defines if the audio engine relies on a custom unlocked button.
  98574. * In this case, the embedded button will not be displayed.
  98575. */
  98576. useCustomUnlockedButton: boolean;
  98577. /**
  98578. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98579. */
  98580. readonly unlocked: boolean;
  98581. /**
  98582. * Event raised when audio has been unlocked on the browser.
  98583. */
  98584. onAudioUnlockedObservable: Observable<AudioEngine>;
  98585. /**
  98586. * Event raised when audio has been locked on the browser.
  98587. */
  98588. onAudioLockedObservable: Observable<AudioEngine>;
  98589. /**
  98590. * Flags the audio engine in Locked state.
  98591. * This happens due to new browser policies preventing audio to autoplay.
  98592. */
  98593. lock(): void;
  98594. /**
  98595. * Unlocks the audio engine once a user action has been done on the dom.
  98596. * This is helpful to resume play once browser policies have been satisfied.
  98597. */
  98598. unlock(): void;
  98599. }
  98600. /**
  98601. * This represents the default audio engine used in babylon.
  98602. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98604. */
  98605. export class AudioEngine implements IAudioEngine {
  98606. private _audioContext;
  98607. private _audioContextInitialized;
  98608. private _muteButton;
  98609. private _hostElement;
  98610. /**
  98611. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98612. */
  98613. canUseWebAudio: boolean;
  98614. /**
  98615. * The master gain node defines the global audio volume of your audio engine.
  98616. */
  98617. masterGain: GainNode;
  98618. /**
  98619. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98620. * @ignoreNaming
  98621. */
  98622. WarnedWebAudioUnsupported: boolean;
  98623. /**
  98624. * Gets whether or not mp3 are supported by your browser.
  98625. */
  98626. isMP3supported: boolean;
  98627. /**
  98628. * Gets whether or not ogg are supported by your browser.
  98629. */
  98630. isOGGsupported: boolean;
  98631. /**
  98632. * Gets whether audio has been unlocked on the device.
  98633. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98634. * a user interaction has happened.
  98635. */
  98636. unlocked: boolean;
  98637. /**
  98638. * Defines if the audio engine relies on a custom unlocked button.
  98639. * In this case, the embedded button will not be displayed.
  98640. */
  98641. useCustomUnlockedButton: boolean;
  98642. /**
  98643. * Event raised when audio has been unlocked on the browser.
  98644. */
  98645. onAudioUnlockedObservable: Observable<AudioEngine>;
  98646. /**
  98647. * Event raised when audio has been locked on the browser.
  98648. */
  98649. onAudioLockedObservable: Observable<AudioEngine>;
  98650. /**
  98651. * Gets the current AudioContext if available.
  98652. */
  98653. readonly audioContext: Nullable<AudioContext>;
  98654. private _connectedAnalyser;
  98655. /**
  98656. * Instantiates a new audio engine.
  98657. *
  98658. * There should be only one per page as some browsers restrict the number
  98659. * of audio contexts you can create.
  98660. * @param hostElement defines the host element where to display the mute icon if necessary
  98661. */
  98662. constructor(hostElement?: Nullable<HTMLElement>);
  98663. /**
  98664. * Flags the audio engine in Locked state.
  98665. * This happens due to new browser policies preventing audio to autoplay.
  98666. */
  98667. lock(): void;
  98668. /**
  98669. * Unlocks the audio engine once a user action has been done on the dom.
  98670. * This is helpful to resume play once browser policies have been satisfied.
  98671. */
  98672. unlock(): void;
  98673. private _resumeAudioContext;
  98674. private _initializeAudioContext;
  98675. private _tryToRun;
  98676. private _triggerRunningState;
  98677. private _triggerSuspendedState;
  98678. private _displayMuteButton;
  98679. private _moveButtonToTopLeft;
  98680. private _onResize;
  98681. private _hideMuteButton;
  98682. /**
  98683. * Destroy and release the resources associated with the audio ccontext.
  98684. */
  98685. dispose(): void;
  98686. /**
  98687. * Gets the global volume sets on the master gain.
  98688. * @returns the global volume if set or -1 otherwise
  98689. */
  98690. getGlobalVolume(): number;
  98691. /**
  98692. * Sets the global volume of your experience (sets on the master gain).
  98693. * @param newVolume Defines the new global volume of the application
  98694. */
  98695. setGlobalVolume(newVolume: number): void;
  98696. /**
  98697. * Connect the audio engine to an audio analyser allowing some amazing
  98698. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98700. * @param analyser The analyser to connect to the engine
  98701. */
  98702. connectToAnalyser(analyser: Analyser): void;
  98703. }
  98704. }
  98705. declare module BABYLON {
  98706. /**
  98707. * Interface used to present a loading screen while loading a scene
  98708. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98709. */
  98710. export interface ILoadingScreen {
  98711. /**
  98712. * Function called to display the loading screen
  98713. */
  98714. displayLoadingUI: () => void;
  98715. /**
  98716. * Function called to hide the loading screen
  98717. */
  98718. hideLoadingUI: () => void;
  98719. /**
  98720. * Gets or sets the color to use for the background
  98721. */
  98722. loadingUIBackgroundColor: string;
  98723. /**
  98724. * Gets or sets the text to display while loading
  98725. */
  98726. loadingUIText: string;
  98727. }
  98728. /**
  98729. * Class used for the default loading screen
  98730. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98731. */
  98732. export class DefaultLoadingScreen implements ILoadingScreen {
  98733. private _renderingCanvas;
  98734. private _loadingText;
  98735. private _loadingDivBackgroundColor;
  98736. private _loadingDiv;
  98737. private _loadingTextDiv;
  98738. /** Gets or sets the logo url to use for the default loading screen */
  98739. static DefaultLogoUrl: string;
  98740. /** Gets or sets the spinner url to use for the default loading screen */
  98741. static DefaultSpinnerUrl: string;
  98742. /**
  98743. * Creates a new default loading screen
  98744. * @param _renderingCanvas defines the canvas used to render the scene
  98745. * @param _loadingText defines the default text to display
  98746. * @param _loadingDivBackgroundColor defines the default background color
  98747. */
  98748. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98749. /**
  98750. * Function called to display the loading screen
  98751. */
  98752. displayLoadingUI(): void;
  98753. /**
  98754. * Function called to hide the loading screen
  98755. */
  98756. hideLoadingUI(): void;
  98757. /**
  98758. * Gets or sets the text to display while loading
  98759. */
  98760. loadingUIText: string;
  98761. /**
  98762. * Gets or sets the color to use for the background
  98763. */
  98764. loadingUIBackgroundColor: string;
  98765. private _resizeLoadingUI;
  98766. }
  98767. }
  98768. declare module BABYLON {
  98769. /**
  98770. * Interface for any object that can request an animation frame
  98771. */
  98772. export interface ICustomAnimationFrameRequester {
  98773. /**
  98774. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  98775. */
  98776. renderFunction?: Function;
  98777. /**
  98778. * Called to request the next frame to render to
  98779. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  98780. */
  98781. requestAnimationFrame: Function;
  98782. /**
  98783. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  98784. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  98785. */
  98786. requestID?: number;
  98787. }
  98788. }
  98789. declare module BABYLON {
  98790. /**
  98791. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98792. */
  98793. export class PerformanceMonitor {
  98794. private _enabled;
  98795. private _rollingFrameTime;
  98796. private _lastFrameTimeMs;
  98797. /**
  98798. * constructor
  98799. * @param frameSampleSize The number of samples required to saturate the sliding window
  98800. */
  98801. constructor(frameSampleSize?: number);
  98802. /**
  98803. * Samples current frame
  98804. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98805. */
  98806. sampleFrame(timeMs?: number): void;
  98807. /**
  98808. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98809. */
  98810. readonly averageFrameTime: number;
  98811. /**
  98812. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98813. */
  98814. readonly averageFrameTimeVariance: number;
  98815. /**
  98816. * Returns the frame time of the most recent frame
  98817. */
  98818. readonly instantaneousFrameTime: number;
  98819. /**
  98820. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98821. */
  98822. readonly averageFPS: number;
  98823. /**
  98824. * Returns the average framerate in frames per second using the most recent frame time
  98825. */
  98826. readonly instantaneousFPS: number;
  98827. /**
  98828. * Returns true if enough samples have been taken to completely fill the sliding window
  98829. */
  98830. readonly isSaturated: boolean;
  98831. /**
  98832. * Enables contributions to the sliding window sample set
  98833. */
  98834. enable(): void;
  98835. /**
  98836. * Disables contributions to the sliding window sample set
  98837. * Samples will not be interpolated over the disabled period
  98838. */
  98839. disable(): void;
  98840. /**
  98841. * Returns true if sampling is enabled
  98842. */
  98843. readonly isEnabled: boolean;
  98844. /**
  98845. * Resets performance monitor
  98846. */
  98847. reset(): void;
  98848. }
  98849. /**
  98850. * RollingAverage
  98851. *
  98852. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98853. */
  98854. export class RollingAverage {
  98855. /**
  98856. * Current average
  98857. */
  98858. average: number;
  98859. /**
  98860. * Current variance
  98861. */
  98862. variance: number;
  98863. protected _samples: Array<number>;
  98864. protected _sampleCount: number;
  98865. protected _pos: number;
  98866. protected _m2: number;
  98867. /**
  98868. * constructor
  98869. * @param length The number of samples required to saturate the sliding window
  98870. */
  98871. constructor(length: number);
  98872. /**
  98873. * Adds a sample to the sample set
  98874. * @param v The sample value
  98875. */
  98876. add(v: number): void;
  98877. /**
  98878. * Returns previously added values or null if outside of history or outside the sliding window domain
  98879. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98880. * @return Value previously recorded with add() or null if outside of range
  98881. */
  98882. history(i: number): number;
  98883. /**
  98884. * Returns true if enough samples have been taken to completely fill the sliding window
  98885. * @return true if sample-set saturated
  98886. */
  98887. isSaturated(): boolean;
  98888. /**
  98889. * Resets the rolling average (equivalent to 0 samples taken so far)
  98890. */
  98891. reset(): void;
  98892. /**
  98893. * Wraps a value around the sample range boundaries
  98894. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98895. * @return Wrapped position in sample range
  98896. */
  98897. protected _wrapPosition(i: number): number;
  98898. }
  98899. }
  98900. declare module BABYLON {
  98901. /**
  98902. * This class is used to track a performance counter which is number based.
  98903. * The user has access to many properties which give statistics of different nature.
  98904. *
  98905. * The implementer can track two kinds of Performance Counter: time and count.
  98906. * 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.
  98907. * 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.
  98908. */
  98909. export class PerfCounter {
  98910. /**
  98911. * Gets or sets a global boolean to turn on and off all the counters
  98912. */
  98913. static Enabled: boolean;
  98914. /**
  98915. * Returns the smallest value ever
  98916. */
  98917. readonly min: number;
  98918. /**
  98919. * Returns the biggest value ever
  98920. */
  98921. readonly max: number;
  98922. /**
  98923. * Returns the average value since the performance counter is running
  98924. */
  98925. readonly average: number;
  98926. /**
  98927. * Returns the average value of the last second the counter was monitored
  98928. */
  98929. readonly lastSecAverage: number;
  98930. /**
  98931. * Returns the current value
  98932. */
  98933. readonly current: number;
  98934. /**
  98935. * Gets the accumulated total
  98936. */
  98937. readonly total: number;
  98938. /**
  98939. * Gets the total value count
  98940. */
  98941. readonly count: number;
  98942. /**
  98943. * Creates a new counter
  98944. */
  98945. constructor();
  98946. /**
  98947. * Call this method to start monitoring a new frame.
  98948. * 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.
  98949. */
  98950. fetchNewFrame(): void;
  98951. /**
  98952. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98953. * @param newCount the count value to add to the monitored count
  98954. * @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.
  98955. */
  98956. addCount(newCount: number, fetchResult: boolean): void;
  98957. /**
  98958. * Start monitoring this performance counter
  98959. */
  98960. beginMonitoring(): void;
  98961. /**
  98962. * Compute the time lapsed since the previous beginMonitoring() call.
  98963. * @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
  98964. */
  98965. endMonitoring(newFrame?: boolean): void;
  98966. private _fetchResult;
  98967. private _startMonitoringTime;
  98968. private _min;
  98969. private _max;
  98970. private _average;
  98971. private _current;
  98972. private _totalValueCount;
  98973. private _totalAccumulated;
  98974. private _lastSecAverage;
  98975. private _lastSecAccumulated;
  98976. private _lastSecTime;
  98977. private _lastSecValueCount;
  98978. }
  98979. }
  98980. declare module BABYLON {
  98981. /**
  98982. * Defines the interface used by display changed events
  98983. */
  98984. export interface IDisplayChangedEventArgs {
  98985. /** Gets the vrDisplay object (if any) */
  98986. vrDisplay: Nullable<any>;
  98987. /** Gets a boolean indicating if webVR is supported */
  98988. vrSupported: boolean;
  98989. }
  98990. /**
  98991. * Defines the interface used by objects containing a viewport (like a camera)
  98992. */
  98993. interface IViewportOwnerLike {
  98994. /**
  98995. * Gets or sets the viewport
  98996. */
  98997. viewport: IViewportLike;
  98998. }
  98999. /**
  99000. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99001. */
  99002. export class Engine extends ThinEngine {
  99003. /** Defines that alpha blending is disabled */
  99004. static readonly ALPHA_DISABLE: number;
  99005. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99006. static readonly ALPHA_ADD: number;
  99007. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99008. static readonly ALPHA_COMBINE: number;
  99009. /** Defines that alpha blending to DEST - SRC * DEST */
  99010. static readonly ALPHA_SUBTRACT: number;
  99011. /** Defines that alpha blending to SRC * DEST */
  99012. static readonly ALPHA_MULTIPLY: number;
  99013. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99014. static readonly ALPHA_MAXIMIZED: number;
  99015. /** Defines that alpha blending to SRC + DEST */
  99016. static readonly ALPHA_ONEONE: number;
  99017. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99018. static readonly ALPHA_PREMULTIPLIED: number;
  99019. /**
  99020. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99021. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99022. */
  99023. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99024. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99025. static readonly ALPHA_INTERPOLATE: number;
  99026. /**
  99027. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99028. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99029. */
  99030. static readonly ALPHA_SCREENMODE: number;
  99031. /** Defines that the ressource is not delayed*/
  99032. static readonly DELAYLOADSTATE_NONE: number;
  99033. /** Defines that the ressource was successfully delay loaded */
  99034. static readonly DELAYLOADSTATE_LOADED: number;
  99035. /** Defines that the ressource is currently delay loading */
  99036. static readonly DELAYLOADSTATE_LOADING: number;
  99037. /** Defines that the ressource is delayed and has not started loading */
  99038. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99039. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99040. static readonly NEVER: number;
  99041. /** 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 */
  99042. static readonly ALWAYS: number;
  99043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99044. static readonly LESS: number;
  99045. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99046. static readonly EQUAL: number;
  99047. /** 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 */
  99048. static readonly LEQUAL: number;
  99049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99050. static readonly GREATER: number;
  99051. /** 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 */
  99052. static readonly GEQUAL: number;
  99053. /** 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 */
  99054. static readonly NOTEQUAL: number;
  99055. /** Passed to stencilOperation to specify that stencil value must be kept */
  99056. static readonly KEEP: number;
  99057. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99058. static readonly REPLACE: number;
  99059. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99060. static readonly INCR: number;
  99061. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99062. static readonly DECR: number;
  99063. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99064. static readonly INVERT: number;
  99065. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99066. static readonly INCR_WRAP: number;
  99067. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99068. static readonly DECR_WRAP: number;
  99069. /** Texture is not repeating outside of 0..1 UVs */
  99070. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99071. /** Texture is repeating outside of 0..1 UVs */
  99072. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99073. /** Texture is repeating and mirrored */
  99074. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99075. /** ALPHA */
  99076. static readonly TEXTUREFORMAT_ALPHA: number;
  99077. /** LUMINANCE */
  99078. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99079. /** LUMINANCE_ALPHA */
  99080. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99081. /** RGB */
  99082. static readonly TEXTUREFORMAT_RGB: number;
  99083. /** RGBA */
  99084. static readonly TEXTUREFORMAT_RGBA: number;
  99085. /** RED */
  99086. static readonly TEXTUREFORMAT_RED: number;
  99087. /** RED (2nd reference) */
  99088. static readonly TEXTUREFORMAT_R: number;
  99089. /** RG */
  99090. static readonly TEXTUREFORMAT_RG: number;
  99091. /** RED_INTEGER */
  99092. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99093. /** RED_INTEGER (2nd reference) */
  99094. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99095. /** RG_INTEGER */
  99096. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99097. /** RGB_INTEGER */
  99098. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99099. /** RGBA_INTEGER */
  99100. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99101. /** UNSIGNED_BYTE */
  99102. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99103. /** UNSIGNED_BYTE (2nd reference) */
  99104. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99105. /** FLOAT */
  99106. static readonly TEXTURETYPE_FLOAT: number;
  99107. /** HALF_FLOAT */
  99108. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99109. /** BYTE */
  99110. static readonly TEXTURETYPE_BYTE: number;
  99111. /** SHORT */
  99112. static readonly TEXTURETYPE_SHORT: number;
  99113. /** UNSIGNED_SHORT */
  99114. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99115. /** INT */
  99116. static readonly TEXTURETYPE_INT: number;
  99117. /** UNSIGNED_INT */
  99118. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99119. /** UNSIGNED_SHORT_4_4_4_4 */
  99120. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99121. /** UNSIGNED_SHORT_5_5_5_1 */
  99122. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99123. /** UNSIGNED_SHORT_5_6_5 */
  99124. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99125. /** UNSIGNED_INT_2_10_10_10_REV */
  99126. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99127. /** UNSIGNED_INT_24_8 */
  99128. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99129. /** UNSIGNED_INT_10F_11F_11F_REV */
  99130. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99131. /** UNSIGNED_INT_5_9_9_9_REV */
  99132. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99133. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99134. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99135. /** nearest is mag = nearest and min = nearest and mip = linear */
  99136. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99137. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99138. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99139. /** Trilinear is mag = linear and min = linear and mip = linear */
  99140. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99141. /** nearest is mag = nearest and min = nearest and mip = linear */
  99142. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99143. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99144. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99145. /** Trilinear is mag = linear and min = linear and mip = linear */
  99146. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99147. /** mag = nearest and min = nearest and mip = nearest */
  99148. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99149. /** mag = nearest and min = linear and mip = nearest */
  99150. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99151. /** mag = nearest and min = linear and mip = linear */
  99152. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99153. /** mag = nearest and min = linear and mip = none */
  99154. static readonly TEXTURE_NEAREST_LINEAR: number;
  99155. /** mag = nearest and min = nearest and mip = none */
  99156. static readonly TEXTURE_NEAREST_NEAREST: number;
  99157. /** mag = linear and min = nearest and mip = nearest */
  99158. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99159. /** mag = linear and min = nearest and mip = linear */
  99160. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99161. /** mag = linear and min = linear and mip = none */
  99162. static readonly TEXTURE_LINEAR_LINEAR: number;
  99163. /** mag = linear and min = nearest and mip = none */
  99164. static readonly TEXTURE_LINEAR_NEAREST: number;
  99165. /** Explicit coordinates mode */
  99166. static readonly TEXTURE_EXPLICIT_MODE: number;
  99167. /** Spherical coordinates mode */
  99168. static readonly TEXTURE_SPHERICAL_MODE: number;
  99169. /** Planar coordinates mode */
  99170. static readonly TEXTURE_PLANAR_MODE: number;
  99171. /** Cubic coordinates mode */
  99172. static readonly TEXTURE_CUBIC_MODE: number;
  99173. /** Projection coordinates mode */
  99174. static readonly TEXTURE_PROJECTION_MODE: number;
  99175. /** Skybox coordinates mode */
  99176. static readonly TEXTURE_SKYBOX_MODE: number;
  99177. /** Inverse Cubic coordinates mode */
  99178. static readonly TEXTURE_INVCUBIC_MODE: number;
  99179. /** Equirectangular coordinates mode */
  99180. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99181. /** Equirectangular Fixed coordinates mode */
  99182. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99183. /** Equirectangular Fixed Mirrored coordinates mode */
  99184. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99185. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99186. static readonly SCALEMODE_FLOOR: number;
  99187. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99188. static readonly SCALEMODE_NEAREST: number;
  99189. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99190. static readonly SCALEMODE_CEILING: number;
  99191. /**
  99192. * Returns the current npm package of the sdk
  99193. */
  99194. static readonly NpmPackage: string;
  99195. /**
  99196. * Returns the current version of the framework
  99197. */
  99198. static readonly Version: string;
  99199. /** Gets the list of created engines */
  99200. static readonly Instances: Engine[];
  99201. /**
  99202. * Gets the latest created engine
  99203. */
  99204. static readonly LastCreatedEngine: Nullable<Engine>;
  99205. /**
  99206. * Gets the latest created scene
  99207. */
  99208. static readonly LastCreatedScene: Nullable<Scene>;
  99209. /**
  99210. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99211. * @param flag defines which part of the materials must be marked as dirty
  99212. * @param predicate defines a predicate used to filter which materials should be affected
  99213. */
  99214. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99215. /**
  99216. * Method called to create the default loading screen.
  99217. * This can be overriden in your own app.
  99218. * @param canvas The rendering canvas element
  99219. * @returns The loading screen
  99220. */
  99221. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99222. /**
  99223. * Method called to create the default rescale post process on each engine.
  99224. */
  99225. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99226. /**
  99227. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99228. **/
  99229. enableOfflineSupport: boolean;
  99230. /**
  99231. * 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)
  99232. **/
  99233. disableManifestCheck: boolean;
  99234. /**
  99235. * Gets the list of created scenes
  99236. */
  99237. scenes: Scene[];
  99238. /**
  99239. * Event raised when a new scene is created
  99240. */
  99241. onNewSceneAddedObservable: Observable<Scene>;
  99242. /**
  99243. * Gets the list of created postprocesses
  99244. */
  99245. postProcesses: PostProcess[];
  99246. /**
  99247. * Gets a boolean indicating if the pointer is currently locked
  99248. */
  99249. isPointerLock: boolean;
  99250. /**
  99251. * Observable event triggered each time the rendering canvas is resized
  99252. */
  99253. onResizeObservable: Observable<Engine>;
  99254. /**
  99255. * Observable event triggered each time the canvas loses focus
  99256. */
  99257. onCanvasBlurObservable: Observable<Engine>;
  99258. /**
  99259. * Observable event triggered each time the canvas gains focus
  99260. */
  99261. onCanvasFocusObservable: Observable<Engine>;
  99262. /**
  99263. * Observable event triggered each time the canvas receives pointerout event
  99264. */
  99265. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99266. /**
  99267. * Observable raised when the engine begins a new frame
  99268. */
  99269. onBeginFrameObservable: Observable<Engine>;
  99270. /**
  99271. * If set, will be used to request the next animation frame for the render loop
  99272. */
  99273. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99274. /**
  99275. * Observable raised when the engine ends the current frame
  99276. */
  99277. onEndFrameObservable: Observable<Engine>;
  99278. /**
  99279. * Observable raised when the engine is about to compile a shader
  99280. */
  99281. onBeforeShaderCompilationObservable: Observable<Engine>;
  99282. /**
  99283. * Observable raised when the engine has jsut compiled a shader
  99284. */
  99285. onAfterShaderCompilationObservable: Observable<Engine>;
  99286. /**
  99287. * Gets the audio engine
  99288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99289. * @ignorenaming
  99290. */
  99291. static audioEngine: IAudioEngine;
  99292. /**
  99293. * Default AudioEngine factory responsible of creating the Audio Engine.
  99294. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99295. */
  99296. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99297. /**
  99298. * Default offline support factory responsible of creating a tool used to store data locally.
  99299. * By default, this will create a Database object if the workload has been embedded.
  99300. */
  99301. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99302. private _loadingScreen;
  99303. private _pointerLockRequested;
  99304. private _dummyFramebuffer;
  99305. private _rescalePostProcess;
  99306. /** @hidden */
  99307. protected _alphaMode: number;
  99308. /** @hidden */
  99309. protected _alphaEquation: number;
  99310. private _deterministicLockstep;
  99311. private _lockstepMaxSteps;
  99312. protected readonly _supportsHardwareTextureRescaling: boolean;
  99313. private _fps;
  99314. private _deltaTime;
  99315. /** @hidden */
  99316. _drawCalls: PerfCounter;
  99317. /**
  99318. * Turn this value on if you want to pause FPS computation when in background
  99319. */
  99320. disablePerformanceMonitorInBackground: boolean;
  99321. private _performanceMonitor;
  99322. /**
  99323. * Gets the performance monitor attached to this engine
  99324. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99325. */
  99326. readonly performanceMonitor: PerformanceMonitor;
  99327. private _onFocus;
  99328. private _onBlur;
  99329. private _onCanvasPointerOut;
  99330. private _onCanvasBlur;
  99331. private _onCanvasFocus;
  99332. private _onFullscreenChange;
  99333. private _onPointerLockChange;
  99334. /**
  99335. * Gets the HTML element used to attach event listeners
  99336. * @returns a HTML element
  99337. */
  99338. getInputElement(): Nullable<HTMLElement>;
  99339. /**
  99340. * Creates a new engine
  99341. * @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
  99342. * @param antialias defines enable antialiasing (default: false)
  99343. * @param options defines further options to be sent to the getContext() function
  99344. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99345. */
  99346. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99347. /**
  99348. * Gets current aspect ratio
  99349. * @param viewportOwner defines the camera to use to get the aspect ratio
  99350. * @param useScreen defines if screen size must be used (or the current render target if any)
  99351. * @returns a number defining the aspect ratio
  99352. */
  99353. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99354. /**
  99355. * Gets current screen aspect ratio
  99356. * @returns a number defining the aspect ratio
  99357. */
  99358. getScreenAspectRatio(): number;
  99359. /**
  99360. * Gets host document
  99361. * @returns the host document object
  99362. */
  99363. getHostDocument(): Document;
  99364. /**
  99365. * Gets the client rect of the HTML canvas attached with the current webGL context
  99366. * @returns a client rectanglee
  99367. */
  99368. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99369. /**
  99370. * Gets the client rect of the HTML element used for events
  99371. * @returns a client rectanglee
  99372. */
  99373. getInputElementClientRect(): Nullable<ClientRect>;
  99374. /**
  99375. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99376. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99377. * @returns true if engine is in deterministic lock step mode
  99378. */
  99379. isDeterministicLockStep(): boolean;
  99380. /**
  99381. * Gets the max steps when engine is running in deterministic lock step
  99382. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99383. * @returns the max steps
  99384. */
  99385. getLockstepMaxSteps(): number;
  99386. /**
  99387. * Force the mipmap generation for the given render target texture
  99388. * @param texture defines the render target texture to use
  99389. */
  99390. generateMipMapsForCubemap(texture: InternalTexture): void;
  99391. /** States */
  99392. /**
  99393. * Set various states to the webGL context
  99394. * @param culling defines backface culling state
  99395. * @param zOffset defines the value to apply to zOffset (0 by default)
  99396. * @param force defines if states must be applied even if cache is up to date
  99397. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99398. */
  99399. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99400. /**
  99401. * Set the z offset to apply to current rendering
  99402. * @param value defines the offset to apply
  99403. */
  99404. setZOffset(value: number): void;
  99405. /**
  99406. * Gets the current value of the zOffset
  99407. * @returns the current zOffset state
  99408. */
  99409. getZOffset(): number;
  99410. /**
  99411. * Enable or disable depth buffering
  99412. * @param enable defines the state to set
  99413. */
  99414. setDepthBuffer(enable: boolean): void;
  99415. /**
  99416. * Gets a boolean indicating if depth writing is enabled
  99417. * @returns the current depth writing state
  99418. */
  99419. getDepthWrite(): boolean;
  99420. /**
  99421. * Enable or disable depth writing
  99422. * @param enable defines the state to set
  99423. */
  99424. setDepthWrite(enable: boolean): void;
  99425. /**
  99426. * Enable or disable color writing
  99427. * @param enable defines the state to set
  99428. */
  99429. setColorWrite(enable: boolean): void;
  99430. /**
  99431. * Gets a boolean indicating if color writing is enabled
  99432. * @returns the current color writing state
  99433. */
  99434. getColorWrite(): boolean;
  99435. /**
  99436. * Sets alpha constants used by some alpha blending modes
  99437. * @param r defines the red component
  99438. * @param g defines the green component
  99439. * @param b defines the blue component
  99440. * @param a defines the alpha component
  99441. */
  99442. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99443. /**
  99444. * Sets the current alpha mode
  99445. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99446. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99447. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99448. */
  99449. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99450. /**
  99451. * Gets the current alpha mode
  99452. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99453. * @returns the current alpha mode
  99454. */
  99455. getAlphaMode(): number;
  99456. /**
  99457. * Sets the current alpha equation
  99458. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99459. */
  99460. setAlphaEquation(equation: number): void;
  99461. /**
  99462. * Gets the current alpha equation.
  99463. * @returns the current alpha equation
  99464. */
  99465. getAlphaEquation(): number;
  99466. /**
  99467. * Gets a boolean indicating if stencil buffer is enabled
  99468. * @returns the current stencil buffer state
  99469. */
  99470. getStencilBuffer(): boolean;
  99471. /**
  99472. * Enable or disable the stencil buffer
  99473. * @param enable defines if the stencil buffer must be enabled or disabled
  99474. */
  99475. setStencilBuffer(enable: boolean): void;
  99476. /**
  99477. * Gets the current stencil mask
  99478. * @returns a number defining the new stencil mask to use
  99479. */
  99480. getStencilMask(): number;
  99481. /**
  99482. * Sets the current stencil mask
  99483. * @param mask defines the new stencil mask to use
  99484. */
  99485. setStencilMask(mask: number): void;
  99486. /**
  99487. * Gets the current stencil function
  99488. * @returns a number defining the stencil function to use
  99489. */
  99490. getStencilFunction(): number;
  99491. /**
  99492. * Gets the current stencil reference value
  99493. * @returns a number defining the stencil reference value to use
  99494. */
  99495. getStencilFunctionReference(): number;
  99496. /**
  99497. * Gets the current stencil mask
  99498. * @returns a number defining the stencil mask to use
  99499. */
  99500. getStencilFunctionMask(): number;
  99501. /**
  99502. * Sets the current stencil function
  99503. * @param stencilFunc defines the new stencil function to use
  99504. */
  99505. setStencilFunction(stencilFunc: number): void;
  99506. /**
  99507. * Sets the current stencil reference
  99508. * @param reference defines the new stencil reference to use
  99509. */
  99510. setStencilFunctionReference(reference: number): void;
  99511. /**
  99512. * Sets the current stencil mask
  99513. * @param mask defines the new stencil mask to use
  99514. */
  99515. setStencilFunctionMask(mask: number): void;
  99516. /**
  99517. * Gets the current stencil operation when stencil fails
  99518. * @returns a number defining stencil operation to use when stencil fails
  99519. */
  99520. getStencilOperationFail(): number;
  99521. /**
  99522. * Gets the current stencil operation when depth fails
  99523. * @returns a number defining stencil operation to use when depth fails
  99524. */
  99525. getStencilOperationDepthFail(): number;
  99526. /**
  99527. * Gets the current stencil operation when stencil passes
  99528. * @returns a number defining stencil operation to use when stencil passes
  99529. */
  99530. getStencilOperationPass(): number;
  99531. /**
  99532. * Sets the stencil operation to use when stencil fails
  99533. * @param operation defines the stencil operation to use when stencil fails
  99534. */
  99535. setStencilOperationFail(operation: number): void;
  99536. /**
  99537. * Sets the stencil operation to use when depth fails
  99538. * @param operation defines the stencil operation to use when depth fails
  99539. */
  99540. setStencilOperationDepthFail(operation: number): void;
  99541. /**
  99542. * Sets the stencil operation to use when stencil passes
  99543. * @param operation defines the stencil operation to use when stencil passes
  99544. */
  99545. setStencilOperationPass(operation: number): void;
  99546. /**
  99547. * Sets a boolean indicating if the dithering state is enabled or disabled
  99548. * @param value defines the dithering state
  99549. */
  99550. setDitheringState(value: boolean): void;
  99551. /**
  99552. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99553. * @param value defines the rasterizer state
  99554. */
  99555. setRasterizerState(value: boolean): void;
  99556. /**
  99557. * Gets the current depth function
  99558. * @returns a number defining the depth function
  99559. */
  99560. getDepthFunction(): Nullable<number>;
  99561. /**
  99562. * Sets the current depth function
  99563. * @param depthFunc defines the function to use
  99564. */
  99565. setDepthFunction(depthFunc: number): void;
  99566. /**
  99567. * Sets the current depth function to GREATER
  99568. */
  99569. setDepthFunctionToGreater(): void;
  99570. /**
  99571. * Sets the current depth function to GEQUAL
  99572. */
  99573. setDepthFunctionToGreaterOrEqual(): void;
  99574. /**
  99575. * Sets the current depth function to LESS
  99576. */
  99577. setDepthFunctionToLess(): void;
  99578. /**
  99579. * Sets the current depth function to LEQUAL
  99580. */
  99581. setDepthFunctionToLessOrEqual(): void;
  99582. private _cachedStencilBuffer;
  99583. private _cachedStencilFunction;
  99584. private _cachedStencilMask;
  99585. private _cachedStencilOperationPass;
  99586. private _cachedStencilOperationFail;
  99587. private _cachedStencilOperationDepthFail;
  99588. private _cachedStencilReference;
  99589. /**
  99590. * Caches the the state of the stencil buffer
  99591. */
  99592. cacheStencilState(): void;
  99593. /**
  99594. * Restores the state of the stencil buffer
  99595. */
  99596. restoreStencilState(): void;
  99597. /**
  99598. * Directly set the WebGL Viewport
  99599. * @param x defines the x coordinate of the viewport (in screen space)
  99600. * @param y defines the y coordinate of the viewport (in screen space)
  99601. * @param width defines the width of the viewport (in screen space)
  99602. * @param height defines the height of the viewport (in screen space)
  99603. * @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
  99604. */
  99605. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99606. /**
  99607. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99608. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99609. * @param y defines the y-coordinate of the corner of the clear rectangle
  99610. * @param width defines the width of the clear rectangle
  99611. * @param height defines the height of the clear rectangle
  99612. * @param clearColor defines the clear color
  99613. */
  99614. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99615. /**
  99616. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99617. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99618. * @param y defines the y-coordinate of the corner of the clear rectangle
  99619. * @param width defines the width of the clear rectangle
  99620. * @param height defines the height of the clear rectangle
  99621. */
  99622. enableScissor(x: number, y: number, width: number, height: number): void;
  99623. /**
  99624. * Disable previously set scissor test rectangle
  99625. */
  99626. disableScissor(): void;
  99627. protected _reportDrawCall(): void;
  99628. /**
  99629. * Initializes a webVR display and starts listening to display change events
  99630. * The onVRDisplayChangedObservable will be notified upon these changes
  99631. * @returns The onVRDisplayChangedObservable
  99632. */
  99633. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99634. /** @hidden */
  99635. _prepareVRComponent(): void;
  99636. /** @hidden */
  99637. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99638. /** @hidden */
  99639. _submitVRFrame(): void;
  99640. /**
  99641. * Call this function to leave webVR mode
  99642. * Will do nothing if webVR is not supported or if there is no webVR device
  99643. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99644. */
  99645. disableVR(): void;
  99646. /**
  99647. * Gets a boolean indicating that the system is in VR mode and is presenting
  99648. * @returns true if VR mode is engaged
  99649. */
  99650. isVRPresenting(): boolean;
  99651. /** @hidden */
  99652. _requestVRFrame(): void;
  99653. /** @hidden */
  99654. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99655. /**
  99656. * Gets the source code of the vertex shader associated with a specific webGL program
  99657. * @param program defines the program to use
  99658. * @returns a string containing the source code of the vertex shader associated with the program
  99659. */
  99660. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99661. /**
  99662. * Gets the source code of the fragment shader associated with a specific webGL program
  99663. * @param program defines the program to use
  99664. * @returns a string containing the source code of the fragment shader associated with the program
  99665. */
  99666. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99667. /**
  99668. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99669. * @param x defines the x coordinate of the rectangle where pixels must be read
  99670. * @param y defines the y coordinate of the rectangle where pixels must be read
  99671. * @param width defines the width of the rectangle where pixels must be read
  99672. * @param height defines the height of the rectangle where pixels must be read
  99673. * @returns a Uint8Array containing RGBA colors
  99674. */
  99675. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99676. /**
  99677. * Sets a depth stencil texture from a render target to the according uniform.
  99678. * @param channel The texture channel
  99679. * @param uniform The uniform to set
  99680. * @param texture The render target texture containing the depth stencil texture to apply
  99681. */
  99682. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99683. /**
  99684. * Sets a texture to the webGL context from a postprocess
  99685. * @param channel defines the channel to use
  99686. * @param postProcess defines the source postprocess
  99687. */
  99688. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99689. /**
  99690. * Binds the output of the passed in post process to the texture channel specified
  99691. * @param channel The channel the texture should be bound to
  99692. * @param postProcess The post process which's output should be bound
  99693. */
  99694. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99695. /** @hidden */
  99696. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99697. protected _rebuildBuffers(): void;
  99698. /** @hidden */
  99699. _renderFrame(): void;
  99700. _renderLoop(): void;
  99701. /** @hidden */
  99702. _renderViews(): boolean;
  99703. /**
  99704. * Toggle full screen mode
  99705. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99706. */
  99707. switchFullscreen(requestPointerLock: boolean): void;
  99708. /**
  99709. * Enters full screen mode
  99710. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99711. */
  99712. enterFullscreen(requestPointerLock: boolean): void;
  99713. /**
  99714. * Exits full screen mode
  99715. */
  99716. exitFullscreen(): void;
  99717. /**
  99718. * Enters Pointerlock mode
  99719. */
  99720. enterPointerlock(): void;
  99721. /**
  99722. * Exits Pointerlock mode
  99723. */
  99724. exitPointerlock(): void;
  99725. /**
  99726. * Begin a new frame
  99727. */
  99728. beginFrame(): void;
  99729. /**
  99730. * Enf the current frame
  99731. */
  99732. endFrame(): void;
  99733. resize(): void;
  99734. /**
  99735. * Set the compressed texture format to use, based on the formats you have, and the formats
  99736. * supported by the hardware / browser.
  99737. *
  99738. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99739. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99740. * to API arguments needed to compressed textures. This puts the burden on the container
  99741. * generator to house the arcane code for determining these for current & future formats.
  99742. *
  99743. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99744. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99745. *
  99746. * Note: The result of this call is not taken into account when a texture is base64.
  99747. *
  99748. * @param formatsAvailable defines the list of those format families you have created
  99749. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99750. *
  99751. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  99752. * @returns The extension selected.
  99753. */
  99754. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  99755. /**
  99756. * Force a specific size of the canvas
  99757. * @param width defines the new canvas' width
  99758. * @param height defines the new canvas' height
  99759. */
  99760. setSize(width: number, height: number): void;
  99761. /**
  99762. * Updates a dynamic vertex buffer.
  99763. * @param vertexBuffer the vertex buffer to update
  99764. * @param data the data used to update the vertex buffer
  99765. * @param byteOffset the byte offset of the data
  99766. * @param byteLength the byte length of the data
  99767. */
  99768. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  99769. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99770. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99771. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99772. _releaseTexture(texture: InternalTexture): void;
  99773. /**
  99774. * @hidden
  99775. * Rescales a texture
  99776. * @param source input texutre
  99777. * @param destination destination texture
  99778. * @param scene scene to use to render the resize
  99779. * @param internalFormat format to use when resizing
  99780. * @param onComplete callback to be called when resize has completed
  99781. */
  99782. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  99783. /**
  99784. * Gets the current framerate
  99785. * @returns a number representing the framerate
  99786. */
  99787. getFps(): number;
  99788. /**
  99789. * Gets the time spent between current and previous frame
  99790. * @returns a number representing the delta time in ms
  99791. */
  99792. getDeltaTime(): number;
  99793. private _measureFps;
  99794. /** @hidden */
  99795. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  99796. /**
  99797. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  99798. * @param renderTarget The render target to set the frame buffer for
  99799. */
  99800. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  99801. /**
  99802. * Update a dynamic index buffer
  99803. * @param indexBuffer defines the target index buffer
  99804. * @param indices defines the data to update
  99805. * @param offset defines the offset in the target index buffer where update should start
  99806. */
  99807. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99808. /**
  99809. * Updates the sample count of a render target texture
  99810. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99811. * @param texture defines the texture to update
  99812. * @param samples defines the sample count to set
  99813. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99814. */
  99815. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  99816. /**
  99817. * Updates a depth texture Comparison Mode and Function.
  99818. * If the comparison Function is equal to 0, the mode will be set to none.
  99819. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  99820. * @param texture The texture to set the comparison function for
  99821. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  99822. */
  99823. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  99824. /**
  99825. * Creates a webGL buffer to use with instanciation
  99826. * @param capacity defines the size of the buffer
  99827. * @returns the webGL buffer
  99828. */
  99829. createInstancesBuffer(capacity: number): DataBuffer;
  99830. /**
  99831. * Delete a webGL buffer used with instanciation
  99832. * @param buffer defines the webGL buffer to delete
  99833. */
  99834. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  99835. /** @hidden */
  99836. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  99837. dispose(): void;
  99838. private _disableTouchAction;
  99839. /**
  99840. * Display the loading screen
  99841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99842. */
  99843. displayLoadingUI(): void;
  99844. /**
  99845. * Hide the loading screen
  99846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99847. */
  99848. hideLoadingUI(): void;
  99849. /**
  99850. * Gets the current loading screen object
  99851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99852. */
  99853. /**
  99854. * Sets the current loading screen object
  99855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99856. */
  99857. loadingScreen: ILoadingScreen;
  99858. /**
  99859. * Sets the current loading screen text
  99860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99861. */
  99862. loadingUIText: string;
  99863. /**
  99864. * Sets the current loading screen background color
  99865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99866. */
  99867. loadingUIBackgroundColor: string;
  99868. /** Pointerlock and fullscreen */
  99869. /**
  99870. * Ask the browser to promote the current element to pointerlock mode
  99871. * @param element defines the DOM element to promote
  99872. */
  99873. static _RequestPointerlock(element: HTMLElement): void;
  99874. /**
  99875. * Asks the browser to exit pointerlock mode
  99876. */
  99877. static _ExitPointerlock(): void;
  99878. /**
  99879. * Ask the browser to promote the current element to fullscreen rendering mode
  99880. * @param element defines the DOM element to promote
  99881. */
  99882. static _RequestFullscreen(element: HTMLElement): void;
  99883. /**
  99884. * Asks the browser to exit fullscreen mode
  99885. */
  99886. static _ExitFullscreen(): void;
  99887. }
  99888. }
  99889. declare module BABYLON {
  99890. /**
  99891. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99892. * during the life time of the application.
  99893. */
  99894. export class EngineStore {
  99895. /** Gets the list of created engines */
  99896. static Instances: Engine[];
  99897. /** @hidden */
  99898. static _LastCreatedScene: Nullable<Scene>;
  99899. /**
  99900. * Gets the latest created engine
  99901. */
  99902. static readonly LastCreatedEngine: Nullable<Engine>;
  99903. /**
  99904. * Gets the latest created scene
  99905. */
  99906. static readonly LastCreatedScene: Nullable<Scene>;
  99907. /**
  99908. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99909. * @ignorenaming
  99910. */
  99911. static UseFallbackTexture: boolean;
  99912. /**
  99913. * Texture content used if a texture cannot loaded
  99914. * @ignorenaming
  99915. */
  99916. static FallbackTexture: string;
  99917. }
  99918. }
  99919. declare module BABYLON {
  99920. /**
  99921. * Helper class that provides a small promise polyfill
  99922. */
  99923. export class PromisePolyfill {
  99924. /**
  99925. * Static function used to check if the polyfill is required
  99926. * If this is the case then the function will inject the polyfill to window.Promise
  99927. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99928. */
  99929. static Apply(force?: boolean): void;
  99930. }
  99931. }
  99932. declare module BABYLON {
  99933. /**
  99934. * Interface for screenshot methods with describe argument called `size` as object with options
  99935. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99936. */
  99937. export interface IScreenshotSize {
  99938. /**
  99939. * number in pixels for canvas height
  99940. */
  99941. height?: number;
  99942. /**
  99943. * multiplier allowing render at a higher or lower resolution
  99944. * If value is defined then height and width will be ignored and taken from camera
  99945. */
  99946. precision?: number;
  99947. /**
  99948. * number in pixels for canvas width
  99949. */
  99950. width?: number;
  99951. }
  99952. }
  99953. declare module BABYLON {
  99954. interface IColor4Like {
  99955. r: float;
  99956. g: float;
  99957. b: float;
  99958. a: float;
  99959. }
  99960. /**
  99961. * Class containing a set of static utilities functions
  99962. */
  99963. export class Tools {
  99964. /**
  99965. * Gets or sets the base URL to use to load assets
  99966. */
  99967. static BaseUrl: string;
  99968. /**
  99969. * Enable/Disable Custom HTTP Request Headers globally.
  99970. * default = false
  99971. * @see CustomRequestHeaders
  99972. */
  99973. static UseCustomRequestHeaders: boolean;
  99974. /**
  99975. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99976. * i.e. when loading files, where the server/service expects an Authorization header
  99977. */
  99978. static CustomRequestHeaders: {
  99979. [key: string]: string;
  99980. };
  99981. /**
  99982. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99983. */
  99984. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99985. /**
  99986. * Default behaviour for cors in the application.
  99987. * It can be a string if the expected behavior is identical in the entire app.
  99988. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99989. */
  99990. static CorsBehavior: string | ((url: string | string[]) => string);
  99991. /**
  99992. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99993. * @ignorenaming
  99994. */
  99995. static UseFallbackTexture: boolean;
  99996. /**
  99997. * Use this object to register external classes like custom textures or material
  99998. * to allow the laoders to instantiate them
  99999. */
  100000. static RegisteredExternalClasses: {
  100001. [key: string]: Object;
  100002. };
  100003. /**
  100004. * Texture content used if a texture cannot loaded
  100005. * @ignorenaming
  100006. */
  100007. static fallbackTexture: string;
  100008. /**
  100009. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100010. * @param u defines the coordinate on X axis
  100011. * @param v defines the coordinate on Y axis
  100012. * @param width defines the width of the source data
  100013. * @param height defines the height of the source data
  100014. * @param pixels defines the source byte array
  100015. * @param color defines the output color
  100016. */
  100017. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100018. /**
  100019. * Interpolates between a and b via alpha
  100020. * @param a The lower value (returned when alpha = 0)
  100021. * @param b The upper value (returned when alpha = 1)
  100022. * @param alpha The interpolation-factor
  100023. * @return The mixed value
  100024. */
  100025. static Mix(a: number, b: number, alpha: number): number;
  100026. /**
  100027. * Tries to instantiate a new object from a given class name
  100028. * @param className defines the class name to instantiate
  100029. * @returns the new object or null if the system was not able to do the instantiation
  100030. */
  100031. static Instantiate(className: string): any;
  100032. /**
  100033. * Provides a slice function that will work even on IE
  100034. * @param data defines the array to slice
  100035. * @param start defines the start of the data (optional)
  100036. * @param end defines the end of the data (optional)
  100037. * @returns the new sliced array
  100038. */
  100039. static Slice<T>(data: T, start?: number, end?: number): T;
  100040. /**
  100041. * Polyfill for setImmediate
  100042. * @param action defines the action to execute after the current execution block
  100043. */
  100044. static SetImmediate(action: () => void): void;
  100045. /**
  100046. * Function indicating if a number is an exponent of 2
  100047. * @param value defines the value to test
  100048. * @returns true if the value is an exponent of 2
  100049. */
  100050. static IsExponentOfTwo(value: number): boolean;
  100051. private static _tmpFloatArray;
  100052. /**
  100053. * Returns the nearest 32-bit single precision float representation of a Number
  100054. * @param value A Number. If the parameter is of a different type, it will get converted
  100055. * to a number or to NaN if it cannot be converted
  100056. * @returns number
  100057. */
  100058. static FloatRound(value: number): number;
  100059. /**
  100060. * Extracts the filename from a path
  100061. * @param path defines the path to use
  100062. * @returns the filename
  100063. */
  100064. static GetFilename(path: string): string;
  100065. /**
  100066. * Extracts the "folder" part of a path (everything before the filename).
  100067. * @param uri The URI to extract the info from
  100068. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100069. * @returns The "folder" part of the path
  100070. */
  100071. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100072. /**
  100073. * Extracts text content from a DOM element hierarchy
  100074. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100075. */
  100076. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100077. /**
  100078. * Convert an angle in radians to degrees
  100079. * @param angle defines the angle to convert
  100080. * @returns the angle in degrees
  100081. */
  100082. static ToDegrees(angle: number): number;
  100083. /**
  100084. * Convert an angle in degrees to radians
  100085. * @param angle defines the angle to convert
  100086. * @returns the angle in radians
  100087. */
  100088. static ToRadians(angle: number): number;
  100089. /**
  100090. * Returns an array if obj is not an array
  100091. * @param obj defines the object to evaluate as an array
  100092. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100093. * @returns either obj directly if obj is an array or a new array containing obj
  100094. */
  100095. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100096. /**
  100097. * Gets the pointer prefix to use
  100098. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100099. */
  100100. static GetPointerPrefix(): string;
  100101. /**
  100102. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100103. * @param url define the url we are trying
  100104. * @param element define the dom element where to configure the cors policy
  100105. */
  100106. static SetCorsBehavior(url: string | string[], element: {
  100107. crossOrigin: string | null;
  100108. }): void;
  100109. /**
  100110. * Removes unwanted characters from an url
  100111. * @param url defines the url to clean
  100112. * @returns the cleaned url
  100113. */
  100114. static CleanUrl(url: string): string;
  100115. /**
  100116. * Gets or sets a function used to pre-process url before using them to load assets
  100117. */
  100118. static PreprocessUrl: (url: string) => string;
  100119. /**
  100120. * Loads an image as an HTMLImageElement.
  100121. * @param input url string, ArrayBuffer, or Blob to load
  100122. * @param onLoad callback called when the image successfully loads
  100123. * @param onError callback called when the image fails to load
  100124. * @param offlineProvider offline provider for caching
  100125. * @param mimeType optional mime type
  100126. * @returns the HTMLImageElement of the loaded image
  100127. */
  100128. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100129. /**
  100130. * Loads a file from a url
  100131. * @param url url string, ArrayBuffer, or Blob to load
  100132. * @param onSuccess callback called when the file successfully loads
  100133. * @param onProgress callback called while file is loading (if the server supports this mode)
  100134. * @param offlineProvider defines the offline provider for caching
  100135. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100136. * @param onError callback called when the file fails to load
  100137. * @returns a file request object
  100138. */
  100139. 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;
  100140. /**
  100141. * Loads a file from a url
  100142. * @param url the file url to load
  100143. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100144. */
  100145. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100146. /**
  100147. * Load a script (identified by an url). When the url returns, the
  100148. * content of this file is added into a new script element, attached to the DOM (body element)
  100149. * @param scriptUrl defines the url of the script to laod
  100150. * @param onSuccess defines the callback called when the script is loaded
  100151. * @param onError defines the callback to call if an error occurs
  100152. * @param scriptId defines the id of the script element
  100153. */
  100154. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100155. /**
  100156. * Load an asynchronous script (identified by an url). When the url returns, the
  100157. * content of this file is added into a new script element, attached to the DOM (body element)
  100158. * @param scriptUrl defines the url of the script to laod
  100159. * @param scriptId defines the id of the script element
  100160. * @returns a promise request object
  100161. */
  100162. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100163. /**
  100164. * Loads a file from a blob
  100165. * @param fileToLoad defines the blob to use
  100166. * @param callback defines the callback to call when data is loaded
  100167. * @param progressCallback defines the callback to call during loading process
  100168. * @returns a file request object
  100169. */
  100170. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100171. /**
  100172. * Reads a file from a File object
  100173. * @param file defines the file to load
  100174. * @param onSuccess defines the callback to call when data is loaded
  100175. * @param onProgress defines the callback to call during loading process
  100176. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100177. * @param onError defines the callback to call when an error occurs
  100178. * @returns a file request object
  100179. */
  100180. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100181. /**
  100182. * Creates a data url from a given string content
  100183. * @param content defines the content to convert
  100184. * @returns the new data url link
  100185. */
  100186. static FileAsURL(content: string): string;
  100187. /**
  100188. * Format the given number to a specific decimal format
  100189. * @param value defines the number to format
  100190. * @param decimals defines the number of decimals to use
  100191. * @returns the formatted string
  100192. */
  100193. static Format(value: number, decimals?: number): string;
  100194. /**
  100195. * Tries to copy an object by duplicating every property
  100196. * @param source defines the source object
  100197. * @param destination defines the target object
  100198. * @param doNotCopyList defines a list of properties to avoid
  100199. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100200. */
  100201. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100202. /**
  100203. * Gets a boolean indicating if the given object has no own property
  100204. * @param obj defines the object to test
  100205. * @returns true if object has no own property
  100206. */
  100207. static IsEmpty(obj: any): boolean;
  100208. /**
  100209. * Function used to register events at window level
  100210. * @param windowElement defines the Window object to use
  100211. * @param events defines the events to register
  100212. */
  100213. static RegisterTopRootEvents(windowElement: Window, events: {
  100214. name: string;
  100215. handler: Nullable<(e: FocusEvent) => any>;
  100216. }[]): void;
  100217. /**
  100218. * Function used to unregister events from window level
  100219. * @param windowElement defines the Window object to use
  100220. * @param events defines the events to unregister
  100221. */
  100222. static UnregisterTopRootEvents(windowElement: Window, events: {
  100223. name: string;
  100224. handler: Nullable<(e: FocusEvent) => any>;
  100225. }[]): void;
  100226. /**
  100227. * @ignore
  100228. */
  100229. static _ScreenshotCanvas: HTMLCanvasElement;
  100230. /**
  100231. * Dumps the current bound framebuffer
  100232. * @param width defines the rendering width
  100233. * @param height defines the rendering height
  100234. * @param engine defines the hosting engine
  100235. * @param successCallback defines the callback triggered once the data are available
  100236. * @param mimeType defines the mime type of the result
  100237. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100238. */
  100239. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100240. /**
  100241. * Converts the canvas data to blob.
  100242. * This acts as a polyfill for browsers not supporting the to blob function.
  100243. * @param canvas Defines the canvas to extract the data from
  100244. * @param successCallback Defines the callback triggered once the data are available
  100245. * @param mimeType Defines the mime type of the result
  100246. */
  100247. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100248. /**
  100249. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100250. * @param successCallback defines the callback triggered once the data are available
  100251. * @param mimeType defines the mime type of the result
  100252. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100253. */
  100254. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100255. /**
  100256. * Downloads a blob in the browser
  100257. * @param blob defines the blob to download
  100258. * @param fileName defines the name of the downloaded file
  100259. */
  100260. static Download(blob: Blob, fileName: string): void;
  100261. /**
  100262. * Captures a screenshot of the current rendering
  100263. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100264. * @param engine defines the rendering engine
  100265. * @param camera defines the source camera
  100266. * @param size This parameter can be set to a single number or to an object with the
  100267. * following (optional) properties: precision, width, height. If a single number is passed,
  100268. * it will be used for both width and height. If an object is passed, the screenshot size
  100269. * will be derived from the parameters. The precision property is a multiplier allowing
  100270. * rendering at a higher or lower resolution
  100271. * @param successCallback defines the callback receives a single parameter which contains the
  100272. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100273. * src parameter of an <img> to display it
  100274. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100275. * Check your browser for supported MIME types
  100276. */
  100277. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100278. /**
  100279. * Captures a screenshot of the current rendering
  100280. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100281. * @param engine defines the rendering engine
  100282. * @param camera defines the source camera
  100283. * @param size This parameter can be set to a single number or to an object with the
  100284. * following (optional) properties: precision, width, height. If a single number is passed,
  100285. * it will be used for both width and height. If an object is passed, the screenshot size
  100286. * will be derived from the parameters. The precision property is a multiplier allowing
  100287. * rendering at a higher or lower resolution
  100288. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100289. * Check your browser for supported MIME types
  100290. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100291. * to the src parameter of an <img> to display it
  100292. */
  100293. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100294. /**
  100295. * Generates an image screenshot from the specified camera.
  100296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100297. * @param engine The engine to use for rendering
  100298. * @param camera The camera to use for rendering
  100299. * @param size This parameter can be set to a single number or to an object with the
  100300. * following (optional) properties: precision, width, height. If a single number is passed,
  100301. * it will be used for both width and height. If an object is passed, the screenshot size
  100302. * will be derived from the parameters. The precision property is a multiplier allowing
  100303. * rendering at a higher or lower resolution
  100304. * @param successCallback The callback receives a single parameter which contains the
  100305. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100306. * src parameter of an <img> to display it
  100307. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100308. * Check your browser for supported MIME types
  100309. * @param samples Texture samples (default: 1)
  100310. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100311. * @param fileName A name for for the downloaded file.
  100312. */
  100313. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100314. /**
  100315. * Generates an image screenshot from the specified camera.
  100316. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100317. * @param engine The engine to use for rendering
  100318. * @param camera The camera to use for rendering
  100319. * @param size This parameter can be set to a single number or to an object with the
  100320. * following (optional) properties: precision, width, height. If a single number is passed,
  100321. * it will be used for both width and height. If an object is passed, the screenshot size
  100322. * will be derived from the parameters. The precision property is a multiplier allowing
  100323. * rendering at a higher or lower resolution
  100324. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100325. * Check your browser for supported MIME types
  100326. * @param samples Texture samples (default: 1)
  100327. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100328. * @param fileName A name for for the downloaded file.
  100329. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100330. * to the src parameter of an <img> to display it
  100331. */
  100332. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100333. /**
  100334. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100335. * Be aware Math.random() could cause collisions, but:
  100336. * "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"
  100337. * @returns a pseudo random id
  100338. */
  100339. static RandomId(): string;
  100340. /**
  100341. * Test if the given uri is a base64 string
  100342. * @param uri The uri to test
  100343. * @return True if the uri is a base64 string or false otherwise
  100344. */
  100345. static IsBase64(uri: string): boolean;
  100346. /**
  100347. * Decode the given base64 uri.
  100348. * @param uri The uri to decode
  100349. * @return The decoded base64 data.
  100350. */
  100351. static DecodeBase64(uri: string): ArrayBuffer;
  100352. /**
  100353. * Gets the absolute url.
  100354. * @param url the input url
  100355. * @return the absolute url
  100356. */
  100357. static GetAbsoluteUrl(url: string): string;
  100358. /**
  100359. * No log
  100360. */
  100361. static readonly NoneLogLevel: number;
  100362. /**
  100363. * Only message logs
  100364. */
  100365. static readonly MessageLogLevel: number;
  100366. /**
  100367. * Only warning logs
  100368. */
  100369. static readonly WarningLogLevel: number;
  100370. /**
  100371. * Only error logs
  100372. */
  100373. static readonly ErrorLogLevel: number;
  100374. /**
  100375. * All logs
  100376. */
  100377. static readonly AllLogLevel: number;
  100378. /**
  100379. * Gets a value indicating the number of loading errors
  100380. * @ignorenaming
  100381. */
  100382. static readonly errorsCount: number;
  100383. /**
  100384. * Callback called when a new log is added
  100385. */
  100386. static OnNewCacheEntry: (entry: string) => void;
  100387. /**
  100388. * Log a message to the console
  100389. * @param message defines the message to log
  100390. */
  100391. static Log(message: string): void;
  100392. /**
  100393. * Write a warning message to the console
  100394. * @param message defines the message to log
  100395. */
  100396. static Warn(message: string): void;
  100397. /**
  100398. * Write an error message to the console
  100399. * @param message defines the message to log
  100400. */
  100401. static Error(message: string): void;
  100402. /**
  100403. * Gets current log cache (list of logs)
  100404. */
  100405. static readonly LogCache: string;
  100406. /**
  100407. * Clears the log cache
  100408. */
  100409. static ClearLogCache(): void;
  100410. /**
  100411. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100412. */
  100413. static LogLevels: number;
  100414. /**
  100415. * Checks if the window object exists
  100416. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100417. */
  100418. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100419. /**
  100420. * No performance log
  100421. */
  100422. static readonly PerformanceNoneLogLevel: number;
  100423. /**
  100424. * Use user marks to log performance
  100425. */
  100426. static readonly PerformanceUserMarkLogLevel: number;
  100427. /**
  100428. * Log performance to the console
  100429. */
  100430. static readonly PerformanceConsoleLogLevel: number;
  100431. private static _performance;
  100432. /**
  100433. * Sets the current performance log level
  100434. */
  100435. static PerformanceLogLevel: number;
  100436. private static _StartPerformanceCounterDisabled;
  100437. private static _EndPerformanceCounterDisabled;
  100438. private static _StartUserMark;
  100439. private static _EndUserMark;
  100440. private static _StartPerformanceConsole;
  100441. private static _EndPerformanceConsole;
  100442. /**
  100443. * Starts a performance counter
  100444. */
  100445. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100446. /**
  100447. * Ends a specific performance coutner
  100448. */
  100449. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100450. /**
  100451. * Gets either window.performance.now() if supported or Date.now() else
  100452. */
  100453. static readonly Now: number;
  100454. /**
  100455. * This method will return the name of the class used to create the instance of the given object.
  100456. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100457. * @param object the object to get the class name from
  100458. * @param isType defines if the object is actually a type
  100459. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100460. */
  100461. static GetClassName(object: any, isType?: boolean): string;
  100462. /**
  100463. * Gets the first element of an array satisfying a given predicate
  100464. * @param array defines the array to browse
  100465. * @param predicate defines the predicate to use
  100466. * @returns null if not found or the element
  100467. */
  100468. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100469. /**
  100470. * This method will return the name of the full name of the class, including its owning module (if any).
  100471. * 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).
  100472. * @param object the object to get the class name from
  100473. * @param isType defines if the object is actually a type
  100474. * @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.
  100475. * @ignorenaming
  100476. */
  100477. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100478. /**
  100479. * Returns a promise that resolves after the given amount of time.
  100480. * @param delay Number of milliseconds to delay
  100481. * @returns Promise that resolves after the given amount of time
  100482. */
  100483. static DelayAsync(delay: number): Promise<void>;
  100484. }
  100485. /**
  100486. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100487. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100488. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100489. * @param name The name of the class, case should be preserved
  100490. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100491. */
  100492. export function className(name: string, module?: string): (target: Object) => void;
  100493. /**
  100494. * An implementation of a loop for asynchronous functions.
  100495. */
  100496. export class AsyncLoop {
  100497. /**
  100498. * Defines the number of iterations for the loop
  100499. */
  100500. iterations: number;
  100501. /**
  100502. * Defines the current index of the loop.
  100503. */
  100504. index: number;
  100505. private _done;
  100506. private _fn;
  100507. private _successCallback;
  100508. /**
  100509. * Constructor.
  100510. * @param iterations the number of iterations.
  100511. * @param func the function to run each iteration
  100512. * @param successCallback the callback that will be called upon succesful execution
  100513. * @param offset starting offset.
  100514. */
  100515. constructor(
  100516. /**
  100517. * Defines the number of iterations for the loop
  100518. */
  100519. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  100520. /**
  100521. * Execute the next iteration. Must be called after the last iteration was finished.
  100522. */
  100523. executeNext(): void;
  100524. /**
  100525. * Break the loop and run the success callback.
  100526. */
  100527. breakLoop(): void;
  100528. /**
  100529. * Create and run an async loop.
  100530. * @param iterations the number of iterations.
  100531. * @param fn the function to run each iteration
  100532. * @param successCallback the callback that will be called upon succesful execution
  100533. * @param offset starting offset.
  100534. * @returns the created async loop object
  100535. */
  100536. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  100537. /**
  100538. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100539. * @param iterations total number of iterations
  100540. * @param syncedIterations number of synchronous iterations in each async iteration.
  100541. * @param fn the function to call each iteration.
  100542. * @param callback a success call back that will be called when iterating stops.
  100543. * @param breakFunction a break condition (optional)
  100544. * @param timeout timeout settings for the setTimeout function. default - 0.
  100545. * @returns the created async loop object
  100546. */
  100547. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  100548. }
  100549. }
  100550. declare module BABYLON {
  100551. /**
  100552. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100553. * The underlying implementation relies on an associative array to ensure the best performances.
  100554. * The value can be anything including 'null' but except 'undefined'
  100555. */
  100556. export class StringDictionary<T> {
  100557. /**
  100558. * This will clear this dictionary and copy the content from the 'source' one.
  100559. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100560. * @param source the dictionary to take the content from and copy to this dictionary
  100561. */
  100562. copyFrom(source: StringDictionary<T>): void;
  100563. /**
  100564. * Get a value based from its key
  100565. * @param key the given key to get the matching value from
  100566. * @return the value if found, otherwise undefined is returned
  100567. */
  100568. get(key: string): T | undefined;
  100569. /**
  100570. * Get a value from its key or add it if it doesn't exist.
  100571. * This method will ensure you that a given key/data will be present in the dictionary.
  100572. * @param key the given key to get the matching value from
  100573. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100574. * The factory will only be invoked if there's no data for the given key.
  100575. * @return the value corresponding to the key.
  100576. */
  100577. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100578. /**
  100579. * Get a value from its key if present in the dictionary otherwise add it
  100580. * @param key the key to get the value from
  100581. * @param val if there's no such key/value pair in the dictionary add it with this value
  100582. * @return the value corresponding to the key
  100583. */
  100584. getOrAdd(key: string, val: T): T;
  100585. /**
  100586. * Check if there's a given key in the dictionary
  100587. * @param key the key to check for
  100588. * @return true if the key is present, false otherwise
  100589. */
  100590. contains(key: string): boolean;
  100591. /**
  100592. * Add a new key and its corresponding value
  100593. * @param key the key to add
  100594. * @param value the value corresponding to the key
  100595. * @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
  100596. */
  100597. add(key: string, value: T): boolean;
  100598. /**
  100599. * Update a specific value associated to a key
  100600. * @param key defines the key to use
  100601. * @param value defines the value to store
  100602. * @returns true if the value was updated (or false if the key was not found)
  100603. */
  100604. set(key: string, value: T): boolean;
  100605. /**
  100606. * Get the element of the given key and remove it from the dictionary
  100607. * @param key defines the key to search
  100608. * @returns the value associated with the key or null if not found
  100609. */
  100610. getAndRemove(key: string): Nullable<T>;
  100611. /**
  100612. * Remove a key/value from the dictionary.
  100613. * @param key the key to remove
  100614. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100615. */
  100616. remove(key: string): boolean;
  100617. /**
  100618. * Clear the whole content of the dictionary
  100619. */
  100620. clear(): void;
  100621. /**
  100622. * Gets the current count
  100623. */
  100624. readonly count: number;
  100625. /**
  100626. * Execute a callback on each key/val of the dictionary.
  100627. * Note that you can remove any element in this dictionary in the callback implementation
  100628. * @param callback the callback to execute on a given key/value pair
  100629. */
  100630. forEach(callback: (key: string, val: T) => void): void;
  100631. /**
  100632. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100633. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100634. * Note that you can remove any element in this dictionary in the callback implementation
  100635. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100636. * @returns the first item
  100637. */
  100638. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100639. private _count;
  100640. private _data;
  100641. }
  100642. }
  100643. declare module BABYLON {
  100644. /** @hidden */
  100645. export interface ICollisionCoordinator {
  100646. createCollider(): Collider;
  100647. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100648. init(scene: Scene): void;
  100649. }
  100650. /** @hidden */
  100651. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100652. private _scene;
  100653. private _scaledPosition;
  100654. private _scaledVelocity;
  100655. private _finalPosition;
  100656. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100657. createCollider(): Collider;
  100658. init(scene: Scene): void;
  100659. private _collideWithWorld;
  100660. }
  100661. }
  100662. declare module BABYLON {
  100663. /**
  100664. * Class used to manage all inputs for the scene.
  100665. */
  100666. export class InputManager {
  100667. /** The distance in pixel that you have to move to prevent some events */
  100668. static DragMovementThreshold: number;
  100669. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100670. static LongPressDelay: number;
  100671. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100672. static DoubleClickDelay: number;
  100673. /** If you need to check double click without raising a single click at first click, enable this flag */
  100674. static ExclusiveDoubleClickMode: boolean;
  100675. private _wheelEventName;
  100676. private _onPointerMove;
  100677. private _onPointerDown;
  100678. private _onPointerUp;
  100679. private _initClickEvent;
  100680. private _initActionManager;
  100681. private _delayedSimpleClick;
  100682. private _delayedSimpleClickTimeout;
  100683. private _previousDelayedSimpleClickTimeout;
  100684. private _meshPickProceed;
  100685. private _previousButtonPressed;
  100686. private _currentPickResult;
  100687. private _previousPickResult;
  100688. private _totalPointersPressed;
  100689. private _doubleClickOccured;
  100690. private _pointerOverMesh;
  100691. private _pickedDownMesh;
  100692. private _pickedUpMesh;
  100693. private _pointerX;
  100694. private _pointerY;
  100695. private _unTranslatedPointerX;
  100696. private _unTranslatedPointerY;
  100697. private _startingPointerPosition;
  100698. private _previousStartingPointerPosition;
  100699. private _startingPointerTime;
  100700. private _previousStartingPointerTime;
  100701. private _pointerCaptures;
  100702. private _onKeyDown;
  100703. private _onKeyUp;
  100704. private _onCanvasFocusObserver;
  100705. private _onCanvasBlurObserver;
  100706. private _scene;
  100707. /**
  100708. * Creates a new InputManager
  100709. * @param scene defines the hosting scene
  100710. */
  100711. constructor(scene: Scene);
  100712. /**
  100713. * Gets the mesh that is currently under the pointer
  100714. */
  100715. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100716. /**
  100717. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100718. */
  100719. readonly unTranslatedPointer: Vector2;
  100720. /**
  100721. * Gets or sets the current on-screen X position of the pointer
  100722. */
  100723. pointerX: number;
  100724. /**
  100725. * Gets or sets the current on-screen Y position of the pointer
  100726. */
  100727. pointerY: number;
  100728. private _updatePointerPosition;
  100729. private _processPointerMove;
  100730. private _setRayOnPointerInfo;
  100731. private _checkPrePointerObservable;
  100732. /**
  100733. * Use this method to simulate a pointer move on a mesh
  100734. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100735. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100736. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100737. */
  100738. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100739. /**
  100740. * Use this method to simulate a pointer down on a mesh
  100741. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100742. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100743. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100744. */
  100745. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100746. private _processPointerDown;
  100747. /** @hidden */
  100748. _isPointerSwiping(): boolean;
  100749. /**
  100750. * Use this method to simulate a pointer up on a mesh
  100751. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100752. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100753. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100754. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100755. */
  100756. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  100757. private _processPointerUp;
  100758. /**
  100759. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100760. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100761. * @returns true if the pointer was captured
  100762. */
  100763. isPointerCaptured(pointerId?: number): boolean;
  100764. /**
  100765. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100766. * @param attachUp defines if you want to attach events to pointerup
  100767. * @param attachDown defines if you want to attach events to pointerdown
  100768. * @param attachMove defines if you want to attach events to pointermove
  100769. */
  100770. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100771. /**
  100772. * Detaches all event handlers
  100773. */
  100774. detachControl(): void;
  100775. /**
  100776. * Force the value of meshUnderPointer
  100777. * @param mesh defines the mesh to use
  100778. */
  100779. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100780. /**
  100781. * Gets the mesh under the pointer
  100782. * @returns a Mesh or null if no mesh is under the pointer
  100783. */
  100784. getPointerOverMesh(): Nullable<AbstractMesh>;
  100785. }
  100786. }
  100787. declare module BABYLON {
  100788. /**
  100789. * Helper class used to generate session unique ID
  100790. */
  100791. export class UniqueIdGenerator {
  100792. private static _UniqueIdCounter;
  100793. /**
  100794. * Gets an unique (relatively to the current scene) Id
  100795. */
  100796. static readonly UniqueId: number;
  100797. }
  100798. }
  100799. declare module BABYLON {
  100800. /**
  100801. * This class defines the direct association between an animation and a target
  100802. */
  100803. export class TargetedAnimation {
  100804. /**
  100805. * Animation to perform
  100806. */
  100807. animation: Animation;
  100808. /**
  100809. * Target to animate
  100810. */
  100811. target: any;
  100812. /**
  100813. * Serialize the object
  100814. * @returns the JSON object representing the current entity
  100815. */
  100816. serialize(): any;
  100817. }
  100818. /**
  100819. * Use this class to create coordinated animations on multiple targets
  100820. */
  100821. export class AnimationGroup implements IDisposable {
  100822. /** The name of the animation group */
  100823. name: string;
  100824. private _scene;
  100825. private _targetedAnimations;
  100826. private _animatables;
  100827. private _from;
  100828. private _to;
  100829. private _isStarted;
  100830. private _isPaused;
  100831. private _speedRatio;
  100832. private _loopAnimation;
  100833. /**
  100834. * Gets or sets the unique id of the node
  100835. */
  100836. uniqueId: number;
  100837. /**
  100838. * This observable will notify when one animation have ended
  100839. */
  100840. onAnimationEndObservable: Observable<TargetedAnimation>;
  100841. /**
  100842. * Observer raised when one animation loops
  100843. */
  100844. onAnimationLoopObservable: Observable<TargetedAnimation>;
  100845. /**
  100846. * Observer raised when all animations have looped
  100847. */
  100848. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  100849. /**
  100850. * This observable will notify when all animations have ended.
  100851. */
  100852. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  100853. /**
  100854. * This observable will notify when all animations have paused.
  100855. */
  100856. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  100857. /**
  100858. * This observable will notify when all animations are playing.
  100859. */
  100860. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100861. /**
  100862. * Gets the first frame
  100863. */
  100864. readonly from: number;
  100865. /**
  100866. * Gets the last frame
  100867. */
  100868. readonly to: number;
  100869. /**
  100870. * Define if the animations are started
  100871. */
  100872. readonly isStarted: boolean;
  100873. /**
  100874. * Gets a value indicating that the current group is playing
  100875. */
  100876. readonly isPlaying: boolean;
  100877. /**
  100878. * Gets or sets the speed ratio to use for all animations
  100879. */
  100880. /**
  100881. * Gets or sets the speed ratio to use for all animations
  100882. */
  100883. speedRatio: number;
  100884. /**
  100885. * Gets or sets if all animations should loop or not
  100886. */
  100887. loopAnimation: boolean;
  100888. /**
  100889. * Gets the targeted animations for this animation group
  100890. */
  100891. readonly targetedAnimations: Array<TargetedAnimation>;
  100892. /**
  100893. * returning the list of animatables controlled by this animation group.
  100894. */
  100895. readonly animatables: Array<Animatable>;
  100896. /**
  100897. * Instantiates a new Animation Group.
  100898. * This helps managing several animations at once.
  100899. * @see http://doc.babylonjs.com/how_to/group
  100900. * @param name Defines the name of the group
  100901. * @param scene Defines the scene the group belongs to
  100902. */
  100903. constructor(
  100904. /** The name of the animation group */
  100905. name: string, scene?: Nullable<Scene>);
  100906. /**
  100907. * Add an animation (with its target) in the group
  100908. * @param animation defines the animation we want to add
  100909. * @param target defines the target of the animation
  100910. * @returns the TargetedAnimation object
  100911. */
  100912. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100913. /**
  100914. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100915. * It can add constant keys at begin or end
  100916. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100917. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100918. * @returns the animation group
  100919. */
  100920. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100921. private _animationLoopCount;
  100922. private _animationLoopFlags;
  100923. private _processLoop;
  100924. /**
  100925. * Start all animations on given targets
  100926. * @param loop defines if animations must loop
  100927. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100928. * @param from defines the from key (optional)
  100929. * @param to defines the to key (optional)
  100930. * @returns the current animation group
  100931. */
  100932. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100933. /**
  100934. * Pause all animations
  100935. * @returns the animation group
  100936. */
  100937. pause(): AnimationGroup;
  100938. /**
  100939. * Play all animations to initial state
  100940. * This function will start() the animations if they were not started or will restart() them if they were paused
  100941. * @param loop defines if animations must loop
  100942. * @returns the animation group
  100943. */
  100944. play(loop?: boolean): AnimationGroup;
  100945. /**
  100946. * Reset all animations to initial state
  100947. * @returns the animation group
  100948. */
  100949. reset(): AnimationGroup;
  100950. /**
  100951. * Restart animations from key 0
  100952. * @returns the animation group
  100953. */
  100954. restart(): AnimationGroup;
  100955. /**
  100956. * Stop all animations
  100957. * @returns the animation group
  100958. */
  100959. stop(): AnimationGroup;
  100960. /**
  100961. * Set animation weight for all animatables
  100962. * @param weight defines the weight to use
  100963. * @return the animationGroup
  100964. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100965. */
  100966. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100967. /**
  100968. * Synchronize and normalize all animatables with a source animatable
  100969. * @param root defines the root animatable to synchronize with
  100970. * @return the animationGroup
  100971. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100972. */
  100973. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100974. /**
  100975. * Goes to a specific frame in this animation group
  100976. * @param frame the frame number to go to
  100977. * @return the animationGroup
  100978. */
  100979. goToFrame(frame: number): AnimationGroup;
  100980. /**
  100981. * Dispose all associated resources
  100982. */
  100983. dispose(): void;
  100984. private _checkAnimationGroupEnded;
  100985. /**
  100986. * Clone the current animation group and returns a copy
  100987. * @param newName defines the name of the new group
  100988. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100989. * @returns the new aniamtion group
  100990. */
  100991. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100992. /**
  100993. * Serializes the animationGroup to an object
  100994. * @returns Serialized object
  100995. */
  100996. serialize(): any;
  100997. /**
  100998. * Returns a new AnimationGroup object parsed from the source provided.
  100999. * @param parsedAnimationGroup defines the source
  101000. * @param scene defines the scene that will receive the animationGroup
  101001. * @returns a new AnimationGroup
  101002. */
  101003. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101004. /**
  101005. * Returns the string "AnimationGroup"
  101006. * @returns "AnimationGroup"
  101007. */
  101008. getClassName(): string;
  101009. /**
  101010. * Creates a detailled string about the object
  101011. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101012. * @returns a string representing the object
  101013. */
  101014. toString(fullDetails?: boolean): string;
  101015. }
  101016. }
  101017. declare module BABYLON {
  101018. /**
  101019. * Define an interface for all classes that will hold resources
  101020. */
  101021. export interface IDisposable {
  101022. /**
  101023. * Releases all held resources
  101024. */
  101025. dispose(): void;
  101026. }
  101027. /** Interface defining initialization parameters for Scene class */
  101028. export interface SceneOptions {
  101029. /**
  101030. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101031. * It will improve performance when the number of geometries becomes important.
  101032. */
  101033. useGeometryUniqueIdsMap?: boolean;
  101034. /**
  101035. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101036. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101037. */
  101038. useMaterialMeshMap?: boolean;
  101039. /**
  101040. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101041. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101042. */
  101043. useClonedMeshhMap?: boolean;
  101044. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101045. virtual?: boolean;
  101046. }
  101047. /**
  101048. * Represents a scene to be rendered by the engine.
  101049. * @see http://doc.babylonjs.com/features/scene
  101050. */
  101051. export class Scene extends AbstractScene implements IAnimatable {
  101052. /** The fog is deactivated */
  101053. static readonly FOGMODE_NONE: number;
  101054. /** The fog density is following an exponential function */
  101055. static readonly FOGMODE_EXP: number;
  101056. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101057. static readonly FOGMODE_EXP2: number;
  101058. /** The fog density is following a linear function. */
  101059. static readonly FOGMODE_LINEAR: number;
  101060. /**
  101061. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101062. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101063. */
  101064. static MinDeltaTime: number;
  101065. /**
  101066. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101067. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101068. */
  101069. static MaxDeltaTime: number;
  101070. /**
  101071. * Factory used to create the default material.
  101072. * @param name The name of the material to create
  101073. * @param scene The scene to create the material for
  101074. * @returns The default material
  101075. */
  101076. static DefaultMaterialFactory(scene: Scene): Material;
  101077. /**
  101078. * Factory used to create the a collision coordinator.
  101079. * @returns The collision coordinator
  101080. */
  101081. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101082. /** @hidden */
  101083. _inputManager: InputManager;
  101084. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101085. cameraToUseForPointers: Nullable<Camera>;
  101086. /** @hidden */
  101087. readonly _isScene: boolean;
  101088. /**
  101089. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101090. */
  101091. autoClear: boolean;
  101092. /**
  101093. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101094. */
  101095. autoClearDepthAndStencil: boolean;
  101096. /**
  101097. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101098. */
  101099. clearColor: Color4;
  101100. /**
  101101. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101102. */
  101103. ambientColor: Color3;
  101104. /**
  101105. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101106. * It should only be one of the following (if not the default embedded one):
  101107. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101108. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101109. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101110. * The material properties need to be setup according to the type of texture in use.
  101111. */
  101112. environmentBRDFTexture: BaseTexture;
  101113. /** @hidden */
  101114. protected _environmentTexture: Nullable<BaseTexture>;
  101115. /**
  101116. * Texture used in all pbr material as the reflection texture.
  101117. * As in the majority of the scene they are the same (exception for multi room and so on),
  101118. * this is easier to reference from here than from all the materials.
  101119. */
  101120. /**
  101121. * Texture used in all pbr material as the reflection texture.
  101122. * As in the majority of the scene they are the same (exception for multi room and so on),
  101123. * this is easier to set here than in all the materials.
  101124. */
  101125. environmentTexture: Nullable<BaseTexture>;
  101126. /** @hidden */
  101127. protected _environmentIntensity: number;
  101128. /**
  101129. * Intensity of the environment in all pbr material.
  101130. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101131. * As in the majority of the scene they are the same (exception for multi room and so on),
  101132. * this is easier to reference from here than from all the materials.
  101133. */
  101134. /**
  101135. * Intensity of the environment in all pbr material.
  101136. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101137. * As in the majority of the scene they are the same (exception for multi room and so on),
  101138. * this is easier to set here than in all the materials.
  101139. */
  101140. environmentIntensity: number;
  101141. /** @hidden */
  101142. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101143. /**
  101144. * Default image processing configuration used either in the rendering
  101145. * Forward main pass or through the imageProcessingPostProcess if present.
  101146. * As in the majority of the scene they are the same (exception for multi camera),
  101147. * this is easier to reference from here than from all the materials and post process.
  101148. *
  101149. * No setter as we it is a shared configuration, you can set the values instead.
  101150. */
  101151. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101152. private _forceWireframe;
  101153. /**
  101154. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101155. */
  101156. forceWireframe: boolean;
  101157. private _forcePointsCloud;
  101158. /**
  101159. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101160. */
  101161. forcePointsCloud: boolean;
  101162. /**
  101163. * Gets or sets the active clipplane 1
  101164. */
  101165. clipPlane: Nullable<Plane>;
  101166. /**
  101167. * Gets or sets the active clipplane 2
  101168. */
  101169. clipPlane2: Nullable<Plane>;
  101170. /**
  101171. * Gets or sets the active clipplane 3
  101172. */
  101173. clipPlane3: Nullable<Plane>;
  101174. /**
  101175. * Gets or sets the active clipplane 4
  101176. */
  101177. clipPlane4: Nullable<Plane>;
  101178. /**
  101179. * Gets or sets a boolean indicating if animations are enabled
  101180. */
  101181. animationsEnabled: boolean;
  101182. private _animationPropertiesOverride;
  101183. /**
  101184. * Gets or sets the animation properties override
  101185. */
  101186. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101187. /**
  101188. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101189. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101190. */
  101191. useConstantAnimationDeltaTime: boolean;
  101192. /**
  101193. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101194. * Please note that it requires to run a ray cast through the scene on every frame
  101195. */
  101196. constantlyUpdateMeshUnderPointer: boolean;
  101197. /**
  101198. * Defines the HTML cursor to use when hovering over interactive elements
  101199. */
  101200. hoverCursor: string;
  101201. /**
  101202. * Defines the HTML default cursor to use (empty by default)
  101203. */
  101204. defaultCursor: string;
  101205. /**
  101206. * Defines wether cursors are handled by the scene.
  101207. */
  101208. doNotHandleCursors: boolean;
  101209. /**
  101210. * This is used to call preventDefault() on pointer down
  101211. * in order to block unwanted artifacts like system double clicks
  101212. */
  101213. preventDefaultOnPointerDown: boolean;
  101214. /**
  101215. * This is used to call preventDefault() on pointer up
  101216. * in order to block unwanted artifacts like system double clicks
  101217. */
  101218. preventDefaultOnPointerUp: boolean;
  101219. /**
  101220. * Gets or sets user defined metadata
  101221. */
  101222. metadata: any;
  101223. /**
  101224. * For internal use only. Please do not use.
  101225. */
  101226. reservedDataStore: any;
  101227. /**
  101228. * Gets the name of the plugin used to load this scene (null by default)
  101229. */
  101230. loadingPluginName: string;
  101231. /**
  101232. * Use this array to add regular expressions used to disable offline support for specific urls
  101233. */
  101234. disableOfflineSupportExceptionRules: RegExp[];
  101235. /**
  101236. * An event triggered when the scene is disposed.
  101237. */
  101238. onDisposeObservable: Observable<Scene>;
  101239. private _onDisposeObserver;
  101240. /** Sets a function to be executed when this scene is disposed. */
  101241. onDispose: () => void;
  101242. /**
  101243. * An event triggered before rendering the scene (right after animations and physics)
  101244. */
  101245. onBeforeRenderObservable: Observable<Scene>;
  101246. private _onBeforeRenderObserver;
  101247. /** Sets a function to be executed before rendering this scene */
  101248. beforeRender: Nullable<() => void>;
  101249. /**
  101250. * An event triggered after rendering the scene
  101251. */
  101252. onAfterRenderObservable: Observable<Scene>;
  101253. /**
  101254. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101255. */
  101256. onAfterRenderCameraObservable: Observable<Camera>;
  101257. private _onAfterRenderObserver;
  101258. /** Sets a function to be executed after rendering this scene */
  101259. afterRender: Nullable<() => void>;
  101260. /**
  101261. * An event triggered before animating the scene
  101262. */
  101263. onBeforeAnimationsObservable: Observable<Scene>;
  101264. /**
  101265. * An event triggered after animations processing
  101266. */
  101267. onAfterAnimationsObservable: Observable<Scene>;
  101268. /**
  101269. * An event triggered before draw calls are ready to be sent
  101270. */
  101271. onBeforeDrawPhaseObservable: Observable<Scene>;
  101272. /**
  101273. * An event triggered after draw calls have been sent
  101274. */
  101275. onAfterDrawPhaseObservable: Observable<Scene>;
  101276. /**
  101277. * An event triggered when the scene is ready
  101278. */
  101279. onReadyObservable: Observable<Scene>;
  101280. /**
  101281. * An event triggered before rendering a camera
  101282. */
  101283. onBeforeCameraRenderObservable: Observable<Camera>;
  101284. private _onBeforeCameraRenderObserver;
  101285. /** Sets a function to be executed before rendering a camera*/
  101286. beforeCameraRender: () => void;
  101287. /**
  101288. * An event triggered after rendering a camera
  101289. */
  101290. onAfterCameraRenderObservable: Observable<Camera>;
  101291. private _onAfterCameraRenderObserver;
  101292. /** Sets a function to be executed after rendering a camera*/
  101293. afterCameraRender: () => void;
  101294. /**
  101295. * An event triggered when active meshes evaluation is about to start
  101296. */
  101297. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101298. /**
  101299. * An event triggered when active meshes evaluation is done
  101300. */
  101301. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101302. /**
  101303. * An event triggered when particles rendering is about to start
  101304. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101305. */
  101306. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101307. /**
  101308. * An event triggered when particles rendering is done
  101309. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101310. */
  101311. onAfterParticlesRenderingObservable: Observable<Scene>;
  101312. /**
  101313. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101314. */
  101315. onDataLoadedObservable: Observable<Scene>;
  101316. /**
  101317. * An event triggered when a camera is created
  101318. */
  101319. onNewCameraAddedObservable: Observable<Camera>;
  101320. /**
  101321. * An event triggered when a camera is removed
  101322. */
  101323. onCameraRemovedObservable: Observable<Camera>;
  101324. /**
  101325. * An event triggered when a light is created
  101326. */
  101327. onNewLightAddedObservable: Observable<Light>;
  101328. /**
  101329. * An event triggered when a light is removed
  101330. */
  101331. onLightRemovedObservable: Observable<Light>;
  101332. /**
  101333. * An event triggered when a geometry is created
  101334. */
  101335. onNewGeometryAddedObservable: Observable<Geometry>;
  101336. /**
  101337. * An event triggered when a geometry is removed
  101338. */
  101339. onGeometryRemovedObservable: Observable<Geometry>;
  101340. /**
  101341. * An event triggered when a transform node is created
  101342. */
  101343. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101344. /**
  101345. * An event triggered when a transform node is removed
  101346. */
  101347. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101348. /**
  101349. * An event triggered when a mesh is created
  101350. */
  101351. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101352. /**
  101353. * An event triggered when a mesh is removed
  101354. */
  101355. onMeshRemovedObservable: Observable<AbstractMesh>;
  101356. /**
  101357. * An event triggered when a skeleton is created
  101358. */
  101359. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101360. /**
  101361. * An event triggered when a skeleton is removed
  101362. */
  101363. onSkeletonRemovedObservable: Observable<Skeleton>;
  101364. /**
  101365. * An event triggered when a material is created
  101366. */
  101367. onNewMaterialAddedObservable: Observable<Material>;
  101368. /**
  101369. * An event triggered when a material is removed
  101370. */
  101371. onMaterialRemovedObservable: Observable<Material>;
  101372. /**
  101373. * An event triggered when a texture is created
  101374. */
  101375. onNewTextureAddedObservable: Observable<BaseTexture>;
  101376. /**
  101377. * An event triggered when a texture is removed
  101378. */
  101379. onTextureRemovedObservable: Observable<BaseTexture>;
  101380. /**
  101381. * An event triggered when render targets are about to be rendered
  101382. * Can happen multiple times per frame.
  101383. */
  101384. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101385. /**
  101386. * An event triggered when render targets were rendered.
  101387. * Can happen multiple times per frame.
  101388. */
  101389. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101390. /**
  101391. * An event triggered before calculating deterministic simulation step
  101392. */
  101393. onBeforeStepObservable: Observable<Scene>;
  101394. /**
  101395. * An event triggered after calculating deterministic simulation step
  101396. */
  101397. onAfterStepObservable: Observable<Scene>;
  101398. /**
  101399. * An event triggered when the activeCamera property is updated
  101400. */
  101401. onActiveCameraChanged: Observable<Scene>;
  101402. /**
  101403. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101404. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101405. * 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)
  101406. */
  101407. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101408. /**
  101409. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101410. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101411. * 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)
  101412. */
  101413. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101414. /**
  101415. * This Observable will when a mesh has been imported into the scene.
  101416. */
  101417. onMeshImportedObservable: Observable<AbstractMesh>;
  101418. /**
  101419. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101420. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101421. */
  101422. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101423. /** @hidden */
  101424. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101425. /**
  101426. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101427. */
  101428. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101429. /**
  101430. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101431. */
  101432. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101433. /**
  101434. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101435. */
  101436. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101437. /** Callback called when a pointer move is detected */
  101438. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101439. /** Callback called when a pointer down is detected */
  101440. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101441. /** Callback called when a pointer up is detected */
  101442. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101443. /** Callback called when a pointer pick is detected */
  101444. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101445. /**
  101446. * 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).
  101447. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101448. */
  101449. onPrePointerObservable: Observable<PointerInfoPre>;
  101450. /**
  101451. * Observable event triggered each time an input event is received from the rendering canvas
  101452. */
  101453. onPointerObservable: Observable<PointerInfo>;
  101454. /**
  101455. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101456. */
  101457. readonly unTranslatedPointer: Vector2;
  101458. /**
  101459. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101460. */
  101461. static DragMovementThreshold: number;
  101462. /**
  101463. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101464. */
  101465. static LongPressDelay: number;
  101466. /**
  101467. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101468. */
  101469. static DoubleClickDelay: number;
  101470. /** If you need to check double click without raising a single click at first click, enable this flag */
  101471. static ExclusiveDoubleClickMode: boolean;
  101472. /** @hidden */
  101473. _mirroredCameraPosition: Nullable<Vector3>;
  101474. /**
  101475. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101476. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101477. */
  101478. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  101479. /**
  101480. * Observable event triggered each time an keyboard event is received from the hosting window
  101481. */
  101482. onKeyboardObservable: Observable<KeyboardInfo>;
  101483. private _useRightHandedSystem;
  101484. /**
  101485. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  101486. */
  101487. useRightHandedSystem: boolean;
  101488. private _timeAccumulator;
  101489. private _currentStepId;
  101490. private _currentInternalStep;
  101491. /**
  101492. * Sets the step Id used by deterministic lock step
  101493. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101494. * @param newStepId defines the step Id
  101495. */
  101496. setStepId(newStepId: number): void;
  101497. /**
  101498. * Gets the step Id used by deterministic lock step
  101499. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101500. * @returns the step Id
  101501. */
  101502. getStepId(): number;
  101503. /**
  101504. * Gets the internal step used by deterministic lock step
  101505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101506. * @returns the internal step
  101507. */
  101508. getInternalStep(): number;
  101509. private _fogEnabled;
  101510. /**
  101511. * Gets or sets a boolean indicating if fog is enabled on this scene
  101512. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101513. * (Default is true)
  101514. */
  101515. fogEnabled: boolean;
  101516. private _fogMode;
  101517. /**
  101518. * Gets or sets the fog mode to use
  101519. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101520. * | mode | value |
  101521. * | --- | --- |
  101522. * | FOGMODE_NONE | 0 |
  101523. * | FOGMODE_EXP | 1 |
  101524. * | FOGMODE_EXP2 | 2 |
  101525. * | FOGMODE_LINEAR | 3 |
  101526. */
  101527. fogMode: number;
  101528. /**
  101529. * Gets or sets the fog color to use
  101530. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101531. * (Default is Color3(0.2, 0.2, 0.3))
  101532. */
  101533. fogColor: Color3;
  101534. /**
  101535. * Gets or sets the fog density to use
  101536. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101537. * (Default is 0.1)
  101538. */
  101539. fogDensity: number;
  101540. /**
  101541. * Gets or sets the fog start distance to use
  101542. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101543. * (Default is 0)
  101544. */
  101545. fogStart: number;
  101546. /**
  101547. * Gets or sets the fog end distance to use
  101548. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101549. * (Default is 1000)
  101550. */
  101551. fogEnd: number;
  101552. private _shadowsEnabled;
  101553. /**
  101554. * Gets or sets a boolean indicating if shadows are enabled on this scene
  101555. */
  101556. shadowsEnabled: boolean;
  101557. private _lightsEnabled;
  101558. /**
  101559. * Gets or sets a boolean indicating if lights are enabled on this scene
  101560. */
  101561. lightsEnabled: boolean;
  101562. /** All of the active cameras added to this scene. */
  101563. activeCameras: Camera[];
  101564. /** @hidden */
  101565. _activeCamera: Nullable<Camera>;
  101566. /** Gets or sets the current active camera */
  101567. activeCamera: Nullable<Camera>;
  101568. private _defaultMaterial;
  101569. /** The default material used on meshes when no material is affected */
  101570. /** The default material used on meshes when no material is affected */
  101571. defaultMaterial: Material;
  101572. private _texturesEnabled;
  101573. /**
  101574. * Gets or sets a boolean indicating if textures are enabled on this scene
  101575. */
  101576. texturesEnabled: boolean;
  101577. /**
  101578. * Gets or sets a boolean indicating if particles are enabled on this scene
  101579. */
  101580. particlesEnabled: boolean;
  101581. /**
  101582. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101583. */
  101584. spritesEnabled: boolean;
  101585. private _skeletonsEnabled;
  101586. /**
  101587. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101588. */
  101589. skeletonsEnabled: boolean;
  101590. /**
  101591. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101592. */
  101593. lensFlaresEnabled: boolean;
  101594. /**
  101595. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101596. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101597. */
  101598. collisionsEnabled: boolean;
  101599. private _collisionCoordinator;
  101600. /** @hidden */
  101601. readonly collisionCoordinator: ICollisionCoordinator;
  101602. /**
  101603. * Defines the gravity applied to this scene (used only for collisions)
  101604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101605. */
  101606. gravity: Vector3;
  101607. /**
  101608. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101609. */
  101610. postProcessesEnabled: boolean;
  101611. /**
  101612. * The list of postprocesses added to the scene
  101613. */
  101614. postProcesses: PostProcess[];
  101615. /**
  101616. * Gets the current postprocess manager
  101617. */
  101618. postProcessManager: PostProcessManager;
  101619. /**
  101620. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101621. */
  101622. renderTargetsEnabled: boolean;
  101623. /**
  101624. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101625. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101626. */
  101627. dumpNextRenderTargets: boolean;
  101628. /**
  101629. * The list of user defined render targets added to the scene
  101630. */
  101631. customRenderTargets: RenderTargetTexture[];
  101632. /**
  101633. * Defines if texture loading must be delayed
  101634. * If true, textures will only be loaded when they need to be rendered
  101635. */
  101636. useDelayedTextureLoading: boolean;
  101637. /**
  101638. * Gets the list of meshes imported to the scene through SceneLoader
  101639. */
  101640. importedMeshesFiles: String[];
  101641. /**
  101642. * Gets or sets a boolean indicating if probes are enabled on this scene
  101643. */
  101644. probesEnabled: boolean;
  101645. /**
  101646. * Gets or sets the current offline provider to use to store scene data
  101647. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101648. */
  101649. offlineProvider: IOfflineProvider;
  101650. /**
  101651. * Gets or sets the action manager associated with the scene
  101652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101653. */
  101654. actionManager: AbstractActionManager;
  101655. private _meshesForIntersections;
  101656. /**
  101657. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101658. */
  101659. proceduralTexturesEnabled: boolean;
  101660. private _engine;
  101661. private _totalVertices;
  101662. /** @hidden */
  101663. _activeIndices: PerfCounter;
  101664. /** @hidden */
  101665. _activeParticles: PerfCounter;
  101666. /** @hidden */
  101667. _activeBones: PerfCounter;
  101668. private _animationRatio;
  101669. /** @hidden */
  101670. _animationTimeLast: number;
  101671. /** @hidden */
  101672. _animationTime: number;
  101673. /**
  101674. * Gets or sets a general scale for animation speed
  101675. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101676. */
  101677. animationTimeScale: number;
  101678. /** @hidden */
  101679. _cachedMaterial: Nullable<Material>;
  101680. /** @hidden */
  101681. _cachedEffect: Nullable<Effect>;
  101682. /** @hidden */
  101683. _cachedVisibility: Nullable<number>;
  101684. private _renderId;
  101685. private _frameId;
  101686. private _executeWhenReadyTimeoutId;
  101687. private _intermediateRendering;
  101688. private _viewUpdateFlag;
  101689. private _projectionUpdateFlag;
  101690. /** @hidden */
  101691. _toBeDisposed: Nullable<IDisposable>[];
  101692. private _activeRequests;
  101693. /** @hidden */
  101694. _pendingData: any[];
  101695. private _isDisposed;
  101696. /**
  101697. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101698. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101699. */
  101700. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101701. private _activeMeshes;
  101702. private _processedMaterials;
  101703. private _renderTargets;
  101704. /** @hidden */
  101705. _activeParticleSystems: SmartArray<IParticleSystem>;
  101706. private _activeSkeletons;
  101707. private _softwareSkinnedMeshes;
  101708. private _renderingManager;
  101709. /** @hidden */
  101710. _activeAnimatables: Animatable[];
  101711. private _transformMatrix;
  101712. private _sceneUbo;
  101713. /** @hidden */
  101714. _viewMatrix: Matrix;
  101715. private _projectionMatrix;
  101716. /** @hidden */
  101717. _forcedViewPosition: Nullable<Vector3>;
  101718. /** @hidden */
  101719. _frustumPlanes: Plane[];
  101720. /**
  101721. * Gets the list of frustum planes (built from the active camera)
  101722. */
  101723. readonly frustumPlanes: Plane[];
  101724. /**
  101725. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101726. * This is useful if there are more lights that the maximum simulteanous authorized
  101727. */
  101728. requireLightSorting: boolean;
  101729. /** @hidden */
  101730. readonly useMaterialMeshMap: boolean;
  101731. /** @hidden */
  101732. readonly useClonedMeshhMap: boolean;
  101733. private _externalData;
  101734. private _uid;
  101735. /**
  101736. * @hidden
  101737. * Backing store of defined scene components.
  101738. */
  101739. _components: ISceneComponent[];
  101740. /**
  101741. * @hidden
  101742. * Backing store of defined scene components.
  101743. */
  101744. _serializableComponents: ISceneSerializableComponent[];
  101745. /**
  101746. * List of components to register on the next registration step.
  101747. */
  101748. private _transientComponents;
  101749. /**
  101750. * Registers the transient components if needed.
  101751. */
  101752. private _registerTransientComponents;
  101753. /**
  101754. * @hidden
  101755. * Add a component to the scene.
  101756. * Note that the ccomponent could be registered on th next frame if this is called after
  101757. * the register component stage.
  101758. * @param component Defines the component to add to the scene
  101759. */
  101760. _addComponent(component: ISceneComponent): void;
  101761. /**
  101762. * @hidden
  101763. * Gets a component from the scene.
  101764. * @param name defines the name of the component to retrieve
  101765. * @returns the component or null if not present
  101766. */
  101767. _getComponent(name: string): Nullable<ISceneComponent>;
  101768. /**
  101769. * @hidden
  101770. * Defines the actions happening before camera updates.
  101771. */
  101772. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  101773. /**
  101774. * @hidden
  101775. * Defines the actions happening before clear the canvas.
  101776. */
  101777. _beforeClearStage: Stage<SimpleStageAction>;
  101778. /**
  101779. * @hidden
  101780. * Defines the actions when collecting render targets for the frame.
  101781. */
  101782. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101783. /**
  101784. * @hidden
  101785. * Defines the actions happening for one camera in the frame.
  101786. */
  101787. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101788. /**
  101789. * @hidden
  101790. * Defines the actions happening during the per mesh ready checks.
  101791. */
  101792. _isReadyForMeshStage: Stage<MeshStageAction>;
  101793. /**
  101794. * @hidden
  101795. * Defines the actions happening before evaluate active mesh checks.
  101796. */
  101797. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  101798. /**
  101799. * @hidden
  101800. * Defines the actions happening during the evaluate sub mesh checks.
  101801. */
  101802. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  101803. /**
  101804. * @hidden
  101805. * Defines the actions happening during the active mesh stage.
  101806. */
  101807. _activeMeshStage: Stage<ActiveMeshStageAction>;
  101808. /**
  101809. * @hidden
  101810. * Defines the actions happening during the per camera render target step.
  101811. */
  101812. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  101813. /**
  101814. * @hidden
  101815. * Defines the actions happening just before the active camera is drawing.
  101816. */
  101817. _beforeCameraDrawStage: Stage<CameraStageAction>;
  101818. /**
  101819. * @hidden
  101820. * Defines the actions happening just before a render target is drawing.
  101821. */
  101822. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101823. /**
  101824. * @hidden
  101825. * Defines the actions happening just before a rendering group is drawing.
  101826. */
  101827. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101828. /**
  101829. * @hidden
  101830. * Defines the actions happening just before a mesh is drawing.
  101831. */
  101832. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101833. /**
  101834. * @hidden
  101835. * Defines the actions happening just after a mesh has been drawn.
  101836. */
  101837. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101838. /**
  101839. * @hidden
  101840. * Defines the actions happening just after a rendering group has been drawn.
  101841. */
  101842. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101843. /**
  101844. * @hidden
  101845. * Defines the actions happening just after the active camera has been drawn.
  101846. */
  101847. _afterCameraDrawStage: Stage<CameraStageAction>;
  101848. /**
  101849. * @hidden
  101850. * Defines the actions happening just after a render target has been drawn.
  101851. */
  101852. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101853. /**
  101854. * @hidden
  101855. * Defines the actions happening just after rendering all cameras and computing intersections.
  101856. */
  101857. _afterRenderStage: Stage<SimpleStageAction>;
  101858. /**
  101859. * @hidden
  101860. * Defines the actions happening when a pointer move event happens.
  101861. */
  101862. _pointerMoveStage: Stage<PointerMoveStageAction>;
  101863. /**
  101864. * @hidden
  101865. * Defines the actions happening when a pointer down event happens.
  101866. */
  101867. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101868. /**
  101869. * @hidden
  101870. * Defines the actions happening when a pointer up event happens.
  101871. */
  101872. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101873. /**
  101874. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101875. */
  101876. private geometriesByUniqueId;
  101877. /**
  101878. * Creates a new Scene
  101879. * @param engine defines the engine to use to render this scene
  101880. * @param options defines the scene options
  101881. */
  101882. constructor(engine: Engine, options?: SceneOptions);
  101883. /**
  101884. * Gets a string idenfifying the name of the class
  101885. * @returns "Scene" string
  101886. */
  101887. getClassName(): string;
  101888. private _defaultMeshCandidates;
  101889. /**
  101890. * @hidden
  101891. */
  101892. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101893. private _defaultSubMeshCandidates;
  101894. /**
  101895. * @hidden
  101896. */
  101897. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101898. /**
  101899. * Sets the default candidate providers for the scene.
  101900. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101901. * and getCollidingSubMeshCandidates to their default function
  101902. */
  101903. setDefaultCandidateProviders(): void;
  101904. /**
  101905. * Gets the mesh that is currently under the pointer
  101906. */
  101907. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101908. /**
  101909. * Gets or sets the current on-screen X position of the pointer
  101910. */
  101911. pointerX: number;
  101912. /**
  101913. * Gets or sets the current on-screen Y position of the pointer
  101914. */
  101915. pointerY: number;
  101916. /**
  101917. * Gets the cached material (ie. the latest rendered one)
  101918. * @returns the cached material
  101919. */
  101920. getCachedMaterial(): Nullable<Material>;
  101921. /**
  101922. * Gets the cached effect (ie. the latest rendered one)
  101923. * @returns the cached effect
  101924. */
  101925. getCachedEffect(): Nullable<Effect>;
  101926. /**
  101927. * Gets the cached visibility state (ie. the latest rendered one)
  101928. * @returns the cached visibility state
  101929. */
  101930. getCachedVisibility(): Nullable<number>;
  101931. /**
  101932. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101933. * @param material defines the current material
  101934. * @param effect defines the current effect
  101935. * @param visibility defines the current visibility state
  101936. * @returns true if one parameter is not cached
  101937. */
  101938. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101939. /**
  101940. * Gets the engine associated with the scene
  101941. * @returns an Engine
  101942. */
  101943. getEngine(): Engine;
  101944. /**
  101945. * Gets the total number of vertices rendered per frame
  101946. * @returns the total number of vertices rendered per frame
  101947. */
  101948. getTotalVertices(): number;
  101949. /**
  101950. * Gets the performance counter for total vertices
  101951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101952. */
  101953. readonly totalVerticesPerfCounter: PerfCounter;
  101954. /**
  101955. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101956. * @returns the total number of active indices rendered per frame
  101957. */
  101958. getActiveIndices(): number;
  101959. /**
  101960. * Gets the performance counter for active indices
  101961. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101962. */
  101963. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101964. /**
  101965. * Gets the total number of active particles rendered per frame
  101966. * @returns the total number of active particles rendered per frame
  101967. */
  101968. getActiveParticles(): number;
  101969. /**
  101970. * Gets the performance counter for active particles
  101971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101972. */
  101973. readonly activeParticlesPerfCounter: PerfCounter;
  101974. /**
  101975. * Gets the total number of active bones rendered per frame
  101976. * @returns the total number of active bones rendered per frame
  101977. */
  101978. getActiveBones(): number;
  101979. /**
  101980. * Gets the performance counter for active bones
  101981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101982. */
  101983. readonly activeBonesPerfCounter: PerfCounter;
  101984. /**
  101985. * Gets the array of active meshes
  101986. * @returns an array of AbstractMesh
  101987. */
  101988. getActiveMeshes(): SmartArray<AbstractMesh>;
  101989. /**
  101990. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101991. * @returns a number
  101992. */
  101993. getAnimationRatio(): number;
  101994. /**
  101995. * Gets an unique Id for the current render phase
  101996. * @returns a number
  101997. */
  101998. getRenderId(): number;
  101999. /**
  102000. * Gets an unique Id for the current frame
  102001. * @returns a number
  102002. */
  102003. getFrameId(): number;
  102004. /** Call this function if you want to manually increment the render Id*/
  102005. incrementRenderId(): void;
  102006. private _createUbo;
  102007. /**
  102008. * Use this method to simulate a pointer move on a mesh
  102009. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102010. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102011. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102012. * @returns the current scene
  102013. */
  102014. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102015. /**
  102016. * Use this method to simulate a pointer down on a mesh
  102017. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102018. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102019. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102020. * @returns the current scene
  102021. */
  102022. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102023. /**
  102024. * Use this method to simulate a pointer up on a mesh
  102025. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102026. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102027. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102028. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102029. * @returns the current scene
  102030. */
  102031. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102032. /**
  102033. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102034. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102035. * @returns true if the pointer was captured
  102036. */
  102037. isPointerCaptured(pointerId?: number): boolean;
  102038. /**
  102039. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102040. * @param attachUp defines if you want to attach events to pointerup
  102041. * @param attachDown defines if you want to attach events to pointerdown
  102042. * @param attachMove defines if you want to attach events to pointermove
  102043. */
  102044. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102045. /** Detaches all event handlers*/
  102046. detachControl(): void;
  102047. /**
  102048. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102049. * Delay loaded resources are not taking in account
  102050. * @return true if all required resources are ready
  102051. */
  102052. isReady(): boolean;
  102053. /** Resets all cached information relative to material (including effect and visibility) */
  102054. resetCachedMaterial(): void;
  102055. /**
  102056. * Registers a function to be called before every frame render
  102057. * @param func defines the function to register
  102058. */
  102059. registerBeforeRender(func: () => void): void;
  102060. /**
  102061. * Unregisters a function called before every frame render
  102062. * @param func defines the function to unregister
  102063. */
  102064. unregisterBeforeRender(func: () => void): void;
  102065. /**
  102066. * Registers a function to be called after every frame render
  102067. * @param func defines the function to register
  102068. */
  102069. registerAfterRender(func: () => void): void;
  102070. /**
  102071. * Unregisters a function called after every frame render
  102072. * @param func defines the function to unregister
  102073. */
  102074. unregisterAfterRender(func: () => void): void;
  102075. private _executeOnceBeforeRender;
  102076. /**
  102077. * The provided function will run before render once and will be disposed afterwards.
  102078. * A timeout delay can be provided so that the function will be executed in N ms.
  102079. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102080. * @param func The function to be executed.
  102081. * @param timeout optional delay in ms
  102082. */
  102083. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102084. /** @hidden */
  102085. _addPendingData(data: any): void;
  102086. /** @hidden */
  102087. _removePendingData(data: any): void;
  102088. /**
  102089. * Returns the number of items waiting to be loaded
  102090. * @returns the number of items waiting to be loaded
  102091. */
  102092. getWaitingItemsCount(): number;
  102093. /**
  102094. * Returns a boolean indicating if the scene is still loading data
  102095. */
  102096. readonly isLoading: boolean;
  102097. /**
  102098. * Registers a function to be executed when the scene is ready
  102099. * @param {Function} func - the function to be executed
  102100. */
  102101. executeWhenReady(func: () => void): void;
  102102. /**
  102103. * Returns a promise that resolves when the scene is ready
  102104. * @returns A promise that resolves when the scene is ready
  102105. */
  102106. whenReadyAsync(): Promise<void>;
  102107. /** @hidden */
  102108. _checkIsReady(): void;
  102109. /**
  102110. * Gets all animatable attached to the scene
  102111. */
  102112. readonly animatables: Animatable[];
  102113. /**
  102114. * Resets the last animation time frame.
  102115. * Useful to override when animations start running when loading a scene for the first time.
  102116. */
  102117. resetLastAnimationTimeFrame(): void;
  102118. /**
  102119. * Gets the current view matrix
  102120. * @returns a Matrix
  102121. */
  102122. getViewMatrix(): Matrix;
  102123. /**
  102124. * Gets the current projection matrix
  102125. * @returns a Matrix
  102126. */
  102127. getProjectionMatrix(): Matrix;
  102128. /**
  102129. * Gets the current transform matrix
  102130. * @returns a Matrix made of View * Projection
  102131. */
  102132. getTransformMatrix(): Matrix;
  102133. /**
  102134. * Sets the current transform matrix
  102135. * @param viewL defines the View matrix to use
  102136. * @param projectionL defines the Projection matrix to use
  102137. * @param viewR defines the right View matrix to use (if provided)
  102138. * @param projectionR defines the right Projection matrix to use (if provided)
  102139. */
  102140. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102141. /**
  102142. * Gets the uniform buffer used to store scene data
  102143. * @returns a UniformBuffer
  102144. */
  102145. getSceneUniformBuffer(): UniformBuffer;
  102146. /**
  102147. * Gets an unique (relatively to the current scene) Id
  102148. * @returns an unique number for the scene
  102149. */
  102150. getUniqueId(): number;
  102151. /**
  102152. * Add a mesh to the list of scene's meshes
  102153. * @param newMesh defines the mesh to add
  102154. * @param recursive if all child meshes should also be added to the scene
  102155. */
  102156. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102157. /**
  102158. * Remove a mesh for the list of scene's meshes
  102159. * @param toRemove defines the mesh to remove
  102160. * @param recursive if all child meshes should also be removed from the scene
  102161. * @returns the index where the mesh was in the mesh list
  102162. */
  102163. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102164. /**
  102165. * Add a transform node to the list of scene's transform nodes
  102166. * @param newTransformNode defines the transform node to add
  102167. */
  102168. addTransformNode(newTransformNode: TransformNode): void;
  102169. /**
  102170. * Remove a transform node for the list of scene's transform nodes
  102171. * @param toRemove defines the transform node to remove
  102172. * @returns the index where the transform node was in the transform node list
  102173. */
  102174. removeTransformNode(toRemove: TransformNode): number;
  102175. /**
  102176. * Remove a skeleton for the list of scene's skeletons
  102177. * @param toRemove defines the skeleton to remove
  102178. * @returns the index where the skeleton was in the skeleton list
  102179. */
  102180. removeSkeleton(toRemove: Skeleton): number;
  102181. /**
  102182. * Remove a morph target for the list of scene's morph targets
  102183. * @param toRemove defines the morph target to remove
  102184. * @returns the index where the morph target was in the morph target list
  102185. */
  102186. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102187. /**
  102188. * Remove a light for the list of scene's lights
  102189. * @param toRemove defines the light to remove
  102190. * @returns the index where the light was in the light list
  102191. */
  102192. removeLight(toRemove: Light): number;
  102193. /**
  102194. * Remove a camera for the list of scene's cameras
  102195. * @param toRemove defines the camera to remove
  102196. * @returns the index where the camera was in the camera list
  102197. */
  102198. removeCamera(toRemove: Camera): number;
  102199. /**
  102200. * Remove a particle system for the list of scene's particle systems
  102201. * @param toRemove defines the particle system to remove
  102202. * @returns the index where the particle system was in the particle system list
  102203. */
  102204. removeParticleSystem(toRemove: IParticleSystem): number;
  102205. /**
  102206. * Remove a animation for the list of scene's animations
  102207. * @param toRemove defines the animation to remove
  102208. * @returns the index where the animation was in the animation list
  102209. */
  102210. removeAnimation(toRemove: Animation): number;
  102211. /**
  102212. * Will stop the animation of the given target
  102213. * @param target - the target
  102214. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102215. * @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)
  102216. */
  102217. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102218. /**
  102219. * Removes the given animation group from this scene.
  102220. * @param toRemove The animation group to remove
  102221. * @returns The index of the removed animation group
  102222. */
  102223. removeAnimationGroup(toRemove: AnimationGroup): number;
  102224. /**
  102225. * Removes the given multi-material from this scene.
  102226. * @param toRemove The multi-material to remove
  102227. * @returns The index of the removed multi-material
  102228. */
  102229. removeMultiMaterial(toRemove: MultiMaterial): number;
  102230. /**
  102231. * Removes the given material from this scene.
  102232. * @param toRemove The material to remove
  102233. * @returns The index of the removed material
  102234. */
  102235. removeMaterial(toRemove: Material): number;
  102236. /**
  102237. * Removes the given action manager from this scene.
  102238. * @param toRemove The action manager to remove
  102239. * @returns The index of the removed action manager
  102240. */
  102241. removeActionManager(toRemove: AbstractActionManager): number;
  102242. /**
  102243. * Removes the given texture from this scene.
  102244. * @param toRemove The texture to remove
  102245. * @returns The index of the removed texture
  102246. */
  102247. removeTexture(toRemove: BaseTexture): number;
  102248. /**
  102249. * Adds the given light to this scene
  102250. * @param newLight The light to add
  102251. */
  102252. addLight(newLight: Light): void;
  102253. /**
  102254. * Sorts the list list based on light priorities
  102255. */
  102256. sortLightsByPriority(): void;
  102257. /**
  102258. * Adds the given camera to this scene
  102259. * @param newCamera The camera to add
  102260. */
  102261. addCamera(newCamera: Camera): void;
  102262. /**
  102263. * Adds the given skeleton to this scene
  102264. * @param newSkeleton The skeleton to add
  102265. */
  102266. addSkeleton(newSkeleton: Skeleton): void;
  102267. /**
  102268. * Adds the given particle system to this scene
  102269. * @param newParticleSystem The particle system to add
  102270. */
  102271. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102272. /**
  102273. * Adds the given animation to this scene
  102274. * @param newAnimation The animation to add
  102275. */
  102276. addAnimation(newAnimation: Animation): void;
  102277. /**
  102278. * Adds the given animation group to this scene.
  102279. * @param newAnimationGroup The animation group to add
  102280. */
  102281. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102282. /**
  102283. * Adds the given multi-material to this scene
  102284. * @param newMultiMaterial The multi-material to add
  102285. */
  102286. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102287. /**
  102288. * Adds the given material to this scene
  102289. * @param newMaterial The material to add
  102290. */
  102291. addMaterial(newMaterial: Material): void;
  102292. /**
  102293. * Adds the given morph target to this scene
  102294. * @param newMorphTargetManager The morph target to add
  102295. */
  102296. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102297. /**
  102298. * Adds the given geometry to this scene
  102299. * @param newGeometry The geometry to add
  102300. */
  102301. addGeometry(newGeometry: Geometry): void;
  102302. /**
  102303. * Adds the given action manager to this scene
  102304. * @param newActionManager The action manager to add
  102305. */
  102306. addActionManager(newActionManager: AbstractActionManager): void;
  102307. /**
  102308. * Adds the given texture to this scene.
  102309. * @param newTexture The texture to add
  102310. */
  102311. addTexture(newTexture: BaseTexture): void;
  102312. /**
  102313. * Switch active camera
  102314. * @param newCamera defines the new active camera
  102315. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102316. */
  102317. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102318. /**
  102319. * sets the active camera of the scene using its ID
  102320. * @param id defines the camera's ID
  102321. * @return the new active camera or null if none found.
  102322. */
  102323. setActiveCameraByID(id: string): Nullable<Camera>;
  102324. /**
  102325. * sets the active camera of the scene using its name
  102326. * @param name defines the camera's name
  102327. * @returns the new active camera or null if none found.
  102328. */
  102329. setActiveCameraByName(name: string): Nullable<Camera>;
  102330. /**
  102331. * get an animation group using its name
  102332. * @param name defines the material's name
  102333. * @return the animation group or null if none found.
  102334. */
  102335. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102336. /**
  102337. * Get a material using its unique id
  102338. * @param uniqueId defines the material's unique id
  102339. * @return the material or null if none found.
  102340. */
  102341. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102342. /**
  102343. * get a material using its id
  102344. * @param id defines the material's ID
  102345. * @return the material or null if none found.
  102346. */
  102347. getMaterialByID(id: string): Nullable<Material>;
  102348. /**
  102349. * Gets a the last added material using a given id
  102350. * @param id defines the material's ID
  102351. * @return the last material with the given id or null if none found.
  102352. */
  102353. getLastMaterialByID(id: string): Nullable<Material>;
  102354. /**
  102355. * Gets a material using its name
  102356. * @param name defines the material's name
  102357. * @return the material or null if none found.
  102358. */
  102359. getMaterialByName(name: string): Nullable<Material>;
  102360. /**
  102361. * Get a texture using its unique id
  102362. * @param uniqueId defines the texture's unique id
  102363. * @return the texture or null if none found.
  102364. */
  102365. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102366. /**
  102367. * Gets a camera using its id
  102368. * @param id defines the id to look for
  102369. * @returns the camera or null if not found
  102370. */
  102371. getCameraByID(id: string): Nullable<Camera>;
  102372. /**
  102373. * Gets a camera using its unique id
  102374. * @param uniqueId defines the unique id to look for
  102375. * @returns the camera or null if not found
  102376. */
  102377. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102378. /**
  102379. * Gets a camera using its name
  102380. * @param name defines the camera's name
  102381. * @return the camera or null if none found.
  102382. */
  102383. getCameraByName(name: string): Nullable<Camera>;
  102384. /**
  102385. * Gets a bone using its id
  102386. * @param id defines the bone's id
  102387. * @return the bone or null if not found
  102388. */
  102389. getBoneByID(id: string): Nullable<Bone>;
  102390. /**
  102391. * Gets a bone using its id
  102392. * @param name defines the bone's name
  102393. * @return the bone or null if not found
  102394. */
  102395. getBoneByName(name: string): Nullable<Bone>;
  102396. /**
  102397. * Gets a light node using its name
  102398. * @param name defines the the light's name
  102399. * @return the light or null if none found.
  102400. */
  102401. getLightByName(name: string): Nullable<Light>;
  102402. /**
  102403. * Gets a light node using its id
  102404. * @param id defines the light's id
  102405. * @return the light or null if none found.
  102406. */
  102407. getLightByID(id: string): Nullable<Light>;
  102408. /**
  102409. * Gets a light node using its scene-generated unique ID
  102410. * @param uniqueId defines the light's unique id
  102411. * @return the light or null if none found.
  102412. */
  102413. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102414. /**
  102415. * Gets a particle system by id
  102416. * @param id defines the particle system id
  102417. * @return the corresponding system or null if none found
  102418. */
  102419. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102420. /**
  102421. * Gets a geometry using its ID
  102422. * @param id defines the geometry's id
  102423. * @return the geometry or null if none found.
  102424. */
  102425. getGeometryByID(id: string): Nullable<Geometry>;
  102426. private _getGeometryByUniqueID;
  102427. /**
  102428. * Add a new geometry to this scene
  102429. * @param geometry defines the geometry to be added to the scene.
  102430. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102431. * @return a boolean defining if the geometry was added or not
  102432. */
  102433. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102434. /**
  102435. * Removes an existing geometry
  102436. * @param geometry defines the geometry to be removed from the scene
  102437. * @return a boolean defining if the geometry was removed or not
  102438. */
  102439. removeGeometry(geometry: Geometry): boolean;
  102440. /**
  102441. * Gets the list of geometries attached to the scene
  102442. * @returns an array of Geometry
  102443. */
  102444. getGeometries(): Geometry[];
  102445. /**
  102446. * Gets the first added mesh found of a given ID
  102447. * @param id defines the id to search for
  102448. * @return the mesh found or null if not found at all
  102449. */
  102450. getMeshByID(id: string): Nullable<AbstractMesh>;
  102451. /**
  102452. * Gets a list of meshes using their id
  102453. * @param id defines the id to search for
  102454. * @returns a list of meshes
  102455. */
  102456. getMeshesByID(id: string): Array<AbstractMesh>;
  102457. /**
  102458. * Gets the first added transform node found of a given ID
  102459. * @param id defines the id to search for
  102460. * @return the found transform node or null if not found at all.
  102461. */
  102462. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102463. /**
  102464. * Gets a transform node with its auto-generated unique id
  102465. * @param uniqueId efines the unique id to search for
  102466. * @return the found transform node or null if not found at all.
  102467. */
  102468. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102469. /**
  102470. * Gets a list of transform nodes using their id
  102471. * @param id defines the id to search for
  102472. * @returns a list of transform nodes
  102473. */
  102474. getTransformNodesByID(id: string): Array<TransformNode>;
  102475. /**
  102476. * Gets a mesh with its auto-generated unique id
  102477. * @param uniqueId defines the unique id to search for
  102478. * @return the found mesh or null if not found at all.
  102479. */
  102480. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  102481. /**
  102482. * Gets a the last added mesh using a given id
  102483. * @param id defines the id to search for
  102484. * @return the found mesh or null if not found at all.
  102485. */
  102486. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  102487. /**
  102488. * Gets a the last added node (Mesh, Camera, Light) using a given id
  102489. * @param id defines the id to search for
  102490. * @return the found node or null if not found at all
  102491. */
  102492. getLastEntryByID(id: string): Nullable<Node>;
  102493. /**
  102494. * Gets a node (Mesh, Camera, Light) using a given id
  102495. * @param id defines the id to search for
  102496. * @return the found node or null if not found at all
  102497. */
  102498. getNodeByID(id: string): Nullable<Node>;
  102499. /**
  102500. * Gets a node (Mesh, Camera, Light) using a given name
  102501. * @param name defines the name to search for
  102502. * @return the found node or null if not found at all.
  102503. */
  102504. getNodeByName(name: string): Nullable<Node>;
  102505. /**
  102506. * Gets a mesh using a given name
  102507. * @param name defines the name to search for
  102508. * @return the found mesh or null if not found at all.
  102509. */
  102510. getMeshByName(name: string): Nullable<AbstractMesh>;
  102511. /**
  102512. * Gets a transform node using a given name
  102513. * @param name defines the name to search for
  102514. * @return the found transform node or null if not found at all.
  102515. */
  102516. getTransformNodeByName(name: string): Nullable<TransformNode>;
  102517. /**
  102518. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  102519. * @param id defines the id to search for
  102520. * @return the found skeleton or null if not found at all.
  102521. */
  102522. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  102523. /**
  102524. * Gets a skeleton using a given auto generated unique id
  102525. * @param uniqueId defines the unique id to search for
  102526. * @return the found skeleton or null if not found at all.
  102527. */
  102528. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  102529. /**
  102530. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  102531. * @param id defines the id to search for
  102532. * @return the found skeleton or null if not found at all.
  102533. */
  102534. getSkeletonById(id: string): Nullable<Skeleton>;
  102535. /**
  102536. * Gets a skeleton using a given name
  102537. * @param name defines the name to search for
  102538. * @return the found skeleton or null if not found at all.
  102539. */
  102540. getSkeletonByName(name: string): Nullable<Skeleton>;
  102541. /**
  102542. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  102543. * @param id defines the id to search for
  102544. * @return the found morph target manager or null if not found at all.
  102545. */
  102546. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  102547. /**
  102548. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  102549. * @param id defines the id to search for
  102550. * @return the found morph target or null if not found at all.
  102551. */
  102552. getMorphTargetById(id: string): Nullable<MorphTarget>;
  102553. /**
  102554. * Gets a boolean indicating if the given mesh is active
  102555. * @param mesh defines the mesh to look for
  102556. * @returns true if the mesh is in the active list
  102557. */
  102558. isActiveMesh(mesh: AbstractMesh): boolean;
  102559. /**
  102560. * Return a unique id as a string which can serve as an identifier for the scene
  102561. */
  102562. readonly uid: string;
  102563. /**
  102564. * Add an externaly attached data from its key.
  102565. * This method call will fail and return false, if such key already exists.
  102566. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102567. * @param key the unique key that identifies the data
  102568. * @param data the data object to associate to the key for this Engine instance
  102569. * @return true if no such key were already present and the data was added successfully, false otherwise
  102570. */
  102571. addExternalData<T>(key: string, data: T): boolean;
  102572. /**
  102573. * Get an externaly attached data from its key
  102574. * @param key the unique key that identifies the data
  102575. * @return the associated data, if present (can be null), or undefined if not present
  102576. */
  102577. getExternalData<T>(key: string): Nullable<T>;
  102578. /**
  102579. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102580. * @param key the unique key that identifies the data
  102581. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102582. * @return the associated data, can be null if the factory returned null.
  102583. */
  102584. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102585. /**
  102586. * Remove an externaly attached data from the Engine instance
  102587. * @param key the unique key that identifies the data
  102588. * @return true if the data was successfully removed, false if it doesn't exist
  102589. */
  102590. removeExternalData(key: string): boolean;
  102591. private _evaluateSubMesh;
  102592. /**
  102593. * Clear the processed materials smart array preventing retention point in material dispose.
  102594. */
  102595. freeProcessedMaterials(): void;
  102596. private _preventFreeActiveMeshesAndRenderingGroups;
  102597. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102598. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102599. * when disposing several meshes in a row or a hierarchy of meshes.
  102600. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102601. */
  102602. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102603. /**
  102604. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102605. */
  102606. freeActiveMeshes(): void;
  102607. /**
  102608. * Clear the info related to rendering groups preventing retention points during dispose.
  102609. */
  102610. freeRenderingGroups(): void;
  102611. /** @hidden */
  102612. _isInIntermediateRendering(): boolean;
  102613. /**
  102614. * Lambda returning the list of potentially active meshes.
  102615. */
  102616. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102617. /**
  102618. * Lambda returning the list of potentially active sub meshes.
  102619. */
  102620. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102621. /**
  102622. * Lambda returning the list of potentially intersecting sub meshes.
  102623. */
  102624. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102625. /**
  102626. * Lambda returning the list of potentially colliding sub meshes.
  102627. */
  102628. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102629. private _activeMeshesFrozen;
  102630. /**
  102631. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102632. * @returns the current scene
  102633. */
  102634. freezeActiveMeshes(): Scene;
  102635. /**
  102636. * Use this function to restart evaluating active meshes on every frame
  102637. * @returns the current scene
  102638. */
  102639. unfreezeActiveMeshes(): Scene;
  102640. private _evaluateActiveMeshes;
  102641. private _activeMesh;
  102642. /**
  102643. * Update the transform matrix to update from the current active camera
  102644. * @param force defines a boolean used to force the update even if cache is up to date
  102645. */
  102646. updateTransformMatrix(force?: boolean): void;
  102647. private _bindFrameBuffer;
  102648. /** @hidden */
  102649. _allowPostProcessClearColor: boolean;
  102650. /** @hidden */
  102651. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102652. private _processSubCameras;
  102653. private _checkIntersections;
  102654. /** @hidden */
  102655. _advancePhysicsEngineStep(step: number): void;
  102656. /**
  102657. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102658. */
  102659. getDeterministicFrameTime: () => number;
  102660. /** @hidden */
  102661. _animate(): void;
  102662. /** Execute all animations (for a frame) */
  102663. animate(): void;
  102664. /**
  102665. * Render the scene
  102666. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102667. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102668. */
  102669. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102670. /**
  102671. * Freeze all materials
  102672. * A frozen material will not be updatable but should be faster to render
  102673. */
  102674. freezeMaterials(): void;
  102675. /**
  102676. * Unfreeze all materials
  102677. * A frozen material will not be updatable but should be faster to render
  102678. */
  102679. unfreezeMaterials(): void;
  102680. /**
  102681. * Releases all held ressources
  102682. */
  102683. dispose(): void;
  102684. /**
  102685. * Gets if the scene is already disposed
  102686. */
  102687. readonly isDisposed: boolean;
  102688. /**
  102689. * Call this function to reduce memory footprint of the scene.
  102690. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102691. */
  102692. clearCachedVertexData(): void;
  102693. /**
  102694. * This function will remove the local cached buffer data from texture.
  102695. * It will save memory but will prevent the texture from being rebuilt
  102696. */
  102697. cleanCachedTextureBuffer(): void;
  102698. /**
  102699. * Get the world extend vectors with an optional filter
  102700. *
  102701. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102702. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102703. */
  102704. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102705. min: Vector3;
  102706. max: Vector3;
  102707. };
  102708. /**
  102709. * Creates a ray that can be used to pick in the scene
  102710. * @param x defines the x coordinate of the origin (on-screen)
  102711. * @param y defines the y coordinate of the origin (on-screen)
  102712. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102713. * @param camera defines the camera to use for the picking
  102714. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102715. * @returns a Ray
  102716. */
  102717. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102718. /**
  102719. * Creates a ray that can be used to pick in the scene
  102720. * @param x defines the x coordinate of the origin (on-screen)
  102721. * @param y defines the y coordinate of the origin (on-screen)
  102722. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102723. * @param result defines the ray where to store the picking ray
  102724. * @param camera defines the camera to use for the picking
  102725. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102726. * @returns the current scene
  102727. */
  102728. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102729. /**
  102730. * Creates a ray that can be used to pick in the scene
  102731. * @param x defines the x coordinate of the origin (on-screen)
  102732. * @param y defines the y coordinate of the origin (on-screen)
  102733. * @param camera defines the camera to use for the picking
  102734. * @returns a Ray
  102735. */
  102736. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102737. /**
  102738. * Creates a ray that can be used to pick in the scene
  102739. * @param x defines the x coordinate of the origin (on-screen)
  102740. * @param y defines the y coordinate of the origin (on-screen)
  102741. * @param result defines the ray where to store the picking ray
  102742. * @param camera defines the camera to use for the picking
  102743. * @returns the current scene
  102744. */
  102745. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102746. /** Launch a ray to try to pick a mesh in the scene
  102747. * @param x position on screen
  102748. * @param y position on screen
  102749. * @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
  102750. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  102751. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102752. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102753. * @returns a PickingInfo
  102754. */
  102755. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102756. /** Use the given ray to pick a mesh in the scene
  102757. * @param ray The ray to use to pick meshes
  102758. * @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
  102759. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  102760. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102761. * @returns a PickingInfo
  102762. */
  102763. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102764. /**
  102765. * Launch a ray to try to pick a mesh in the scene
  102766. * @param x X position on screen
  102767. * @param y Y position on screen
  102768. * @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
  102769. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102770. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102771. * @returns an array of PickingInfo
  102772. */
  102773. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102774. /**
  102775. * Launch a ray to try to pick a mesh in the scene
  102776. * @param ray Ray to use
  102777. * @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
  102778. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102779. * @returns an array of PickingInfo
  102780. */
  102781. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102782. /**
  102783. * Force the value of meshUnderPointer
  102784. * @param mesh defines the mesh to use
  102785. */
  102786. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  102787. /**
  102788. * Gets the mesh under the pointer
  102789. * @returns a Mesh or null if no mesh is under the pointer
  102790. */
  102791. getPointerOverMesh(): Nullable<AbstractMesh>;
  102792. /** @hidden */
  102793. _rebuildGeometries(): void;
  102794. /** @hidden */
  102795. _rebuildTextures(): void;
  102796. private _getByTags;
  102797. /**
  102798. * Get a list of meshes by tags
  102799. * @param tagsQuery defines the tags query to use
  102800. * @param forEach defines a predicate used to filter results
  102801. * @returns an array of Mesh
  102802. */
  102803. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  102804. /**
  102805. * Get a list of cameras by tags
  102806. * @param tagsQuery defines the tags query to use
  102807. * @param forEach defines a predicate used to filter results
  102808. * @returns an array of Camera
  102809. */
  102810. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  102811. /**
  102812. * Get a list of lights by tags
  102813. * @param tagsQuery defines the tags query to use
  102814. * @param forEach defines a predicate used to filter results
  102815. * @returns an array of Light
  102816. */
  102817. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  102818. /**
  102819. * Get a list of materials by tags
  102820. * @param tagsQuery defines the tags query to use
  102821. * @param forEach defines a predicate used to filter results
  102822. * @returns an array of Material
  102823. */
  102824. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  102825. /**
  102826. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102827. * This allowed control for front to back rendering or reversly depending of the special needs.
  102828. *
  102829. * @param renderingGroupId The rendering group id corresponding to its index
  102830. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102831. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102832. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102833. */
  102834. 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;
  102835. /**
  102836. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102837. *
  102838. * @param renderingGroupId The rendering group id corresponding to its index
  102839. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102840. * @param depth Automatically clears depth between groups if true and autoClear is true.
  102841. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  102842. */
  102843. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  102844. /**
  102845. * Gets the current auto clear configuration for one rendering group of the rendering
  102846. * manager.
  102847. * @param index the rendering group index to get the information for
  102848. * @returns The auto clear setup for the requested rendering group
  102849. */
  102850. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  102851. private _blockMaterialDirtyMechanism;
  102852. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  102853. blockMaterialDirtyMechanism: boolean;
  102854. /**
  102855. * Will flag all materials as dirty to trigger new shader compilation
  102856. * @param flag defines the flag used to specify which material part must be marked as dirty
  102857. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  102858. */
  102859. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102860. /** @hidden */
  102861. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  102862. /** @hidden */
  102863. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102864. /** @hidden */
  102865. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  102866. /** @hidden */
  102867. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  102868. /** @hidden */
  102869. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102870. /** @hidden */
  102871. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102872. }
  102873. }
  102874. declare module BABYLON {
  102875. /**
  102876. * Set of assets to keep when moving a scene into an asset container.
  102877. */
  102878. export class KeepAssets extends AbstractScene {
  102879. }
  102880. /**
  102881. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  102882. */
  102883. export class InstantiatedEntries {
  102884. /**
  102885. * List of new root nodes (eg. nodes with no parent)
  102886. */
  102887. rootNodes: TransformNode[];
  102888. /**
  102889. * List of new skeletons
  102890. */
  102891. skeletons: Skeleton[];
  102892. /**
  102893. * List of new animation groups
  102894. */
  102895. animationGroups: AnimationGroup[];
  102896. }
  102897. /**
  102898. * Container with a set of assets that can be added or removed from a scene.
  102899. */
  102900. export class AssetContainer extends AbstractScene {
  102901. /**
  102902. * The scene the AssetContainer belongs to.
  102903. */
  102904. scene: Scene;
  102905. /**
  102906. * Instantiates an AssetContainer.
  102907. * @param scene The scene the AssetContainer belongs to.
  102908. */
  102909. constructor(scene: Scene);
  102910. /**
  102911. * Instantiate or clone all meshes and add the new ones to the scene.
  102912. * Skeletons and animation groups will all be cloned
  102913. * @param nameFunction defines an optional function used to get new names for clones
  102914. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  102915. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  102916. */
  102917. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  102918. /**
  102919. * Adds all the assets from the container to the scene.
  102920. */
  102921. addAllToScene(): void;
  102922. /**
  102923. * Removes all the assets in the container from the scene
  102924. */
  102925. removeAllFromScene(): void;
  102926. /**
  102927. * Disposes all the assets in the container
  102928. */
  102929. dispose(): void;
  102930. private _moveAssets;
  102931. /**
  102932. * Removes all the assets contained in the scene and adds them to the container.
  102933. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102934. */
  102935. moveAllFromScene(keepAssets?: KeepAssets): void;
  102936. /**
  102937. * 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.
  102938. * @returns the root mesh
  102939. */
  102940. createRootMesh(): Mesh;
  102941. }
  102942. }
  102943. declare module BABYLON {
  102944. /**
  102945. * Defines how the parser contract is defined.
  102946. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102947. */
  102948. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102949. /**
  102950. * Defines how the individual parser contract is defined.
  102951. * These parser can parse an individual asset
  102952. */
  102953. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102954. /**
  102955. * Base class of the scene acting as a container for the different elements composing a scene.
  102956. * This class is dynamically extended by the different components of the scene increasing
  102957. * flexibility and reducing coupling
  102958. */
  102959. export abstract class AbstractScene {
  102960. /**
  102961. * Stores the list of available parsers in the application.
  102962. */
  102963. private static _BabylonFileParsers;
  102964. /**
  102965. * Stores the list of available individual parsers in the application.
  102966. */
  102967. private static _IndividualBabylonFileParsers;
  102968. /**
  102969. * Adds a parser in the list of available ones
  102970. * @param name Defines the name of the parser
  102971. * @param parser Defines the parser to add
  102972. */
  102973. static AddParser(name: string, parser: BabylonFileParser): void;
  102974. /**
  102975. * Gets a general parser from the list of avaialble ones
  102976. * @param name Defines the name of the parser
  102977. * @returns the requested parser or null
  102978. */
  102979. static GetParser(name: string): Nullable<BabylonFileParser>;
  102980. /**
  102981. * Adds n individual parser in the list of available ones
  102982. * @param name Defines the name of the parser
  102983. * @param parser Defines the parser to add
  102984. */
  102985. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102986. /**
  102987. * Gets an individual parser from the list of avaialble ones
  102988. * @param name Defines the name of the parser
  102989. * @returns the requested parser or null
  102990. */
  102991. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102992. /**
  102993. * Parser json data and populate both a scene and its associated container object
  102994. * @param jsonData Defines the data to parse
  102995. * @param scene Defines the scene to parse the data for
  102996. * @param container Defines the container attached to the parsing sequence
  102997. * @param rootUrl Defines the root url of the data
  102998. */
  102999. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103000. /**
  103001. * Gets the list of root nodes (ie. nodes with no parent)
  103002. */
  103003. rootNodes: Node[];
  103004. /** All of the cameras added to this scene
  103005. * @see http://doc.babylonjs.com/babylon101/cameras
  103006. */
  103007. cameras: Camera[];
  103008. /**
  103009. * All of the lights added to this scene
  103010. * @see http://doc.babylonjs.com/babylon101/lights
  103011. */
  103012. lights: Light[];
  103013. /**
  103014. * All of the (abstract) meshes added to this scene
  103015. */
  103016. meshes: AbstractMesh[];
  103017. /**
  103018. * The list of skeletons added to the scene
  103019. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103020. */
  103021. skeletons: Skeleton[];
  103022. /**
  103023. * All of the particle systems added to this scene
  103024. * @see http://doc.babylonjs.com/babylon101/particles
  103025. */
  103026. particleSystems: IParticleSystem[];
  103027. /**
  103028. * Gets a list of Animations associated with the scene
  103029. */
  103030. animations: Animation[];
  103031. /**
  103032. * All of the animation groups added to this scene
  103033. * @see http://doc.babylonjs.com/how_to/group
  103034. */
  103035. animationGroups: AnimationGroup[];
  103036. /**
  103037. * All of the multi-materials added to this scene
  103038. * @see http://doc.babylonjs.com/how_to/multi_materials
  103039. */
  103040. multiMaterials: MultiMaterial[];
  103041. /**
  103042. * All of the materials added to this scene
  103043. * In the context of a Scene, it is not supposed to be modified manually.
  103044. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103045. * Note also that the order of the Material within the array is not significant and might change.
  103046. * @see http://doc.babylonjs.com/babylon101/materials
  103047. */
  103048. materials: Material[];
  103049. /**
  103050. * The list of morph target managers added to the scene
  103051. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103052. */
  103053. morphTargetManagers: MorphTargetManager[];
  103054. /**
  103055. * The list of geometries used in the scene.
  103056. */
  103057. geometries: Geometry[];
  103058. /**
  103059. * All of the tranform nodes added to this scene
  103060. * In the context of a Scene, it is not supposed to be modified manually.
  103061. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103062. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103063. * @see http://doc.babylonjs.com/how_to/transformnode
  103064. */
  103065. transformNodes: TransformNode[];
  103066. /**
  103067. * ActionManagers available on the scene.
  103068. */
  103069. actionManagers: AbstractActionManager[];
  103070. /**
  103071. * Textures to keep.
  103072. */
  103073. textures: BaseTexture[];
  103074. /**
  103075. * Environment texture for the scene
  103076. */
  103077. environmentTexture: Nullable<BaseTexture>;
  103078. }
  103079. }
  103080. declare module BABYLON {
  103081. /**
  103082. * Interface used to define options for Sound class
  103083. */
  103084. export interface ISoundOptions {
  103085. /**
  103086. * Does the sound autoplay once loaded.
  103087. */
  103088. autoplay?: boolean;
  103089. /**
  103090. * Does the sound loop after it finishes playing once.
  103091. */
  103092. loop?: boolean;
  103093. /**
  103094. * Sound's volume
  103095. */
  103096. volume?: number;
  103097. /**
  103098. * Is it a spatial sound?
  103099. */
  103100. spatialSound?: boolean;
  103101. /**
  103102. * Maximum distance to hear that sound
  103103. */
  103104. maxDistance?: number;
  103105. /**
  103106. * Uses user defined attenuation function
  103107. */
  103108. useCustomAttenuation?: boolean;
  103109. /**
  103110. * Define the roll off factor of spatial sounds.
  103111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103112. */
  103113. rolloffFactor?: number;
  103114. /**
  103115. * Define the reference distance the sound should be heard perfectly.
  103116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103117. */
  103118. refDistance?: number;
  103119. /**
  103120. * Define the distance attenuation model the sound will follow.
  103121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103122. */
  103123. distanceModel?: string;
  103124. /**
  103125. * Defines the playback speed (1 by default)
  103126. */
  103127. playbackRate?: number;
  103128. /**
  103129. * Defines if the sound is from a streaming source
  103130. */
  103131. streaming?: boolean;
  103132. /**
  103133. * Defines an optional length (in seconds) inside the sound file
  103134. */
  103135. length?: number;
  103136. /**
  103137. * Defines an optional offset (in seconds) inside the sound file
  103138. */
  103139. offset?: number;
  103140. /**
  103141. * If true, URLs will not be required to state the audio file codec to use.
  103142. */
  103143. skipCodecCheck?: boolean;
  103144. }
  103145. /**
  103146. * Defines a sound that can be played in the application.
  103147. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103149. */
  103150. export class Sound {
  103151. /**
  103152. * The name of the sound in the scene.
  103153. */
  103154. name: string;
  103155. /**
  103156. * Does the sound autoplay once loaded.
  103157. */
  103158. autoplay: boolean;
  103159. /**
  103160. * Does the sound loop after it finishes playing once.
  103161. */
  103162. loop: boolean;
  103163. /**
  103164. * Does the sound use a custom attenuation curve to simulate the falloff
  103165. * happening when the source gets further away from the camera.
  103166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103167. */
  103168. useCustomAttenuation: boolean;
  103169. /**
  103170. * The sound track id this sound belongs to.
  103171. */
  103172. soundTrackId: number;
  103173. /**
  103174. * Is this sound currently played.
  103175. */
  103176. isPlaying: boolean;
  103177. /**
  103178. * Is this sound currently paused.
  103179. */
  103180. isPaused: boolean;
  103181. /**
  103182. * Does this sound enables spatial sound.
  103183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103184. */
  103185. spatialSound: boolean;
  103186. /**
  103187. * Define the reference distance the sound should be heard perfectly.
  103188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103189. */
  103190. refDistance: number;
  103191. /**
  103192. * Define the roll off factor of spatial sounds.
  103193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103194. */
  103195. rolloffFactor: number;
  103196. /**
  103197. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103199. */
  103200. maxDistance: number;
  103201. /**
  103202. * Define the distance attenuation model the sound will follow.
  103203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103204. */
  103205. distanceModel: string;
  103206. /**
  103207. * @hidden
  103208. * Back Compat
  103209. **/
  103210. onended: () => any;
  103211. /**
  103212. * Observable event when the current playing sound finishes.
  103213. */
  103214. onEndedObservable: Observable<Sound>;
  103215. private _panningModel;
  103216. private _playbackRate;
  103217. private _streaming;
  103218. private _startTime;
  103219. private _startOffset;
  103220. private _position;
  103221. /** @hidden */
  103222. _positionInEmitterSpace: boolean;
  103223. private _localDirection;
  103224. private _volume;
  103225. private _isReadyToPlay;
  103226. private _isDirectional;
  103227. private _readyToPlayCallback;
  103228. private _audioBuffer;
  103229. private _soundSource;
  103230. private _streamingSource;
  103231. private _soundPanner;
  103232. private _soundGain;
  103233. private _inputAudioNode;
  103234. private _outputAudioNode;
  103235. private _coneInnerAngle;
  103236. private _coneOuterAngle;
  103237. private _coneOuterGain;
  103238. private _scene;
  103239. private _connectedTransformNode;
  103240. private _customAttenuationFunction;
  103241. private _registerFunc;
  103242. private _isOutputConnected;
  103243. private _htmlAudioElement;
  103244. private _urlType;
  103245. private _length?;
  103246. private _offset?;
  103247. /** @hidden */
  103248. static _SceneComponentInitialization: (scene: Scene) => void;
  103249. /**
  103250. * Create a sound and attach it to a scene
  103251. * @param name Name of your sound
  103252. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103253. * @param scene defines the scene the sound belongs to
  103254. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103255. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103256. */
  103257. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103258. /**
  103259. * Release the sound and its associated resources
  103260. */
  103261. dispose(): void;
  103262. /**
  103263. * Gets if the sounds is ready to be played or not.
  103264. * @returns true if ready, otherwise false
  103265. */
  103266. isReady(): boolean;
  103267. private _soundLoaded;
  103268. /**
  103269. * Sets the data of the sound from an audiobuffer
  103270. * @param audioBuffer The audioBuffer containing the data
  103271. */
  103272. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103273. /**
  103274. * Updates the current sounds options such as maxdistance, loop...
  103275. * @param options A JSON object containing values named as the object properties
  103276. */
  103277. updateOptions(options: ISoundOptions): void;
  103278. private _createSpatialParameters;
  103279. private _updateSpatialParameters;
  103280. /**
  103281. * Switch the panning model to HRTF:
  103282. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103284. */
  103285. switchPanningModelToHRTF(): void;
  103286. /**
  103287. * Switch the panning model to Equal Power:
  103288. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103290. */
  103291. switchPanningModelToEqualPower(): void;
  103292. private _switchPanningModel;
  103293. /**
  103294. * Connect this sound to a sound track audio node like gain...
  103295. * @param soundTrackAudioNode the sound track audio node to connect to
  103296. */
  103297. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103298. /**
  103299. * Transform this sound into a directional source
  103300. * @param coneInnerAngle Size of the inner cone in degree
  103301. * @param coneOuterAngle Size of the outer cone in degree
  103302. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103303. */
  103304. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103305. /**
  103306. * Gets or sets the inner angle for the directional cone.
  103307. */
  103308. /**
  103309. * Gets or sets the inner angle for the directional cone.
  103310. */
  103311. directionalConeInnerAngle: number;
  103312. /**
  103313. * Gets or sets the outer angle for the directional cone.
  103314. */
  103315. /**
  103316. * Gets or sets the outer angle for the directional cone.
  103317. */
  103318. directionalConeOuterAngle: number;
  103319. /**
  103320. * Sets the position of the emitter if spatial sound is enabled
  103321. * @param newPosition Defines the new posisiton
  103322. */
  103323. setPosition(newPosition: Vector3): void;
  103324. /**
  103325. * Sets the local direction of the emitter if spatial sound is enabled
  103326. * @param newLocalDirection Defines the new local direction
  103327. */
  103328. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103329. private _updateDirection;
  103330. /** @hidden */
  103331. updateDistanceFromListener(): void;
  103332. /**
  103333. * Sets a new custom attenuation function for the sound.
  103334. * @param callback Defines the function used for the attenuation
  103335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103336. */
  103337. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103338. /**
  103339. * Play the sound
  103340. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103341. * @param offset (optional) Start the sound at a specific time in seconds
  103342. * @param length (optional) Sound duration (in seconds)
  103343. */
  103344. play(time?: number, offset?: number, length?: number): void;
  103345. private _onended;
  103346. /**
  103347. * Stop the sound
  103348. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103349. */
  103350. stop(time?: number): void;
  103351. /**
  103352. * Put the sound in pause
  103353. */
  103354. pause(): void;
  103355. /**
  103356. * Sets a dedicated volume for this sounds
  103357. * @param newVolume Define the new volume of the sound
  103358. * @param time Define time for gradual change to new volume
  103359. */
  103360. setVolume(newVolume: number, time?: number): void;
  103361. /**
  103362. * Set the sound play back rate
  103363. * @param newPlaybackRate Define the playback rate the sound should be played at
  103364. */
  103365. setPlaybackRate(newPlaybackRate: number): void;
  103366. /**
  103367. * Gets the volume of the sound.
  103368. * @returns the volume of the sound
  103369. */
  103370. getVolume(): number;
  103371. /**
  103372. * Attach the sound to a dedicated mesh
  103373. * @param transformNode The transform node to connect the sound with
  103374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103375. */
  103376. attachToMesh(transformNode: TransformNode): void;
  103377. /**
  103378. * Detach the sound from the previously attached mesh
  103379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103380. */
  103381. detachFromMesh(): void;
  103382. private _onRegisterAfterWorldMatrixUpdate;
  103383. /**
  103384. * Clone the current sound in the scene.
  103385. * @returns the new sound clone
  103386. */
  103387. clone(): Nullable<Sound>;
  103388. /**
  103389. * Gets the current underlying audio buffer containing the data
  103390. * @returns the audio buffer
  103391. */
  103392. getAudioBuffer(): Nullable<AudioBuffer>;
  103393. /**
  103394. * Serializes the Sound in a JSON representation
  103395. * @returns the JSON representation of the sound
  103396. */
  103397. serialize(): any;
  103398. /**
  103399. * Parse a JSON representation of a sound to innstantiate in a given scene
  103400. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103401. * @param scene Define the scene the new parsed sound should be created in
  103402. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103403. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103404. * @returns the newly parsed sound
  103405. */
  103406. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103407. }
  103408. }
  103409. declare module BABYLON {
  103410. /**
  103411. * This defines an action helpful to play a defined sound on a triggered action.
  103412. */
  103413. export class PlaySoundAction extends Action {
  103414. private _sound;
  103415. /**
  103416. * Instantiate the action
  103417. * @param triggerOptions defines the trigger options
  103418. * @param sound defines the sound to play
  103419. * @param condition defines the trigger related conditions
  103420. */
  103421. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103422. /** @hidden */
  103423. _prepare(): void;
  103424. /**
  103425. * Execute the action and play the sound.
  103426. */
  103427. execute(): void;
  103428. /**
  103429. * Serializes the actions and its related information.
  103430. * @param parent defines the object to serialize in
  103431. * @returns the serialized object
  103432. */
  103433. serialize(parent: any): any;
  103434. }
  103435. /**
  103436. * This defines an action helpful to stop a defined sound on a triggered action.
  103437. */
  103438. export class StopSoundAction extends Action {
  103439. private _sound;
  103440. /**
  103441. * Instantiate the action
  103442. * @param triggerOptions defines the trigger options
  103443. * @param sound defines the sound to stop
  103444. * @param condition defines the trigger related conditions
  103445. */
  103446. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103447. /** @hidden */
  103448. _prepare(): void;
  103449. /**
  103450. * Execute the action and stop the sound.
  103451. */
  103452. execute(): void;
  103453. /**
  103454. * Serializes the actions and its related information.
  103455. * @param parent defines the object to serialize in
  103456. * @returns the serialized object
  103457. */
  103458. serialize(parent: any): any;
  103459. }
  103460. }
  103461. declare module BABYLON {
  103462. /**
  103463. * This defines an action responsible to change the value of a property
  103464. * by interpolating between its current value and the newly set one once triggered.
  103465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103466. */
  103467. export class InterpolateValueAction extends Action {
  103468. /**
  103469. * Defines the path of the property where the value should be interpolated
  103470. */
  103471. propertyPath: string;
  103472. /**
  103473. * Defines the target value at the end of the interpolation.
  103474. */
  103475. value: any;
  103476. /**
  103477. * Defines the time it will take for the property to interpolate to the value.
  103478. */
  103479. duration: number;
  103480. /**
  103481. * Defines if the other scene animations should be stopped when the action has been triggered
  103482. */
  103483. stopOtherAnimations?: boolean;
  103484. /**
  103485. * Defines a callback raised once the interpolation animation has been done.
  103486. */
  103487. onInterpolationDone?: () => void;
  103488. /**
  103489. * Observable triggered once the interpolation animation has been done.
  103490. */
  103491. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  103492. private _target;
  103493. private _effectiveTarget;
  103494. private _property;
  103495. /**
  103496. * Instantiate the action
  103497. * @param triggerOptions defines the trigger options
  103498. * @param target defines the object containing the value to interpolate
  103499. * @param propertyPath defines the path to the property in the target object
  103500. * @param value defines the target value at the end of the interpolation
  103501. * @param duration deines the time it will take for the property to interpolate to the value.
  103502. * @param condition defines the trigger related conditions
  103503. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  103504. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  103505. */
  103506. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  103507. /** @hidden */
  103508. _prepare(): void;
  103509. /**
  103510. * Execute the action starts the value interpolation.
  103511. */
  103512. execute(): void;
  103513. /**
  103514. * Serializes the actions and its related information.
  103515. * @param parent defines the object to serialize in
  103516. * @returns the serialized object
  103517. */
  103518. serialize(parent: any): any;
  103519. }
  103520. }
  103521. declare module BABYLON {
  103522. /**
  103523. * Options allowed during the creation of a sound track.
  103524. */
  103525. export interface ISoundTrackOptions {
  103526. /**
  103527. * The volume the sound track should take during creation
  103528. */
  103529. volume?: number;
  103530. /**
  103531. * Define if the sound track is the main sound track of the scene
  103532. */
  103533. mainTrack?: boolean;
  103534. }
  103535. /**
  103536. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  103537. * It will be also used in a future release to apply effects on a specific track.
  103538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103539. */
  103540. export class SoundTrack {
  103541. /**
  103542. * The unique identifier of the sound track in the scene.
  103543. */
  103544. id: number;
  103545. /**
  103546. * The list of sounds included in the sound track.
  103547. */
  103548. soundCollection: Array<Sound>;
  103549. private _outputAudioNode;
  103550. private _scene;
  103551. private _isMainTrack;
  103552. private _connectedAnalyser;
  103553. private _options;
  103554. private _isInitialized;
  103555. /**
  103556. * Creates a new sound track.
  103557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103558. * @param scene Define the scene the sound track belongs to
  103559. * @param options
  103560. */
  103561. constructor(scene: Scene, options?: ISoundTrackOptions);
  103562. private _initializeSoundTrackAudioGraph;
  103563. /**
  103564. * Release the sound track and its associated resources
  103565. */
  103566. dispose(): void;
  103567. /**
  103568. * Adds a sound to this sound track
  103569. * @param sound define the cound to add
  103570. * @ignoreNaming
  103571. */
  103572. AddSound(sound: Sound): void;
  103573. /**
  103574. * Removes a sound to this sound track
  103575. * @param sound define the cound to remove
  103576. * @ignoreNaming
  103577. */
  103578. RemoveSound(sound: Sound): void;
  103579. /**
  103580. * Set a global volume for the full sound track.
  103581. * @param newVolume Define the new volume of the sound track
  103582. */
  103583. setVolume(newVolume: number): void;
  103584. /**
  103585. * Switch the panning model to HRTF:
  103586. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103588. */
  103589. switchPanningModelToHRTF(): void;
  103590. /**
  103591. * Switch the panning model to Equal Power:
  103592. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103594. */
  103595. switchPanningModelToEqualPower(): void;
  103596. /**
  103597. * Connect the sound track to an audio analyser allowing some amazing
  103598. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103600. * @param analyser The analyser to connect to the engine
  103601. */
  103602. connectToAnalyser(analyser: Analyser): void;
  103603. }
  103604. }
  103605. declare module BABYLON {
  103606. interface AbstractScene {
  103607. /**
  103608. * The list of sounds used in the scene.
  103609. */
  103610. sounds: Nullable<Array<Sound>>;
  103611. }
  103612. interface Scene {
  103613. /**
  103614. * @hidden
  103615. * Backing field
  103616. */
  103617. _mainSoundTrack: SoundTrack;
  103618. /**
  103619. * The main sound track played by the scene.
  103620. * It cotains your primary collection of sounds.
  103621. */
  103622. mainSoundTrack: SoundTrack;
  103623. /**
  103624. * The list of sound tracks added to the scene
  103625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103626. */
  103627. soundTracks: Nullable<Array<SoundTrack>>;
  103628. /**
  103629. * Gets a sound using a given name
  103630. * @param name defines the name to search for
  103631. * @return the found sound or null if not found at all.
  103632. */
  103633. getSoundByName(name: string): Nullable<Sound>;
  103634. /**
  103635. * Gets or sets if audio support is enabled
  103636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103637. */
  103638. audioEnabled: boolean;
  103639. /**
  103640. * Gets or sets if audio will be output to headphones
  103641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103642. */
  103643. headphone: boolean;
  103644. /**
  103645. * Gets or sets custom audio listener position provider
  103646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103647. */
  103648. audioListenerPositionProvider: Nullable<() => Vector3>;
  103649. /**
  103650. * Gets or sets a refresh rate when using 3D audio positioning
  103651. */
  103652. audioPositioningRefreshRate: number;
  103653. }
  103654. /**
  103655. * Defines the sound scene component responsible to manage any sounds
  103656. * in a given scene.
  103657. */
  103658. export class AudioSceneComponent implements ISceneSerializableComponent {
  103659. /**
  103660. * The component name helpfull to identify the component in the list of scene components.
  103661. */
  103662. readonly name: string;
  103663. /**
  103664. * The scene the component belongs to.
  103665. */
  103666. scene: Scene;
  103667. private _audioEnabled;
  103668. /**
  103669. * Gets whether audio is enabled or not.
  103670. * Please use related enable/disable method to switch state.
  103671. */
  103672. readonly audioEnabled: boolean;
  103673. private _headphone;
  103674. /**
  103675. * Gets whether audio is outputing to headphone or not.
  103676. * Please use the according Switch methods to change output.
  103677. */
  103678. readonly headphone: boolean;
  103679. /**
  103680. * Gets or sets a refresh rate when using 3D audio positioning
  103681. */
  103682. audioPositioningRefreshRate: number;
  103683. private _audioListenerPositionProvider;
  103684. /**
  103685. * Gets the current audio listener position provider
  103686. */
  103687. /**
  103688. * Sets a custom listener position for all sounds in the scene
  103689. * By default, this is the position of the first active camera
  103690. */
  103691. audioListenerPositionProvider: Nullable<() => Vector3>;
  103692. /**
  103693. * Creates a new instance of the component for the given scene
  103694. * @param scene Defines the scene to register the component in
  103695. */
  103696. constructor(scene: Scene);
  103697. /**
  103698. * Registers the component in a given scene
  103699. */
  103700. register(): void;
  103701. /**
  103702. * Rebuilds the elements related to this component in case of
  103703. * context lost for instance.
  103704. */
  103705. rebuild(): void;
  103706. /**
  103707. * Serializes the component data to the specified json object
  103708. * @param serializationObject The object to serialize to
  103709. */
  103710. serialize(serializationObject: any): void;
  103711. /**
  103712. * Adds all the elements from the container to the scene
  103713. * @param container the container holding the elements
  103714. */
  103715. addFromContainer(container: AbstractScene): void;
  103716. /**
  103717. * Removes all the elements in the container from the scene
  103718. * @param container contains the elements to remove
  103719. * @param dispose if the removed element should be disposed (default: false)
  103720. */
  103721. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103722. /**
  103723. * Disposes the component and the associated ressources.
  103724. */
  103725. dispose(): void;
  103726. /**
  103727. * Disables audio in the associated scene.
  103728. */
  103729. disableAudio(): void;
  103730. /**
  103731. * Enables audio in the associated scene.
  103732. */
  103733. enableAudio(): void;
  103734. /**
  103735. * Switch audio to headphone output.
  103736. */
  103737. switchAudioModeForHeadphones(): void;
  103738. /**
  103739. * Switch audio to normal speakers.
  103740. */
  103741. switchAudioModeForNormalSpeakers(): void;
  103742. private _cachedCameraDirection;
  103743. private _cachedCameraPosition;
  103744. private _lastCheck;
  103745. private _afterRender;
  103746. }
  103747. }
  103748. declare module BABYLON {
  103749. /**
  103750. * Wraps one or more Sound objects and selects one with random weight for playback.
  103751. */
  103752. export class WeightedSound {
  103753. /** When true a Sound will be selected and played when the current playing Sound completes. */
  103754. loop: boolean;
  103755. private _coneInnerAngle;
  103756. private _coneOuterAngle;
  103757. private _volume;
  103758. /** A Sound is currently playing. */
  103759. isPlaying: boolean;
  103760. /** A Sound is currently paused. */
  103761. isPaused: boolean;
  103762. private _sounds;
  103763. private _weights;
  103764. private _currentIndex?;
  103765. /**
  103766. * Creates a new WeightedSound from the list of sounds given.
  103767. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  103768. * @param sounds Array of Sounds that will be selected from.
  103769. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  103770. */
  103771. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  103772. /**
  103773. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  103774. */
  103775. /**
  103776. * The size of cone in degress for a directional sound in which there will be no attenuation.
  103777. */
  103778. directionalConeInnerAngle: number;
  103779. /**
  103780. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103781. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103782. */
  103783. /**
  103784. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103785. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103786. */
  103787. directionalConeOuterAngle: number;
  103788. /**
  103789. * Playback volume.
  103790. */
  103791. /**
  103792. * Playback volume.
  103793. */
  103794. volume: number;
  103795. private _onended;
  103796. /**
  103797. * Suspend playback
  103798. */
  103799. pause(): void;
  103800. /**
  103801. * Stop playback
  103802. */
  103803. stop(): void;
  103804. /**
  103805. * Start playback.
  103806. * @param startOffset Position the clip head at a specific time in seconds.
  103807. */
  103808. play(startOffset?: number): void;
  103809. }
  103810. }
  103811. declare module BABYLON {
  103812. /**
  103813. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  103814. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103815. */
  103816. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  103817. /**
  103818. * Gets the name of the behavior.
  103819. */
  103820. readonly name: string;
  103821. /**
  103822. * The easing function used by animations
  103823. */
  103824. static EasingFunction: BackEase;
  103825. /**
  103826. * The easing mode used by animations
  103827. */
  103828. static EasingMode: number;
  103829. /**
  103830. * The duration of the animation, in milliseconds
  103831. */
  103832. transitionDuration: number;
  103833. /**
  103834. * Length of the distance animated by the transition when lower radius is reached
  103835. */
  103836. lowerRadiusTransitionRange: number;
  103837. /**
  103838. * Length of the distance animated by the transition when upper radius is reached
  103839. */
  103840. upperRadiusTransitionRange: number;
  103841. private _autoTransitionRange;
  103842. /**
  103843. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103844. */
  103845. /**
  103846. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103847. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  103848. */
  103849. autoTransitionRange: boolean;
  103850. private _attachedCamera;
  103851. private _onAfterCheckInputsObserver;
  103852. private _onMeshTargetChangedObserver;
  103853. /**
  103854. * Initializes the behavior.
  103855. */
  103856. init(): void;
  103857. /**
  103858. * Attaches the behavior to its arc rotate camera.
  103859. * @param camera Defines the camera to attach the behavior to
  103860. */
  103861. attach(camera: ArcRotateCamera): void;
  103862. /**
  103863. * Detaches the behavior from its current arc rotate camera.
  103864. */
  103865. detach(): void;
  103866. private _radiusIsAnimating;
  103867. private _radiusBounceTransition;
  103868. private _animatables;
  103869. private _cachedWheelPrecision;
  103870. /**
  103871. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  103872. * @param radiusLimit The limit to check against.
  103873. * @return Bool to indicate if at limit.
  103874. */
  103875. private _isRadiusAtLimit;
  103876. /**
  103877. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  103878. * @param radiusDelta The delta by which to animate to. Can be negative.
  103879. */
  103880. private _applyBoundRadiusAnimation;
  103881. /**
  103882. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  103883. */
  103884. protected _clearAnimationLocks(): void;
  103885. /**
  103886. * Stops and removes all animations that have been applied to the camera
  103887. */
  103888. stopAllAnimations(): void;
  103889. }
  103890. }
  103891. declare module BABYLON {
  103892. /**
  103893. * 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.
  103894. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103895. */
  103896. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  103897. /**
  103898. * Gets the name of the behavior.
  103899. */
  103900. readonly name: string;
  103901. private _mode;
  103902. private _radiusScale;
  103903. private _positionScale;
  103904. private _defaultElevation;
  103905. private _elevationReturnTime;
  103906. private _elevationReturnWaitTime;
  103907. private _zoomStopsAnimation;
  103908. private _framingTime;
  103909. /**
  103910. * The easing function used by animations
  103911. */
  103912. static EasingFunction: ExponentialEase;
  103913. /**
  103914. * The easing mode used by animations
  103915. */
  103916. static EasingMode: number;
  103917. /**
  103918. * Sets the current mode used by the behavior
  103919. */
  103920. /**
  103921. * Gets current mode used by the behavior.
  103922. */
  103923. mode: number;
  103924. /**
  103925. * Sets the scale applied to the radius (1 by default)
  103926. */
  103927. /**
  103928. * Gets the scale applied to the radius
  103929. */
  103930. radiusScale: number;
  103931. /**
  103932. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103933. */
  103934. /**
  103935. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103936. */
  103937. positionScale: number;
  103938. /**
  103939. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103940. * behaviour is triggered, in radians.
  103941. */
  103942. /**
  103943. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103944. * behaviour is triggered, in radians.
  103945. */
  103946. defaultElevation: number;
  103947. /**
  103948. * Sets the time (in milliseconds) taken to return to the default beta position.
  103949. * Negative value indicates camera should not return to default.
  103950. */
  103951. /**
  103952. * Gets the time (in milliseconds) taken to return to the default beta position.
  103953. * Negative value indicates camera should not return to default.
  103954. */
  103955. elevationReturnTime: number;
  103956. /**
  103957. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103958. */
  103959. /**
  103960. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103961. */
  103962. elevationReturnWaitTime: number;
  103963. /**
  103964. * Sets the flag that indicates if user zooming should stop animation.
  103965. */
  103966. /**
  103967. * Gets the flag that indicates if user zooming should stop animation.
  103968. */
  103969. zoomStopsAnimation: boolean;
  103970. /**
  103971. * Sets the transition time when framing the mesh, in milliseconds
  103972. */
  103973. /**
  103974. * Gets the transition time when framing the mesh, in milliseconds
  103975. */
  103976. framingTime: number;
  103977. /**
  103978. * Define if the behavior should automatically change the configured
  103979. * camera limits and sensibilities.
  103980. */
  103981. autoCorrectCameraLimitsAndSensibility: boolean;
  103982. private _onPrePointerObservableObserver;
  103983. private _onAfterCheckInputsObserver;
  103984. private _onMeshTargetChangedObserver;
  103985. private _attachedCamera;
  103986. private _isPointerDown;
  103987. private _lastInteractionTime;
  103988. /**
  103989. * Initializes the behavior.
  103990. */
  103991. init(): void;
  103992. /**
  103993. * Attaches the behavior to its arc rotate camera.
  103994. * @param camera Defines the camera to attach the behavior to
  103995. */
  103996. attach(camera: ArcRotateCamera): void;
  103997. /**
  103998. * Detaches the behavior from its current arc rotate camera.
  103999. */
  104000. detach(): void;
  104001. private _animatables;
  104002. private _betaIsAnimating;
  104003. private _betaTransition;
  104004. private _radiusTransition;
  104005. private _vectorTransition;
  104006. /**
  104007. * Targets the given mesh and updates zoom level accordingly.
  104008. * @param mesh The mesh to target.
  104009. * @param radius Optional. If a cached radius position already exists, overrides default.
  104010. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104011. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104012. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104013. */
  104014. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104015. /**
  104016. * Targets the given mesh with its children and updates zoom level accordingly.
  104017. * @param mesh The mesh to target.
  104018. * @param radius Optional. If a cached radius position already exists, overrides default.
  104019. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104020. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104021. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104022. */
  104023. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104024. /**
  104025. * Targets the given meshes with their children and updates zoom level accordingly.
  104026. * @param meshes The mesh to target.
  104027. * @param radius Optional. If a cached radius position already exists, overrides default.
  104028. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104029. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104030. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104031. */
  104032. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104033. /**
  104034. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104035. * @param minimumWorld Determines the smaller position of the bounding box extend
  104036. * @param maximumWorld Determines the bigger position of the bounding box extend
  104037. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104038. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104039. */
  104040. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104041. /**
  104042. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104043. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104044. * frustum width.
  104045. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104046. * to fully enclose the mesh in the viewing frustum.
  104047. */
  104048. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104049. /**
  104050. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104051. * is automatically returned to its default position (expected to be above ground plane).
  104052. */
  104053. private _maintainCameraAboveGround;
  104054. /**
  104055. * Returns the frustum slope based on the canvas ratio and camera FOV
  104056. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104057. */
  104058. private _getFrustumSlope;
  104059. /**
  104060. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104061. */
  104062. private _clearAnimationLocks;
  104063. /**
  104064. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104065. */
  104066. private _applyUserInteraction;
  104067. /**
  104068. * Stops and removes all animations that have been applied to the camera
  104069. */
  104070. stopAllAnimations(): void;
  104071. /**
  104072. * Gets a value indicating if the user is moving the camera
  104073. */
  104074. readonly isUserIsMoving: boolean;
  104075. /**
  104076. * The camera can move all the way towards the mesh.
  104077. */
  104078. static IgnoreBoundsSizeMode: number;
  104079. /**
  104080. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104081. */
  104082. static FitFrustumSidesMode: number;
  104083. }
  104084. }
  104085. declare module BABYLON {
  104086. /**
  104087. * Base class for Camera Pointer Inputs.
  104088. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104089. * for example usage.
  104090. */
  104091. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104092. /**
  104093. * Defines the camera the input is attached to.
  104094. */
  104095. abstract camera: Camera;
  104096. /**
  104097. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104098. */
  104099. protected _altKey: boolean;
  104100. protected _ctrlKey: boolean;
  104101. protected _metaKey: boolean;
  104102. protected _shiftKey: boolean;
  104103. /**
  104104. * Which mouse buttons were pressed at time of last mouse event.
  104105. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104106. */
  104107. protected _buttonsPressed: number;
  104108. /**
  104109. * Defines the buttons associated with the input to handle camera move.
  104110. */
  104111. buttons: number[];
  104112. /**
  104113. * Attach the input controls to a specific dom element to get the input from.
  104114. * @param element Defines the element the controls should be listened from
  104115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104116. */
  104117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104118. /**
  104119. * Detach the current controls from the specified dom element.
  104120. * @param element Defines the element to stop listening the inputs from
  104121. */
  104122. detachControl(element: Nullable<HTMLElement>): void;
  104123. /**
  104124. * Gets the class name of the current input.
  104125. * @returns the class name
  104126. */
  104127. getClassName(): string;
  104128. /**
  104129. * Get the friendly name associated with the input class.
  104130. * @returns the input friendly name
  104131. */
  104132. getSimpleName(): string;
  104133. /**
  104134. * Called on pointer POINTERDOUBLETAP event.
  104135. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104136. */
  104137. protected onDoubleTap(type: string): void;
  104138. /**
  104139. * Called on pointer POINTERMOVE event if only a single touch is active.
  104140. * Override this method to provide functionality.
  104141. */
  104142. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104143. /**
  104144. * Called on pointer POINTERMOVE event if multiple touches are active.
  104145. * Override this method to provide functionality.
  104146. */
  104147. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104148. /**
  104149. * Called on JS contextmenu event.
  104150. * Override this method to provide functionality.
  104151. */
  104152. protected onContextMenu(evt: PointerEvent): void;
  104153. /**
  104154. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104155. * press.
  104156. * Override this method to provide functionality.
  104157. */
  104158. protected onButtonDown(evt: PointerEvent): void;
  104159. /**
  104160. * Called each time a new POINTERUP event occurs. Ie, for each button
  104161. * release.
  104162. * Override this method to provide functionality.
  104163. */
  104164. protected onButtonUp(evt: PointerEvent): void;
  104165. /**
  104166. * Called when window becomes inactive.
  104167. * Override this method to provide functionality.
  104168. */
  104169. protected onLostFocus(): void;
  104170. private _pointerInput;
  104171. private _observer;
  104172. private _onLostFocus;
  104173. private pointA;
  104174. private pointB;
  104175. }
  104176. }
  104177. declare module BABYLON {
  104178. /**
  104179. * Manage the pointers inputs to control an arc rotate camera.
  104180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104181. */
  104182. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104183. /**
  104184. * Defines the camera the input is attached to.
  104185. */
  104186. camera: ArcRotateCamera;
  104187. /**
  104188. * Gets the class name of the current input.
  104189. * @returns the class name
  104190. */
  104191. getClassName(): string;
  104192. /**
  104193. * Defines the buttons associated with the input to handle camera move.
  104194. */
  104195. buttons: number[];
  104196. /**
  104197. * Defines the pointer angular sensibility along the X axis or how fast is
  104198. * the camera rotating.
  104199. */
  104200. angularSensibilityX: number;
  104201. /**
  104202. * Defines the pointer angular sensibility along the Y axis or how fast is
  104203. * the camera rotating.
  104204. */
  104205. angularSensibilityY: number;
  104206. /**
  104207. * Defines the pointer pinch precision or how fast is the camera zooming.
  104208. */
  104209. pinchPrecision: number;
  104210. /**
  104211. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104212. * from 0.
  104213. * It defines the percentage of current camera.radius to use as delta when
  104214. * pinch zoom is used.
  104215. */
  104216. pinchDeltaPercentage: number;
  104217. /**
  104218. * Defines the pointer panning sensibility or how fast is the camera moving.
  104219. */
  104220. panningSensibility: number;
  104221. /**
  104222. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104223. */
  104224. multiTouchPanning: boolean;
  104225. /**
  104226. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104227. * zoom (pinch) through multitouch.
  104228. */
  104229. multiTouchPanAndZoom: boolean;
  104230. /**
  104231. * Revers pinch action direction.
  104232. */
  104233. pinchInwards: boolean;
  104234. private _isPanClick;
  104235. private _twoFingerActivityCount;
  104236. private _isPinching;
  104237. /**
  104238. * Called on pointer POINTERMOVE event if only a single touch is active.
  104239. */
  104240. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104241. /**
  104242. * Called on pointer POINTERDOUBLETAP event.
  104243. */
  104244. protected onDoubleTap(type: string): void;
  104245. /**
  104246. * Called on pointer POINTERMOVE event if multiple touches are active.
  104247. */
  104248. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104249. /**
  104250. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104251. * press.
  104252. */
  104253. protected onButtonDown(evt: PointerEvent): void;
  104254. /**
  104255. * Called each time a new POINTERUP event occurs. Ie, for each button
  104256. * release.
  104257. */
  104258. protected onButtonUp(evt: PointerEvent): void;
  104259. /**
  104260. * Called when window becomes inactive.
  104261. */
  104262. protected onLostFocus(): void;
  104263. }
  104264. }
  104265. declare module BABYLON {
  104266. /**
  104267. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104269. */
  104270. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104271. /**
  104272. * Defines the camera the input is attached to.
  104273. */
  104274. camera: ArcRotateCamera;
  104275. /**
  104276. * Defines the list of key codes associated with the up action (increase alpha)
  104277. */
  104278. keysUp: number[];
  104279. /**
  104280. * Defines the list of key codes associated with the down action (decrease alpha)
  104281. */
  104282. keysDown: number[];
  104283. /**
  104284. * Defines the list of key codes associated with the left action (increase beta)
  104285. */
  104286. keysLeft: number[];
  104287. /**
  104288. * Defines the list of key codes associated with the right action (decrease beta)
  104289. */
  104290. keysRight: number[];
  104291. /**
  104292. * Defines the list of key codes associated with the reset action.
  104293. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104294. */
  104295. keysReset: number[];
  104296. /**
  104297. * Defines the panning sensibility of the inputs.
  104298. * (How fast is the camera paning)
  104299. */
  104300. panningSensibility: number;
  104301. /**
  104302. * Defines the zooming sensibility of the inputs.
  104303. * (How fast is the camera zooming)
  104304. */
  104305. zoomingSensibility: number;
  104306. /**
  104307. * Defines wether maintaining the alt key down switch the movement mode from
  104308. * orientation to zoom.
  104309. */
  104310. useAltToZoom: boolean;
  104311. /**
  104312. * Rotation speed of the camera
  104313. */
  104314. angularSpeed: number;
  104315. private _keys;
  104316. private _ctrlPressed;
  104317. private _altPressed;
  104318. private _onCanvasBlurObserver;
  104319. private _onKeyboardObserver;
  104320. private _engine;
  104321. private _scene;
  104322. /**
  104323. * Attach the input controls to a specific dom element to get the input from.
  104324. * @param element Defines the element the controls should be listened from
  104325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104326. */
  104327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104328. /**
  104329. * Detach the current controls from the specified dom element.
  104330. * @param element Defines the element to stop listening the inputs from
  104331. */
  104332. detachControl(element: Nullable<HTMLElement>): void;
  104333. /**
  104334. * Update the current camera state depending on the inputs that have been used this frame.
  104335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104336. */
  104337. checkInputs(): void;
  104338. /**
  104339. * Gets the class name of the current intput.
  104340. * @returns the class name
  104341. */
  104342. getClassName(): string;
  104343. /**
  104344. * Get the friendly name associated with the input class.
  104345. * @returns the input friendly name
  104346. */
  104347. getSimpleName(): string;
  104348. }
  104349. }
  104350. declare module BABYLON {
  104351. /**
  104352. * Manage the mouse wheel inputs to control an arc rotate camera.
  104353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104354. */
  104355. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104356. /**
  104357. * Defines the camera the input is attached to.
  104358. */
  104359. camera: ArcRotateCamera;
  104360. /**
  104361. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104362. */
  104363. wheelPrecision: number;
  104364. /**
  104365. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104366. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104367. */
  104368. wheelDeltaPercentage: number;
  104369. private _wheel;
  104370. private _observer;
  104371. private computeDeltaFromMouseWheelLegacyEvent;
  104372. /**
  104373. * Attach the input controls to a specific dom element to get the input from.
  104374. * @param element Defines the element the controls should be listened from
  104375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104376. */
  104377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104378. /**
  104379. * Detach the current controls from the specified dom element.
  104380. * @param element Defines the element to stop listening the inputs from
  104381. */
  104382. detachControl(element: Nullable<HTMLElement>): void;
  104383. /**
  104384. * Gets the class name of the current intput.
  104385. * @returns the class name
  104386. */
  104387. getClassName(): string;
  104388. /**
  104389. * Get the friendly name associated with the input class.
  104390. * @returns the input friendly name
  104391. */
  104392. getSimpleName(): string;
  104393. }
  104394. }
  104395. declare module BABYLON {
  104396. /**
  104397. * Default Inputs manager for the ArcRotateCamera.
  104398. * It groups all the default supported inputs for ease of use.
  104399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104400. */
  104401. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104402. /**
  104403. * Instantiates a new ArcRotateCameraInputsManager.
  104404. * @param camera Defines the camera the inputs belong to
  104405. */
  104406. constructor(camera: ArcRotateCamera);
  104407. /**
  104408. * Add mouse wheel input support to the input manager.
  104409. * @returns the current input manager
  104410. */
  104411. addMouseWheel(): ArcRotateCameraInputsManager;
  104412. /**
  104413. * Add pointers input support to the input manager.
  104414. * @returns the current input manager
  104415. */
  104416. addPointers(): ArcRotateCameraInputsManager;
  104417. /**
  104418. * Add keyboard input support to the input manager.
  104419. * @returns the current input manager
  104420. */
  104421. addKeyboard(): ArcRotateCameraInputsManager;
  104422. }
  104423. }
  104424. declare module BABYLON {
  104425. /**
  104426. * This represents an orbital type of camera.
  104427. *
  104428. * 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.
  104429. * 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.
  104430. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104431. */
  104432. export class ArcRotateCamera extends TargetCamera {
  104433. /**
  104434. * Defines the rotation angle of the camera along the longitudinal axis.
  104435. */
  104436. alpha: number;
  104437. /**
  104438. * Defines the rotation angle of the camera along the latitudinal axis.
  104439. */
  104440. beta: number;
  104441. /**
  104442. * Defines the radius of the camera from it s target point.
  104443. */
  104444. radius: number;
  104445. protected _target: Vector3;
  104446. protected _targetHost: Nullable<AbstractMesh>;
  104447. /**
  104448. * Defines the target point of the camera.
  104449. * The camera looks towards it form the radius distance.
  104450. */
  104451. target: Vector3;
  104452. /**
  104453. * Define the current local position of the camera in the scene
  104454. */
  104455. position: Vector3;
  104456. protected _upVector: Vector3;
  104457. protected _upToYMatrix: Matrix;
  104458. protected _YToUpMatrix: Matrix;
  104459. /**
  104460. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104461. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104462. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104463. */
  104464. upVector: Vector3;
  104465. /**
  104466. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104467. */
  104468. setMatUp(): void;
  104469. /**
  104470. * Current inertia value on the longitudinal axis.
  104471. * The bigger this number the longer it will take for the camera to stop.
  104472. */
  104473. inertialAlphaOffset: number;
  104474. /**
  104475. * Current inertia value on the latitudinal axis.
  104476. * The bigger this number the longer it will take for the camera to stop.
  104477. */
  104478. inertialBetaOffset: number;
  104479. /**
  104480. * Current inertia value on the radius axis.
  104481. * The bigger this number the longer it will take for the camera to stop.
  104482. */
  104483. inertialRadiusOffset: number;
  104484. /**
  104485. * Minimum allowed angle on the longitudinal axis.
  104486. * This can help limiting how the Camera is able to move in the scene.
  104487. */
  104488. lowerAlphaLimit: Nullable<number>;
  104489. /**
  104490. * Maximum allowed angle on the longitudinal axis.
  104491. * This can help limiting how the Camera is able to move in the scene.
  104492. */
  104493. upperAlphaLimit: Nullable<number>;
  104494. /**
  104495. * Minimum allowed angle on the latitudinal axis.
  104496. * This can help limiting how the Camera is able to move in the scene.
  104497. */
  104498. lowerBetaLimit: number;
  104499. /**
  104500. * Maximum allowed angle on the latitudinal axis.
  104501. * This can help limiting how the Camera is able to move in the scene.
  104502. */
  104503. upperBetaLimit: number;
  104504. /**
  104505. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  104506. * This can help limiting how the Camera is able to move in the scene.
  104507. */
  104508. lowerRadiusLimit: Nullable<number>;
  104509. /**
  104510. * Maximum allowed distance of the camera to the target (The camera can not get further).
  104511. * This can help limiting how the Camera is able to move in the scene.
  104512. */
  104513. upperRadiusLimit: Nullable<number>;
  104514. /**
  104515. * Defines the current inertia value used during panning of the camera along the X axis.
  104516. */
  104517. inertialPanningX: number;
  104518. /**
  104519. * Defines the current inertia value used during panning of the camera along the Y axis.
  104520. */
  104521. inertialPanningY: number;
  104522. /**
  104523. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  104524. * Basically if your fingers moves away from more than this distance you will be considered
  104525. * in pinch mode.
  104526. */
  104527. pinchToPanMaxDistance: number;
  104528. /**
  104529. * Defines the maximum distance the camera can pan.
  104530. * This could help keeping the cammera always in your scene.
  104531. */
  104532. panningDistanceLimit: Nullable<number>;
  104533. /**
  104534. * Defines the target of the camera before paning.
  104535. */
  104536. panningOriginTarget: Vector3;
  104537. /**
  104538. * Defines the value of the inertia used during panning.
  104539. * 0 would mean stop inertia and one would mean no decelleration at all.
  104540. */
  104541. panningInertia: number;
  104542. /**
  104543. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  104544. */
  104545. angularSensibilityX: number;
  104546. /**
  104547. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  104548. */
  104549. angularSensibilityY: number;
  104550. /**
  104551. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  104552. */
  104553. pinchPrecision: number;
  104554. /**
  104555. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  104556. * It will be used instead of pinchDeltaPrecision if different from 0.
  104557. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104558. */
  104559. pinchDeltaPercentage: number;
  104560. /**
  104561. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  104562. */
  104563. panningSensibility: number;
  104564. /**
  104565. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  104566. */
  104567. keysUp: number[];
  104568. /**
  104569. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  104570. */
  104571. keysDown: number[];
  104572. /**
  104573. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  104574. */
  104575. keysLeft: number[];
  104576. /**
  104577. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  104578. */
  104579. keysRight: number[];
  104580. /**
  104581. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104582. */
  104583. wheelPrecision: number;
  104584. /**
  104585. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  104586. * It will be used instead of pinchDeltaPrecision if different from 0.
  104587. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104588. */
  104589. wheelDeltaPercentage: number;
  104590. /**
  104591. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  104592. */
  104593. zoomOnFactor: number;
  104594. /**
  104595. * Defines a screen offset for the camera position.
  104596. */
  104597. targetScreenOffset: Vector2;
  104598. /**
  104599. * Allows the camera to be completely reversed.
  104600. * If false the camera can not arrive upside down.
  104601. */
  104602. allowUpsideDown: boolean;
  104603. /**
  104604. * Define if double tap/click is used to restore the previously saved state of the camera.
  104605. */
  104606. useInputToRestoreState: boolean;
  104607. /** @hidden */
  104608. _viewMatrix: Matrix;
  104609. /** @hidden */
  104610. _useCtrlForPanning: boolean;
  104611. /** @hidden */
  104612. _panningMouseButton: number;
  104613. /**
  104614. * Defines the input associated to the camera.
  104615. */
  104616. inputs: ArcRotateCameraInputsManager;
  104617. /** @hidden */
  104618. _reset: () => void;
  104619. /**
  104620. * Defines the allowed panning axis.
  104621. */
  104622. panningAxis: Vector3;
  104623. protected _localDirection: Vector3;
  104624. protected _transformedDirection: Vector3;
  104625. private _bouncingBehavior;
  104626. /**
  104627. * Gets the bouncing behavior of the camera if it has been enabled.
  104628. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104629. */
  104630. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104631. /**
  104632. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104633. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104634. */
  104635. useBouncingBehavior: boolean;
  104636. private _framingBehavior;
  104637. /**
  104638. * Gets the framing behavior of the camera if it has been enabled.
  104639. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104640. */
  104641. readonly framingBehavior: Nullable<FramingBehavior>;
  104642. /**
  104643. * Defines if the framing behavior of the camera is enabled on the camera.
  104644. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104645. */
  104646. useFramingBehavior: boolean;
  104647. private _autoRotationBehavior;
  104648. /**
  104649. * Gets the auto rotation behavior of the camera if it has been enabled.
  104650. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104651. */
  104652. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104653. /**
  104654. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104655. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104656. */
  104657. useAutoRotationBehavior: boolean;
  104658. /**
  104659. * Observable triggered when the mesh target has been changed on the camera.
  104660. */
  104661. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104662. /**
  104663. * Event raised when the camera is colliding with a mesh.
  104664. */
  104665. onCollide: (collidedMesh: AbstractMesh) => void;
  104666. /**
  104667. * Defines whether the camera should check collision with the objects oh the scene.
  104668. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104669. */
  104670. checkCollisions: boolean;
  104671. /**
  104672. * Defines the collision radius of the camera.
  104673. * This simulates a sphere around the camera.
  104674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104675. */
  104676. collisionRadius: Vector3;
  104677. protected _collider: Collider;
  104678. protected _previousPosition: Vector3;
  104679. protected _collisionVelocity: Vector3;
  104680. protected _newPosition: Vector3;
  104681. protected _previousAlpha: number;
  104682. protected _previousBeta: number;
  104683. protected _previousRadius: number;
  104684. protected _collisionTriggered: boolean;
  104685. protected _targetBoundingCenter: Nullable<Vector3>;
  104686. private _computationVector;
  104687. /**
  104688. * Instantiates a new ArcRotateCamera in a given scene
  104689. * @param name Defines the name of the camera
  104690. * @param alpha Defines the camera rotation along the logitudinal axis
  104691. * @param beta Defines the camera rotation along the latitudinal axis
  104692. * @param radius Defines the camera distance from its target
  104693. * @param target Defines the camera target
  104694. * @param scene Defines the scene the camera belongs to
  104695. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104696. */
  104697. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104698. /** @hidden */
  104699. _initCache(): void;
  104700. /** @hidden */
  104701. _updateCache(ignoreParentClass?: boolean): void;
  104702. protected _getTargetPosition(): Vector3;
  104703. private _storedAlpha;
  104704. private _storedBeta;
  104705. private _storedRadius;
  104706. private _storedTarget;
  104707. private _storedTargetScreenOffset;
  104708. /**
  104709. * Stores the current state of the camera (alpha, beta, radius and target)
  104710. * @returns the camera itself
  104711. */
  104712. storeState(): Camera;
  104713. /**
  104714. * @hidden
  104715. * Restored camera state. You must call storeState() first
  104716. */
  104717. _restoreStateValues(): boolean;
  104718. /** @hidden */
  104719. _isSynchronizedViewMatrix(): boolean;
  104720. /**
  104721. * Attached controls to the current camera.
  104722. * @param element Defines the element the controls should be listened from
  104723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104724. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104725. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104726. */
  104727. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104728. /**
  104729. * Detach the current controls from the camera.
  104730. * The camera will stop reacting to inputs.
  104731. * @param element Defines the element to stop listening the inputs from
  104732. */
  104733. detachControl(element: HTMLElement): void;
  104734. /** @hidden */
  104735. _checkInputs(): void;
  104736. protected _checkLimits(): void;
  104737. /**
  104738. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104739. */
  104740. rebuildAnglesAndRadius(): void;
  104741. /**
  104742. * Use a position to define the current camera related information like alpha, beta and radius
  104743. * @param position Defines the position to set the camera at
  104744. */
  104745. setPosition(position: Vector3): void;
  104746. /**
  104747. * Defines the target the camera should look at.
  104748. * This will automatically adapt alpha beta and radius to fit within the new target.
  104749. * @param target Defines the new target as a Vector or a mesh
  104750. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  104751. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  104752. */
  104753. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  104754. /** @hidden */
  104755. _getViewMatrix(): Matrix;
  104756. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  104757. /**
  104758. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  104759. * @param meshes Defines the mesh to zoom on
  104760. * @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)
  104761. */
  104762. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  104763. /**
  104764. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  104765. * The target will be changed but the radius
  104766. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  104767. * @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)
  104768. */
  104769. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  104770. min: Vector3;
  104771. max: Vector3;
  104772. distance: number;
  104773. }, doNotUpdateMaxZ?: boolean): void;
  104774. /**
  104775. * @override
  104776. * Override Camera.createRigCamera
  104777. */
  104778. createRigCamera(name: string, cameraIndex: number): Camera;
  104779. /**
  104780. * @hidden
  104781. * @override
  104782. * Override Camera._updateRigCameras
  104783. */
  104784. _updateRigCameras(): void;
  104785. /**
  104786. * Destroy the camera and release the current resources hold by it.
  104787. */
  104788. dispose(): void;
  104789. /**
  104790. * Gets the current object class name.
  104791. * @return the class name
  104792. */
  104793. getClassName(): string;
  104794. }
  104795. }
  104796. declare module BABYLON {
  104797. /**
  104798. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  104799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104800. */
  104801. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  104802. /**
  104803. * Gets the name of the behavior.
  104804. */
  104805. readonly name: string;
  104806. private _zoomStopsAnimation;
  104807. private _idleRotationSpeed;
  104808. private _idleRotationWaitTime;
  104809. private _idleRotationSpinupTime;
  104810. /**
  104811. * Sets the flag that indicates if user zooming should stop animation.
  104812. */
  104813. /**
  104814. * Gets the flag that indicates if user zooming should stop animation.
  104815. */
  104816. zoomStopsAnimation: boolean;
  104817. /**
  104818. * Sets the default speed at which the camera rotates around the model.
  104819. */
  104820. /**
  104821. * Gets the default speed at which the camera rotates around the model.
  104822. */
  104823. idleRotationSpeed: number;
  104824. /**
  104825. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  104826. */
  104827. /**
  104828. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  104829. */
  104830. idleRotationWaitTime: number;
  104831. /**
  104832. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104833. */
  104834. /**
  104835. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104836. */
  104837. idleRotationSpinupTime: number;
  104838. /**
  104839. * Gets a value indicating if the camera is currently rotating because of this behavior
  104840. */
  104841. readonly rotationInProgress: boolean;
  104842. private _onPrePointerObservableObserver;
  104843. private _onAfterCheckInputsObserver;
  104844. private _attachedCamera;
  104845. private _isPointerDown;
  104846. private _lastFrameTime;
  104847. private _lastInteractionTime;
  104848. private _cameraRotationSpeed;
  104849. /**
  104850. * Initializes the behavior.
  104851. */
  104852. init(): void;
  104853. /**
  104854. * Attaches the behavior to its arc rotate camera.
  104855. * @param camera Defines the camera to attach the behavior to
  104856. */
  104857. attach(camera: ArcRotateCamera): void;
  104858. /**
  104859. * Detaches the behavior from its current arc rotate camera.
  104860. */
  104861. detach(): void;
  104862. /**
  104863. * Returns true if user is scrolling.
  104864. * @return true if user is scrolling.
  104865. */
  104866. private _userIsZooming;
  104867. private _lastFrameRadius;
  104868. private _shouldAnimationStopForInteraction;
  104869. /**
  104870. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104871. */
  104872. private _applyUserInteraction;
  104873. private _userIsMoving;
  104874. }
  104875. }
  104876. declare module BABYLON {
  104877. /**
  104878. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  104879. */
  104880. export class AttachToBoxBehavior implements Behavior<Mesh> {
  104881. private ui;
  104882. /**
  104883. * The name of the behavior
  104884. */
  104885. name: string;
  104886. /**
  104887. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  104888. */
  104889. distanceAwayFromFace: number;
  104890. /**
  104891. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  104892. */
  104893. distanceAwayFromBottomOfFace: number;
  104894. private _faceVectors;
  104895. private _target;
  104896. private _scene;
  104897. private _onRenderObserver;
  104898. private _tmpMatrix;
  104899. private _tmpVector;
  104900. /**
  104901. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  104902. * @param ui The transform node that should be attched to the mesh
  104903. */
  104904. constructor(ui: TransformNode);
  104905. /**
  104906. * Initializes the behavior
  104907. */
  104908. init(): void;
  104909. private _closestFace;
  104910. private _zeroVector;
  104911. private _lookAtTmpMatrix;
  104912. private _lookAtToRef;
  104913. /**
  104914. * Attaches the AttachToBoxBehavior to the passed in mesh
  104915. * @param target The mesh that the specified node will be attached to
  104916. */
  104917. attach(target: Mesh): void;
  104918. /**
  104919. * Detaches the behavior from the mesh
  104920. */
  104921. detach(): void;
  104922. }
  104923. }
  104924. declare module BABYLON {
  104925. /**
  104926. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104927. */
  104928. export class FadeInOutBehavior implements Behavior<Mesh> {
  104929. /**
  104930. * Time in milliseconds to delay before fading in (Default: 0)
  104931. */
  104932. delay: number;
  104933. /**
  104934. * Time in milliseconds for the mesh to fade in (Default: 300)
  104935. */
  104936. fadeInTime: number;
  104937. private _millisecondsPerFrame;
  104938. private _hovered;
  104939. private _hoverValue;
  104940. private _ownerNode;
  104941. /**
  104942. * Instatiates the FadeInOutBehavior
  104943. */
  104944. constructor();
  104945. /**
  104946. * The name of the behavior
  104947. */
  104948. readonly name: string;
  104949. /**
  104950. * Initializes the behavior
  104951. */
  104952. init(): void;
  104953. /**
  104954. * Attaches the fade behavior on the passed in mesh
  104955. * @param ownerNode The mesh that will be faded in/out once attached
  104956. */
  104957. attach(ownerNode: Mesh): void;
  104958. /**
  104959. * Detaches the behavior from the mesh
  104960. */
  104961. detach(): void;
  104962. /**
  104963. * Triggers the mesh to begin fading in or out
  104964. * @param value if the object should fade in or out (true to fade in)
  104965. */
  104966. fadeIn(value: boolean): void;
  104967. private _update;
  104968. private _setAllVisibility;
  104969. }
  104970. }
  104971. declare module BABYLON {
  104972. /**
  104973. * Class containing a set of static utilities functions for managing Pivots
  104974. * @hidden
  104975. */
  104976. export class PivotTools {
  104977. private static _PivotCached;
  104978. private static _OldPivotPoint;
  104979. private static _PivotTranslation;
  104980. private static _PivotTmpVector;
  104981. /** @hidden */
  104982. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104983. /** @hidden */
  104984. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104985. }
  104986. }
  104987. declare module BABYLON {
  104988. /**
  104989. * Class containing static functions to help procedurally build meshes
  104990. */
  104991. export class PlaneBuilder {
  104992. /**
  104993. * Creates a plane mesh
  104994. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104995. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104996. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105000. * @param name defines the name of the mesh
  105001. * @param options defines the options used to create the mesh
  105002. * @param scene defines the hosting scene
  105003. * @returns the plane mesh
  105004. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105005. */
  105006. static CreatePlane(name: string, options: {
  105007. size?: number;
  105008. width?: number;
  105009. height?: number;
  105010. sideOrientation?: number;
  105011. frontUVs?: Vector4;
  105012. backUVs?: Vector4;
  105013. updatable?: boolean;
  105014. sourcePlane?: Plane;
  105015. }, scene?: Nullable<Scene>): Mesh;
  105016. }
  105017. }
  105018. declare module BABYLON {
  105019. /**
  105020. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105021. */
  105022. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105023. private static _AnyMouseID;
  105024. /**
  105025. * Abstract mesh the behavior is set on
  105026. */
  105027. attachedNode: AbstractMesh;
  105028. private _dragPlane;
  105029. private _scene;
  105030. private _pointerObserver;
  105031. private _beforeRenderObserver;
  105032. private static _planeScene;
  105033. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105034. /**
  105035. * 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)
  105036. */
  105037. maxDragAngle: number;
  105038. /**
  105039. * @hidden
  105040. */
  105041. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105042. /**
  105043. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105044. */
  105045. currentDraggingPointerID: number;
  105046. /**
  105047. * The last position where the pointer hit the drag plane in world space
  105048. */
  105049. lastDragPosition: Vector3;
  105050. /**
  105051. * If the behavior is currently in a dragging state
  105052. */
  105053. dragging: boolean;
  105054. /**
  105055. * 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)
  105056. */
  105057. dragDeltaRatio: number;
  105058. /**
  105059. * If the drag plane orientation should be updated during the dragging (Default: true)
  105060. */
  105061. updateDragPlane: boolean;
  105062. private _debugMode;
  105063. private _moving;
  105064. /**
  105065. * Fires each time the attached mesh is dragged with the pointer
  105066. * * delta between last drag position and current drag position in world space
  105067. * * dragDistance along the drag axis
  105068. * * dragPlaneNormal normal of the current drag plane used during the drag
  105069. * * dragPlanePoint in world space where the drag intersects the drag plane
  105070. */
  105071. onDragObservable: Observable<{
  105072. delta: Vector3;
  105073. dragPlanePoint: Vector3;
  105074. dragPlaneNormal: Vector3;
  105075. dragDistance: number;
  105076. pointerId: number;
  105077. }>;
  105078. /**
  105079. * Fires each time a drag begins (eg. mouse down on mesh)
  105080. */
  105081. onDragStartObservable: Observable<{
  105082. dragPlanePoint: Vector3;
  105083. pointerId: number;
  105084. }>;
  105085. /**
  105086. * Fires each time a drag ends (eg. mouse release after drag)
  105087. */
  105088. onDragEndObservable: Observable<{
  105089. dragPlanePoint: Vector3;
  105090. pointerId: number;
  105091. }>;
  105092. /**
  105093. * If the attached mesh should be moved when dragged
  105094. */
  105095. moveAttached: boolean;
  105096. /**
  105097. * If the drag behavior will react to drag events (Default: true)
  105098. */
  105099. enabled: boolean;
  105100. /**
  105101. * If pointer events should start and release the drag (Default: true)
  105102. */
  105103. startAndReleaseDragOnPointerEvents: boolean;
  105104. /**
  105105. * If camera controls should be detached during the drag
  105106. */
  105107. detachCameraControls: boolean;
  105108. /**
  105109. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105110. */
  105111. useObjectOrienationForDragging: boolean;
  105112. private _options;
  105113. /**
  105114. * Creates a pointer drag behavior that can be attached to a mesh
  105115. * @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)
  105116. */
  105117. constructor(options?: {
  105118. dragAxis?: Vector3;
  105119. dragPlaneNormal?: Vector3;
  105120. });
  105121. /**
  105122. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105123. */
  105124. validateDrag: (targetPosition: Vector3) => boolean;
  105125. /**
  105126. * The name of the behavior
  105127. */
  105128. readonly name: string;
  105129. /**
  105130. * Initializes the behavior
  105131. */
  105132. init(): void;
  105133. private _tmpVector;
  105134. private _alternatePickedPoint;
  105135. private _worldDragAxis;
  105136. private _targetPosition;
  105137. private _attachedElement;
  105138. /**
  105139. * Attaches the drag behavior the passed in mesh
  105140. * @param ownerNode The mesh that will be dragged around once attached
  105141. * @param predicate Predicate to use for pick filtering
  105142. */
  105143. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105144. /**
  105145. * Force relase the drag action by code.
  105146. */
  105147. releaseDrag(): void;
  105148. private _startDragRay;
  105149. private _lastPointerRay;
  105150. /**
  105151. * Simulates the start of a pointer drag event on the behavior
  105152. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105153. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105154. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105155. */
  105156. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105157. private _startDrag;
  105158. private _dragDelta;
  105159. private _moveDrag;
  105160. private _pickWithRayOnDragPlane;
  105161. private _pointA;
  105162. private _pointB;
  105163. private _pointC;
  105164. private _lineA;
  105165. private _lineB;
  105166. private _localAxis;
  105167. private _lookAt;
  105168. private _updateDragPlanePosition;
  105169. /**
  105170. * Detaches the behavior from the mesh
  105171. */
  105172. detach(): void;
  105173. }
  105174. }
  105175. declare module BABYLON {
  105176. /**
  105177. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105178. */
  105179. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105180. private _dragBehaviorA;
  105181. private _dragBehaviorB;
  105182. private _startDistance;
  105183. private _initialScale;
  105184. private _targetScale;
  105185. private _ownerNode;
  105186. private _sceneRenderObserver;
  105187. /**
  105188. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105189. */
  105190. constructor();
  105191. /**
  105192. * The name of the behavior
  105193. */
  105194. readonly name: string;
  105195. /**
  105196. * Initializes the behavior
  105197. */
  105198. init(): void;
  105199. private _getCurrentDistance;
  105200. /**
  105201. * Attaches the scale behavior the passed in mesh
  105202. * @param ownerNode The mesh that will be scaled around once attached
  105203. */
  105204. attach(ownerNode: Mesh): void;
  105205. /**
  105206. * Detaches the behavior from the mesh
  105207. */
  105208. detach(): void;
  105209. }
  105210. }
  105211. declare module BABYLON {
  105212. /**
  105213. * 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
  105214. */
  105215. export class SixDofDragBehavior implements Behavior<Mesh> {
  105216. private static _virtualScene;
  105217. private _ownerNode;
  105218. private _sceneRenderObserver;
  105219. private _scene;
  105220. private _targetPosition;
  105221. private _virtualOriginMesh;
  105222. private _virtualDragMesh;
  105223. private _pointerObserver;
  105224. private _moving;
  105225. private _startingOrientation;
  105226. /**
  105227. * 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)
  105228. */
  105229. private zDragFactor;
  105230. /**
  105231. * If the object should rotate to face the drag origin
  105232. */
  105233. rotateDraggedObject: boolean;
  105234. /**
  105235. * If the behavior is currently in a dragging state
  105236. */
  105237. dragging: boolean;
  105238. /**
  105239. * 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)
  105240. */
  105241. dragDeltaRatio: number;
  105242. /**
  105243. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105244. */
  105245. currentDraggingPointerID: number;
  105246. /**
  105247. * If camera controls should be detached during the drag
  105248. */
  105249. detachCameraControls: boolean;
  105250. /**
  105251. * Fires each time a drag starts
  105252. */
  105253. onDragStartObservable: Observable<{}>;
  105254. /**
  105255. * Fires each time a drag ends (eg. mouse release after drag)
  105256. */
  105257. onDragEndObservable: Observable<{}>;
  105258. /**
  105259. * 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
  105260. */
  105261. constructor();
  105262. /**
  105263. * The name of the behavior
  105264. */
  105265. readonly name: string;
  105266. /**
  105267. * Initializes the behavior
  105268. */
  105269. init(): void;
  105270. /**
  105271. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105272. */
  105273. private readonly _pointerCamera;
  105274. /**
  105275. * Attaches the scale behavior the passed in mesh
  105276. * @param ownerNode The mesh that will be scaled around once attached
  105277. */
  105278. attach(ownerNode: Mesh): void;
  105279. /**
  105280. * Detaches the behavior from the mesh
  105281. */
  105282. detach(): void;
  105283. }
  105284. }
  105285. declare module BABYLON {
  105286. /**
  105287. * Class used to apply inverse kinematics to bones
  105288. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105289. */
  105290. export class BoneIKController {
  105291. private static _tmpVecs;
  105292. private static _tmpQuat;
  105293. private static _tmpMats;
  105294. /**
  105295. * Gets or sets the target mesh
  105296. */
  105297. targetMesh: AbstractMesh;
  105298. /** Gets or sets the mesh used as pole */
  105299. poleTargetMesh: AbstractMesh;
  105300. /**
  105301. * Gets or sets the bone used as pole
  105302. */
  105303. poleTargetBone: Nullable<Bone>;
  105304. /**
  105305. * Gets or sets the target position
  105306. */
  105307. targetPosition: Vector3;
  105308. /**
  105309. * Gets or sets the pole target position
  105310. */
  105311. poleTargetPosition: Vector3;
  105312. /**
  105313. * Gets or sets the pole target local offset
  105314. */
  105315. poleTargetLocalOffset: Vector3;
  105316. /**
  105317. * Gets or sets the pole angle
  105318. */
  105319. poleAngle: number;
  105320. /**
  105321. * Gets or sets the mesh associated with the controller
  105322. */
  105323. mesh: AbstractMesh;
  105324. /**
  105325. * 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)
  105326. */
  105327. slerpAmount: number;
  105328. private _bone1Quat;
  105329. private _bone1Mat;
  105330. private _bone2Ang;
  105331. private _bone1;
  105332. private _bone2;
  105333. private _bone1Length;
  105334. private _bone2Length;
  105335. private _maxAngle;
  105336. private _maxReach;
  105337. private _rightHandedSystem;
  105338. private _bendAxis;
  105339. private _slerping;
  105340. private _adjustRoll;
  105341. /**
  105342. * Gets or sets maximum allowed angle
  105343. */
  105344. maxAngle: number;
  105345. /**
  105346. * Creates a new BoneIKController
  105347. * @param mesh defines the mesh to control
  105348. * @param bone defines the bone to control
  105349. * @param options defines options to set up the controller
  105350. */
  105351. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105352. targetMesh?: AbstractMesh;
  105353. poleTargetMesh?: AbstractMesh;
  105354. poleTargetBone?: Bone;
  105355. poleTargetLocalOffset?: Vector3;
  105356. poleAngle?: number;
  105357. bendAxis?: Vector3;
  105358. maxAngle?: number;
  105359. slerpAmount?: number;
  105360. });
  105361. private _setMaxAngle;
  105362. /**
  105363. * Force the controller to update the bones
  105364. */
  105365. update(): void;
  105366. }
  105367. }
  105368. declare module BABYLON {
  105369. /**
  105370. * Class used to make a bone look toward a point in space
  105371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105372. */
  105373. export class BoneLookController {
  105374. private static _tmpVecs;
  105375. private static _tmpQuat;
  105376. private static _tmpMats;
  105377. /**
  105378. * The target Vector3 that the bone will look at
  105379. */
  105380. target: Vector3;
  105381. /**
  105382. * The mesh that the bone is attached to
  105383. */
  105384. mesh: AbstractMesh;
  105385. /**
  105386. * The bone that will be looking to the target
  105387. */
  105388. bone: Bone;
  105389. /**
  105390. * The up axis of the coordinate system that is used when the bone is rotated
  105391. */
  105392. upAxis: Vector3;
  105393. /**
  105394. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105395. */
  105396. upAxisSpace: Space;
  105397. /**
  105398. * Used to make an adjustment to the yaw of the bone
  105399. */
  105400. adjustYaw: number;
  105401. /**
  105402. * Used to make an adjustment to the pitch of the bone
  105403. */
  105404. adjustPitch: number;
  105405. /**
  105406. * Used to make an adjustment to the roll of the bone
  105407. */
  105408. adjustRoll: number;
  105409. /**
  105410. * 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)
  105411. */
  105412. slerpAmount: number;
  105413. private _minYaw;
  105414. private _maxYaw;
  105415. private _minPitch;
  105416. private _maxPitch;
  105417. private _minYawSin;
  105418. private _minYawCos;
  105419. private _maxYawSin;
  105420. private _maxYawCos;
  105421. private _midYawConstraint;
  105422. private _minPitchTan;
  105423. private _maxPitchTan;
  105424. private _boneQuat;
  105425. private _slerping;
  105426. private _transformYawPitch;
  105427. private _transformYawPitchInv;
  105428. private _firstFrameSkipped;
  105429. private _yawRange;
  105430. private _fowardAxis;
  105431. /**
  105432. * Gets or sets the minimum yaw angle that the bone can look to
  105433. */
  105434. minYaw: number;
  105435. /**
  105436. * Gets or sets the maximum yaw angle that the bone can look to
  105437. */
  105438. maxYaw: number;
  105439. /**
  105440. * Gets or sets the minimum pitch angle that the bone can look to
  105441. */
  105442. minPitch: number;
  105443. /**
  105444. * Gets or sets the maximum pitch angle that the bone can look to
  105445. */
  105446. maxPitch: number;
  105447. /**
  105448. * Create a BoneLookController
  105449. * @param mesh the mesh that the bone belongs to
  105450. * @param bone the bone that will be looking to the target
  105451. * @param target the target Vector3 to look at
  105452. * @param options optional settings:
  105453. * * maxYaw: the maximum angle the bone will yaw to
  105454. * * minYaw: the minimum angle the bone will yaw to
  105455. * * maxPitch: the maximum angle the bone will pitch to
  105456. * * minPitch: the minimum angle the bone will yaw to
  105457. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105458. * * upAxis: the up axis of the coordinate system
  105459. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105460. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105461. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105462. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105463. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105464. * * adjustRoll: used to make an adjustment to the roll of the bone
  105465. **/
  105466. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105467. maxYaw?: number;
  105468. minYaw?: number;
  105469. maxPitch?: number;
  105470. minPitch?: number;
  105471. slerpAmount?: number;
  105472. upAxis?: Vector3;
  105473. upAxisSpace?: Space;
  105474. yawAxis?: Vector3;
  105475. pitchAxis?: Vector3;
  105476. adjustYaw?: number;
  105477. adjustPitch?: number;
  105478. adjustRoll?: number;
  105479. });
  105480. /**
  105481. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  105482. */
  105483. update(): void;
  105484. private _getAngleDiff;
  105485. private _getAngleBetween;
  105486. private _isAngleBetween;
  105487. }
  105488. }
  105489. declare module BABYLON {
  105490. /**
  105491. * Manage the gamepad inputs to control an arc rotate camera.
  105492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105493. */
  105494. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  105495. /**
  105496. * Defines the camera the input is attached to.
  105497. */
  105498. camera: ArcRotateCamera;
  105499. /**
  105500. * Defines the gamepad the input is gathering event from.
  105501. */
  105502. gamepad: Nullable<Gamepad>;
  105503. /**
  105504. * Defines the gamepad rotation sensiblity.
  105505. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105506. */
  105507. gamepadRotationSensibility: number;
  105508. /**
  105509. * Defines the gamepad move sensiblity.
  105510. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105511. */
  105512. gamepadMoveSensibility: number;
  105513. private _yAxisScale;
  105514. /**
  105515. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105516. */
  105517. invertYAxis: boolean;
  105518. private _onGamepadConnectedObserver;
  105519. private _onGamepadDisconnectedObserver;
  105520. /**
  105521. * Attach the input controls to a specific dom element to get the input from.
  105522. * @param element Defines the element the controls should be listened from
  105523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105524. */
  105525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105526. /**
  105527. * Detach the current controls from the specified dom element.
  105528. * @param element Defines the element to stop listening the inputs from
  105529. */
  105530. detachControl(element: Nullable<HTMLElement>): void;
  105531. /**
  105532. * Update the current camera state depending on the inputs that have been used this frame.
  105533. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105534. */
  105535. checkInputs(): void;
  105536. /**
  105537. * Gets the class name of the current intput.
  105538. * @returns the class name
  105539. */
  105540. getClassName(): string;
  105541. /**
  105542. * Get the friendly name associated with the input class.
  105543. * @returns the input friendly name
  105544. */
  105545. getSimpleName(): string;
  105546. }
  105547. }
  105548. declare module BABYLON {
  105549. interface ArcRotateCameraInputsManager {
  105550. /**
  105551. * Add orientation input support to the input manager.
  105552. * @returns the current input manager
  105553. */
  105554. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  105555. }
  105556. /**
  105557. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  105558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105559. */
  105560. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  105561. /**
  105562. * Defines the camera the input is attached to.
  105563. */
  105564. camera: ArcRotateCamera;
  105565. /**
  105566. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  105567. */
  105568. alphaCorrection: number;
  105569. /**
  105570. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  105571. */
  105572. gammaCorrection: number;
  105573. private _alpha;
  105574. private _gamma;
  105575. private _dirty;
  105576. private _deviceOrientationHandler;
  105577. /**
  105578. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  105579. */
  105580. constructor();
  105581. /**
  105582. * Attach the input controls to a specific dom element to get the input from.
  105583. * @param element Defines the element the controls should be listened from
  105584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105585. */
  105586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105587. /** @hidden */
  105588. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  105589. /**
  105590. * Update the current camera state depending on the inputs that have been used this frame.
  105591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105592. */
  105593. checkInputs(): void;
  105594. /**
  105595. * Detach the current controls from the specified dom element.
  105596. * @param element Defines the element to stop listening the inputs from
  105597. */
  105598. detachControl(element: Nullable<HTMLElement>): void;
  105599. /**
  105600. * Gets the class name of the current intput.
  105601. * @returns the class name
  105602. */
  105603. getClassName(): string;
  105604. /**
  105605. * Get the friendly name associated with the input class.
  105606. * @returns the input friendly name
  105607. */
  105608. getSimpleName(): string;
  105609. }
  105610. }
  105611. declare module BABYLON {
  105612. /**
  105613. * Listen to mouse events to control the camera.
  105614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105615. */
  105616. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105617. /**
  105618. * Defines the camera the input is attached to.
  105619. */
  105620. camera: FlyCamera;
  105621. /**
  105622. * Defines if touch is enabled. (Default is true.)
  105623. */
  105624. touchEnabled: boolean;
  105625. /**
  105626. * Defines the buttons associated with the input to handle camera rotation.
  105627. */
  105628. buttons: number[];
  105629. /**
  105630. * Assign buttons for Yaw control.
  105631. */
  105632. buttonsYaw: number[];
  105633. /**
  105634. * Assign buttons for Pitch control.
  105635. */
  105636. buttonsPitch: number[];
  105637. /**
  105638. * Assign buttons for Roll control.
  105639. */
  105640. buttonsRoll: number[];
  105641. /**
  105642. * Detect if any button is being pressed while mouse is moved.
  105643. * -1 = Mouse locked.
  105644. * 0 = Left button.
  105645. * 1 = Middle Button.
  105646. * 2 = Right Button.
  105647. */
  105648. activeButton: number;
  105649. /**
  105650. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105651. * Higher values reduce its sensitivity.
  105652. */
  105653. angularSensibility: number;
  105654. private _mousemoveCallback;
  105655. private _observer;
  105656. private _rollObserver;
  105657. private previousPosition;
  105658. private noPreventDefault;
  105659. private element;
  105660. /**
  105661. * Listen to mouse events to control the camera.
  105662. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105664. */
  105665. constructor(touchEnabled?: boolean);
  105666. /**
  105667. * Attach the mouse control to the HTML DOM element.
  105668. * @param element Defines the element that listens to the input events.
  105669. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105670. */
  105671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105672. /**
  105673. * Detach the current controls from the specified dom element.
  105674. * @param element Defines the element to stop listening the inputs from
  105675. */
  105676. detachControl(element: Nullable<HTMLElement>): void;
  105677. /**
  105678. * Gets the class name of the current input.
  105679. * @returns the class name.
  105680. */
  105681. getClassName(): string;
  105682. /**
  105683. * Get the friendly name associated with the input class.
  105684. * @returns the input's friendly name.
  105685. */
  105686. getSimpleName(): string;
  105687. private _pointerInput;
  105688. private _onMouseMove;
  105689. /**
  105690. * Rotate camera by mouse offset.
  105691. */
  105692. private rotateCamera;
  105693. }
  105694. }
  105695. declare module BABYLON {
  105696. /**
  105697. * Default Inputs manager for the FlyCamera.
  105698. * It groups all the default supported inputs for ease of use.
  105699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105700. */
  105701. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105702. /**
  105703. * Instantiates a new FlyCameraInputsManager.
  105704. * @param camera Defines the camera the inputs belong to.
  105705. */
  105706. constructor(camera: FlyCamera);
  105707. /**
  105708. * Add keyboard input support to the input manager.
  105709. * @returns the new FlyCameraKeyboardMoveInput().
  105710. */
  105711. addKeyboard(): FlyCameraInputsManager;
  105712. /**
  105713. * Add mouse input support to the input manager.
  105714. * @param touchEnabled Enable touch screen support.
  105715. * @returns the new FlyCameraMouseInput().
  105716. */
  105717. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105718. }
  105719. }
  105720. declare module BABYLON {
  105721. /**
  105722. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105723. * such as in a 3D Space Shooter or a Flight Simulator.
  105724. */
  105725. export class FlyCamera extends TargetCamera {
  105726. /**
  105727. * Define the collision ellipsoid of the camera.
  105728. * This is helpful for simulating a camera body, like a player's body.
  105729. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105730. */
  105731. ellipsoid: Vector3;
  105732. /**
  105733. * Define an offset for the position of the ellipsoid around the camera.
  105734. * This can be helpful if the camera is attached away from the player's body center,
  105735. * such as at its head.
  105736. */
  105737. ellipsoidOffset: Vector3;
  105738. /**
  105739. * Enable or disable collisions of the camera with the rest of the scene objects.
  105740. */
  105741. checkCollisions: boolean;
  105742. /**
  105743. * Enable or disable gravity on the camera.
  105744. */
  105745. applyGravity: boolean;
  105746. /**
  105747. * Define the current direction the camera is moving to.
  105748. */
  105749. cameraDirection: Vector3;
  105750. /**
  105751. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  105752. * This overrides and empties cameraRotation.
  105753. */
  105754. rotationQuaternion: Quaternion;
  105755. /**
  105756. * Track Roll to maintain the wanted Rolling when looking around.
  105757. */
  105758. _trackRoll: number;
  105759. /**
  105760. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  105761. */
  105762. rollCorrect: number;
  105763. /**
  105764. * Mimic a banked turn, Rolling the camera when Yawing.
  105765. * It's recommended to use rollCorrect = 10 for faster banking correction.
  105766. */
  105767. bankedTurn: boolean;
  105768. /**
  105769. * Limit in radians for how much Roll banking will add. (Default: 90°)
  105770. */
  105771. bankedTurnLimit: number;
  105772. /**
  105773. * Value of 0 disables the banked Roll.
  105774. * Value of 1 is equal to the Yaw angle in radians.
  105775. */
  105776. bankedTurnMultiplier: number;
  105777. /**
  105778. * The inputs manager loads all the input sources, such as keyboard and mouse.
  105779. */
  105780. inputs: FlyCameraInputsManager;
  105781. /**
  105782. * Gets the input sensibility for mouse input.
  105783. * Higher values reduce sensitivity.
  105784. */
  105785. /**
  105786. * Sets the input sensibility for a mouse input.
  105787. * Higher values reduce sensitivity.
  105788. */
  105789. angularSensibility: number;
  105790. /**
  105791. * Get the keys for camera movement forward.
  105792. */
  105793. /**
  105794. * Set the keys for camera movement forward.
  105795. */
  105796. keysForward: number[];
  105797. /**
  105798. * Get the keys for camera movement backward.
  105799. */
  105800. keysBackward: number[];
  105801. /**
  105802. * Get the keys for camera movement up.
  105803. */
  105804. /**
  105805. * Set the keys for camera movement up.
  105806. */
  105807. keysUp: number[];
  105808. /**
  105809. * Get the keys for camera movement down.
  105810. */
  105811. /**
  105812. * Set the keys for camera movement down.
  105813. */
  105814. keysDown: number[];
  105815. /**
  105816. * Get the keys for camera movement left.
  105817. */
  105818. /**
  105819. * Set the keys for camera movement left.
  105820. */
  105821. keysLeft: number[];
  105822. /**
  105823. * Set the keys for camera movement right.
  105824. */
  105825. /**
  105826. * Set the keys for camera movement right.
  105827. */
  105828. keysRight: number[];
  105829. /**
  105830. * Event raised when the camera collides with a mesh in the scene.
  105831. */
  105832. onCollide: (collidedMesh: AbstractMesh) => void;
  105833. private _collider;
  105834. private _needMoveForGravity;
  105835. private _oldPosition;
  105836. private _diffPosition;
  105837. private _newPosition;
  105838. /** @hidden */
  105839. _localDirection: Vector3;
  105840. /** @hidden */
  105841. _transformedDirection: Vector3;
  105842. /**
  105843. * Instantiates a FlyCamera.
  105844. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105845. * such as in a 3D Space Shooter or a Flight Simulator.
  105846. * @param name Define the name of the camera in the scene.
  105847. * @param position Define the starting position of the camera in the scene.
  105848. * @param scene Define the scene the camera belongs to.
  105849. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  105850. */
  105851. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105852. /**
  105853. * Attach a control to the HTML DOM element.
  105854. * @param element Defines the element that listens to the input events.
  105855. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  105856. */
  105857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105858. /**
  105859. * Detach a control from the HTML DOM element.
  105860. * The camera will stop reacting to that input.
  105861. * @param element Defines the element that listens to the input events.
  105862. */
  105863. detachControl(element: HTMLElement): void;
  105864. private _collisionMask;
  105865. /**
  105866. * Get the mask that the camera ignores in collision events.
  105867. */
  105868. /**
  105869. * Set the mask that the camera ignores in collision events.
  105870. */
  105871. collisionMask: number;
  105872. /** @hidden */
  105873. _collideWithWorld(displacement: Vector3): void;
  105874. /** @hidden */
  105875. private _onCollisionPositionChange;
  105876. /** @hidden */
  105877. _checkInputs(): void;
  105878. /** @hidden */
  105879. _decideIfNeedsToMove(): boolean;
  105880. /** @hidden */
  105881. _updatePosition(): void;
  105882. /**
  105883. * Restore the Roll to its target value at the rate specified.
  105884. * @param rate - Higher means slower restoring.
  105885. * @hidden
  105886. */
  105887. restoreRoll(rate: number): void;
  105888. /**
  105889. * Destroy the camera and release the current resources held by it.
  105890. */
  105891. dispose(): void;
  105892. /**
  105893. * Get the current object class name.
  105894. * @returns the class name.
  105895. */
  105896. getClassName(): string;
  105897. }
  105898. }
  105899. declare module BABYLON {
  105900. /**
  105901. * Listen to keyboard events to control the camera.
  105902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105903. */
  105904. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  105905. /**
  105906. * Defines the camera the input is attached to.
  105907. */
  105908. camera: FlyCamera;
  105909. /**
  105910. * The list of keyboard keys used to control the forward move of the camera.
  105911. */
  105912. keysForward: number[];
  105913. /**
  105914. * The list of keyboard keys used to control the backward move of the camera.
  105915. */
  105916. keysBackward: number[];
  105917. /**
  105918. * The list of keyboard keys used to control the forward move of the camera.
  105919. */
  105920. keysUp: number[];
  105921. /**
  105922. * The list of keyboard keys used to control the backward move of the camera.
  105923. */
  105924. keysDown: number[];
  105925. /**
  105926. * The list of keyboard keys used to control the right strafe move of the camera.
  105927. */
  105928. keysRight: number[];
  105929. /**
  105930. * The list of keyboard keys used to control the left strafe move of the camera.
  105931. */
  105932. keysLeft: number[];
  105933. private _keys;
  105934. private _onCanvasBlurObserver;
  105935. private _onKeyboardObserver;
  105936. private _engine;
  105937. private _scene;
  105938. /**
  105939. * Attach the input controls to a specific dom element to get the input from.
  105940. * @param element Defines the element the controls should be listened from
  105941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105942. */
  105943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105944. /**
  105945. * Detach the current controls from the specified dom element.
  105946. * @param element Defines the element to stop listening the inputs from
  105947. */
  105948. detachControl(element: Nullable<HTMLElement>): void;
  105949. /**
  105950. * Gets the class name of the current intput.
  105951. * @returns the class name
  105952. */
  105953. getClassName(): string;
  105954. /** @hidden */
  105955. _onLostFocus(e: FocusEvent): void;
  105956. /**
  105957. * Get the friendly name associated with the input class.
  105958. * @returns the input friendly name
  105959. */
  105960. getSimpleName(): string;
  105961. /**
  105962. * Update the current camera state depending on the inputs that have been used this frame.
  105963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105964. */
  105965. checkInputs(): void;
  105966. }
  105967. }
  105968. declare module BABYLON {
  105969. /**
  105970. * Manage the mouse wheel inputs to control a follow camera.
  105971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105972. */
  105973. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105974. /**
  105975. * Defines the camera the input is attached to.
  105976. */
  105977. camera: FollowCamera;
  105978. /**
  105979. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105980. */
  105981. axisControlRadius: boolean;
  105982. /**
  105983. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105984. */
  105985. axisControlHeight: boolean;
  105986. /**
  105987. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105988. */
  105989. axisControlRotation: boolean;
  105990. /**
  105991. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105992. * relation to mouseWheel events.
  105993. */
  105994. wheelPrecision: number;
  105995. /**
  105996. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105997. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105998. */
  105999. wheelDeltaPercentage: number;
  106000. private _wheel;
  106001. private _observer;
  106002. /**
  106003. * Attach the input controls to a specific dom element to get the input from.
  106004. * @param element Defines the element the controls should be listened from
  106005. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106006. */
  106007. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106008. /**
  106009. * Detach the current controls from the specified dom element.
  106010. * @param element Defines the element to stop listening the inputs from
  106011. */
  106012. detachControl(element: Nullable<HTMLElement>): void;
  106013. /**
  106014. * Gets the class name of the current intput.
  106015. * @returns the class name
  106016. */
  106017. getClassName(): string;
  106018. /**
  106019. * Get the friendly name associated with the input class.
  106020. * @returns the input friendly name
  106021. */
  106022. getSimpleName(): string;
  106023. }
  106024. }
  106025. declare module BABYLON {
  106026. /**
  106027. * Manage the pointers inputs to control an follow camera.
  106028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106029. */
  106030. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106031. /**
  106032. * Defines the camera the input is attached to.
  106033. */
  106034. camera: FollowCamera;
  106035. /**
  106036. * Gets the class name of the current input.
  106037. * @returns the class name
  106038. */
  106039. getClassName(): string;
  106040. /**
  106041. * Defines the pointer angular sensibility along the X axis or how fast is
  106042. * the camera rotating.
  106043. * A negative number will reverse the axis direction.
  106044. */
  106045. angularSensibilityX: number;
  106046. /**
  106047. * Defines the pointer angular sensibility along the Y axis or how fast is
  106048. * the camera rotating.
  106049. * A negative number will reverse the axis direction.
  106050. */
  106051. angularSensibilityY: number;
  106052. /**
  106053. * Defines the pointer pinch precision or how fast is the camera zooming.
  106054. * A negative number will reverse the axis direction.
  106055. */
  106056. pinchPrecision: number;
  106057. /**
  106058. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106059. * from 0.
  106060. * It defines the percentage of current camera.radius to use as delta when
  106061. * pinch zoom is used.
  106062. */
  106063. pinchDeltaPercentage: number;
  106064. /**
  106065. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106066. */
  106067. axisXControlRadius: boolean;
  106068. /**
  106069. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106070. */
  106071. axisXControlHeight: boolean;
  106072. /**
  106073. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106074. */
  106075. axisXControlRotation: boolean;
  106076. /**
  106077. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106078. */
  106079. axisYControlRadius: boolean;
  106080. /**
  106081. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106082. */
  106083. axisYControlHeight: boolean;
  106084. /**
  106085. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106086. */
  106087. axisYControlRotation: boolean;
  106088. /**
  106089. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106090. */
  106091. axisPinchControlRadius: boolean;
  106092. /**
  106093. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106094. */
  106095. axisPinchControlHeight: boolean;
  106096. /**
  106097. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106098. */
  106099. axisPinchControlRotation: boolean;
  106100. /**
  106101. * Log error messages if basic misconfiguration has occurred.
  106102. */
  106103. warningEnable: boolean;
  106104. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106105. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106106. private _warningCounter;
  106107. private _warning;
  106108. }
  106109. }
  106110. declare module BABYLON {
  106111. /**
  106112. * Default Inputs manager for the FollowCamera.
  106113. * It groups all the default supported inputs for ease of use.
  106114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106115. */
  106116. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106117. /**
  106118. * Instantiates a new FollowCameraInputsManager.
  106119. * @param camera Defines the camera the inputs belong to
  106120. */
  106121. constructor(camera: FollowCamera);
  106122. /**
  106123. * Add keyboard input support to the input manager.
  106124. * @returns the current input manager
  106125. */
  106126. addKeyboard(): FollowCameraInputsManager;
  106127. /**
  106128. * Add mouse wheel input support to the input manager.
  106129. * @returns the current input manager
  106130. */
  106131. addMouseWheel(): FollowCameraInputsManager;
  106132. /**
  106133. * Add pointers input support to the input manager.
  106134. * @returns the current input manager
  106135. */
  106136. addPointers(): FollowCameraInputsManager;
  106137. /**
  106138. * Add orientation input support to the input manager.
  106139. * @returns the current input manager
  106140. */
  106141. addVRDeviceOrientation(): FollowCameraInputsManager;
  106142. }
  106143. }
  106144. declare module BABYLON {
  106145. /**
  106146. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106147. * an arc rotate version arcFollowCamera are available.
  106148. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106149. */
  106150. export class FollowCamera extends TargetCamera {
  106151. /**
  106152. * Distance the follow camera should follow an object at
  106153. */
  106154. radius: number;
  106155. /**
  106156. * Minimum allowed distance of the camera to the axis of rotation
  106157. * (The camera can not get closer).
  106158. * This can help limiting how the Camera is able to move in the scene.
  106159. */
  106160. lowerRadiusLimit: Nullable<number>;
  106161. /**
  106162. * Maximum allowed distance of the camera to the axis of rotation
  106163. * (The camera can not get further).
  106164. * This can help limiting how the Camera is able to move in the scene.
  106165. */
  106166. upperRadiusLimit: Nullable<number>;
  106167. /**
  106168. * Define a rotation offset between the camera and the object it follows
  106169. */
  106170. rotationOffset: number;
  106171. /**
  106172. * Minimum allowed angle to camera position relative to target object.
  106173. * This can help limiting how the Camera is able to move in the scene.
  106174. */
  106175. lowerRotationOffsetLimit: Nullable<number>;
  106176. /**
  106177. * Maximum allowed angle to camera position relative to target object.
  106178. * This can help limiting how the Camera is able to move in the scene.
  106179. */
  106180. upperRotationOffsetLimit: Nullable<number>;
  106181. /**
  106182. * Define a height offset between the camera and the object it follows.
  106183. * It can help following an object from the top (like a car chaing a plane)
  106184. */
  106185. heightOffset: number;
  106186. /**
  106187. * Minimum allowed height of camera position relative to target object.
  106188. * This can help limiting how the Camera is able to move in the scene.
  106189. */
  106190. lowerHeightOffsetLimit: Nullable<number>;
  106191. /**
  106192. * Maximum allowed height of camera position relative to target object.
  106193. * This can help limiting how the Camera is able to move in the scene.
  106194. */
  106195. upperHeightOffsetLimit: Nullable<number>;
  106196. /**
  106197. * Define how fast the camera can accelerate to follow it s target.
  106198. */
  106199. cameraAcceleration: number;
  106200. /**
  106201. * Define the speed limit of the camera following an object.
  106202. */
  106203. maxCameraSpeed: number;
  106204. /**
  106205. * Define the target of the camera.
  106206. */
  106207. lockedTarget: Nullable<AbstractMesh>;
  106208. /**
  106209. * Defines the input associated with the camera.
  106210. */
  106211. inputs: FollowCameraInputsManager;
  106212. /**
  106213. * Instantiates the follow camera.
  106214. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106215. * @param name Define the name of the camera in the scene
  106216. * @param position Define the position of the camera
  106217. * @param scene Define the scene the camera belong to
  106218. * @param lockedTarget Define the target of the camera
  106219. */
  106220. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106221. private _follow;
  106222. /**
  106223. * Attached controls to the current camera.
  106224. * @param element Defines the element the controls should be listened from
  106225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106226. */
  106227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106228. /**
  106229. * Detach the current controls from the camera.
  106230. * The camera will stop reacting to inputs.
  106231. * @param element Defines the element to stop listening the inputs from
  106232. */
  106233. detachControl(element: HTMLElement): void;
  106234. /** @hidden */
  106235. _checkInputs(): void;
  106236. private _checkLimits;
  106237. /**
  106238. * Gets the camera class name.
  106239. * @returns the class name
  106240. */
  106241. getClassName(): string;
  106242. }
  106243. /**
  106244. * Arc Rotate version of the follow camera.
  106245. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106246. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106247. */
  106248. export class ArcFollowCamera extends TargetCamera {
  106249. /** The longitudinal angle of the camera */
  106250. alpha: number;
  106251. /** The latitudinal angle of the camera */
  106252. beta: number;
  106253. /** The radius of the camera from its target */
  106254. radius: number;
  106255. /** Define the camera target (the messh it should follow) */
  106256. target: Nullable<AbstractMesh>;
  106257. private _cartesianCoordinates;
  106258. /**
  106259. * Instantiates a new ArcFollowCamera
  106260. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106261. * @param name Define the name of the camera
  106262. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106263. * @param beta Define the rotation angle of the camera around the elevation axis
  106264. * @param radius Define the radius of the camera from its target point
  106265. * @param target Define the target of the camera
  106266. * @param scene Define the scene the camera belongs to
  106267. */
  106268. constructor(name: string,
  106269. /** The longitudinal angle of the camera */
  106270. alpha: number,
  106271. /** The latitudinal angle of the camera */
  106272. beta: number,
  106273. /** The radius of the camera from its target */
  106274. radius: number,
  106275. /** Define the camera target (the messh it should follow) */
  106276. target: Nullable<AbstractMesh>, scene: Scene);
  106277. private _follow;
  106278. /** @hidden */
  106279. _checkInputs(): void;
  106280. /**
  106281. * Returns the class name of the object.
  106282. * It is mostly used internally for serialization purposes.
  106283. */
  106284. getClassName(): string;
  106285. }
  106286. }
  106287. declare module BABYLON {
  106288. /**
  106289. * Manage the keyboard inputs to control the movement of a follow camera.
  106290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106291. */
  106292. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106293. /**
  106294. * Defines the camera the input is attached to.
  106295. */
  106296. camera: FollowCamera;
  106297. /**
  106298. * Defines the list of key codes associated with the up action (increase heightOffset)
  106299. */
  106300. keysHeightOffsetIncr: number[];
  106301. /**
  106302. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106303. */
  106304. keysHeightOffsetDecr: number[];
  106305. /**
  106306. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106307. */
  106308. keysHeightOffsetModifierAlt: boolean;
  106309. /**
  106310. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106311. */
  106312. keysHeightOffsetModifierCtrl: boolean;
  106313. /**
  106314. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106315. */
  106316. keysHeightOffsetModifierShift: boolean;
  106317. /**
  106318. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106319. */
  106320. keysRotationOffsetIncr: number[];
  106321. /**
  106322. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106323. */
  106324. keysRotationOffsetDecr: number[];
  106325. /**
  106326. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106327. */
  106328. keysRotationOffsetModifierAlt: boolean;
  106329. /**
  106330. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106331. */
  106332. keysRotationOffsetModifierCtrl: boolean;
  106333. /**
  106334. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106335. */
  106336. keysRotationOffsetModifierShift: boolean;
  106337. /**
  106338. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106339. */
  106340. keysRadiusIncr: number[];
  106341. /**
  106342. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106343. */
  106344. keysRadiusDecr: number[];
  106345. /**
  106346. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106347. */
  106348. keysRadiusModifierAlt: boolean;
  106349. /**
  106350. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106351. */
  106352. keysRadiusModifierCtrl: boolean;
  106353. /**
  106354. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106355. */
  106356. keysRadiusModifierShift: boolean;
  106357. /**
  106358. * Defines the rate of change of heightOffset.
  106359. */
  106360. heightSensibility: number;
  106361. /**
  106362. * Defines the rate of change of rotationOffset.
  106363. */
  106364. rotationSensibility: number;
  106365. /**
  106366. * Defines the rate of change of radius.
  106367. */
  106368. radiusSensibility: number;
  106369. private _keys;
  106370. private _ctrlPressed;
  106371. private _altPressed;
  106372. private _shiftPressed;
  106373. private _onCanvasBlurObserver;
  106374. private _onKeyboardObserver;
  106375. private _engine;
  106376. private _scene;
  106377. /**
  106378. * Attach the input controls to a specific dom element to get the input from.
  106379. * @param element Defines the element the controls should be listened from
  106380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106381. */
  106382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106383. /**
  106384. * Detach the current controls from the specified dom element.
  106385. * @param element Defines the element to stop listening the inputs from
  106386. */
  106387. detachControl(element: Nullable<HTMLElement>): void;
  106388. /**
  106389. * Update the current camera state depending on the inputs that have been used this frame.
  106390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106391. */
  106392. checkInputs(): void;
  106393. /**
  106394. * Gets the class name of the current input.
  106395. * @returns the class name
  106396. */
  106397. getClassName(): string;
  106398. /**
  106399. * Get the friendly name associated with the input class.
  106400. * @returns the input friendly name
  106401. */
  106402. getSimpleName(): string;
  106403. /**
  106404. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106405. * allow modification of the heightOffset value.
  106406. */
  106407. private _modifierHeightOffset;
  106408. /**
  106409. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106410. * allow modification of the rotationOffset value.
  106411. */
  106412. private _modifierRotationOffset;
  106413. /**
  106414. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106415. * allow modification of the radius value.
  106416. */
  106417. private _modifierRadius;
  106418. }
  106419. }
  106420. declare module BABYLON {
  106421. interface FreeCameraInputsManager {
  106422. /**
  106423. * @hidden
  106424. */
  106425. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106426. /**
  106427. * Add orientation input support to the input manager.
  106428. * @returns the current input manager
  106429. */
  106430. addDeviceOrientation(): FreeCameraInputsManager;
  106431. }
  106432. /**
  106433. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106434. * Screen rotation is taken into account.
  106435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106436. */
  106437. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106438. private _camera;
  106439. private _screenOrientationAngle;
  106440. private _constantTranform;
  106441. private _screenQuaternion;
  106442. private _alpha;
  106443. private _beta;
  106444. private _gamma;
  106445. /**
  106446. * Can be used to detect if a device orientation sensor is availible on a device
  106447. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106448. * @returns a promise that will resolve on orientation change
  106449. */
  106450. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106451. /**
  106452. * @hidden
  106453. */
  106454. _onDeviceOrientationChangedObservable: Observable<void>;
  106455. /**
  106456. * Instantiates a new input
  106457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106458. */
  106459. constructor();
  106460. /**
  106461. * Define the camera controlled by the input.
  106462. */
  106463. camera: FreeCamera;
  106464. /**
  106465. * Attach the input controls to a specific dom element to get the input from.
  106466. * @param element Defines the element the controls should be listened from
  106467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106468. */
  106469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106470. private _orientationChanged;
  106471. private _deviceOrientation;
  106472. /**
  106473. * Detach the current controls from the specified dom element.
  106474. * @param element Defines the element to stop listening the inputs from
  106475. */
  106476. detachControl(element: Nullable<HTMLElement>): void;
  106477. /**
  106478. * Update the current camera state depending on the inputs that have been used this frame.
  106479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106480. */
  106481. checkInputs(): void;
  106482. /**
  106483. * Gets the class name of the current intput.
  106484. * @returns the class name
  106485. */
  106486. getClassName(): string;
  106487. /**
  106488. * Get the friendly name associated with the input class.
  106489. * @returns the input friendly name
  106490. */
  106491. getSimpleName(): string;
  106492. }
  106493. }
  106494. declare module BABYLON {
  106495. /**
  106496. * Manage the gamepad inputs to control a free camera.
  106497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106498. */
  106499. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  106500. /**
  106501. * Define the camera the input is attached to.
  106502. */
  106503. camera: FreeCamera;
  106504. /**
  106505. * Define the Gamepad controlling the input
  106506. */
  106507. gamepad: Nullable<Gamepad>;
  106508. /**
  106509. * Defines the gamepad rotation sensiblity.
  106510. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106511. */
  106512. gamepadAngularSensibility: number;
  106513. /**
  106514. * Defines the gamepad move sensiblity.
  106515. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106516. */
  106517. gamepadMoveSensibility: number;
  106518. private _yAxisScale;
  106519. /**
  106520. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106521. */
  106522. invertYAxis: boolean;
  106523. private _onGamepadConnectedObserver;
  106524. private _onGamepadDisconnectedObserver;
  106525. private _cameraTransform;
  106526. private _deltaTransform;
  106527. private _vector3;
  106528. private _vector2;
  106529. /**
  106530. * Attach the input controls to a specific dom element to get the input from.
  106531. * @param element Defines the element the controls should be listened from
  106532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106533. */
  106534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106535. /**
  106536. * Detach the current controls from the specified dom element.
  106537. * @param element Defines the element to stop listening the inputs from
  106538. */
  106539. detachControl(element: Nullable<HTMLElement>): void;
  106540. /**
  106541. * Update the current camera state depending on the inputs that have been used this frame.
  106542. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106543. */
  106544. checkInputs(): void;
  106545. /**
  106546. * Gets the class name of the current intput.
  106547. * @returns the class name
  106548. */
  106549. getClassName(): string;
  106550. /**
  106551. * Get the friendly name associated with the input class.
  106552. * @returns the input friendly name
  106553. */
  106554. getSimpleName(): string;
  106555. }
  106556. }
  106557. declare module BABYLON {
  106558. /**
  106559. * Defines the potential axis of a Joystick
  106560. */
  106561. export enum JoystickAxis {
  106562. /** X axis */
  106563. X = 0,
  106564. /** Y axis */
  106565. Y = 1,
  106566. /** Z axis */
  106567. Z = 2
  106568. }
  106569. /**
  106570. * Class used to define virtual joystick (used in touch mode)
  106571. */
  106572. export class VirtualJoystick {
  106573. /**
  106574. * Gets or sets a boolean indicating that left and right values must be inverted
  106575. */
  106576. reverseLeftRight: boolean;
  106577. /**
  106578. * Gets or sets a boolean indicating that up and down values must be inverted
  106579. */
  106580. reverseUpDown: boolean;
  106581. /**
  106582. * Gets the offset value for the position (ie. the change of the position value)
  106583. */
  106584. deltaPosition: Vector3;
  106585. /**
  106586. * Gets a boolean indicating if the virtual joystick was pressed
  106587. */
  106588. pressed: boolean;
  106589. /**
  106590. * Canvas the virtual joystick will render onto, default z-index of this is 5
  106591. */
  106592. static Canvas: Nullable<HTMLCanvasElement>;
  106593. private static _globalJoystickIndex;
  106594. private static vjCanvasContext;
  106595. private static vjCanvasWidth;
  106596. private static vjCanvasHeight;
  106597. private static halfWidth;
  106598. private _action;
  106599. private _axisTargetedByLeftAndRight;
  106600. private _axisTargetedByUpAndDown;
  106601. private _joystickSensibility;
  106602. private _inversedSensibility;
  106603. private _joystickPointerID;
  106604. private _joystickColor;
  106605. private _joystickPointerPos;
  106606. private _joystickPreviousPointerPos;
  106607. private _joystickPointerStartPos;
  106608. private _deltaJoystickVector;
  106609. private _leftJoystick;
  106610. private _touches;
  106611. private _onPointerDownHandlerRef;
  106612. private _onPointerMoveHandlerRef;
  106613. private _onPointerUpHandlerRef;
  106614. private _onResize;
  106615. /**
  106616. * Creates a new virtual joystick
  106617. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106618. */
  106619. constructor(leftJoystick?: boolean);
  106620. /**
  106621. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106622. * @param newJoystickSensibility defines the new sensibility
  106623. */
  106624. setJoystickSensibility(newJoystickSensibility: number): void;
  106625. private _onPointerDown;
  106626. private _onPointerMove;
  106627. private _onPointerUp;
  106628. /**
  106629. * Change the color of the virtual joystick
  106630. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106631. */
  106632. setJoystickColor(newColor: string): void;
  106633. /**
  106634. * Defines a callback to call when the joystick is touched
  106635. * @param action defines the callback
  106636. */
  106637. setActionOnTouch(action: () => any): void;
  106638. /**
  106639. * Defines which axis you'd like to control for left & right
  106640. * @param axis defines the axis to use
  106641. */
  106642. setAxisForLeftRight(axis: JoystickAxis): void;
  106643. /**
  106644. * Defines which axis you'd like to control for up & down
  106645. * @param axis defines the axis to use
  106646. */
  106647. setAxisForUpDown(axis: JoystickAxis): void;
  106648. private _drawVirtualJoystick;
  106649. /**
  106650. * Release internal HTML canvas
  106651. */
  106652. releaseCanvas(): void;
  106653. }
  106654. }
  106655. declare module BABYLON {
  106656. interface FreeCameraInputsManager {
  106657. /**
  106658. * Add virtual joystick input support to the input manager.
  106659. * @returns the current input manager
  106660. */
  106661. addVirtualJoystick(): FreeCameraInputsManager;
  106662. }
  106663. /**
  106664. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106666. */
  106667. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106668. /**
  106669. * Defines the camera the input is attached to.
  106670. */
  106671. camera: FreeCamera;
  106672. private _leftjoystick;
  106673. private _rightjoystick;
  106674. /**
  106675. * Gets the left stick of the virtual joystick.
  106676. * @returns The virtual Joystick
  106677. */
  106678. getLeftJoystick(): VirtualJoystick;
  106679. /**
  106680. * Gets the right stick of the virtual joystick.
  106681. * @returns The virtual Joystick
  106682. */
  106683. getRightJoystick(): VirtualJoystick;
  106684. /**
  106685. * Update the current camera state depending on the inputs that have been used this frame.
  106686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106687. */
  106688. checkInputs(): void;
  106689. /**
  106690. * Attach the input controls to a specific dom element to get the input from.
  106691. * @param element Defines the element the controls should be listened from
  106692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106693. */
  106694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106695. /**
  106696. * Detach the current controls from the specified dom element.
  106697. * @param element Defines the element to stop listening the inputs from
  106698. */
  106699. detachControl(element: Nullable<HTMLElement>): void;
  106700. /**
  106701. * Gets the class name of the current intput.
  106702. * @returns the class name
  106703. */
  106704. getClassName(): string;
  106705. /**
  106706. * Get the friendly name associated with the input class.
  106707. * @returns the input friendly name
  106708. */
  106709. getSimpleName(): string;
  106710. }
  106711. }
  106712. declare module BABYLON {
  106713. /**
  106714. * This represents a FPS type of camera controlled by touch.
  106715. * This is like a universal camera minus the Gamepad controls.
  106716. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106717. */
  106718. export class TouchCamera extends FreeCamera {
  106719. /**
  106720. * Defines the touch sensibility for rotation.
  106721. * The higher the faster.
  106722. */
  106723. touchAngularSensibility: number;
  106724. /**
  106725. * Defines the touch sensibility for move.
  106726. * The higher the faster.
  106727. */
  106728. touchMoveSensibility: number;
  106729. /**
  106730. * Instantiates a new touch camera.
  106731. * This represents a FPS type of camera controlled by touch.
  106732. * This is like a universal camera minus the Gamepad controls.
  106733. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106734. * @param name Define the name of the camera in the scene
  106735. * @param position Define the start position of the camera in the scene
  106736. * @param scene Define the scene the camera belongs to
  106737. */
  106738. constructor(name: string, position: Vector3, scene: Scene);
  106739. /**
  106740. * Gets the current object class name.
  106741. * @return the class name
  106742. */
  106743. getClassName(): string;
  106744. /** @hidden */
  106745. _setupInputs(): void;
  106746. }
  106747. }
  106748. declare module BABYLON {
  106749. /**
  106750. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  106751. * being tilted forward or back and left or right.
  106752. */
  106753. export class DeviceOrientationCamera extends FreeCamera {
  106754. private _initialQuaternion;
  106755. private _quaternionCache;
  106756. private _tmpDragQuaternion;
  106757. private _disablePointerInputWhenUsingDeviceOrientation;
  106758. /**
  106759. * Creates a new device orientation camera
  106760. * @param name The name of the camera
  106761. * @param position The start position camera
  106762. * @param scene The scene the camera belongs to
  106763. */
  106764. constructor(name: string, position: Vector3, scene: Scene);
  106765. /**
  106766. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  106767. */
  106768. disablePointerInputWhenUsingDeviceOrientation: boolean;
  106769. private _dragFactor;
  106770. /**
  106771. * Enabled turning on the y axis when the orientation sensor is active
  106772. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  106773. */
  106774. enableHorizontalDragging(dragFactor?: number): void;
  106775. /**
  106776. * Gets the current instance class name ("DeviceOrientationCamera").
  106777. * This helps avoiding instanceof at run time.
  106778. * @returns the class name
  106779. */
  106780. getClassName(): string;
  106781. /**
  106782. * @hidden
  106783. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  106784. */
  106785. _checkInputs(): void;
  106786. /**
  106787. * Reset the camera to its default orientation on the specified axis only.
  106788. * @param axis The axis to reset
  106789. */
  106790. resetToCurrentRotation(axis?: Axis): void;
  106791. }
  106792. }
  106793. declare module BABYLON {
  106794. /**
  106795. * Defines supported buttons for XBox360 compatible gamepads
  106796. */
  106797. export enum Xbox360Button {
  106798. /** A */
  106799. A = 0,
  106800. /** B */
  106801. B = 1,
  106802. /** X */
  106803. X = 2,
  106804. /** Y */
  106805. Y = 3,
  106806. /** Start */
  106807. Start = 4,
  106808. /** Back */
  106809. Back = 5,
  106810. /** Left button */
  106811. LB = 6,
  106812. /** Right button */
  106813. RB = 7,
  106814. /** Left stick */
  106815. LeftStick = 8,
  106816. /** Right stick */
  106817. RightStick = 9
  106818. }
  106819. /** Defines values for XBox360 DPad */
  106820. export enum Xbox360Dpad {
  106821. /** Up */
  106822. Up = 0,
  106823. /** Down */
  106824. Down = 1,
  106825. /** Left */
  106826. Left = 2,
  106827. /** Right */
  106828. Right = 3
  106829. }
  106830. /**
  106831. * Defines a XBox360 gamepad
  106832. */
  106833. export class Xbox360Pad extends Gamepad {
  106834. private _leftTrigger;
  106835. private _rightTrigger;
  106836. private _onlefttriggerchanged;
  106837. private _onrighttriggerchanged;
  106838. private _onbuttondown;
  106839. private _onbuttonup;
  106840. private _ondpaddown;
  106841. private _ondpadup;
  106842. /** Observable raised when a button is pressed */
  106843. onButtonDownObservable: Observable<Xbox360Button>;
  106844. /** Observable raised when a button is released */
  106845. onButtonUpObservable: Observable<Xbox360Button>;
  106846. /** Observable raised when a pad is pressed */
  106847. onPadDownObservable: Observable<Xbox360Dpad>;
  106848. /** Observable raised when a pad is released */
  106849. onPadUpObservable: Observable<Xbox360Dpad>;
  106850. private _buttonA;
  106851. private _buttonB;
  106852. private _buttonX;
  106853. private _buttonY;
  106854. private _buttonBack;
  106855. private _buttonStart;
  106856. private _buttonLB;
  106857. private _buttonRB;
  106858. private _buttonLeftStick;
  106859. private _buttonRightStick;
  106860. private _dPadUp;
  106861. private _dPadDown;
  106862. private _dPadLeft;
  106863. private _dPadRight;
  106864. private _isXboxOnePad;
  106865. /**
  106866. * Creates a new XBox360 gamepad object
  106867. * @param id defines the id of this gamepad
  106868. * @param index defines its index
  106869. * @param gamepad defines the internal HTML gamepad object
  106870. * @param xboxOne defines if it is a XBox One gamepad
  106871. */
  106872. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  106873. /**
  106874. * Defines the callback to call when left trigger is pressed
  106875. * @param callback defines the callback to use
  106876. */
  106877. onlefttriggerchanged(callback: (value: number) => void): void;
  106878. /**
  106879. * Defines the callback to call when right trigger is pressed
  106880. * @param callback defines the callback to use
  106881. */
  106882. onrighttriggerchanged(callback: (value: number) => void): void;
  106883. /**
  106884. * Gets the left trigger value
  106885. */
  106886. /**
  106887. * Sets the left trigger value
  106888. */
  106889. leftTrigger: number;
  106890. /**
  106891. * Gets the right trigger value
  106892. */
  106893. /**
  106894. * Sets the right trigger value
  106895. */
  106896. rightTrigger: number;
  106897. /**
  106898. * Defines the callback to call when a button is pressed
  106899. * @param callback defines the callback to use
  106900. */
  106901. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  106902. /**
  106903. * Defines the callback to call when a button is released
  106904. * @param callback defines the callback to use
  106905. */
  106906. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  106907. /**
  106908. * Defines the callback to call when a pad is pressed
  106909. * @param callback defines the callback to use
  106910. */
  106911. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106912. /**
  106913. * Defines the callback to call when a pad is released
  106914. * @param callback defines the callback to use
  106915. */
  106916. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106917. private _setButtonValue;
  106918. private _setDPadValue;
  106919. /**
  106920. * Gets the value of the `A` button
  106921. */
  106922. /**
  106923. * Sets the value of the `A` button
  106924. */
  106925. buttonA: number;
  106926. /**
  106927. * Gets the value of the `B` button
  106928. */
  106929. /**
  106930. * Sets the value of the `B` button
  106931. */
  106932. buttonB: number;
  106933. /**
  106934. * Gets the value of the `X` button
  106935. */
  106936. /**
  106937. * Sets the value of the `X` button
  106938. */
  106939. buttonX: number;
  106940. /**
  106941. * Gets the value of the `Y` button
  106942. */
  106943. /**
  106944. * Sets the value of the `Y` button
  106945. */
  106946. buttonY: number;
  106947. /**
  106948. * Gets the value of the `Start` button
  106949. */
  106950. /**
  106951. * Sets the value of the `Start` button
  106952. */
  106953. buttonStart: number;
  106954. /**
  106955. * Gets the value of the `Back` button
  106956. */
  106957. /**
  106958. * Sets the value of the `Back` button
  106959. */
  106960. buttonBack: number;
  106961. /**
  106962. * Gets the value of the `Left` button
  106963. */
  106964. /**
  106965. * Sets the value of the `Left` button
  106966. */
  106967. buttonLB: number;
  106968. /**
  106969. * Gets the value of the `Right` button
  106970. */
  106971. /**
  106972. * Sets the value of the `Right` button
  106973. */
  106974. buttonRB: number;
  106975. /**
  106976. * Gets the value of the Left joystick
  106977. */
  106978. /**
  106979. * Sets the value of the Left joystick
  106980. */
  106981. buttonLeftStick: number;
  106982. /**
  106983. * Gets the value of the Right joystick
  106984. */
  106985. /**
  106986. * Sets the value of the Right joystick
  106987. */
  106988. buttonRightStick: number;
  106989. /**
  106990. * Gets the value of D-pad up
  106991. */
  106992. /**
  106993. * Sets the value of D-pad up
  106994. */
  106995. dPadUp: number;
  106996. /**
  106997. * Gets the value of D-pad down
  106998. */
  106999. /**
  107000. * Sets the value of D-pad down
  107001. */
  107002. dPadDown: number;
  107003. /**
  107004. * Gets the value of D-pad left
  107005. */
  107006. /**
  107007. * Sets the value of D-pad left
  107008. */
  107009. dPadLeft: number;
  107010. /**
  107011. * Gets the value of D-pad right
  107012. */
  107013. /**
  107014. * Sets the value of D-pad right
  107015. */
  107016. dPadRight: number;
  107017. /**
  107018. * Force the gamepad to synchronize with device values
  107019. */
  107020. update(): void;
  107021. /**
  107022. * Disposes the gamepad
  107023. */
  107024. dispose(): void;
  107025. }
  107026. }
  107027. declare module BABYLON {
  107028. /**
  107029. * Defines supported buttons for DualShock compatible gamepads
  107030. */
  107031. export enum DualShockButton {
  107032. /** Cross */
  107033. Cross = 0,
  107034. /** Circle */
  107035. Circle = 1,
  107036. /** Square */
  107037. Square = 2,
  107038. /** Triangle */
  107039. Triangle = 3,
  107040. /** Options */
  107041. Options = 4,
  107042. /** Share */
  107043. Share = 5,
  107044. /** L1 */
  107045. L1 = 6,
  107046. /** R1 */
  107047. R1 = 7,
  107048. /** Left stick */
  107049. LeftStick = 8,
  107050. /** Right stick */
  107051. RightStick = 9
  107052. }
  107053. /** Defines values for DualShock DPad */
  107054. export enum DualShockDpad {
  107055. /** Up */
  107056. Up = 0,
  107057. /** Down */
  107058. Down = 1,
  107059. /** Left */
  107060. Left = 2,
  107061. /** Right */
  107062. Right = 3
  107063. }
  107064. /**
  107065. * Defines a DualShock gamepad
  107066. */
  107067. export class DualShockPad extends Gamepad {
  107068. private _leftTrigger;
  107069. private _rightTrigger;
  107070. private _onlefttriggerchanged;
  107071. private _onrighttriggerchanged;
  107072. private _onbuttondown;
  107073. private _onbuttonup;
  107074. private _ondpaddown;
  107075. private _ondpadup;
  107076. /** Observable raised when a button is pressed */
  107077. onButtonDownObservable: Observable<DualShockButton>;
  107078. /** Observable raised when a button is released */
  107079. onButtonUpObservable: Observable<DualShockButton>;
  107080. /** Observable raised when a pad is pressed */
  107081. onPadDownObservable: Observable<DualShockDpad>;
  107082. /** Observable raised when a pad is released */
  107083. onPadUpObservable: Observable<DualShockDpad>;
  107084. private _buttonCross;
  107085. private _buttonCircle;
  107086. private _buttonSquare;
  107087. private _buttonTriangle;
  107088. private _buttonShare;
  107089. private _buttonOptions;
  107090. private _buttonL1;
  107091. private _buttonR1;
  107092. private _buttonLeftStick;
  107093. private _buttonRightStick;
  107094. private _dPadUp;
  107095. private _dPadDown;
  107096. private _dPadLeft;
  107097. private _dPadRight;
  107098. /**
  107099. * Creates a new DualShock gamepad object
  107100. * @param id defines the id of this gamepad
  107101. * @param index defines its index
  107102. * @param gamepad defines the internal HTML gamepad object
  107103. */
  107104. constructor(id: string, index: number, gamepad: any);
  107105. /**
  107106. * Defines the callback to call when left trigger is pressed
  107107. * @param callback defines the callback to use
  107108. */
  107109. onlefttriggerchanged(callback: (value: number) => void): void;
  107110. /**
  107111. * Defines the callback to call when right trigger is pressed
  107112. * @param callback defines the callback to use
  107113. */
  107114. onrighttriggerchanged(callback: (value: number) => void): void;
  107115. /**
  107116. * Gets the left trigger value
  107117. */
  107118. /**
  107119. * Sets the left trigger value
  107120. */
  107121. leftTrigger: number;
  107122. /**
  107123. * Gets the right trigger value
  107124. */
  107125. /**
  107126. * Sets the right trigger value
  107127. */
  107128. rightTrigger: number;
  107129. /**
  107130. * Defines the callback to call when a button is pressed
  107131. * @param callback defines the callback to use
  107132. */
  107133. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107134. /**
  107135. * Defines the callback to call when a button is released
  107136. * @param callback defines the callback to use
  107137. */
  107138. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107139. /**
  107140. * Defines the callback to call when a pad is pressed
  107141. * @param callback defines the callback to use
  107142. */
  107143. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107144. /**
  107145. * Defines the callback to call when a pad is released
  107146. * @param callback defines the callback to use
  107147. */
  107148. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107149. private _setButtonValue;
  107150. private _setDPadValue;
  107151. /**
  107152. * Gets the value of the `Cross` button
  107153. */
  107154. /**
  107155. * Sets the value of the `Cross` button
  107156. */
  107157. buttonCross: number;
  107158. /**
  107159. * Gets the value of the `Circle` button
  107160. */
  107161. /**
  107162. * Sets the value of the `Circle` button
  107163. */
  107164. buttonCircle: number;
  107165. /**
  107166. * Gets the value of the `Square` button
  107167. */
  107168. /**
  107169. * Sets the value of the `Square` button
  107170. */
  107171. buttonSquare: number;
  107172. /**
  107173. * Gets the value of the `Triangle` button
  107174. */
  107175. /**
  107176. * Sets the value of the `Triangle` button
  107177. */
  107178. buttonTriangle: number;
  107179. /**
  107180. * Gets the value of the `Options` button
  107181. */
  107182. /**
  107183. * Sets the value of the `Options` button
  107184. */
  107185. buttonOptions: number;
  107186. /**
  107187. * Gets the value of the `Share` button
  107188. */
  107189. /**
  107190. * Sets the value of the `Share` button
  107191. */
  107192. buttonShare: number;
  107193. /**
  107194. * Gets the value of the `L1` button
  107195. */
  107196. /**
  107197. * Sets the value of the `L1` button
  107198. */
  107199. buttonL1: number;
  107200. /**
  107201. * Gets the value of the `R1` button
  107202. */
  107203. /**
  107204. * Sets the value of the `R1` button
  107205. */
  107206. buttonR1: number;
  107207. /**
  107208. * Gets the value of the Left joystick
  107209. */
  107210. /**
  107211. * Sets the value of the Left joystick
  107212. */
  107213. buttonLeftStick: number;
  107214. /**
  107215. * Gets the value of the Right joystick
  107216. */
  107217. /**
  107218. * Sets the value of the Right joystick
  107219. */
  107220. buttonRightStick: number;
  107221. /**
  107222. * Gets the value of D-pad up
  107223. */
  107224. /**
  107225. * Sets the value of D-pad up
  107226. */
  107227. dPadUp: number;
  107228. /**
  107229. * Gets the value of D-pad down
  107230. */
  107231. /**
  107232. * Sets the value of D-pad down
  107233. */
  107234. dPadDown: number;
  107235. /**
  107236. * Gets the value of D-pad left
  107237. */
  107238. /**
  107239. * Sets the value of D-pad left
  107240. */
  107241. dPadLeft: number;
  107242. /**
  107243. * Gets the value of D-pad right
  107244. */
  107245. /**
  107246. * Sets the value of D-pad right
  107247. */
  107248. dPadRight: number;
  107249. /**
  107250. * Force the gamepad to synchronize with device values
  107251. */
  107252. update(): void;
  107253. /**
  107254. * Disposes the gamepad
  107255. */
  107256. dispose(): void;
  107257. }
  107258. }
  107259. declare module BABYLON {
  107260. /**
  107261. * Manager for handling gamepads
  107262. */
  107263. export class GamepadManager {
  107264. private _scene?;
  107265. private _babylonGamepads;
  107266. private _oneGamepadConnected;
  107267. /** @hidden */
  107268. _isMonitoring: boolean;
  107269. private _gamepadEventSupported;
  107270. private _gamepadSupport;
  107271. /**
  107272. * observable to be triggered when the gamepad controller has been connected
  107273. */
  107274. onGamepadConnectedObservable: Observable<Gamepad>;
  107275. /**
  107276. * observable to be triggered when the gamepad controller has been disconnected
  107277. */
  107278. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107279. private _onGamepadConnectedEvent;
  107280. private _onGamepadDisconnectedEvent;
  107281. /**
  107282. * Initializes the gamepad manager
  107283. * @param _scene BabylonJS scene
  107284. */
  107285. constructor(_scene?: Scene | undefined);
  107286. /**
  107287. * The gamepads in the game pad manager
  107288. */
  107289. readonly gamepads: Gamepad[];
  107290. /**
  107291. * Get the gamepad controllers based on type
  107292. * @param type The type of gamepad controller
  107293. * @returns Nullable gamepad
  107294. */
  107295. getGamepadByType(type?: number): Nullable<Gamepad>;
  107296. /**
  107297. * Disposes the gamepad manager
  107298. */
  107299. dispose(): void;
  107300. private _addNewGamepad;
  107301. private _startMonitoringGamepads;
  107302. private _stopMonitoringGamepads;
  107303. /** @hidden */
  107304. _checkGamepadsStatus(): void;
  107305. private _updateGamepadObjects;
  107306. }
  107307. }
  107308. declare module BABYLON {
  107309. interface Scene {
  107310. /** @hidden */
  107311. _gamepadManager: Nullable<GamepadManager>;
  107312. /**
  107313. * Gets the gamepad manager associated with the scene
  107314. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107315. */
  107316. gamepadManager: GamepadManager;
  107317. }
  107318. /**
  107319. * Interface representing a free camera inputs manager
  107320. */
  107321. interface FreeCameraInputsManager {
  107322. /**
  107323. * Adds gamepad input support to the FreeCameraInputsManager.
  107324. * @returns the FreeCameraInputsManager
  107325. */
  107326. addGamepad(): FreeCameraInputsManager;
  107327. }
  107328. /**
  107329. * Interface representing an arc rotate camera inputs manager
  107330. */
  107331. interface ArcRotateCameraInputsManager {
  107332. /**
  107333. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107334. * @returns the camera inputs manager
  107335. */
  107336. addGamepad(): ArcRotateCameraInputsManager;
  107337. }
  107338. /**
  107339. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107340. */
  107341. export class GamepadSystemSceneComponent implements ISceneComponent {
  107342. /**
  107343. * The component name helpfull to identify the component in the list of scene components.
  107344. */
  107345. readonly name: string;
  107346. /**
  107347. * The scene the component belongs to.
  107348. */
  107349. scene: Scene;
  107350. /**
  107351. * Creates a new instance of the component for the given scene
  107352. * @param scene Defines the scene to register the component in
  107353. */
  107354. constructor(scene: Scene);
  107355. /**
  107356. * Registers the component in a given scene
  107357. */
  107358. register(): void;
  107359. /**
  107360. * Rebuilds the elements related to this component in case of
  107361. * context lost for instance.
  107362. */
  107363. rebuild(): void;
  107364. /**
  107365. * Disposes the component and the associated ressources
  107366. */
  107367. dispose(): void;
  107368. private _beforeCameraUpdate;
  107369. }
  107370. }
  107371. declare module BABYLON {
  107372. /**
  107373. * 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,
  107374. * which still works and will still be found in many Playgrounds.
  107375. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107376. */
  107377. export class UniversalCamera extends TouchCamera {
  107378. /**
  107379. * Defines the gamepad rotation sensiblity.
  107380. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107381. */
  107382. gamepadAngularSensibility: number;
  107383. /**
  107384. * Defines the gamepad move sensiblity.
  107385. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107386. */
  107387. gamepadMoveSensibility: number;
  107388. /**
  107389. * 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,
  107390. * which still works and will still be found in many Playgrounds.
  107391. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107392. * @param name Define the name of the camera in the scene
  107393. * @param position Define the start position of the camera in the scene
  107394. * @param scene Define the scene the camera belongs to
  107395. */
  107396. constructor(name: string, position: Vector3, scene: Scene);
  107397. /**
  107398. * Gets the current object class name.
  107399. * @return the class name
  107400. */
  107401. getClassName(): string;
  107402. }
  107403. }
  107404. declare module BABYLON {
  107405. /**
  107406. * This represents a FPS type of camera. This is only here for back compat purpose.
  107407. * Please use the UniversalCamera instead as both are identical.
  107408. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107409. */
  107410. export class GamepadCamera extends UniversalCamera {
  107411. /**
  107412. * Instantiates a new Gamepad Camera
  107413. * This represents a FPS type of camera. This is only here for back compat purpose.
  107414. * Please use the UniversalCamera instead as both are identical.
  107415. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107416. * @param name Define the name of the camera in the scene
  107417. * @param position Define the start position of the camera in the scene
  107418. * @param scene Define the scene the camera belongs to
  107419. */
  107420. constructor(name: string, position: Vector3, scene: Scene);
  107421. /**
  107422. * Gets the current object class name.
  107423. * @return the class name
  107424. */
  107425. getClassName(): string;
  107426. }
  107427. }
  107428. declare module BABYLON {
  107429. /** @hidden */
  107430. export var passPixelShader: {
  107431. name: string;
  107432. shader: string;
  107433. };
  107434. }
  107435. declare module BABYLON {
  107436. /** @hidden */
  107437. export var passCubePixelShader: {
  107438. name: string;
  107439. shader: string;
  107440. };
  107441. }
  107442. declare module BABYLON {
  107443. /**
  107444. * PassPostProcess which produces an output the same as it's input
  107445. */
  107446. export class PassPostProcess extends PostProcess {
  107447. /**
  107448. * Creates the PassPostProcess
  107449. * @param name The name of the effect.
  107450. * @param options The required width/height ratio to downsize to before computing the render pass.
  107451. * @param camera The camera to apply the render pass to.
  107452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107453. * @param engine The engine which the post process will be applied. (default: current engine)
  107454. * @param reusable If the post process can be reused on the same frame. (default: false)
  107455. * @param textureType The type of texture to be used when performing the post processing.
  107456. * @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)
  107457. */
  107458. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107459. }
  107460. /**
  107461. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107462. */
  107463. export class PassCubePostProcess extends PostProcess {
  107464. private _face;
  107465. /**
  107466. * Gets or sets the cube face to display.
  107467. * * 0 is +X
  107468. * * 1 is -X
  107469. * * 2 is +Y
  107470. * * 3 is -Y
  107471. * * 4 is +Z
  107472. * * 5 is -Z
  107473. */
  107474. face: number;
  107475. /**
  107476. * Creates the PassCubePostProcess
  107477. * @param name The name of the effect.
  107478. * @param options The required width/height ratio to downsize to before computing the render pass.
  107479. * @param camera The camera to apply the render pass to.
  107480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107481. * @param engine The engine which the post process will be applied. (default: current engine)
  107482. * @param reusable If the post process can be reused on the same frame. (default: false)
  107483. * @param textureType The type of texture to be used when performing the post processing.
  107484. * @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)
  107485. */
  107486. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107487. }
  107488. }
  107489. declare module BABYLON {
  107490. /** @hidden */
  107491. export var anaglyphPixelShader: {
  107492. name: string;
  107493. shader: string;
  107494. };
  107495. }
  107496. declare module BABYLON {
  107497. /**
  107498. * Postprocess used to generate anaglyphic rendering
  107499. */
  107500. export class AnaglyphPostProcess extends PostProcess {
  107501. private _passedProcess;
  107502. /**
  107503. * Creates a new AnaglyphPostProcess
  107504. * @param name defines postprocess name
  107505. * @param options defines creation options or target ratio scale
  107506. * @param rigCameras defines cameras using this postprocess
  107507. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  107508. * @param engine defines hosting engine
  107509. * @param reusable defines if the postprocess will be reused multiple times per frame
  107510. */
  107511. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  107512. }
  107513. }
  107514. declare module BABYLON {
  107515. /**
  107516. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  107517. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107518. */
  107519. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  107520. /**
  107521. * Creates a new AnaglyphArcRotateCamera
  107522. * @param name defines camera name
  107523. * @param alpha defines alpha angle (in radians)
  107524. * @param beta defines beta angle (in radians)
  107525. * @param radius defines radius
  107526. * @param target defines camera target
  107527. * @param interaxialDistance defines distance between each color axis
  107528. * @param scene defines the hosting scene
  107529. */
  107530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  107531. /**
  107532. * Gets camera class name
  107533. * @returns AnaglyphArcRotateCamera
  107534. */
  107535. getClassName(): string;
  107536. }
  107537. }
  107538. declare module BABYLON {
  107539. /**
  107540. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  107541. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107542. */
  107543. export class AnaglyphFreeCamera extends FreeCamera {
  107544. /**
  107545. * Creates a new AnaglyphFreeCamera
  107546. * @param name defines camera name
  107547. * @param position defines initial position
  107548. * @param interaxialDistance defines distance between each color axis
  107549. * @param scene defines the hosting scene
  107550. */
  107551. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107552. /**
  107553. * Gets camera class name
  107554. * @returns AnaglyphFreeCamera
  107555. */
  107556. getClassName(): string;
  107557. }
  107558. }
  107559. declare module BABYLON {
  107560. /**
  107561. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  107562. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107563. */
  107564. export class AnaglyphGamepadCamera extends GamepadCamera {
  107565. /**
  107566. * Creates a new AnaglyphGamepadCamera
  107567. * @param name defines camera name
  107568. * @param position defines initial position
  107569. * @param interaxialDistance defines distance between each color axis
  107570. * @param scene defines the hosting scene
  107571. */
  107572. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107573. /**
  107574. * Gets camera class name
  107575. * @returns AnaglyphGamepadCamera
  107576. */
  107577. getClassName(): string;
  107578. }
  107579. }
  107580. declare module BABYLON {
  107581. /**
  107582. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  107583. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107584. */
  107585. export class AnaglyphUniversalCamera extends UniversalCamera {
  107586. /**
  107587. * Creates a new AnaglyphUniversalCamera
  107588. * @param name defines camera name
  107589. * @param position defines initial position
  107590. * @param interaxialDistance defines distance between each color axis
  107591. * @param scene defines the hosting scene
  107592. */
  107593. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107594. /**
  107595. * Gets camera class name
  107596. * @returns AnaglyphUniversalCamera
  107597. */
  107598. getClassName(): string;
  107599. }
  107600. }
  107601. declare module BABYLON {
  107602. /** @hidden */
  107603. export var stereoscopicInterlacePixelShader: {
  107604. name: string;
  107605. shader: string;
  107606. };
  107607. }
  107608. declare module BABYLON {
  107609. /**
  107610. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107611. */
  107612. export class StereoscopicInterlacePostProcess extends PostProcess {
  107613. private _stepSize;
  107614. private _passedProcess;
  107615. /**
  107616. * Initializes a StereoscopicInterlacePostProcess
  107617. * @param name The name of the effect.
  107618. * @param rigCameras The rig cameras to be appled to the post process
  107619. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107621. * @param engine The engine which the post process will be applied. (default: current engine)
  107622. * @param reusable If the post process can be reused on the same frame. (default: false)
  107623. */
  107624. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107625. }
  107626. }
  107627. declare module BABYLON {
  107628. /**
  107629. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107630. * @see http://doc.babylonjs.com/features/cameras
  107631. */
  107632. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107633. /**
  107634. * Creates a new StereoscopicArcRotateCamera
  107635. * @param name defines camera name
  107636. * @param alpha defines alpha angle (in radians)
  107637. * @param beta defines beta angle (in radians)
  107638. * @param radius defines radius
  107639. * @param target defines camera target
  107640. * @param interaxialDistance defines distance between each color axis
  107641. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107642. * @param scene defines the hosting scene
  107643. */
  107644. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107645. /**
  107646. * Gets camera class name
  107647. * @returns StereoscopicArcRotateCamera
  107648. */
  107649. getClassName(): string;
  107650. }
  107651. }
  107652. declare module BABYLON {
  107653. /**
  107654. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107655. * @see http://doc.babylonjs.com/features/cameras
  107656. */
  107657. export class StereoscopicFreeCamera extends FreeCamera {
  107658. /**
  107659. * Creates a new StereoscopicFreeCamera
  107660. * @param name defines camera name
  107661. * @param position defines initial position
  107662. * @param interaxialDistance defines distance between each color axis
  107663. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107664. * @param scene defines the hosting scene
  107665. */
  107666. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107667. /**
  107668. * Gets camera class name
  107669. * @returns StereoscopicFreeCamera
  107670. */
  107671. getClassName(): string;
  107672. }
  107673. }
  107674. declare module BABYLON {
  107675. /**
  107676. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107677. * @see http://doc.babylonjs.com/features/cameras
  107678. */
  107679. export class StereoscopicGamepadCamera extends GamepadCamera {
  107680. /**
  107681. * Creates a new StereoscopicGamepadCamera
  107682. * @param name defines camera name
  107683. * @param position defines initial position
  107684. * @param interaxialDistance defines distance between each color axis
  107685. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107686. * @param scene defines the hosting scene
  107687. */
  107688. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107689. /**
  107690. * Gets camera class name
  107691. * @returns StereoscopicGamepadCamera
  107692. */
  107693. getClassName(): string;
  107694. }
  107695. }
  107696. declare module BABYLON {
  107697. /**
  107698. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107699. * @see http://doc.babylonjs.com/features/cameras
  107700. */
  107701. export class StereoscopicUniversalCamera extends UniversalCamera {
  107702. /**
  107703. * Creates a new StereoscopicUniversalCamera
  107704. * @param name defines camera name
  107705. * @param position defines initial position
  107706. * @param interaxialDistance defines distance between each color axis
  107707. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107708. * @param scene defines the hosting scene
  107709. */
  107710. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107711. /**
  107712. * Gets camera class name
  107713. * @returns StereoscopicUniversalCamera
  107714. */
  107715. getClassName(): string;
  107716. }
  107717. }
  107718. declare module BABYLON {
  107719. /**
  107720. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107721. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107722. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107723. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107724. */
  107725. export class VirtualJoysticksCamera extends FreeCamera {
  107726. /**
  107727. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107728. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107729. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107730. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107731. * @param name Define the name of the camera in the scene
  107732. * @param position Define the start position of the camera in the scene
  107733. * @param scene Define the scene the camera belongs to
  107734. */
  107735. constructor(name: string, position: Vector3, scene: Scene);
  107736. /**
  107737. * Gets the current object class name.
  107738. * @return the class name
  107739. */
  107740. getClassName(): string;
  107741. }
  107742. }
  107743. declare module BABYLON {
  107744. /**
  107745. * This represents all the required metrics to create a VR camera.
  107746. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107747. */
  107748. export class VRCameraMetrics {
  107749. /**
  107750. * Define the horizontal resolution off the screen.
  107751. */
  107752. hResolution: number;
  107753. /**
  107754. * Define the vertical resolution off the screen.
  107755. */
  107756. vResolution: number;
  107757. /**
  107758. * Define the horizontal screen size.
  107759. */
  107760. hScreenSize: number;
  107761. /**
  107762. * Define the vertical screen size.
  107763. */
  107764. vScreenSize: number;
  107765. /**
  107766. * Define the vertical screen center position.
  107767. */
  107768. vScreenCenter: number;
  107769. /**
  107770. * Define the distance of the eyes to the screen.
  107771. */
  107772. eyeToScreenDistance: number;
  107773. /**
  107774. * Define the distance between both lenses
  107775. */
  107776. lensSeparationDistance: number;
  107777. /**
  107778. * Define the distance between both viewer's eyes.
  107779. */
  107780. interpupillaryDistance: number;
  107781. /**
  107782. * Define the distortion factor of the VR postprocess.
  107783. * Please, touch with care.
  107784. */
  107785. distortionK: number[];
  107786. /**
  107787. * Define the chromatic aberration correction factors for the VR post process.
  107788. */
  107789. chromaAbCorrection: number[];
  107790. /**
  107791. * Define the scale factor of the post process.
  107792. * The smaller the better but the slower.
  107793. */
  107794. postProcessScaleFactor: number;
  107795. /**
  107796. * Define an offset for the lens center.
  107797. */
  107798. lensCenterOffset: number;
  107799. /**
  107800. * Define if the current vr camera should compensate the distortion of the lense or not.
  107801. */
  107802. compensateDistortion: boolean;
  107803. /**
  107804. * Defines if multiview should be enabled when rendering (Default: false)
  107805. */
  107806. multiviewEnabled: boolean;
  107807. /**
  107808. * Gets the rendering aspect ratio based on the provided resolutions.
  107809. */
  107810. readonly aspectRatio: number;
  107811. /**
  107812. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  107813. */
  107814. readonly aspectRatioFov: number;
  107815. /**
  107816. * @hidden
  107817. */
  107818. readonly leftHMatrix: Matrix;
  107819. /**
  107820. * @hidden
  107821. */
  107822. readonly rightHMatrix: Matrix;
  107823. /**
  107824. * @hidden
  107825. */
  107826. readonly leftPreViewMatrix: Matrix;
  107827. /**
  107828. * @hidden
  107829. */
  107830. readonly rightPreViewMatrix: Matrix;
  107831. /**
  107832. * Get the default VRMetrics based on the most generic setup.
  107833. * @returns the default vr metrics
  107834. */
  107835. static GetDefault(): VRCameraMetrics;
  107836. }
  107837. }
  107838. declare module BABYLON {
  107839. /** @hidden */
  107840. export var vrDistortionCorrectionPixelShader: {
  107841. name: string;
  107842. shader: string;
  107843. };
  107844. }
  107845. declare module BABYLON {
  107846. /**
  107847. * VRDistortionCorrectionPostProcess used for mobile VR
  107848. */
  107849. export class VRDistortionCorrectionPostProcess extends PostProcess {
  107850. private _isRightEye;
  107851. private _distortionFactors;
  107852. private _postProcessScaleFactor;
  107853. private _lensCenterOffset;
  107854. private _scaleIn;
  107855. private _scaleFactor;
  107856. private _lensCenter;
  107857. /**
  107858. * Initializes the VRDistortionCorrectionPostProcess
  107859. * @param name The name of the effect.
  107860. * @param camera The camera to apply the render pass to.
  107861. * @param isRightEye If this is for the right eye distortion
  107862. * @param vrMetrics All the required metrics for the VR camera
  107863. */
  107864. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  107865. }
  107866. }
  107867. declare module BABYLON {
  107868. /**
  107869. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  107870. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107871. */
  107872. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  107873. /**
  107874. * Creates a new VRDeviceOrientationArcRotateCamera
  107875. * @param name defines camera name
  107876. * @param alpha defines the camera rotation along the logitudinal axis
  107877. * @param beta defines the camera rotation along the latitudinal axis
  107878. * @param radius defines the camera distance from its target
  107879. * @param target defines the camera target
  107880. * @param scene defines the scene the camera belongs to
  107881. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107882. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107883. */
  107884. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107885. /**
  107886. * Gets camera class name
  107887. * @returns VRDeviceOrientationArcRotateCamera
  107888. */
  107889. getClassName(): string;
  107890. }
  107891. }
  107892. declare module BABYLON {
  107893. /**
  107894. * Camera used to simulate VR rendering (based on FreeCamera)
  107895. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107896. */
  107897. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  107898. /**
  107899. * Creates a new VRDeviceOrientationFreeCamera
  107900. * @param name defines camera name
  107901. * @param position defines the start position of the camera
  107902. * @param scene defines the scene the camera belongs to
  107903. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107904. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107905. */
  107906. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107907. /**
  107908. * Gets camera class name
  107909. * @returns VRDeviceOrientationFreeCamera
  107910. */
  107911. getClassName(): string;
  107912. }
  107913. }
  107914. declare module BABYLON {
  107915. /**
  107916. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107917. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107918. */
  107919. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107920. /**
  107921. * Creates a new VRDeviceOrientationGamepadCamera
  107922. * @param name defines camera name
  107923. * @param position defines the start position of the camera
  107924. * @param scene defines the scene the camera belongs to
  107925. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107926. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107927. */
  107928. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107929. /**
  107930. * Gets camera class name
  107931. * @returns VRDeviceOrientationGamepadCamera
  107932. */
  107933. getClassName(): string;
  107934. }
  107935. }
  107936. declare module BABYLON {
  107937. /**
  107938. * Base class of materials working in push mode in babylon JS
  107939. * @hidden
  107940. */
  107941. export class PushMaterial extends Material {
  107942. protected _activeEffect: Effect;
  107943. protected _normalMatrix: Matrix;
  107944. /**
  107945. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107946. * This means that the material can keep using a previous shader while a new one is being compiled.
  107947. * This is mostly used when shader parallel compilation is supported (true by default)
  107948. */
  107949. allowShaderHotSwapping: boolean;
  107950. constructor(name: string, scene: Scene);
  107951. getEffect(): Effect;
  107952. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107953. /**
  107954. * Binds the given world matrix to the active effect
  107955. *
  107956. * @param world the matrix to bind
  107957. */
  107958. bindOnlyWorldMatrix(world: Matrix): void;
  107959. /**
  107960. * Binds the given normal matrix to the active effect
  107961. *
  107962. * @param normalMatrix the matrix to bind
  107963. */
  107964. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107965. bind(world: Matrix, mesh?: Mesh): void;
  107966. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107967. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107968. }
  107969. }
  107970. declare module BABYLON {
  107971. /**
  107972. * This groups all the flags used to control the materials channel.
  107973. */
  107974. export class MaterialFlags {
  107975. private static _DiffuseTextureEnabled;
  107976. /**
  107977. * Are diffuse textures enabled in the application.
  107978. */
  107979. static DiffuseTextureEnabled: boolean;
  107980. private static _AmbientTextureEnabled;
  107981. /**
  107982. * Are ambient textures enabled in the application.
  107983. */
  107984. static AmbientTextureEnabled: boolean;
  107985. private static _OpacityTextureEnabled;
  107986. /**
  107987. * Are opacity textures enabled in the application.
  107988. */
  107989. static OpacityTextureEnabled: boolean;
  107990. private static _ReflectionTextureEnabled;
  107991. /**
  107992. * Are reflection textures enabled in the application.
  107993. */
  107994. static ReflectionTextureEnabled: boolean;
  107995. private static _EmissiveTextureEnabled;
  107996. /**
  107997. * Are emissive textures enabled in the application.
  107998. */
  107999. static EmissiveTextureEnabled: boolean;
  108000. private static _SpecularTextureEnabled;
  108001. /**
  108002. * Are specular textures enabled in the application.
  108003. */
  108004. static SpecularTextureEnabled: boolean;
  108005. private static _BumpTextureEnabled;
  108006. /**
  108007. * Are bump textures enabled in the application.
  108008. */
  108009. static BumpTextureEnabled: boolean;
  108010. private static _LightmapTextureEnabled;
  108011. /**
  108012. * Are lightmap textures enabled in the application.
  108013. */
  108014. static LightmapTextureEnabled: boolean;
  108015. private static _RefractionTextureEnabled;
  108016. /**
  108017. * Are refraction textures enabled in the application.
  108018. */
  108019. static RefractionTextureEnabled: boolean;
  108020. private static _ColorGradingTextureEnabled;
  108021. /**
  108022. * Are color grading textures enabled in the application.
  108023. */
  108024. static ColorGradingTextureEnabled: boolean;
  108025. private static _FresnelEnabled;
  108026. /**
  108027. * Are fresnels enabled in the application.
  108028. */
  108029. static FresnelEnabled: boolean;
  108030. private static _ClearCoatTextureEnabled;
  108031. /**
  108032. * Are clear coat textures enabled in the application.
  108033. */
  108034. static ClearCoatTextureEnabled: boolean;
  108035. private static _ClearCoatBumpTextureEnabled;
  108036. /**
  108037. * Are clear coat bump textures enabled in the application.
  108038. */
  108039. static ClearCoatBumpTextureEnabled: boolean;
  108040. private static _ClearCoatTintTextureEnabled;
  108041. /**
  108042. * Are clear coat tint textures enabled in the application.
  108043. */
  108044. static ClearCoatTintTextureEnabled: boolean;
  108045. private static _SheenTextureEnabled;
  108046. /**
  108047. * Are sheen textures enabled in the application.
  108048. */
  108049. static SheenTextureEnabled: boolean;
  108050. private static _AnisotropicTextureEnabled;
  108051. /**
  108052. * Are anisotropic textures enabled in the application.
  108053. */
  108054. static AnisotropicTextureEnabled: boolean;
  108055. private static _ThicknessTextureEnabled;
  108056. /**
  108057. * Are thickness textures enabled in the application.
  108058. */
  108059. static ThicknessTextureEnabled: boolean;
  108060. }
  108061. }
  108062. declare module BABYLON {
  108063. /** @hidden */
  108064. export var defaultFragmentDeclaration: {
  108065. name: string;
  108066. shader: string;
  108067. };
  108068. }
  108069. declare module BABYLON {
  108070. /** @hidden */
  108071. export var defaultUboDeclaration: {
  108072. name: string;
  108073. shader: string;
  108074. };
  108075. }
  108076. declare module BABYLON {
  108077. /** @hidden */
  108078. export var lightFragmentDeclaration: {
  108079. name: string;
  108080. shader: string;
  108081. };
  108082. }
  108083. declare module BABYLON {
  108084. /** @hidden */
  108085. export var lightUboDeclaration: {
  108086. name: string;
  108087. shader: string;
  108088. };
  108089. }
  108090. declare module BABYLON {
  108091. /** @hidden */
  108092. export var lightsFragmentFunctions: {
  108093. name: string;
  108094. shader: string;
  108095. };
  108096. }
  108097. declare module BABYLON {
  108098. /** @hidden */
  108099. export var shadowsFragmentFunctions: {
  108100. name: string;
  108101. shader: string;
  108102. };
  108103. }
  108104. declare module BABYLON {
  108105. /** @hidden */
  108106. export var fresnelFunction: {
  108107. name: string;
  108108. shader: string;
  108109. };
  108110. }
  108111. declare module BABYLON {
  108112. /** @hidden */
  108113. export var reflectionFunction: {
  108114. name: string;
  108115. shader: string;
  108116. };
  108117. }
  108118. declare module BABYLON {
  108119. /** @hidden */
  108120. export var bumpFragmentFunctions: {
  108121. name: string;
  108122. shader: string;
  108123. };
  108124. }
  108125. declare module BABYLON {
  108126. /** @hidden */
  108127. export var logDepthDeclaration: {
  108128. name: string;
  108129. shader: string;
  108130. };
  108131. }
  108132. declare module BABYLON {
  108133. /** @hidden */
  108134. export var bumpFragment: {
  108135. name: string;
  108136. shader: string;
  108137. };
  108138. }
  108139. declare module BABYLON {
  108140. /** @hidden */
  108141. export var depthPrePass: {
  108142. name: string;
  108143. shader: string;
  108144. };
  108145. }
  108146. declare module BABYLON {
  108147. /** @hidden */
  108148. export var lightFragment: {
  108149. name: string;
  108150. shader: string;
  108151. };
  108152. }
  108153. declare module BABYLON {
  108154. /** @hidden */
  108155. export var logDepthFragment: {
  108156. name: string;
  108157. shader: string;
  108158. };
  108159. }
  108160. declare module BABYLON {
  108161. /** @hidden */
  108162. export var defaultPixelShader: {
  108163. name: string;
  108164. shader: string;
  108165. };
  108166. }
  108167. declare module BABYLON {
  108168. /** @hidden */
  108169. export var defaultVertexDeclaration: {
  108170. name: string;
  108171. shader: string;
  108172. };
  108173. }
  108174. declare module BABYLON {
  108175. /** @hidden */
  108176. export var bumpVertexDeclaration: {
  108177. name: string;
  108178. shader: string;
  108179. };
  108180. }
  108181. declare module BABYLON {
  108182. /** @hidden */
  108183. export var bumpVertex: {
  108184. name: string;
  108185. shader: string;
  108186. };
  108187. }
  108188. declare module BABYLON {
  108189. /** @hidden */
  108190. export var fogVertex: {
  108191. name: string;
  108192. shader: string;
  108193. };
  108194. }
  108195. declare module BABYLON {
  108196. /** @hidden */
  108197. export var shadowsVertex: {
  108198. name: string;
  108199. shader: string;
  108200. };
  108201. }
  108202. declare module BABYLON {
  108203. /** @hidden */
  108204. export var pointCloudVertex: {
  108205. name: string;
  108206. shader: string;
  108207. };
  108208. }
  108209. declare module BABYLON {
  108210. /** @hidden */
  108211. export var logDepthVertex: {
  108212. name: string;
  108213. shader: string;
  108214. };
  108215. }
  108216. declare module BABYLON {
  108217. /** @hidden */
  108218. export var defaultVertexShader: {
  108219. name: string;
  108220. shader: string;
  108221. };
  108222. }
  108223. declare module BABYLON {
  108224. /** @hidden */
  108225. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108226. MAINUV1: boolean;
  108227. MAINUV2: boolean;
  108228. DIFFUSE: boolean;
  108229. DIFFUSEDIRECTUV: number;
  108230. AMBIENT: boolean;
  108231. AMBIENTDIRECTUV: number;
  108232. OPACITY: boolean;
  108233. OPACITYDIRECTUV: number;
  108234. OPACITYRGB: boolean;
  108235. REFLECTION: boolean;
  108236. EMISSIVE: boolean;
  108237. EMISSIVEDIRECTUV: number;
  108238. SPECULAR: boolean;
  108239. SPECULARDIRECTUV: number;
  108240. BUMP: boolean;
  108241. BUMPDIRECTUV: number;
  108242. PARALLAX: boolean;
  108243. PARALLAXOCCLUSION: boolean;
  108244. SPECULAROVERALPHA: boolean;
  108245. CLIPPLANE: boolean;
  108246. CLIPPLANE2: boolean;
  108247. CLIPPLANE3: boolean;
  108248. CLIPPLANE4: boolean;
  108249. ALPHATEST: boolean;
  108250. DEPTHPREPASS: boolean;
  108251. ALPHAFROMDIFFUSE: boolean;
  108252. POINTSIZE: boolean;
  108253. FOG: boolean;
  108254. SPECULARTERM: boolean;
  108255. DIFFUSEFRESNEL: boolean;
  108256. OPACITYFRESNEL: boolean;
  108257. REFLECTIONFRESNEL: boolean;
  108258. REFRACTIONFRESNEL: boolean;
  108259. EMISSIVEFRESNEL: boolean;
  108260. FRESNEL: boolean;
  108261. NORMAL: boolean;
  108262. UV1: boolean;
  108263. UV2: boolean;
  108264. VERTEXCOLOR: boolean;
  108265. VERTEXALPHA: boolean;
  108266. NUM_BONE_INFLUENCERS: number;
  108267. BonesPerMesh: number;
  108268. BONETEXTURE: boolean;
  108269. INSTANCES: boolean;
  108270. GLOSSINESS: boolean;
  108271. ROUGHNESS: boolean;
  108272. EMISSIVEASILLUMINATION: boolean;
  108273. LINKEMISSIVEWITHDIFFUSE: boolean;
  108274. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108275. LIGHTMAP: boolean;
  108276. LIGHTMAPDIRECTUV: number;
  108277. OBJECTSPACE_NORMALMAP: boolean;
  108278. USELIGHTMAPASSHADOWMAP: boolean;
  108279. REFLECTIONMAP_3D: boolean;
  108280. REFLECTIONMAP_SPHERICAL: boolean;
  108281. REFLECTIONMAP_PLANAR: boolean;
  108282. REFLECTIONMAP_CUBIC: boolean;
  108283. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108284. REFLECTIONMAP_PROJECTION: boolean;
  108285. REFLECTIONMAP_SKYBOX: boolean;
  108286. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108287. REFLECTIONMAP_EXPLICIT: boolean;
  108288. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108289. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108290. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108291. INVERTCUBICMAP: boolean;
  108292. LOGARITHMICDEPTH: boolean;
  108293. REFRACTION: boolean;
  108294. REFRACTIONMAP_3D: boolean;
  108295. REFLECTIONOVERALPHA: boolean;
  108296. TWOSIDEDLIGHTING: boolean;
  108297. SHADOWFLOAT: boolean;
  108298. MORPHTARGETS: boolean;
  108299. MORPHTARGETS_NORMAL: boolean;
  108300. MORPHTARGETS_TANGENT: boolean;
  108301. MORPHTARGETS_UV: boolean;
  108302. NUM_MORPH_INFLUENCERS: number;
  108303. NONUNIFORMSCALING: boolean;
  108304. PREMULTIPLYALPHA: boolean;
  108305. IMAGEPROCESSING: boolean;
  108306. VIGNETTE: boolean;
  108307. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108308. VIGNETTEBLENDMODEOPAQUE: boolean;
  108309. TONEMAPPING: boolean;
  108310. TONEMAPPING_ACES: boolean;
  108311. CONTRAST: boolean;
  108312. COLORCURVES: boolean;
  108313. COLORGRADING: boolean;
  108314. COLORGRADING3D: boolean;
  108315. SAMPLER3DGREENDEPTH: boolean;
  108316. SAMPLER3DBGRMAP: boolean;
  108317. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108318. MULTIVIEW: boolean;
  108319. /**
  108320. * If the reflection texture on this material is in linear color space
  108321. * @hidden
  108322. */
  108323. IS_REFLECTION_LINEAR: boolean;
  108324. /**
  108325. * If the refraction texture on this material is in linear color space
  108326. * @hidden
  108327. */
  108328. IS_REFRACTION_LINEAR: boolean;
  108329. EXPOSURE: boolean;
  108330. constructor();
  108331. setReflectionMode(modeToEnable: string): void;
  108332. }
  108333. /**
  108334. * This is the default material used in Babylon. It is the best trade off between quality
  108335. * and performances.
  108336. * @see http://doc.babylonjs.com/babylon101/materials
  108337. */
  108338. export class StandardMaterial extends PushMaterial {
  108339. private _diffuseTexture;
  108340. /**
  108341. * The basic texture of the material as viewed under a light.
  108342. */
  108343. diffuseTexture: Nullable<BaseTexture>;
  108344. private _ambientTexture;
  108345. /**
  108346. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108347. */
  108348. ambientTexture: Nullable<BaseTexture>;
  108349. private _opacityTexture;
  108350. /**
  108351. * Define the transparency of the material from a texture.
  108352. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108353. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108354. */
  108355. opacityTexture: Nullable<BaseTexture>;
  108356. private _reflectionTexture;
  108357. /**
  108358. * Define the texture used to display the reflection.
  108359. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108360. */
  108361. reflectionTexture: Nullable<BaseTexture>;
  108362. private _emissiveTexture;
  108363. /**
  108364. * Define texture of the material as if self lit.
  108365. * This will be mixed in the final result even in the absence of light.
  108366. */
  108367. emissiveTexture: Nullable<BaseTexture>;
  108368. private _specularTexture;
  108369. /**
  108370. * Define how the color and intensity of the highlight given by the light in the material.
  108371. */
  108372. specularTexture: Nullable<BaseTexture>;
  108373. private _bumpTexture;
  108374. /**
  108375. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108376. * 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.
  108377. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108378. */
  108379. bumpTexture: Nullable<BaseTexture>;
  108380. private _lightmapTexture;
  108381. /**
  108382. * Complex lighting can be computationally expensive to compute at runtime.
  108383. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108384. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108385. */
  108386. lightmapTexture: Nullable<BaseTexture>;
  108387. private _refractionTexture;
  108388. /**
  108389. * Define the texture used to display the refraction.
  108390. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108391. */
  108392. refractionTexture: Nullable<BaseTexture>;
  108393. /**
  108394. * The color of the material lit by the environmental background lighting.
  108395. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108396. */
  108397. ambientColor: Color3;
  108398. /**
  108399. * The basic color of the material as viewed under a light.
  108400. */
  108401. diffuseColor: Color3;
  108402. /**
  108403. * Define how the color and intensity of the highlight given by the light in the material.
  108404. */
  108405. specularColor: Color3;
  108406. /**
  108407. * Define the color of the material as if self lit.
  108408. * This will be mixed in the final result even in the absence of light.
  108409. */
  108410. emissiveColor: Color3;
  108411. /**
  108412. * Defines how sharp are the highlights in the material.
  108413. * The bigger the value the sharper giving a more glossy feeling to the result.
  108414. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108415. */
  108416. specularPower: number;
  108417. private _useAlphaFromDiffuseTexture;
  108418. /**
  108419. * Does the transparency come from the diffuse texture alpha channel.
  108420. */
  108421. useAlphaFromDiffuseTexture: boolean;
  108422. private _useEmissiveAsIllumination;
  108423. /**
  108424. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108425. */
  108426. useEmissiveAsIllumination: boolean;
  108427. private _linkEmissiveWithDiffuse;
  108428. /**
  108429. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108430. * the emissive level when the final color is close to one.
  108431. */
  108432. linkEmissiveWithDiffuse: boolean;
  108433. private _useSpecularOverAlpha;
  108434. /**
  108435. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108436. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108437. */
  108438. useSpecularOverAlpha: boolean;
  108439. private _useReflectionOverAlpha;
  108440. /**
  108441. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108442. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108443. */
  108444. useReflectionOverAlpha: boolean;
  108445. private _disableLighting;
  108446. /**
  108447. * Does lights from the scene impacts this material.
  108448. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108449. */
  108450. disableLighting: boolean;
  108451. private _useObjectSpaceNormalMap;
  108452. /**
  108453. * Allows using an object space normal map (instead of tangent space).
  108454. */
  108455. useObjectSpaceNormalMap: boolean;
  108456. private _useParallax;
  108457. /**
  108458. * Is parallax enabled or not.
  108459. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108460. */
  108461. useParallax: boolean;
  108462. private _useParallaxOcclusion;
  108463. /**
  108464. * Is parallax occlusion enabled or not.
  108465. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108466. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108467. */
  108468. useParallaxOcclusion: boolean;
  108469. /**
  108470. * 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.
  108471. */
  108472. parallaxScaleBias: number;
  108473. private _roughness;
  108474. /**
  108475. * Helps to define how blurry the reflections should appears in the material.
  108476. */
  108477. roughness: number;
  108478. /**
  108479. * In case of refraction, define the value of the index of refraction.
  108480. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108481. */
  108482. indexOfRefraction: number;
  108483. /**
  108484. * Invert the refraction texture alongside the y axis.
  108485. * It can be useful with procedural textures or probe for instance.
  108486. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108487. */
  108488. invertRefractionY: boolean;
  108489. /**
  108490. * Defines the alpha limits in alpha test mode.
  108491. */
  108492. alphaCutOff: number;
  108493. private _useLightmapAsShadowmap;
  108494. /**
  108495. * In case of light mapping, define whether the map contains light or shadow informations.
  108496. */
  108497. useLightmapAsShadowmap: boolean;
  108498. private _diffuseFresnelParameters;
  108499. /**
  108500. * Define the diffuse fresnel parameters of the material.
  108501. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108502. */
  108503. diffuseFresnelParameters: FresnelParameters;
  108504. private _opacityFresnelParameters;
  108505. /**
  108506. * Define the opacity fresnel parameters of the material.
  108507. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108508. */
  108509. opacityFresnelParameters: FresnelParameters;
  108510. private _reflectionFresnelParameters;
  108511. /**
  108512. * Define the reflection fresnel parameters of the material.
  108513. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108514. */
  108515. reflectionFresnelParameters: FresnelParameters;
  108516. private _refractionFresnelParameters;
  108517. /**
  108518. * Define the refraction fresnel parameters of the material.
  108519. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108520. */
  108521. refractionFresnelParameters: FresnelParameters;
  108522. private _emissiveFresnelParameters;
  108523. /**
  108524. * Define the emissive fresnel parameters of the material.
  108525. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108526. */
  108527. emissiveFresnelParameters: FresnelParameters;
  108528. private _useReflectionFresnelFromSpecular;
  108529. /**
  108530. * If true automatically deducts the fresnels values from the material specularity.
  108531. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108532. */
  108533. useReflectionFresnelFromSpecular: boolean;
  108534. private _useGlossinessFromSpecularMapAlpha;
  108535. /**
  108536. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  108537. */
  108538. useGlossinessFromSpecularMapAlpha: boolean;
  108539. private _maxSimultaneousLights;
  108540. /**
  108541. * Defines the maximum number of lights that can be used in the material
  108542. */
  108543. maxSimultaneousLights: number;
  108544. private _invertNormalMapX;
  108545. /**
  108546. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108547. */
  108548. invertNormalMapX: boolean;
  108549. private _invertNormalMapY;
  108550. /**
  108551. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108552. */
  108553. invertNormalMapY: boolean;
  108554. private _twoSidedLighting;
  108555. /**
  108556. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108557. */
  108558. twoSidedLighting: boolean;
  108559. /**
  108560. * Default configuration related to image processing available in the standard Material.
  108561. */
  108562. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108563. /**
  108564. * Gets the image processing configuration used either in this material.
  108565. */
  108566. /**
  108567. * Sets the Default image processing configuration used either in the this material.
  108568. *
  108569. * If sets to null, the scene one is in use.
  108570. */
  108571. imageProcessingConfiguration: ImageProcessingConfiguration;
  108572. /**
  108573. * Keep track of the image processing observer to allow dispose and replace.
  108574. */
  108575. private _imageProcessingObserver;
  108576. /**
  108577. * Attaches a new image processing configuration to the Standard Material.
  108578. * @param configuration
  108579. */
  108580. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108581. /**
  108582. * Gets wether the color curves effect is enabled.
  108583. */
  108584. /**
  108585. * Sets wether the color curves effect is enabled.
  108586. */
  108587. cameraColorCurvesEnabled: boolean;
  108588. /**
  108589. * Gets wether the color grading effect is enabled.
  108590. */
  108591. /**
  108592. * Gets wether the color grading effect is enabled.
  108593. */
  108594. cameraColorGradingEnabled: boolean;
  108595. /**
  108596. * Gets wether tonemapping is enabled or not.
  108597. */
  108598. /**
  108599. * Sets wether tonemapping is enabled or not
  108600. */
  108601. cameraToneMappingEnabled: boolean;
  108602. /**
  108603. * The camera exposure used on this material.
  108604. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108605. * This corresponds to a photographic exposure.
  108606. */
  108607. /**
  108608. * The camera exposure used on this material.
  108609. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108610. * This corresponds to a photographic exposure.
  108611. */
  108612. cameraExposure: number;
  108613. /**
  108614. * Gets The camera contrast used on this material.
  108615. */
  108616. /**
  108617. * Sets The camera contrast used on this material.
  108618. */
  108619. cameraContrast: number;
  108620. /**
  108621. * Gets the Color Grading 2D Lookup Texture.
  108622. */
  108623. /**
  108624. * Sets the Color Grading 2D Lookup Texture.
  108625. */
  108626. cameraColorGradingTexture: Nullable<BaseTexture>;
  108627. /**
  108628. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108629. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108630. * 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;
  108631. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108632. */
  108633. /**
  108634. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108635. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108636. * 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;
  108637. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108638. */
  108639. cameraColorCurves: Nullable<ColorCurves>;
  108640. /**
  108641. * Custom callback helping to override the default shader used in the material.
  108642. */
  108643. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108644. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108645. protected _worldViewProjectionMatrix: Matrix;
  108646. protected _globalAmbientColor: Color3;
  108647. protected _useLogarithmicDepth: boolean;
  108648. protected _rebuildInParallel: boolean;
  108649. /**
  108650. * Instantiates a new standard material.
  108651. * This is the default material used in Babylon. It is the best trade off between quality
  108652. * and performances.
  108653. * @see http://doc.babylonjs.com/babylon101/materials
  108654. * @param name Define the name of the material in the scene
  108655. * @param scene Define the scene the material belong to
  108656. */
  108657. constructor(name: string, scene: Scene);
  108658. /**
  108659. * Gets a boolean indicating that current material needs to register RTT
  108660. */
  108661. readonly hasRenderTargetTextures: boolean;
  108662. /**
  108663. * Gets the current class name of the material e.g. "StandardMaterial"
  108664. * Mainly use in serialization.
  108665. * @returns the class name
  108666. */
  108667. getClassName(): string;
  108668. /**
  108669. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108670. * You can try switching to logarithmic depth.
  108671. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108672. */
  108673. useLogarithmicDepth: boolean;
  108674. /**
  108675. * Specifies if the material will require alpha blending
  108676. * @returns a boolean specifying if alpha blending is needed
  108677. */
  108678. needAlphaBlending(): boolean;
  108679. /**
  108680. * Specifies if this material should be rendered in alpha test mode
  108681. * @returns a boolean specifying if an alpha test is needed.
  108682. */
  108683. needAlphaTesting(): boolean;
  108684. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108685. /**
  108686. * Get the texture used for alpha test purpose.
  108687. * @returns the diffuse texture in case of the standard material.
  108688. */
  108689. getAlphaTestTexture(): Nullable<BaseTexture>;
  108690. /**
  108691. * Get if the submesh is ready to be used and all its information available.
  108692. * Child classes can use it to update shaders
  108693. * @param mesh defines the mesh to check
  108694. * @param subMesh defines which submesh to check
  108695. * @param useInstances specifies that instances should be used
  108696. * @returns a boolean indicating that the submesh is ready or not
  108697. */
  108698. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108699. /**
  108700. * Builds the material UBO layouts.
  108701. * Used internally during the effect preparation.
  108702. */
  108703. buildUniformLayout(): void;
  108704. /**
  108705. * Unbinds the material from the mesh
  108706. */
  108707. unbind(): void;
  108708. /**
  108709. * Binds the submesh to this material by preparing the effect and shader to draw
  108710. * @param world defines the world transformation matrix
  108711. * @param mesh defines the mesh containing the submesh
  108712. * @param subMesh defines the submesh to bind the material to
  108713. */
  108714. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108715. /**
  108716. * Get the list of animatables in the material.
  108717. * @returns the list of animatables object used in the material
  108718. */
  108719. getAnimatables(): IAnimatable[];
  108720. /**
  108721. * Gets the active textures from the material
  108722. * @returns an array of textures
  108723. */
  108724. getActiveTextures(): BaseTexture[];
  108725. /**
  108726. * Specifies if the material uses a texture
  108727. * @param texture defines the texture to check against the material
  108728. * @returns a boolean specifying if the material uses the texture
  108729. */
  108730. hasTexture(texture: BaseTexture): boolean;
  108731. /**
  108732. * Disposes the material
  108733. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108734. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108735. */
  108736. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108737. /**
  108738. * Makes a duplicate of the material, and gives it a new name
  108739. * @param name defines the new name for the duplicated material
  108740. * @returns the cloned material
  108741. */
  108742. clone(name: string): StandardMaterial;
  108743. /**
  108744. * Serializes this material in a JSON representation
  108745. * @returns the serialized material object
  108746. */
  108747. serialize(): any;
  108748. /**
  108749. * Creates a standard material from parsed material data
  108750. * @param source defines the JSON representation of the material
  108751. * @param scene defines the hosting scene
  108752. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108753. * @returns a new standard material
  108754. */
  108755. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108756. /**
  108757. * Are diffuse textures enabled in the application.
  108758. */
  108759. static DiffuseTextureEnabled: boolean;
  108760. /**
  108761. * Are ambient textures enabled in the application.
  108762. */
  108763. static AmbientTextureEnabled: boolean;
  108764. /**
  108765. * Are opacity textures enabled in the application.
  108766. */
  108767. static OpacityTextureEnabled: boolean;
  108768. /**
  108769. * Are reflection textures enabled in the application.
  108770. */
  108771. static ReflectionTextureEnabled: boolean;
  108772. /**
  108773. * Are emissive textures enabled in the application.
  108774. */
  108775. static EmissiveTextureEnabled: boolean;
  108776. /**
  108777. * Are specular textures enabled in the application.
  108778. */
  108779. static SpecularTextureEnabled: boolean;
  108780. /**
  108781. * Are bump textures enabled in the application.
  108782. */
  108783. static BumpTextureEnabled: boolean;
  108784. /**
  108785. * Are lightmap textures enabled in the application.
  108786. */
  108787. static LightmapTextureEnabled: boolean;
  108788. /**
  108789. * Are refraction textures enabled in the application.
  108790. */
  108791. static RefractionTextureEnabled: boolean;
  108792. /**
  108793. * Are color grading textures enabled in the application.
  108794. */
  108795. static ColorGradingTextureEnabled: boolean;
  108796. /**
  108797. * Are fresnels enabled in the application.
  108798. */
  108799. static FresnelEnabled: boolean;
  108800. }
  108801. }
  108802. declare module BABYLON {
  108803. /** @hidden */
  108804. export var imageProcessingPixelShader: {
  108805. name: string;
  108806. shader: string;
  108807. };
  108808. }
  108809. declare module BABYLON {
  108810. /**
  108811. * ImageProcessingPostProcess
  108812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  108813. */
  108814. export class ImageProcessingPostProcess extends PostProcess {
  108815. /**
  108816. * Default configuration related to image processing available in the PBR Material.
  108817. */
  108818. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108819. /**
  108820. * Gets the image processing configuration used either in this material.
  108821. */
  108822. /**
  108823. * Sets the Default image processing configuration used either in the this material.
  108824. *
  108825. * If sets to null, the scene one is in use.
  108826. */
  108827. imageProcessingConfiguration: ImageProcessingConfiguration;
  108828. /**
  108829. * Keep track of the image processing observer to allow dispose and replace.
  108830. */
  108831. private _imageProcessingObserver;
  108832. /**
  108833. * Attaches a new image processing configuration to the PBR Material.
  108834. * @param configuration
  108835. */
  108836. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  108837. /**
  108838. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108839. */
  108840. /**
  108841. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108842. */
  108843. colorCurves: Nullable<ColorCurves>;
  108844. /**
  108845. * Gets wether the color curves effect is enabled.
  108846. */
  108847. /**
  108848. * Sets wether the color curves effect is enabled.
  108849. */
  108850. colorCurvesEnabled: boolean;
  108851. /**
  108852. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108853. */
  108854. /**
  108855. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108856. */
  108857. colorGradingTexture: Nullable<BaseTexture>;
  108858. /**
  108859. * Gets wether the color grading effect is enabled.
  108860. */
  108861. /**
  108862. * Gets wether the color grading effect is enabled.
  108863. */
  108864. colorGradingEnabled: boolean;
  108865. /**
  108866. * Gets exposure used in the effect.
  108867. */
  108868. /**
  108869. * Sets exposure used in the effect.
  108870. */
  108871. exposure: number;
  108872. /**
  108873. * Gets wether tonemapping is enabled or not.
  108874. */
  108875. /**
  108876. * Sets wether tonemapping is enabled or not
  108877. */
  108878. toneMappingEnabled: boolean;
  108879. /**
  108880. * Gets the type of tone mapping effect.
  108881. */
  108882. /**
  108883. * Sets the type of tone mapping effect.
  108884. */
  108885. toneMappingType: number;
  108886. /**
  108887. * Gets contrast used in the effect.
  108888. */
  108889. /**
  108890. * Sets contrast used in the effect.
  108891. */
  108892. contrast: number;
  108893. /**
  108894. * Gets Vignette stretch size.
  108895. */
  108896. /**
  108897. * Sets Vignette stretch size.
  108898. */
  108899. vignetteStretch: number;
  108900. /**
  108901. * Gets Vignette centre X Offset.
  108902. */
  108903. /**
  108904. * Sets Vignette centre X Offset.
  108905. */
  108906. vignetteCentreX: number;
  108907. /**
  108908. * Gets Vignette centre Y Offset.
  108909. */
  108910. /**
  108911. * Sets Vignette centre Y Offset.
  108912. */
  108913. vignetteCentreY: number;
  108914. /**
  108915. * Gets Vignette weight or intensity of the vignette effect.
  108916. */
  108917. /**
  108918. * Sets Vignette weight or intensity of the vignette effect.
  108919. */
  108920. vignetteWeight: number;
  108921. /**
  108922. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108923. * if vignetteEnabled is set to true.
  108924. */
  108925. /**
  108926. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108927. * if vignetteEnabled is set to true.
  108928. */
  108929. vignetteColor: Color4;
  108930. /**
  108931. * Gets Camera field of view used by the Vignette effect.
  108932. */
  108933. /**
  108934. * Sets Camera field of view used by the Vignette effect.
  108935. */
  108936. vignetteCameraFov: number;
  108937. /**
  108938. * Gets the vignette blend mode allowing different kind of effect.
  108939. */
  108940. /**
  108941. * Sets the vignette blend mode allowing different kind of effect.
  108942. */
  108943. vignetteBlendMode: number;
  108944. /**
  108945. * Gets wether the vignette effect is enabled.
  108946. */
  108947. /**
  108948. * Sets wether the vignette effect is enabled.
  108949. */
  108950. vignetteEnabled: boolean;
  108951. private _fromLinearSpace;
  108952. /**
  108953. * Gets wether the input of the processing is in Gamma or Linear Space.
  108954. */
  108955. /**
  108956. * Sets wether the input of the processing is in Gamma or Linear Space.
  108957. */
  108958. fromLinearSpace: boolean;
  108959. /**
  108960. * Defines cache preventing GC.
  108961. */
  108962. private _defines;
  108963. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108964. /**
  108965. * "ImageProcessingPostProcess"
  108966. * @returns "ImageProcessingPostProcess"
  108967. */
  108968. getClassName(): string;
  108969. protected _updateParameters(): void;
  108970. dispose(camera?: Camera): void;
  108971. }
  108972. }
  108973. declare module BABYLON {
  108974. /**
  108975. * Class containing static functions to help procedurally build meshes
  108976. */
  108977. export class GroundBuilder {
  108978. /**
  108979. * Creates a ground mesh
  108980. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108981. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108983. * @param name defines the name of the mesh
  108984. * @param options defines the options used to create the mesh
  108985. * @param scene defines the hosting scene
  108986. * @returns the ground mesh
  108987. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108988. */
  108989. static CreateGround(name: string, options: {
  108990. width?: number;
  108991. height?: number;
  108992. subdivisions?: number;
  108993. subdivisionsX?: number;
  108994. subdivisionsY?: number;
  108995. updatable?: boolean;
  108996. }, scene: any): Mesh;
  108997. /**
  108998. * Creates a tiled ground mesh
  108999. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109000. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109001. * * 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
  109002. * * 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
  109003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109004. * @param name defines the name of the mesh
  109005. * @param options defines the options used to create the mesh
  109006. * @param scene defines the hosting scene
  109007. * @returns the tiled ground mesh
  109008. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109009. */
  109010. static CreateTiledGround(name: string, options: {
  109011. xmin: number;
  109012. zmin: number;
  109013. xmax: number;
  109014. zmax: number;
  109015. subdivisions?: {
  109016. w: number;
  109017. h: number;
  109018. };
  109019. precision?: {
  109020. w: number;
  109021. h: number;
  109022. };
  109023. updatable?: boolean;
  109024. }, scene?: Nullable<Scene>): Mesh;
  109025. /**
  109026. * Creates a ground mesh from a height map
  109027. * * The parameter `url` sets the URL of the height map image resource.
  109028. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109029. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109030. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109031. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109032. * * 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.
  109033. * * 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).
  109034. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109036. * @param name defines the name of the mesh
  109037. * @param url defines the url to the height map
  109038. * @param options defines the options used to create the mesh
  109039. * @param scene defines the hosting scene
  109040. * @returns the ground mesh
  109041. * @see https://doc.babylonjs.com/babylon101/height_map
  109042. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109043. */
  109044. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109045. width?: number;
  109046. height?: number;
  109047. subdivisions?: number;
  109048. minHeight?: number;
  109049. maxHeight?: number;
  109050. colorFilter?: Color3;
  109051. alphaFilter?: number;
  109052. updatable?: boolean;
  109053. onReady?: (mesh: GroundMesh) => void;
  109054. }, scene?: Nullable<Scene>): GroundMesh;
  109055. }
  109056. }
  109057. declare module BABYLON {
  109058. /**
  109059. * Class containing static functions to help procedurally build meshes
  109060. */
  109061. export class TorusBuilder {
  109062. /**
  109063. * Creates a torus mesh
  109064. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109065. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109066. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109070. * @param name defines the name of the mesh
  109071. * @param options defines the options used to create the mesh
  109072. * @param scene defines the hosting scene
  109073. * @returns the torus mesh
  109074. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109075. */
  109076. static CreateTorus(name: string, options: {
  109077. diameter?: number;
  109078. thickness?: number;
  109079. tessellation?: number;
  109080. updatable?: boolean;
  109081. sideOrientation?: number;
  109082. frontUVs?: Vector4;
  109083. backUVs?: Vector4;
  109084. }, scene: any): Mesh;
  109085. }
  109086. }
  109087. declare module BABYLON {
  109088. /**
  109089. * Class containing static functions to help procedurally build meshes
  109090. */
  109091. export class CylinderBuilder {
  109092. /**
  109093. * Creates a cylinder or a cone mesh
  109094. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109095. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109096. * * 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.
  109097. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109098. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109099. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109100. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109101. * * 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).
  109102. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109103. * * 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).
  109104. * * 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
  109105. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109106. * * 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
  109107. * * 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.
  109108. * * If `enclose` is false, a ring surface is one element.
  109109. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109110. * * 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
  109111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109114. * @param name defines the name of the mesh
  109115. * @param options defines the options used to create the mesh
  109116. * @param scene defines the hosting scene
  109117. * @returns the cylinder mesh
  109118. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109119. */
  109120. static CreateCylinder(name: string, options: {
  109121. height?: number;
  109122. diameterTop?: number;
  109123. diameterBottom?: number;
  109124. diameter?: number;
  109125. tessellation?: number;
  109126. subdivisions?: number;
  109127. arc?: number;
  109128. faceColors?: Color4[];
  109129. faceUV?: Vector4[];
  109130. updatable?: boolean;
  109131. hasRings?: boolean;
  109132. enclose?: boolean;
  109133. cap?: number;
  109134. sideOrientation?: number;
  109135. frontUVs?: Vector4;
  109136. backUVs?: Vector4;
  109137. }, scene: any): Mesh;
  109138. }
  109139. }
  109140. declare module BABYLON {
  109141. /**
  109142. * Options to modify the vr teleportation behavior.
  109143. */
  109144. export interface VRTeleportationOptions {
  109145. /**
  109146. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109147. */
  109148. floorMeshName?: string;
  109149. /**
  109150. * A list of meshes to be used as the teleportation floor. (default: empty)
  109151. */
  109152. floorMeshes?: Mesh[];
  109153. }
  109154. /**
  109155. * Options to modify the vr experience helper's behavior.
  109156. */
  109157. export interface VRExperienceHelperOptions extends WebVROptions {
  109158. /**
  109159. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109160. */
  109161. createDeviceOrientationCamera?: boolean;
  109162. /**
  109163. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109164. */
  109165. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109166. /**
  109167. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109168. */
  109169. laserToggle?: boolean;
  109170. /**
  109171. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109172. */
  109173. floorMeshes?: Mesh[];
  109174. /**
  109175. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109176. */
  109177. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109178. }
  109179. /**
  109180. * Event containing information after VR has been entered
  109181. */
  109182. export class OnAfterEnteringVRObservableEvent {
  109183. /**
  109184. * If entering vr was successful
  109185. */
  109186. success: boolean;
  109187. }
  109188. /**
  109189. * Helps to quickly add VR support to an existing scene.
  109190. * See http://doc.babylonjs.com/how_to/webvr_helper
  109191. */
  109192. export class VRExperienceHelper {
  109193. /** Options to modify the vr experience helper's behavior. */
  109194. webVROptions: VRExperienceHelperOptions;
  109195. private _scene;
  109196. private _position;
  109197. private _btnVR;
  109198. private _btnVRDisplayed;
  109199. private _webVRsupported;
  109200. private _webVRready;
  109201. private _webVRrequesting;
  109202. private _webVRpresenting;
  109203. private _hasEnteredVR;
  109204. private _fullscreenVRpresenting;
  109205. private _inputElement;
  109206. private _webVRCamera;
  109207. private _vrDeviceOrientationCamera;
  109208. private _deviceOrientationCamera;
  109209. private _existingCamera;
  109210. private _onKeyDown;
  109211. private _onVrDisplayPresentChange;
  109212. private _onVRDisplayChanged;
  109213. private _onVRRequestPresentStart;
  109214. private _onVRRequestPresentComplete;
  109215. /**
  109216. * 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)
  109217. */
  109218. enableGazeEvenWhenNoPointerLock: boolean;
  109219. /**
  109220. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109221. */
  109222. exitVROnDoubleTap: boolean;
  109223. /**
  109224. * Observable raised right before entering VR.
  109225. */
  109226. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109227. /**
  109228. * Observable raised when entering VR has completed.
  109229. */
  109230. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109231. /**
  109232. * Observable raised when exiting VR.
  109233. */
  109234. onExitingVRObservable: Observable<VRExperienceHelper>;
  109235. /**
  109236. * Observable raised when controller mesh is loaded.
  109237. */
  109238. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109239. /** Return this.onEnteringVRObservable
  109240. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109241. */
  109242. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109243. /** Return this.onExitingVRObservable
  109244. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109245. */
  109246. readonly onExitingVR: Observable<VRExperienceHelper>;
  109247. /** Return this.onControllerMeshLoadedObservable
  109248. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109249. */
  109250. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109251. private _rayLength;
  109252. private _useCustomVRButton;
  109253. private _teleportationRequested;
  109254. private _teleportActive;
  109255. private _floorMeshName;
  109256. private _floorMeshesCollection;
  109257. private _rotationAllowed;
  109258. private _teleportBackwardsVector;
  109259. private _teleportationTarget;
  109260. private _isDefaultTeleportationTarget;
  109261. private _postProcessMove;
  109262. private _teleportationFillColor;
  109263. private _teleportationBorderColor;
  109264. private _rotationAngle;
  109265. private _haloCenter;
  109266. private _cameraGazer;
  109267. private _padSensibilityUp;
  109268. private _padSensibilityDown;
  109269. private _leftController;
  109270. private _rightController;
  109271. /**
  109272. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109273. */
  109274. onNewMeshSelected: Observable<AbstractMesh>;
  109275. /**
  109276. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109277. * This observable will provide the mesh and the controller used to select the mesh
  109278. */
  109279. onMeshSelectedWithController: Observable<{
  109280. mesh: AbstractMesh;
  109281. controller: WebVRController;
  109282. }>;
  109283. /**
  109284. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109285. */
  109286. onNewMeshPicked: Observable<PickingInfo>;
  109287. private _circleEase;
  109288. /**
  109289. * Observable raised before camera teleportation
  109290. */
  109291. onBeforeCameraTeleport: Observable<Vector3>;
  109292. /**
  109293. * Observable raised after camera teleportation
  109294. */
  109295. onAfterCameraTeleport: Observable<Vector3>;
  109296. /**
  109297. * Observable raised when current selected mesh gets unselected
  109298. */
  109299. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109300. private _raySelectionPredicate;
  109301. /**
  109302. * To be optionaly changed by user to define custom ray selection
  109303. */
  109304. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109305. /**
  109306. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109307. */
  109308. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109309. /**
  109310. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109311. */
  109312. teleportationEnabled: boolean;
  109313. private _defaultHeight;
  109314. private _teleportationInitialized;
  109315. private _interactionsEnabled;
  109316. private _interactionsRequested;
  109317. private _displayGaze;
  109318. private _displayLaserPointer;
  109319. /**
  109320. * The mesh used to display where the user is going to teleport.
  109321. */
  109322. /**
  109323. * Sets the mesh to be used to display where the user is going to teleport.
  109324. */
  109325. teleportationTarget: Mesh;
  109326. /**
  109327. * 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
  109328. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109329. * See http://doc.babylonjs.com/resources/baking_transformations
  109330. */
  109331. gazeTrackerMesh: Mesh;
  109332. /**
  109333. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109334. */
  109335. updateGazeTrackerScale: boolean;
  109336. /**
  109337. * If the gaze trackers color should be updated when selecting meshes
  109338. */
  109339. updateGazeTrackerColor: boolean;
  109340. /**
  109341. * If the controller laser color should be updated when selecting meshes
  109342. */
  109343. updateControllerLaserColor: boolean;
  109344. /**
  109345. * The gaze tracking mesh corresponding to the left controller
  109346. */
  109347. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109348. /**
  109349. * The gaze tracking mesh corresponding to the right controller
  109350. */
  109351. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109352. /**
  109353. * If the ray of the gaze should be displayed.
  109354. */
  109355. /**
  109356. * Sets if the ray of the gaze should be displayed.
  109357. */
  109358. displayGaze: boolean;
  109359. /**
  109360. * If the ray of the LaserPointer should be displayed.
  109361. */
  109362. /**
  109363. * Sets if the ray of the LaserPointer should be displayed.
  109364. */
  109365. displayLaserPointer: boolean;
  109366. /**
  109367. * The deviceOrientationCamera used as the camera when not in VR.
  109368. */
  109369. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109370. /**
  109371. * Based on the current WebVR support, returns the current VR camera used.
  109372. */
  109373. readonly currentVRCamera: Nullable<Camera>;
  109374. /**
  109375. * The webVRCamera which is used when in VR.
  109376. */
  109377. readonly webVRCamera: WebVRFreeCamera;
  109378. /**
  109379. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109380. */
  109381. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109382. /**
  109383. * The html button that is used to trigger entering into VR.
  109384. */
  109385. readonly vrButton: Nullable<HTMLButtonElement>;
  109386. private readonly _teleportationRequestInitiated;
  109387. /**
  109388. * Defines wether or not Pointer lock should be requested when switching to
  109389. * full screen.
  109390. */
  109391. requestPointerLockOnFullScreen: boolean;
  109392. /**
  109393. * Instantiates a VRExperienceHelper.
  109394. * Helps to quickly add VR support to an existing scene.
  109395. * @param scene The scene the VRExperienceHelper belongs to.
  109396. * @param webVROptions Options to modify the vr experience helper's behavior.
  109397. */
  109398. constructor(scene: Scene,
  109399. /** Options to modify the vr experience helper's behavior. */
  109400. webVROptions?: VRExperienceHelperOptions);
  109401. private _onDefaultMeshLoaded;
  109402. private _onResize;
  109403. private _onFullscreenChange;
  109404. /**
  109405. * Gets a value indicating if we are currently in VR mode.
  109406. */
  109407. readonly isInVRMode: boolean;
  109408. private onVrDisplayPresentChange;
  109409. private onVRDisplayChanged;
  109410. private moveButtonToBottomRight;
  109411. private displayVRButton;
  109412. private updateButtonVisibility;
  109413. private _cachedAngularSensibility;
  109414. /**
  109415. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109416. * Otherwise, will use the fullscreen API.
  109417. */
  109418. enterVR(): void;
  109419. /**
  109420. * Attempt to exit VR, or fullscreen.
  109421. */
  109422. exitVR(): void;
  109423. /**
  109424. * The position of the vr experience helper.
  109425. */
  109426. /**
  109427. * Sets the position of the vr experience helper.
  109428. */
  109429. position: Vector3;
  109430. /**
  109431. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109432. */
  109433. enableInteractions(): void;
  109434. private readonly _noControllerIsActive;
  109435. private beforeRender;
  109436. private _isTeleportationFloor;
  109437. /**
  109438. * Adds a floor mesh to be used for teleportation.
  109439. * @param floorMesh the mesh to be used for teleportation.
  109440. */
  109441. addFloorMesh(floorMesh: Mesh): void;
  109442. /**
  109443. * Removes a floor mesh from being used for teleportation.
  109444. * @param floorMesh the mesh to be removed.
  109445. */
  109446. removeFloorMesh(floorMesh: Mesh): void;
  109447. /**
  109448. * Enables interactions and teleportation using the VR controllers and gaze.
  109449. * @param vrTeleportationOptions options to modify teleportation behavior.
  109450. */
  109451. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109452. private _onNewGamepadConnected;
  109453. private _tryEnableInteractionOnController;
  109454. private _onNewGamepadDisconnected;
  109455. private _enableInteractionOnController;
  109456. private _checkTeleportWithRay;
  109457. private _checkRotate;
  109458. private _checkTeleportBackwards;
  109459. private _enableTeleportationOnController;
  109460. private _createTeleportationCircles;
  109461. private _displayTeleportationTarget;
  109462. private _hideTeleportationTarget;
  109463. private _rotateCamera;
  109464. private _moveTeleportationSelectorTo;
  109465. private _workingVector;
  109466. private _workingQuaternion;
  109467. private _workingMatrix;
  109468. /**
  109469. * Teleports the users feet to the desired location
  109470. * @param location The location where the user's feet should be placed
  109471. */
  109472. teleportCamera(location: Vector3): void;
  109473. private _convertNormalToDirectionOfRay;
  109474. private _castRayAndSelectObject;
  109475. private _notifySelectedMeshUnselected;
  109476. /**
  109477. * Sets the color of the laser ray from the vr controllers.
  109478. * @param color new color for the ray.
  109479. */
  109480. changeLaserColor(color: Color3): void;
  109481. /**
  109482. * Sets the color of the ray from the vr headsets gaze.
  109483. * @param color new color for the ray.
  109484. */
  109485. changeGazeColor(color: Color3): void;
  109486. /**
  109487. * Exits VR and disposes of the vr experience helper
  109488. */
  109489. dispose(): void;
  109490. /**
  109491. * Gets the name of the VRExperienceHelper class
  109492. * @returns "VRExperienceHelper"
  109493. */
  109494. getClassName(): string;
  109495. }
  109496. }
  109497. declare module BABYLON {
  109498. /**
  109499. * States of the webXR experience
  109500. */
  109501. export enum WebXRState {
  109502. /**
  109503. * Transitioning to being in XR mode
  109504. */
  109505. ENTERING_XR = 0,
  109506. /**
  109507. * Transitioning to non XR mode
  109508. */
  109509. EXITING_XR = 1,
  109510. /**
  109511. * In XR mode and presenting
  109512. */
  109513. IN_XR = 2,
  109514. /**
  109515. * Not entered XR mode
  109516. */
  109517. NOT_IN_XR = 3
  109518. }
  109519. /**
  109520. * Abstraction of the XR render target
  109521. */
  109522. export interface WebXRRenderTarget extends IDisposable {
  109523. /**
  109524. * xrpresent context of the canvas which can be used to display/mirror xr content
  109525. */
  109526. canvasContext: WebGLRenderingContext;
  109527. /**
  109528. * xr layer for the canvas
  109529. */
  109530. xrLayer: Nullable<XRWebGLLayer>;
  109531. /**
  109532. * Initializes the xr layer for the session
  109533. * @param xrSession xr session
  109534. * @returns a promise that will resolve once the XR Layer has been created
  109535. */
  109536. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  109537. }
  109538. }
  109539. declare module BABYLON {
  109540. /**
  109541. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109542. */
  109543. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  109544. private _engine;
  109545. private _canvas;
  109546. /**
  109547. * xrpresent context of the canvas which can be used to display/mirror xr content
  109548. */
  109549. canvasContext: WebGLRenderingContext;
  109550. /**
  109551. * xr layer for the canvas
  109552. */
  109553. xrLayer: Nullable<XRWebGLLayer>;
  109554. /**
  109555. * Initializes the xr layer for the session
  109556. * @param xrSession xr session
  109557. * @returns a promise that will resolve once the XR Layer has been created
  109558. */
  109559. initializeXRLayerAsync(xrSession: any): any;
  109560. /**
  109561. * Initializes the canvas to be added/removed upon entering/exiting xr
  109562. * @param engine the Babylon engine
  109563. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109564. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  109565. */
  109566. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  109567. /**
  109568. * Disposes of the object
  109569. */
  109570. dispose(): void;
  109571. private _setManagedOutputCanvas;
  109572. private _addCanvas;
  109573. private _removeCanvas;
  109574. }
  109575. }
  109576. declare module BABYLON {
  109577. /**
  109578. * Manages an XRSession to work with Babylon's engine
  109579. * @see https://doc.babylonjs.com/how_to/webxr
  109580. */
  109581. export class WebXRSessionManager implements IDisposable {
  109582. private scene;
  109583. /**
  109584. * Fires every time a new xrFrame arrives which can be used to update the camera
  109585. */
  109586. onXRFrameObservable: Observable<any>;
  109587. /**
  109588. * Fires when the xr session is ended either by the device or manually done
  109589. */
  109590. onXRSessionEnded: Observable<any>;
  109591. /**
  109592. * Underlying xr session
  109593. */
  109594. session: XRSession;
  109595. /**
  109596. * Type of reference space used when creating the session
  109597. */
  109598. referenceSpace: XRReferenceSpace;
  109599. /**
  109600. * Current XR frame
  109601. */
  109602. currentFrame: Nullable<XRFrame>;
  109603. private _xrNavigator;
  109604. private baseLayer;
  109605. private _rttProvider;
  109606. private _sessionEnded;
  109607. /**
  109608. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  109609. * @param scene The scene which the session should be created for
  109610. */
  109611. constructor(scene: Scene);
  109612. /**
  109613. * Initializes the manager
  109614. * After initialization enterXR can be called to start an XR session
  109615. * @returns Promise which resolves after it is initialized
  109616. */
  109617. initializeAsync(): Promise<void>;
  109618. /**
  109619. * Initializes an xr session
  109620. * @param xrSessionMode mode to initialize
  109621. * @param optionalFeatures defines optional values to pass to the session builder
  109622. * @returns a promise which will resolve once the session has been initialized
  109623. */
  109624. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  109625. /**
  109626. * Sets the reference space on the xr session
  109627. * @param referenceSpace space to set
  109628. * @returns a promise that will resolve once the reference space has been set
  109629. */
  109630. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  109631. /**
  109632. * Updates the render state of the session
  109633. * @param state state to set
  109634. * @returns a promise that resolves once the render state has been updated
  109635. */
  109636. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  109637. /**
  109638. * Starts rendering to the xr layer
  109639. * @returns a promise that will resolve once rendering has started
  109640. */
  109641. startRenderingToXRAsync(): Promise<void>;
  109642. /**
  109643. * Gets the correct render target texture to be rendered this frame for this eye
  109644. * @param eye the eye for which to get the render target
  109645. * @returns the render target for the specified eye
  109646. */
  109647. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  109648. /**
  109649. * Stops the xrSession and restores the renderloop
  109650. * @returns Promise which resolves after it exits XR
  109651. */
  109652. exitXRAsync(): Promise<void>;
  109653. /**
  109654. * Checks if a session would be supported for the creation options specified
  109655. * @param sessionMode session mode to check if supported eg. immersive-vr
  109656. * @returns true if supported
  109657. */
  109658. supportsSessionAsync(sessionMode: XRSessionMode): any;
  109659. /**
  109660. * Creates a WebXRRenderTarget object for the XR session
  109661. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  109662. * @returns a WebXR render target to which the session can render
  109663. */
  109664. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  109665. /**
  109666. * @hidden
  109667. * Converts the render layer of xrSession to a render target
  109668. * @param session session to create render target for
  109669. * @param scene scene the new render target should be created for
  109670. */
  109671. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  109672. /**
  109673. * Disposes of the session manager
  109674. */
  109675. dispose(): void;
  109676. }
  109677. }
  109678. declare module BABYLON {
  109679. /**
  109680. * WebXR Camera which holds the views for the xrSession
  109681. * @see https://doc.babylonjs.com/how_to/webxr
  109682. */
  109683. export class WebXRCamera extends FreeCamera {
  109684. private static _TmpMatrix;
  109685. /**
  109686. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  109687. * @param name the name of the camera
  109688. * @param scene the scene to add the camera to
  109689. */
  109690. constructor(name: string, scene: Scene);
  109691. private _updateNumberOfRigCameras;
  109692. /** @hidden */
  109693. _updateForDualEyeDebugging(): void;
  109694. /**
  109695. * Updates the cameras position from the current pose information of the XR session
  109696. * @param xrSessionManager the session containing pose information
  109697. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109698. */
  109699. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109700. }
  109701. }
  109702. declare module BABYLON {
  109703. /**
  109704. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109705. * @see https://doc.babylonjs.com/how_to/webxr
  109706. */
  109707. export class WebXRExperienceHelper implements IDisposable {
  109708. private scene;
  109709. /**
  109710. * 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
  109711. */
  109712. container: AbstractMesh;
  109713. /**
  109714. * Camera used to render xr content
  109715. */
  109716. camera: WebXRCamera;
  109717. /**
  109718. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  109719. */
  109720. state: WebXRState;
  109721. private _setState;
  109722. private static _TmpVector;
  109723. /**
  109724. * Fires when the state of the experience helper has changed
  109725. */
  109726. onStateChangedObservable: Observable<WebXRState>;
  109727. /** Session manager used to keep track of xr session */
  109728. sessionManager: WebXRSessionManager;
  109729. private _nonVRCamera;
  109730. private _originalSceneAutoClear;
  109731. private _supported;
  109732. /**
  109733. * Creates the experience helper
  109734. * @param scene the scene to attach the experience helper to
  109735. * @returns a promise for the experience helper
  109736. */
  109737. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  109738. /**
  109739. * Creates a WebXRExperienceHelper
  109740. * @param scene The scene the helper should be created in
  109741. */
  109742. private constructor();
  109743. /**
  109744. * Exits XR mode and returns the scene to its original state
  109745. * @returns promise that resolves after xr mode has exited
  109746. */
  109747. exitXRAsync(): Promise<void>;
  109748. /**
  109749. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109750. * @param sessionMode options for the XR session
  109751. * @param referenceSpaceType frame of reference of the XR session
  109752. * @param renderTarget the output canvas that will be used to enter XR mode
  109753. * @returns promise that resolves after xr mode has entered
  109754. */
  109755. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  109756. /**
  109757. * Updates the global position of the camera by moving the camera's container
  109758. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  109759. * @param position The desired global position of the camera
  109760. */
  109761. setPositionOfCameraUsingContainer(position: Vector3): void;
  109762. /**
  109763. * Rotates the xr camera by rotating the camera's container around the camera's position
  109764. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  109765. * @param rotation the desired quaternion rotation to apply to the camera
  109766. */
  109767. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  109768. /**
  109769. * Disposes of the experience helper
  109770. */
  109771. dispose(): void;
  109772. }
  109773. }
  109774. declare module BABYLON {
  109775. /**
  109776. * Button which can be used to enter a different mode of XR
  109777. */
  109778. export class WebXREnterExitUIButton {
  109779. /** button element */
  109780. element: HTMLElement;
  109781. /** XR initialization options for the button */
  109782. sessionMode: XRSessionMode;
  109783. /** Reference space type */
  109784. referenceSpaceType: XRReferenceSpaceType;
  109785. /**
  109786. * Creates a WebXREnterExitUIButton
  109787. * @param element button element
  109788. * @param sessionMode XR initialization session mode
  109789. * @param referenceSpaceType the type of reference space to be used
  109790. */
  109791. constructor(
  109792. /** button element */
  109793. element: HTMLElement,
  109794. /** XR initialization options for the button */
  109795. sessionMode: XRSessionMode,
  109796. /** Reference space type */
  109797. referenceSpaceType: XRReferenceSpaceType);
  109798. /**
  109799. * Overwritable function which can be used to update the button's visuals when the state changes
  109800. * @param activeButton the current active button in the UI
  109801. */
  109802. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  109803. }
  109804. /**
  109805. * Options to create the webXR UI
  109806. */
  109807. export class WebXREnterExitUIOptions {
  109808. /**
  109809. * Context to enter xr with
  109810. */
  109811. renderTarget?: Nullable<WebXRRenderTarget>;
  109812. /**
  109813. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  109814. */
  109815. customButtons?: Array<WebXREnterExitUIButton>;
  109816. }
  109817. /**
  109818. * UI to allow the user to enter/exit XR mode
  109819. */
  109820. export class WebXREnterExitUI implements IDisposable {
  109821. private scene;
  109822. private _overlay;
  109823. private _buttons;
  109824. private _activeButton;
  109825. /**
  109826. * Fired every time the active button is changed.
  109827. *
  109828. * When xr is entered via a button that launches xr that button will be the callback parameter
  109829. *
  109830. * When exiting xr the callback parameter will be null)
  109831. */
  109832. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  109833. /**
  109834. * Creates UI to allow the user to enter/exit XR mode
  109835. * @param scene the scene to add the ui to
  109836. * @param helper the xr experience helper to enter/exit xr with
  109837. * @param options options to configure the UI
  109838. * @returns the created ui
  109839. */
  109840. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  109841. private constructor();
  109842. private _updateButtons;
  109843. /**
  109844. * Disposes of the object
  109845. */
  109846. dispose(): void;
  109847. }
  109848. }
  109849. declare module BABYLON {
  109850. /**
  109851. * Represents an XR input
  109852. */
  109853. export class WebXRController {
  109854. private scene;
  109855. /** The underlying input source for the controller */
  109856. inputSource: XRInputSource;
  109857. private parentContainer;
  109858. /**
  109859. * 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
  109860. */
  109861. grip?: AbstractMesh;
  109862. /**
  109863. * Pointer which can be used to select objects or attach a visible laser to
  109864. */
  109865. pointer: AbstractMesh;
  109866. private _gamepadMode;
  109867. /**
  109868. * If available, this is the gamepad object related to this controller.
  109869. * Using this object it is possible to get click events and trackpad changes of the
  109870. * webxr controller that is currently being used.
  109871. */
  109872. gamepadController?: WebVRController;
  109873. /**
  109874. * Event that fires when the controller is removed/disposed
  109875. */
  109876. onDisposeObservable: Observable<{}>;
  109877. private _tmpMatrix;
  109878. private _tmpQuaternion;
  109879. private _tmpVector;
  109880. /**
  109881. * Creates the controller
  109882. * @see https://doc.babylonjs.com/how_to/webxr
  109883. * @param scene the scene which the controller should be associated to
  109884. * @param inputSource the underlying input source for the controller
  109885. * @param parentContainer parent that the controller meshes should be children of
  109886. */
  109887. constructor(scene: Scene,
  109888. /** The underlying input source for the controller */
  109889. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  109890. /**
  109891. * Updates the controller pose based on the given XRFrame
  109892. * @param xrFrame xr frame to update the pose with
  109893. * @param referenceSpace reference space to use
  109894. */
  109895. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  109896. /**
  109897. * Gets a world space ray coming from the controller
  109898. * @param result the resulting ray
  109899. */
  109900. getWorldPointerRayToRef(result: Ray): void;
  109901. /**
  109902. * Get the scene associated with this controller
  109903. * @returns the scene object
  109904. */
  109905. getScene(): Scene;
  109906. /**
  109907. * Disposes of the object
  109908. */
  109909. dispose(): void;
  109910. }
  109911. }
  109912. declare module BABYLON {
  109913. /**
  109914. * XR input used to track XR inputs such as controllers/rays
  109915. */
  109916. export class WebXRInput implements IDisposable {
  109917. /**
  109918. * Base experience the input listens to
  109919. */
  109920. baseExperience: WebXRExperienceHelper;
  109921. /**
  109922. * XR controllers being tracked
  109923. */
  109924. controllers: Array<WebXRController>;
  109925. private _frameObserver;
  109926. private _stateObserver;
  109927. /**
  109928. * Event when a controller has been connected/added
  109929. */
  109930. onControllerAddedObservable: Observable<WebXRController>;
  109931. /**
  109932. * Event when a controller has been removed/disconnected
  109933. */
  109934. onControllerRemovedObservable: Observable<WebXRController>;
  109935. /**
  109936. * Initializes the WebXRInput
  109937. * @param baseExperience experience helper which the input should be created for
  109938. */
  109939. constructor(
  109940. /**
  109941. * Base experience the input listens to
  109942. */
  109943. baseExperience: WebXRExperienceHelper);
  109944. private _onInputSourcesChange;
  109945. private _addAndRemoveControllers;
  109946. /**
  109947. * Disposes of the object
  109948. */
  109949. dispose(): void;
  109950. }
  109951. }
  109952. declare module BABYLON {
  109953. /**
  109954. * Enables teleportation
  109955. */
  109956. export class WebXRControllerTeleportation {
  109957. private _teleportationFillColor;
  109958. private _teleportationBorderColor;
  109959. private _tmpRay;
  109960. private _tmpVector;
  109961. /**
  109962. * Creates a WebXRControllerTeleportation
  109963. * @param input input manager to add teleportation to
  109964. * @param floorMeshes floormeshes which can be teleported to
  109965. */
  109966. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109967. }
  109968. }
  109969. declare module BABYLON {
  109970. /**
  109971. * Handles pointer input automatically for the pointer of XR controllers
  109972. */
  109973. export class WebXRControllerPointerSelection {
  109974. private static _idCounter;
  109975. private _tmpRay;
  109976. /**
  109977. * Creates a WebXRControllerPointerSelection
  109978. * @param input input manager to setup pointer selection
  109979. */
  109980. constructor(input: WebXRInput);
  109981. private _convertNormalToDirectionOfRay;
  109982. private _updatePointerDistance;
  109983. }
  109984. }
  109985. declare module BABYLON {
  109986. /**
  109987. * Class used to represent data loading progression
  109988. */
  109989. export class SceneLoaderProgressEvent {
  109990. /** defines if data length to load can be evaluated */
  109991. readonly lengthComputable: boolean;
  109992. /** defines the loaded data length */
  109993. readonly loaded: number;
  109994. /** defines the data length to load */
  109995. readonly total: number;
  109996. /**
  109997. * Create a new progress event
  109998. * @param lengthComputable defines if data length to load can be evaluated
  109999. * @param loaded defines the loaded data length
  110000. * @param total defines the data length to load
  110001. */
  110002. constructor(
  110003. /** defines if data length to load can be evaluated */
  110004. lengthComputable: boolean,
  110005. /** defines the loaded data length */
  110006. loaded: number,
  110007. /** defines the data length to load */
  110008. total: number);
  110009. /**
  110010. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110011. * @param event defines the source event
  110012. * @returns a new SceneLoaderProgressEvent
  110013. */
  110014. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110015. }
  110016. /**
  110017. * Interface used by SceneLoader plugins to define supported file extensions
  110018. */
  110019. export interface ISceneLoaderPluginExtensions {
  110020. /**
  110021. * Defines the list of supported extensions
  110022. */
  110023. [extension: string]: {
  110024. isBinary: boolean;
  110025. };
  110026. }
  110027. /**
  110028. * Interface used by SceneLoader plugin factory
  110029. */
  110030. export interface ISceneLoaderPluginFactory {
  110031. /**
  110032. * Defines the name of the factory
  110033. */
  110034. name: string;
  110035. /**
  110036. * Function called to create a new plugin
  110037. * @return the new plugin
  110038. */
  110039. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110040. /**
  110041. * The callback that returns true if the data can be directly loaded.
  110042. * @param data string containing the file data
  110043. * @returns if the data can be loaded directly
  110044. */
  110045. canDirectLoad?(data: string): boolean;
  110046. }
  110047. /**
  110048. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110049. */
  110050. export interface ISceneLoaderPluginBase {
  110051. /**
  110052. * The friendly name of this plugin.
  110053. */
  110054. name: string;
  110055. /**
  110056. * The file extensions supported by this plugin.
  110057. */
  110058. extensions: string | ISceneLoaderPluginExtensions;
  110059. /**
  110060. * The callback called when loading from a url.
  110061. * @param scene scene loading this url
  110062. * @param url url to load
  110063. * @param onSuccess callback called when the file successfully loads
  110064. * @param onProgress callback called while file is loading (if the server supports this mode)
  110065. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110066. * @param onError callback called when the file fails to load
  110067. * @returns a file request object
  110068. */
  110069. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110070. /**
  110071. * The callback called when loading from a file object.
  110072. * @param scene scene loading this file
  110073. * @param file defines the file to load
  110074. * @param onSuccess defines the callback to call when data is loaded
  110075. * @param onProgress defines the callback to call during loading process
  110076. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110077. * @param onError defines the callback to call when an error occurs
  110078. * @returns a file request object
  110079. */
  110080. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110081. /**
  110082. * The callback that returns true if the data can be directly loaded.
  110083. * @param data string containing the file data
  110084. * @returns if the data can be loaded directly
  110085. */
  110086. canDirectLoad?(data: string): boolean;
  110087. /**
  110088. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110089. * @param scene scene loading this data
  110090. * @param data string containing the data
  110091. * @returns data to pass to the plugin
  110092. */
  110093. directLoad?(scene: Scene, data: string): any;
  110094. /**
  110095. * The callback that allows custom handling of the root url based on the response url.
  110096. * @param rootUrl the original root url
  110097. * @param responseURL the response url if available
  110098. * @returns the new root url
  110099. */
  110100. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110101. }
  110102. /**
  110103. * Interface used to define a SceneLoader plugin
  110104. */
  110105. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110106. /**
  110107. * Import meshes into a scene.
  110108. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110109. * @param scene The scene to import into
  110110. * @param data The data to import
  110111. * @param rootUrl The root url for scene and resources
  110112. * @param meshes The meshes array to import into
  110113. * @param particleSystems The particle systems array to import into
  110114. * @param skeletons The skeletons array to import into
  110115. * @param onError The callback when import fails
  110116. * @returns True if successful or false otherwise
  110117. */
  110118. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110119. /**
  110120. * Load into a scene.
  110121. * @param scene The scene to load into
  110122. * @param data The data to import
  110123. * @param rootUrl The root url for scene and resources
  110124. * @param onError The callback when import fails
  110125. * @returns True if successful or false otherwise
  110126. */
  110127. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110128. /**
  110129. * Load into an asset container.
  110130. * @param scene The scene to load into
  110131. * @param data The data to import
  110132. * @param rootUrl The root url for scene and resources
  110133. * @param onError The callback when import fails
  110134. * @returns The loaded asset container
  110135. */
  110136. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110137. }
  110138. /**
  110139. * Interface used to define an async SceneLoader plugin
  110140. */
  110141. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110142. /**
  110143. * Import meshes into a scene.
  110144. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110145. * @param scene The scene to import into
  110146. * @param data The data to import
  110147. * @param rootUrl The root url for scene and resources
  110148. * @param onProgress The callback when the load progresses
  110149. * @param fileName Defines the name of the file to load
  110150. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110151. */
  110152. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110153. meshes: AbstractMesh[];
  110154. particleSystems: IParticleSystem[];
  110155. skeletons: Skeleton[];
  110156. animationGroups: AnimationGroup[];
  110157. }>;
  110158. /**
  110159. * Load into a scene.
  110160. * @param scene The scene to load into
  110161. * @param data The data to import
  110162. * @param rootUrl The root url for scene and resources
  110163. * @param onProgress The callback when the load progresses
  110164. * @param fileName Defines the name of the file to load
  110165. * @returns Nothing
  110166. */
  110167. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110168. /**
  110169. * Load into an asset container.
  110170. * @param scene The scene to load into
  110171. * @param data The data to import
  110172. * @param rootUrl The root url for scene and resources
  110173. * @param onProgress The callback when the load progresses
  110174. * @param fileName Defines the name of the file to load
  110175. * @returns The loaded asset container
  110176. */
  110177. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110178. }
  110179. /**
  110180. * Class used to load scene from various file formats using registered plugins
  110181. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110182. */
  110183. export class SceneLoader {
  110184. /**
  110185. * No logging while loading
  110186. */
  110187. static readonly NO_LOGGING: number;
  110188. /**
  110189. * Minimal logging while loading
  110190. */
  110191. static readonly MINIMAL_LOGGING: number;
  110192. /**
  110193. * Summary logging while loading
  110194. */
  110195. static readonly SUMMARY_LOGGING: number;
  110196. /**
  110197. * Detailled logging while loading
  110198. */
  110199. static readonly DETAILED_LOGGING: number;
  110200. /**
  110201. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110202. */
  110203. static ForceFullSceneLoadingForIncremental: boolean;
  110204. /**
  110205. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110206. */
  110207. static ShowLoadingScreen: boolean;
  110208. /**
  110209. * Defines the current logging level (while loading the scene)
  110210. * @ignorenaming
  110211. */
  110212. static loggingLevel: number;
  110213. /**
  110214. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110215. */
  110216. static CleanBoneMatrixWeights: boolean;
  110217. /**
  110218. * Event raised when a plugin is used to load a scene
  110219. */
  110220. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110221. private static _registeredPlugins;
  110222. private static _getDefaultPlugin;
  110223. private static _getPluginForExtension;
  110224. private static _getPluginForDirectLoad;
  110225. private static _getPluginForFilename;
  110226. private static _getDirectLoad;
  110227. private static _loadData;
  110228. private static _getFileInfo;
  110229. /**
  110230. * Gets a plugin that can load the given extension
  110231. * @param extension defines the extension to load
  110232. * @returns a plugin or null if none works
  110233. */
  110234. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110235. /**
  110236. * Gets a boolean indicating that the given extension can be loaded
  110237. * @param extension defines the extension to load
  110238. * @returns true if the extension is supported
  110239. */
  110240. static IsPluginForExtensionAvailable(extension: string): boolean;
  110241. /**
  110242. * Adds a new plugin to the list of registered plugins
  110243. * @param plugin defines the plugin to add
  110244. */
  110245. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110246. /**
  110247. * Import meshes into a scene
  110248. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110249. * @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)
  110250. * @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)
  110251. * @param scene the instance of BABYLON.Scene to append to
  110252. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110253. * @param onProgress a callback with a progress event for each file being loaded
  110254. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110255. * @param pluginExtension the extension used to determine the plugin
  110256. * @returns The loaded plugin
  110257. */
  110258. 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>;
  110259. /**
  110260. * Import meshes into a scene
  110261. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110262. * @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)
  110263. * @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)
  110264. * @param scene the instance of BABYLON.Scene to append to
  110265. * @param onProgress a callback with a progress event for each file being loaded
  110266. * @param pluginExtension the extension used to determine the plugin
  110267. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110268. */
  110269. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110270. meshes: AbstractMesh[];
  110271. particleSystems: IParticleSystem[];
  110272. skeletons: Skeleton[];
  110273. animationGroups: AnimationGroup[];
  110274. }>;
  110275. /**
  110276. * Load a scene
  110277. * @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)
  110278. * @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)
  110279. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110280. * @param onSuccess a callback with the scene when import succeeds
  110281. * @param onProgress a callback with a progress event for each file being loaded
  110282. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110283. * @param pluginExtension the extension used to determine the plugin
  110284. * @returns The loaded plugin
  110285. */
  110286. 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>;
  110287. /**
  110288. * Load a scene
  110289. * @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)
  110290. * @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)
  110291. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110292. * @param onProgress a callback with a progress event for each file being loaded
  110293. * @param pluginExtension the extension used to determine the plugin
  110294. * @returns The loaded scene
  110295. */
  110296. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110297. /**
  110298. * Append a scene
  110299. * @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)
  110300. * @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)
  110301. * @param scene is the instance of BABYLON.Scene to append to
  110302. * @param onSuccess a callback with the scene when import succeeds
  110303. * @param onProgress a callback with a progress event for each file being loaded
  110304. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110305. * @param pluginExtension the extension used to determine the plugin
  110306. * @returns The loaded plugin
  110307. */
  110308. 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>;
  110309. /**
  110310. * Append a scene
  110311. * @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)
  110312. * @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)
  110313. * @param scene is the instance of BABYLON.Scene to append to
  110314. * @param onProgress a callback with a progress event for each file being loaded
  110315. * @param pluginExtension the extension used to determine the plugin
  110316. * @returns The given scene
  110317. */
  110318. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110319. /**
  110320. * Load a scene into an asset container
  110321. * @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)
  110322. * @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)
  110323. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110324. * @param onSuccess a callback with the scene when import succeeds
  110325. * @param onProgress a callback with a progress event for each file being loaded
  110326. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110327. * @param pluginExtension the extension used to determine the plugin
  110328. * @returns The loaded plugin
  110329. */
  110330. 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>;
  110331. /**
  110332. * Load a scene into an asset container
  110333. * @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)
  110334. * @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)
  110335. * @param scene is the instance of Scene to append to
  110336. * @param onProgress a callback with a progress event for each file being loaded
  110337. * @param pluginExtension the extension used to determine the plugin
  110338. * @returns The loaded asset container
  110339. */
  110340. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110341. }
  110342. }
  110343. declare module BABYLON {
  110344. /**
  110345. * Generic Controller
  110346. */
  110347. export class GenericController extends WebVRController {
  110348. /**
  110349. * Base Url for the controller model.
  110350. */
  110351. static readonly MODEL_BASE_URL: string;
  110352. /**
  110353. * File name for the controller model.
  110354. */
  110355. static readonly MODEL_FILENAME: string;
  110356. /**
  110357. * Creates a new GenericController from a gamepad
  110358. * @param vrGamepad the gamepad that the controller should be created from
  110359. */
  110360. constructor(vrGamepad: any);
  110361. /**
  110362. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110363. * @param scene scene in which to add meshes
  110364. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110365. */
  110366. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110367. /**
  110368. * Called once for each button that changed state since the last frame
  110369. * @param buttonIdx Which button index changed
  110370. * @param state New state of the button
  110371. * @param changes Which properties on the state changed since last frame
  110372. */
  110373. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110374. }
  110375. }
  110376. declare module BABYLON {
  110377. /**
  110378. * Defines the WindowsMotionController object that the state of the windows motion controller
  110379. */
  110380. export class WindowsMotionController extends WebVRController {
  110381. /**
  110382. * The base url used to load the left and right controller models
  110383. */
  110384. static MODEL_BASE_URL: string;
  110385. /**
  110386. * The name of the left controller model file
  110387. */
  110388. static MODEL_LEFT_FILENAME: string;
  110389. /**
  110390. * The name of the right controller model file
  110391. */
  110392. static MODEL_RIGHT_FILENAME: string;
  110393. /**
  110394. * The controller name prefix for this controller type
  110395. */
  110396. static readonly GAMEPAD_ID_PREFIX: string;
  110397. /**
  110398. * The controller id pattern for this controller type
  110399. */
  110400. private static readonly GAMEPAD_ID_PATTERN;
  110401. private _loadedMeshInfo;
  110402. private readonly _mapping;
  110403. /**
  110404. * Fired when the trackpad on this controller is clicked
  110405. */
  110406. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110407. /**
  110408. * Fired when the trackpad on this controller is modified
  110409. */
  110410. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110411. /**
  110412. * The current x and y values of this controller's trackpad
  110413. */
  110414. trackpad: StickValues;
  110415. /**
  110416. * Creates a new WindowsMotionController from a gamepad
  110417. * @param vrGamepad the gamepad that the controller should be created from
  110418. */
  110419. constructor(vrGamepad: any);
  110420. /**
  110421. * Fired when the trigger on this controller is modified
  110422. */
  110423. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110424. /**
  110425. * Fired when the menu button on this controller is modified
  110426. */
  110427. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110428. /**
  110429. * Fired when the grip button on this controller is modified
  110430. */
  110431. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110432. /**
  110433. * Fired when the thumbstick button on this controller is modified
  110434. */
  110435. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110436. /**
  110437. * Fired when the touchpad button on this controller is modified
  110438. */
  110439. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110440. /**
  110441. * Fired when the touchpad values on this controller are modified
  110442. */
  110443. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110444. private _updateTrackpad;
  110445. /**
  110446. * Called once per frame by the engine.
  110447. */
  110448. update(): void;
  110449. /**
  110450. * Called once for each button that changed state since the last frame
  110451. * @param buttonIdx Which button index changed
  110452. * @param state New state of the button
  110453. * @param changes Which properties on the state changed since last frame
  110454. */
  110455. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110456. /**
  110457. * Moves the buttons on the controller mesh based on their current state
  110458. * @param buttonName the name of the button to move
  110459. * @param buttonValue the value of the button which determines the buttons new position
  110460. */
  110461. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  110462. /**
  110463. * Moves the axis on the controller mesh based on its current state
  110464. * @param axis the index of the axis
  110465. * @param axisValue the value of the axis which determines the meshes new position
  110466. * @hidden
  110467. */
  110468. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  110469. /**
  110470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110471. * @param scene scene in which to add meshes
  110472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110473. */
  110474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  110475. /**
  110476. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  110477. * can be transformed by button presses and axes values, based on this._mapping.
  110478. *
  110479. * @param scene scene in which the meshes exist
  110480. * @param meshes list of meshes that make up the controller model to process
  110481. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  110482. */
  110483. private processModel;
  110484. private createMeshInfo;
  110485. /**
  110486. * Gets the ray of the controller in the direction the controller is pointing
  110487. * @param length the length the resulting ray should be
  110488. * @returns a ray in the direction the controller is pointing
  110489. */
  110490. getForwardRay(length?: number): Ray;
  110491. /**
  110492. * Disposes of the controller
  110493. */
  110494. dispose(): void;
  110495. }
  110496. }
  110497. declare module BABYLON {
  110498. /**
  110499. * Oculus Touch Controller
  110500. */
  110501. export class OculusTouchController extends WebVRController {
  110502. /**
  110503. * Base Url for the controller model.
  110504. */
  110505. static MODEL_BASE_URL: string;
  110506. /**
  110507. * File name for the left controller model.
  110508. */
  110509. static MODEL_LEFT_FILENAME: string;
  110510. /**
  110511. * File name for the right controller model.
  110512. */
  110513. static MODEL_RIGHT_FILENAME: string;
  110514. /**
  110515. * Base Url for the Quest controller model.
  110516. */
  110517. static QUEST_MODEL_BASE_URL: string;
  110518. /**
  110519. * @hidden
  110520. * If the controllers are running on a device that needs the updated Quest controller models
  110521. */
  110522. static _IsQuest: boolean;
  110523. /**
  110524. * Fired when the secondary trigger on this controller is modified
  110525. */
  110526. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  110527. /**
  110528. * Fired when the thumb rest on this controller is modified
  110529. */
  110530. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  110531. /**
  110532. * Creates a new OculusTouchController from a gamepad
  110533. * @param vrGamepad the gamepad that the controller should be created from
  110534. */
  110535. constructor(vrGamepad: any);
  110536. /**
  110537. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110538. * @param scene scene in which to add meshes
  110539. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110540. */
  110541. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110542. /**
  110543. * Fired when the A button on this controller is modified
  110544. */
  110545. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110546. /**
  110547. * Fired when the B button on this controller is modified
  110548. */
  110549. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110550. /**
  110551. * Fired when the X button on this controller is modified
  110552. */
  110553. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110554. /**
  110555. * Fired when the Y button on this controller is modified
  110556. */
  110557. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110558. /**
  110559. * Called once for each button that changed state since the last frame
  110560. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  110561. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  110562. * 2) secondary trigger (same)
  110563. * 3) A (right) X (left), touch, pressed = value
  110564. * 4) B / Y
  110565. * 5) thumb rest
  110566. * @param buttonIdx Which button index changed
  110567. * @param state New state of the button
  110568. * @param changes Which properties on the state changed since last frame
  110569. */
  110570. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110571. }
  110572. }
  110573. declare module BABYLON {
  110574. /**
  110575. * Vive Controller
  110576. */
  110577. export class ViveController extends WebVRController {
  110578. /**
  110579. * Base Url for the controller model.
  110580. */
  110581. static MODEL_BASE_URL: string;
  110582. /**
  110583. * File name for the controller model.
  110584. */
  110585. static MODEL_FILENAME: string;
  110586. /**
  110587. * Creates a new ViveController from a gamepad
  110588. * @param vrGamepad the gamepad that the controller should be created from
  110589. */
  110590. constructor(vrGamepad: any);
  110591. /**
  110592. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110593. * @param scene scene in which to add meshes
  110594. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110595. */
  110596. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110597. /**
  110598. * Fired when the left button on this controller is modified
  110599. */
  110600. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110601. /**
  110602. * Fired when the right button on this controller is modified
  110603. */
  110604. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110605. /**
  110606. * Fired when the menu button on this controller is modified
  110607. */
  110608. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110609. /**
  110610. * Called once for each button that changed state since the last frame
  110611. * Vive mapping:
  110612. * 0: touchpad
  110613. * 1: trigger
  110614. * 2: left AND right buttons
  110615. * 3: menu button
  110616. * @param buttonIdx Which button index changed
  110617. * @param state New state of the button
  110618. * @param changes Which properties on the state changed since last frame
  110619. */
  110620. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110621. }
  110622. }
  110623. declare module BABYLON {
  110624. /**
  110625. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  110626. */
  110627. export class WebXRControllerModelLoader {
  110628. /**
  110629. * Creates the WebXRControllerModelLoader
  110630. * @param input xr input that creates the controllers
  110631. */
  110632. constructor(input: WebXRInput);
  110633. }
  110634. }
  110635. declare module BABYLON {
  110636. /**
  110637. * Contains an array of blocks representing the octree
  110638. */
  110639. export interface IOctreeContainer<T> {
  110640. /**
  110641. * Blocks within the octree
  110642. */
  110643. blocks: Array<OctreeBlock<T>>;
  110644. }
  110645. /**
  110646. * Class used to store a cell in an octree
  110647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110648. */
  110649. export class OctreeBlock<T> {
  110650. /**
  110651. * Gets the content of the current block
  110652. */
  110653. entries: T[];
  110654. /**
  110655. * Gets the list of block children
  110656. */
  110657. blocks: Array<OctreeBlock<T>>;
  110658. private _depth;
  110659. private _maxDepth;
  110660. private _capacity;
  110661. private _minPoint;
  110662. private _maxPoint;
  110663. private _boundingVectors;
  110664. private _creationFunc;
  110665. /**
  110666. * Creates a new block
  110667. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110668. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110669. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110670. * @param depth defines the current depth of this block in the octree
  110671. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110672. * @param creationFunc defines a callback to call when an element is added to the block
  110673. */
  110674. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110675. /**
  110676. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110677. */
  110678. readonly capacity: number;
  110679. /**
  110680. * Gets the minimum vector (in world space) of the block's bounding box
  110681. */
  110682. readonly minPoint: Vector3;
  110683. /**
  110684. * Gets the maximum vector (in world space) of the block's bounding box
  110685. */
  110686. readonly maxPoint: Vector3;
  110687. /**
  110688. * Add a new element to this block
  110689. * @param entry defines the element to add
  110690. */
  110691. addEntry(entry: T): void;
  110692. /**
  110693. * Remove an element from this block
  110694. * @param entry defines the element to remove
  110695. */
  110696. removeEntry(entry: T): void;
  110697. /**
  110698. * Add an array of elements to this block
  110699. * @param entries defines the array of elements to add
  110700. */
  110701. addEntries(entries: T[]): void;
  110702. /**
  110703. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110704. * @param frustumPlanes defines the frustum planes to test
  110705. * @param selection defines the array to store current content if selection is positive
  110706. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110707. */
  110708. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110709. /**
  110710. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110711. * @param sphereCenter defines the bounding sphere center
  110712. * @param sphereRadius defines the bounding sphere radius
  110713. * @param selection defines the array to store current content if selection is positive
  110714. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110715. */
  110716. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110717. /**
  110718. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  110719. * @param ray defines the ray to test with
  110720. * @param selection defines the array to store current content if selection is positive
  110721. */
  110722. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  110723. /**
  110724. * Subdivide the content into child blocks (this block will then be empty)
  110725. */
  110726. createInnerBlocks(): void;
  110727. /**
  110728. * @hidden
  110729. */
  110730. 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;
  110731. }
  110732. }
  110733. declare module BABYLON {
  110734. /**
  110735. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  110736. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110737. */
  110738. export class Octree<T> {
  110739. /** 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.) */
  110740. maxDepth: number;
  110741. /**
  110742. * Blocks within the octree containing objects
  110743. */
  110744. blocks: Array<OctreeBlock<T>>;
  110745. /**
  110746. * Content stored in the octree
  110747. */
  110748. dynamicContent: T[];
  110749. private _maxBlockCapacity;
  110750. private _selectionContent;
  110751. private _creationFunc;
  110752. /**
  110753. * Creates a octree
  110754. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110755. * @param creationFunc function to be used to instatiate the octree
  110756. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  110757. * @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.)
  110758. */
  110759. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  110760. /** 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.) */
  110761. maxDepth?: number);
  110762. /**
  110763. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  110764. * @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);
  110765. * @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);
  110766. * @param entries meshes to be added to the octree blocks
  110767. */
  110768. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  110769. /**
  110770. * Adds a mesh to the octree
  110771. * @param entry Mesh to add to the octree
  110772. */
  110773. addMesh(entry: T): void;
  110774. /**
  110775. * Remove an element from the octree
  110776. * @param entry defines the element to remove
  110777. */
  110778. removeMesh(entry: T): void;
  110779. /**
  110780. * Selects an array of meshes within the frustum
  110781. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  110782. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  110783. * @returns array of meshes within the frustum
  110784. */
  110785. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  110786. /**
  110787. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  110788. * @param sphereCenter defines the bounding sphere center
  110789. * @param sphereRadius defines the bounding sphere radius
  110790. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110791. * @returns an array of objects that intersect the sphere
  110792. */
  110793. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  110794. /**
  110795. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  110796. * @param ray defines the ray to test with
  110797. * @returns array of intersected objects
  110798. */
  110799. intersectsRay(ray: Ray): SmartArray<T>;
  110800. /**
  110801. * Adds a mesh into the octree block if it intersects the block
  110802. */
  110803. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  110804. /**
  110805. * Adds a submesh into the octree block if it intersects the block
  110806. */
  110807. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  110808. }
  110809. }
  110810. declare module BABYLON {
  110811. interface Scene {
  110812. /**
  110813. * @hidden
  110814. * Backing Filed
  110815. */
  110816. _selectionOctree: Octree<AbstractMesh>;
  110817. /**
  110818. * Gets the octree used to boost mesh selection (picking)
  110819. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110820. */
  110821. selectionOctree: Octree<AbstractMesh>;
  110822. /**
  110823. * Creates or updates the octree used to boost selection (picking)
  110824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110825. * @param maxCapacity defines the maximum capacity per leaf
  110826. * @param maxDepth defines the maximum depth of the octree
  110827. * @returns an octree of AbstractMesh
  110828. */
  110829. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  110830. }
  110831. interface AbstractMesh {
  110832. /**
  110833. * @hidden
  110834. * Backing Field
  110835. */
  110836. _submeshesOctree: Octree<SubMesh>;
  110837. /**
  110838. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  110839. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  110840. * @param maxCapacity defines the maximum size of each block (64 by default)
  110841. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  110842. * @returns the new octree
  110843. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  110844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110845. */
  110846. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  110847. }
  110848. /**
  110849. * Defines the octree scene component responsible to manage any octrees
  110850. * in a given scene.
  110851. */
  110852. export class OctreeSceneComponent {
  110853. /**
  110854. * The component name help to identify the component in the list of scene components.
  110855. */
  110856. readonly name: string;
  110857. /**
  110858. * The scene the component belongs to.
  110859. */
  110860. scene: Scene;
  110861. /**
  110862. * Indicates if the meshes have been checked to make sure they are isEnabled()
  110863. */
  110864. readonly checksIsEnabled: boolean;
  110865. /**
  110866. * Creates a new instance of the component for the given scene
  110867. * @param scene Defines the scene to register the component in
  110868. */
  110869. constructor(scene: Scene);
  110870. /**
  110871. * Registers the component in a given scene
  110872. */
  110873. register(): void;
  110874. /**
  110875. * Return the list of active meshes
  110876. * @returns the list of active meshes
  110877. */
  110878. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110879. /**
  110880. * Return the list of active sub meshes
  110881. * @param mesh The mesh to get the candidates sub meshes from
  110882. * @returns the list of active sub meshes
  110883. */
  110884. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110885. private _tempRay;
  110886. /**
  110887. * Return the list of sub meshes intersecting with a given local ray
  110888. * @param mesh defines the mesh to find the submesh for
  110889. * @param localRay defines the ray in local space
  110890. * @returns the list of intersecting sub meshes
  110891. */
  110892. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  110893. /**
  110894. * Return the list of sub meshes colliding with a collider
  110895. * @param mesh defines the mesh to find the submesh for
  110896. * @param collider defines the collider to evaluate the collision against
  110897. * @returns the list of colliding sub meshes
  110898. */
  110899. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  110900. /**
  110901. * Rebuilds the elements related to this component in case of
  110902. * context lost for instance.
  110903. */
  110904. rebuild(): void;
  110905. /**
  110906. * Disposes the component and the associated ressources.
  110907. */
  110908. dispose(): void;
  110909. }
  110910. }
  110911. declare module BABYLON {
  110912. /**
  110913. * Renders a layer on top of an existing scene
  110914. */
  110915. export class UtilityLayerRenderer implements IDisposable {
  110916. /** the original scene that will be rendered on top of */
  110917. originalScene: Scene;
  110918. private _pointerCaptures;
  110919. private _lastPointerEvents;
  110920. private static _DefaultUtilityLayer;
  110921. private static _DefaultKeepDepthUtilityLayer;
  110922. private _sharedGizmoLight;
  110923. private _renderCamera;
  110924. /**
  110925. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  110926. * @returns the camera that is used when rendering the utility layer
  110927. */
  110928. getRenderCamera(): Nullable<Camera>;
  110929. /**
  110930. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  110931. * @param cam the camera that should be used when rendering the utility layer
  110932. */
  110933. setRenderCamera(cam: Nullable<Camera>): void;
  110934. /**
  110935. * @hidden
  110936. * Light which used by gizmos to get light shading
  110937. */
  110938. _getSharedGizmoLight(): HemisphericLight;
  110939. /**
  110940. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  110941. */
  110942. pickUtilitySceneFirst: boolean;
  110943. /**
  110944. * 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)
  110945. */
  110946. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  110947. /**
  110948. * 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)
  110949. */
  110950. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  110951. /**
  110952. * The scene that is rendered on top of the original scene
  110953. */
  110954. utilityLayerScene: Scene;
  110955. /**
  110956. * If the utility layer should automatically be rendered on top of existing scene
  110957. */
  110958. shouldRender: boolean;
  110959. /**
  110960. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  110961. */
  110962. onlyCheckPointerDownEvents: boolean;
  110963. /**
  110964. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  110965. */
  110966. processAllEvents: boolean;
  110967. /**
  110968. * Observable raised when the pointer move from the utility layer scene to the main scene
  110969. */
  110970. onPointerOutObservable: Observable<number>;
  110971. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  110972. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  110973. private _afterRenderObserver;
  110974. private _sceneDisposeObserver;
  110975. private _originalPointerObserver;
  110976. /**
  110977. * Instantiates a UtilityLayerRenderer
  110978. * @param originalScene the original scene that will be rendered on top of
  110979. * @param handleEvents boolean indicating if the utility layer should handle events
  110980. */
  110981. constructor(
  110982. /** the original scene that will be rendered on top of */
  110983. originalScene: Scene, handleEvents?: boolean);
  110984. private _notifyObservers;
  110985. /**
  110986. * Renders the utility layers scene on top of the original scene
  110987. */
  110988. render(): void;
  110989. /**
  110990. * Disposes of the renderer
  110991. */
  110992. dispose(): void;
  110993. private _updateCamera;
  110994. }
  110995. }
  110996. declare module BABYLON {
  110997. /**
  110998. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110999. */
  111000. export class Gizmo implements IDisposable {
  111001. /** The utility layer the gizmo will be added to */
  111002. gizmoLayer: UtilityLayerRenderer;
  111003. /**
  111004. * The root mesh of the gizmo
  111005. */
  111006. _rootMesh: Mesh;
  111007. private _attachedMesh;
  111008. /**
  111009. * Ratio for the scale of the gizmo (Default: 1)
  111010. */
  111011. scaleRatio: number;
  111012. /**
  111013. * If a custom mesh has been set (Default: false)
  111014. */
  111015. protected _customMeshSet: boolean;
  111016. /**
  111017. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111018. * * When set, interactions will be enabled
  111019. */
  111020. attachedMesh: Nullable<AbstractMesh>;
  111021. /**
  111022. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111023. * @param mesh The mesh to replace the default mesh of the gizmo
  111024. */
  111025. setCustomMesh(mesh: Mesh): void;
  111026. /**
  111027. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111028. */
  111029. updateGizmoRotationToMatchAttachedMesh: boolean;
  111030. /**
  111031. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111032. */
  111033. updateGizmoPositionToMatchAttachedMesh: boolean;
  111034. /**
  111035. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111036. */
  111037. updateScale: boolean;
  111038. protected _interactionsEnabled: boolean;
  111039. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111040. private _beforeRenderObserver;
  111041. private _tempVector;
  111042. /**
  111043. * Creates a gizmo
  111044. * @param gizmoLayer The utility layer the gizmo will be added to
  111045. */
  111046. constructor(
  111047. /** The utility layer the gizmo will be added to */
  111048. gizmoLayer?: UtilityLayerRenderer);
  111049. /**
  111050. * Updates the gizmo to match the attached mesh's position/rotation
  111051. */
  111052. protected _update(): void;
  111053. /**
  111054. * Disposes of the gizmo
  111055. */
  111056. dispose(): void;
  111057. }
  111058. }
  111059. declare module BABYLON {
  111060. /**
  111061. * Single plane drag gizmo
  111062. */
  111063. export class PlaneDragGizmo extends Gizmo {
  111064. /**
  111065. * Drag behavior responsible for the gizmos dragging interactions
  111066. */
  111067. dragBehavior: PointerDragBehavior;
  111068. private _pointerObserver;
  111069. /**
  111070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111071. */
  111072. snapDistance: number;
  111073. /**
  111074. * Event that fires each time the gizmo snaps to a new location.
  111075. * * snapDistance is the the change in distance
  111076. */
  111077. onSnapObservable: Observable<{
  111078. snapDistance: number;
  111079. }>;
  111080. private _plane;
  111081. private _coloredMaterial;
  111082. private _hoverMaterial;
  111083. private _isEnabled;
  111084. private _parent;
  111085. /** @hidden */
  111086. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111087. /** @hidden */
  111088. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111089. /**
  111090. * Creates a PlaneDragGizmo
  111091. * @param gizmoLayer The utility layer the gizmo will be added to
  111092. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111093. * @param color The color of the gizmo
  111094. */
  111095. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111096. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111097. /**
  111098. * If the gizmo is enabled
  111099. */
  111100. isEnabled: boolean;
  111101. /**
  111102. * Disposes of the gizmo
  111103. */
  111104. dispose(): void;
  111105. }
  111106. }
  111107. declare module BABYLON {
  111108. /**
  111109. * Gizmo that enables dragging a mesh along 3 axis
  111110. */
  111111. export class PositionGizmo extends Gizmo {
  111112. /**
  111113. * Internal gizmo used for interactions on the x axis
  111114. */
  111115. xGizmo: AxisDragGizmo;
  111116. /**
  111117. * Internal gizmo used for interactions on the y axis
  111118. */
  111119. yGizmo: AxisDragGizmo;
  111120. /**
  111121. * Internal gizmo used for interactions on the z axis
  111122. */
  111123. zGizmo: AxisDragGizmo;
  111124. /**
  111125. * Internal gizmo used for interactions on the yz plane
  111126. */
  111127. xPlaneGizmo: PlaneDragGizmo;
  111128. /**
  111129. * Internal gizmo used for interactions on the xz plane
  111130. */
  111131. yPlaneGizmo: PlaneDragGizmo;
  111132. /**
  111133. * Internal gizmo used for interactions on the xy plane
  111134. */
  111135. zPlaneGizmo: PlaneDragGizmo;
  111136. /**
  111137. * private variables
  111138. */
  111139. private _meshAttached;
  111140. private _updateGizmoRotationToMatchAttachedMesh;
  111141. private _snapDistance;
  111142. private _scaleRatio;
  111143. /** Fires an event when any of it's sub gizmos are dragged */
  111144. onDragStartObservable: Observable<unknown>;
  111145. /** Fires an event when any of it's sub gizmos are released from dragging */
  111146. onDragEndObservable: Observable<unknown>;
  111147. /**
  111148. * If set to true, planar drag is enabled
  111149. */
  111150. private _planarGizmoEnabled;
  111151. attachedMesh: Nullable<AbstractMesh>;
  111152. /**
  111153. * Creates a PositionGizmo
  111154. * @param gizmoLayer The utility layer the gizmo will be added to
  111155. */
  111156. constructor(gizmoLayer?: UtilityLayerRenderer);
  111157. /**
  111158. * If the planar drag gizmo is enabled
  111159. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111160. */
  111161. planarGizmoEnabled: boolean;
  111162. updateGizmoRotationToMatchAttachedMesh: boolean;
  111163. /**
  111164. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111165. */
  111166. snapDistance: number;
  111167. /**
  111168. * Ratio for the scale of the gizmo (Default: 1)
  111169. */
  111170. scaleRatio: number;
  111171. /**
  111172. * Disposes of the gizmo
  111173. */
  111174. dispose(): void;
  111175. /**
  111176. * CustomMeshes are not supported by this gizmo
  111177. * @param mesh The mesh to replace the default mesh of the gizmo
  111178. */
  111179. setCustomMesh(mesh: Mesh): void;
  111180. }
  111181. }
  111182. declare module BABYLON {
  111183. /**
  111184. * Single axis drag gizmo
  111185. */
  111186. export class AxisDragGizmo extends Gizmo {
  111187. /**
  111188. * Drag behavior responsible for the gizmos dragging interactions
  111189. */
  111190. dragBehavior: PointerDragBehavior;
  111191. private _pointerObserver;
  111192. /**
  111193. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111194. */
  111195. snapDistance: number;
  111196. /**
  111197. * Event that fires each time the gizmo snaps to a new location.
  111198. * * snapDistance is the the change in distance
  111199. */
  111200. onSnapObservable: Observable<{
  111201. snapDistance: number;
  111202. }>;
  111203. private _isEnabled;
  111204. private _parent;
  111205. private _arrow;
  111206. private _coloredMaterial;
  111207. private _hoverMaterial;
  111208. /** @hidden */
  111209. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111210. /** @hidden */
  111211. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111212. /**
  111213. * Creates an AxisDragGizmo
  111214. * @param gizmoLayer The utility layer the gizmo will be added to
  111215. * @param dragAxis The axis which the gizmo will be able to drag on
  111216. * @param color The color of the gizmo
  111217. */
  111218. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111219. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111220. /**
  111221. * If the gizmo is enabled
  111222. */
  111223. isEnabled: boolean;
  111224. /**
  111225. * Disposes of the gizmo
  111226. */
  111227. dispose(): void;
  111228. }
  111229. }
  111230. declare module BABYLON.Debug {
  111231. /**
  111232. * The Axes viewer will show 3 axes in a specific point in space
  111233. */
  111234. export class AxesViewer {
  111235. private _xAxis;
  111236. private _yAxis;
  111237. private _zAxis;
  111238. private _scaleLinesFactor;
  111239. private _instanced;
  111240. /**
  111241. * Gets the hosting scene
  111242. */
  111243. scene: Scene;
  111244. /**
  111245. * Gets or sets a number used to scale line length
  111246. */
  111247. scaleLines: number;
  111248. /** Gets the node hierarchy used to render x-axis */
  111249. readonly xAxis: TransformNode;
  111250. /** Gets the node hierarchy used to render y-axis */
  111251. readonly yAxis: TransformNode;
  111252. /** Gets the node hierarchy used to render z-axis */
  111253. readonly zAxis: TransformNode;
  111254. /**
  111255. * Creates a new AxesViewer
  111256. * @param scene defines the hosting scene
  111257. * @param scaleLines defines a number used to scale line length (1 by default)
  111258. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111259. * @param xAxis defines the node hierarchy used to render the x-axis
  111260. * @param yAxis defines the node hierarchy used to render the y-axis
  111261. * @param zAxis defines the node hierarchy used to render the z-axis
  111262. */
  111263. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111264. /**
  111265. * Force the viewer to update
  111266. * @param position defines the position of the viewer
  111267. * @param xaxis defines the x axis of the viewer
  111268. * @param yaxis defines the y axis of the viewer
  111269. * @param zaxis defines the z axis of the viewer
  111270. */
  111271. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111272. /**
  111273. * Creates an instance of this axes viewer.
  111274. * @returns a new axes viewer with instanced meshes
  111275. */
  111276. createInstance(): AxesViewer;
  111277. /** Releases resources */
  111278. dispose(): void;
  111279. private static _SetRenderingGroupId;
  111280. }
  111281. }
  111282. declare module BABYLON.Debug {
  111283. /**
  111284. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111285. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111286. */
  111287. export class BoneAxesViewer extends AxesViewer {
  111288. /**
  111289. * Gets or sets the target mesh where to display the axes viewer
  111290. */
  111291. mesh: Nullable<Mesh>;
  111292. /**
  111293. * Gets or sets the target bone where to display the axes viewer
  111294. */
  111295. bone: Nullable<Bone>;
  111296. /** Gets current position */
  111297. pos: Vector3;
  111298. /** Gets direction of X axis */
  111299. xaxis: Vector3;
  111300. /** Gets direction of Y axis */
  111301. yaxis: Vector3;
  111302. /** Gets direction of Z axis */
  111303. zaxis: Vector3;
  111304. /**
  111305. * Creates a new BoneAxesViewer
  111306. * @param scene defines the hosting scene
  111307. * @param bone defines the target bone
  111308. * @param mesh defines the target mesh
  111309. * @param scaleLines defines a scaling factor for line length (1 by default)
  111310. */
  111311. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  111312. /**
  111313. * Force the viewer to update
  111314. */
  111315. update(): void;
  111316. /** Releases resources */
  111317. dispose(): void;
  111318. }
  111319. }
  111320. declare module BABYLON {
  111321. /**
  111322. * Interface used to define scene explorer extensibility option
  111323. */
  111324. export interface IExplorerExtensibilityOption {
  111325. /**
  111326. * Define the option label
  111327. */
  111328. label: string;
  111329. /**
  111330. * Defines the action to execute on click
  111331. */
  111332. action: (entity: any) => void;
  111333. }
  111334. /**
  111335. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111336. */
  111337. export interface IExplorerExtensibilityGroup {
  111338. /**
  111339. * Defines a predicate to test if a given type mut be extended
  111340. */
  111341. predicate: (entity: any) => boolean;
  111342. /**
  111343. * Gets the list of options added to a type
  111344. */
  111345. entries: IExplorerExtensibilityOption[];
  111346. }
  111347. /**
  111348. * Interface used to define the options to use to create the Inspector
  111349. */
  111350. export interface IInspectorOptions {
  111351. /**
  111352. * Display in overlay mode (default: false)
  111353. */
  111354. overlay?: boolean;
  111355. /**
  111356. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111357. */
  111358. globalRoot?: HTMLElement;
  111359. /**
  111360. * Display the Scene explorer
  111361. */
  111362. showExplorer?: boolean;
  111363. /**
  111364. * Display the property inspector
  111365. */
  111366. showInspector?: boolean;
  111367. /**
  111368. * Display in embed mode (both panes on the right)
  111369. */
  111370. embedMode?: boolean;
  111371. /**
  111372. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111373. */
  111374. handleResize?: boolean;
  111375. /**
  111376. * Allow the panes to popup (default: true)
  111377. */
  111378. enablePopup?: boolean;
  111379. /**
  111380. * Allow the panes to be closed by users (default: true)
  111381. */
  111382. enableClose?: boolean;
  111383. /**
  111384. * Optional list of extensibility entries
  111385. */
  111386. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111387. /**
  111388. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111389. */
  111390. inspectorURL?: string;
  111391. }
  111392. interface Scene {
  111393. /**
  111394. * @hidden
  111395. * Backing field
  111396. */
  111397. _debugLayer: DebugLayer;
  111398. /**
  111399. * Gets the debug layer (aka Inspector) associated with the scene
  111400. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111401. */
  111402. debugLayer: DebugLayer;
  111403. }
  111404. /**
  111405. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111406. * what is happening in your scene
  111407. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111408. */
  111409. export class DebugLayer {
  111410. /**
  111411. * Define the url to get the inspector script from.
  111412. * By default it uses the babylonjs CDN.
  111413. * @ignoreNaming
  111414. */
  111415. static InspectorURL: string;
  111416. private _scene;
  111417. private BJSINSPECTOR;
  111418. private _onPropertyChangedObservable?;
  111419. /**
  111420. * Observable triggered when a property is changed through the inspector.
  111421. */
  111422. readonly onPropertyChangedObservable: any;
  111423. /**
  111424. * Instantiates a new debug layer.
  111425. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111426. * what is happening in your scene
  111427. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111428. * @param scene Defines the scene to inspect
  111429. */
  111430. constructor(scene: Scene);
  111431. /** Creates the inspector window. */
  111432. private _createInspector;
  111433. /**
  111434. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  111435. * @param entity defines the entity to select
  111436. * @param lineContainerTitle defines the specific block to highlight
  111437. */
  111438. select(entity: any, lineContainerTitle?: string): void;
  111439. /** Get the inspector from bundle or global */
  111440. private _getGlobalInspector;
  111441. /**
  111442. * Get if the inspector is visible or not.
  111443. * @returns true if visible otherwise, false
  111444. */
  111445. isVisible(): boolean;
  111446. /**
  111447. * Hide the inspector and close its window.
  111448. */
  111449. hide(): void;
  111450. /**
  111451. * Launch the debugLayer.
  111452. * @param config Define the configuration of the inspector
  111453. * @return a promise fulfilled when the debug layer is visible
  111454. */
  111455. show(config?: IInspectorOptions): Promise<DebugLayer>;
  111456. }
  111457. }
  111458. declare module BABYLON {
  111459. /**
  111460. * Class containing static functions to help procedurally build meshes
  111461. */
  111462. export class BoxBuilder {
  111463. /**
  111464. * Creates a box mesh
  111465. * * The parameter `size` sets the size (float) of each box side (default 1)
  111466. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  111467. * * 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)
  111468. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  111469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111472. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  111473. * @param name defines the name of the mesh
  111474. * @param options defines the options used to create the mesh
  111475. * @param scene defines the hosting scene
  111476. * @returns the box mesh
  111477. */
  111478. static CreateBox(name: string, options: {
  111479. size?: number;
  111480. width?: number;
  111481. height?: number;
  111482. depth?: number;
  111483. faceUV?: Vector4[];
  111484. faceColors?: Color4[];
  111485. sideOrientation?: number;
  111486. frontUVs?: Vector4;
  111487. backUVs?: Vector4;
  111488. wrap?: boolean;
  111489. topBaseAt?: number;
  111490. bottomBaseAt?: number;
  111491. updatable?: boolean;
  111492. }, scene?: Nullable<Scene>): Mesh;
  111493. }
  111494. }
  111495. declare module BABYLON {
  111496. /**
  111497. * Class containing static functions to help procedurally build meshes
  111498. */
  111499. export class SphereBuilder {
  111500. /**
  111501. * Creates a sphere mesh
  111502. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  111503. * * 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`)
  111504. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  111505. * * 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
  111506. * * 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)
  111507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111510. * @param name defines the name of the mesh
  111511. * @param options defines the options used to create the mesh
  111512. * @param scene defines the hosting scene
  111513. * @returns the sphere mesh
  111514. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  111515. */
  111516. static CreateSphere(name: string, options: {
  111517. segments?: number;
  111518. diameter?: number;
  111519. diameterX?: number;
  111520. diameterY?: number;
  111521. diameterZ?: number;
  111522. arc?: number;
  111523. slice?: number;
  111524. sideOrientation?: number;
  111525. frontUVs?: Vector4;
  111526. backUVs?: Vector4;
  111527. updatable?: boolean;
  111528. }, scene?: Nullable<Scene>): Mesh;
  111529. }
  111530. }
  111531. declare module BABYLON.Debug {
  111532. /**
  111533. * Used to show the physics impostor around the specific mesh
  111534. */
  111535. export class PhysicsViewer {
  111536. /** @hidden */
  111537. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  111538. /** @hidden */
  111539. protected _meshes: Array<Nullable<AbstractMesh>>;
  111540. /** @hidden */
  111541. protected _scene: Nullable<Scene>;
  111542. /** @hidden */
  111543. protected _numMeshes: number;
  111544. /** @hidden */
  111545. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  111546. private _renderFunction;
  111547. private _utilityLayer;
  111548. private _debugBoxMesh;
  111549. private _debugSphereMesh;
  111550. private _debugCylinderMesh;
  111551. private _debugMaterial;
  111552. private _debugMeshMeshes;
  111553. /**
  111554. * Creates a new PhysicsViewer
  111555. * @param scene defines the hosting scene
  111556. */
  111557. constructor(scene: Scene);
  111558. /** @hidden */
  111559. protected _updateDebugMeshes(): void;
  111560. /**
  111561. * Renders a specified physic impostor
  111562. * @param impostor defines the impostor to render
  111563. * @param targetMesh defines the mesh represented by the impostor
  111564. * @returns the new debug mesh used to render the impostor
  111565. */
  111566. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  111567. /**
  111568. * Hides a specified physic impostor
  111569. * @param impostor defines the impostor to hide
  111570. */
  111571. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  111572. private _getDebugMaterial;
  111573. private _getDebugBoxMesh;
  111574. private _getDebugSphereMesh;
  111575. private _getDebugCylinderMesh;
  111576. private _getDebugMeshMesh;
  111577. private _getDebugMesh;
  111578. /** Releases all resources */
  111579. dispose(): void;
  111580. }
  111581. }
  111582. declare module BABYLON {
  111583. /**
  111584. * Class containing static functions to help procedurally build meshes
  111585. */
  111586. export class LinesBuilder {
  111587. /**
  111588. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  111589. * * 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
  111590. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  111591. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  111592. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  111593. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  111594. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  111595. * * 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
  111596. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  111597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  111599. * @param name defines the name of the new line system
  111600. * @param options defines the options used to create the line system
  111601. * @param scene defines the hosting scene
  111602. * @returns a new line system mesh
  111603. */
  111604. static CreateLineSystem(name: string, options: {
  111605. lines: Vector3[][];
  111606. updatable?: boolean;
  111607. instance?: Nullable<LinesMesh>;
  111608. colors?: Nullable<Color4[][]>;
  111609. useVertexAlpha?: boolean;
  111610. }, scene: Nullable<Scene>): LinesMesh;
  111611. /**
  111612. * Creates a line mesh
  111613. * 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
  111614. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111615. * * The parameter `points` is an array successive Vector3
  111616. * * 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
  111617. * * The optional parameter `colors` is an array of successive Color4, one per line point
  111618. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  111619. * * When updating an instance, remember that only point positions can change, not the number of points
  111620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  111622. * @param name defines the name of the new line system
  111623. * @param options defines the options used to create the line system
  111624. * @param scene defines the hosting scene
  111625. * @returns a new line mesh
  111626. */
  111627. static CreateLines(name: string, options: {
  111628. points: Vector3[];
  111629. updatable?: boolean;
  111630. instance?: Nullable<LinesMesh>;
  111631. colors?: Color4[];
  111632. useVertexAlpha?: boolean;
  111633. }, scene?: Nullable<Scene>): LinesMesh;
  111634. /**
  111635. * Creates a dashed line mesh
  111636. * * 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
  111637. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111638. * * The parameter `points` is an array successive Vector3
  111639. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  111640. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  111641. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  111642. * * 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
  111643. * * When updating an instance, remember that only point positions can change, not the number of points
  111644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111645. * @param name defines the name of the mesh
  111646. * @param options defines the options used to create the mesh
  111647. * @param scene defines the hosting scene
  111648. * @returns the dashed line mesh
  111649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111650. */
  111651. static CreateDashedLines(name: string, options: {
  111652. points: Vector3[];
  111653. dashSize?: number;
  111654. gapSize?: number;
  111655. dashNb?: number;
  111656. updatable?: boolean;
  111657. instance?: LinesMesh;
  111658. }, scene?: Nullable<Scene>): LinesMesh;
  111659. }
  111660. }
  111661. declare module BABYLON {
  111662. /**
  111663. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111664. * in order to better appreciate the issue one might have.
  111665. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111666. */
  111667. export class RayHelper {
  111668. /**
  111669. * Defines the ray we are currently tryin to visualize.
  111670. */
  111671. ray: Nullable<Ray>;
  111672. private _renderPoints;
  111673. private _renderLine;
  111674. private _renderFunction;
  111675. private _scene;
  111676. private _updateToMeshFunction;
  111677. private _attachedToMesh;
  111678. private _meshSpaceDirection;
  111679. private _meshSpaceOrigin;
  111680. /**
  111681. * Helper function to create a colored helper in a scene in one line.
  111682. * @param ray Defines the ray we are currently tryin to visualize
  111683. * @param scene Defines the scene the ray is used in
  111684. * @param color Defines the color we want to see the ray in
  111685. * @returns The newly created ray helper.
  111686. */
  111687. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111688. /**
  111689. * Instantiate a new ray helper.
  111690. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111691. * in order to better appreciate the issue one might have.
  111692. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111693. * @param ray Defines the ray we are currently tryin to visualize
  111694. */
  111695. constructor(ray: Ray);
  111696. /**
  111697. * Shows the ray we are willing to debug.
  111698. * @param scene Defines the scene the ray needs to be rendered in
  111699. * @param color Defines the color the ray needs to be rendered in
  111700. */
  111701. show(scene: Scene, color?: Color3): void;
  111702. /**
  111703. * Hides the ray we are debugging.
  111704. */
  111705. hide(): void;
  111706. private _render;
  111707. /**
  111708. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111709. * @param mesh Defines the mesh we want the helper attached to
  111710. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111711. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111712. * @param length Defines the length of the ray
  111713. */
  111714. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111715. /**
  111716. * Detach the ray helper from the mesh it has previously been attached to.
  111717. */
  111718. detachFromMesh(): void;
  111719. private _updateToMesh;
  111720. /**
  111721. * Dispose the helper and release its associated resources.
  111722. */
  111723. dispose(): void;
  111724. }
  111725. }
  111726. declare module BABYLON.Debug {
  111727. /**
  111728. * Class used to render a debug view of a given skeleton
  111729. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  111730. */
  111731. export class SkeletonViewer {
  111732. /** defines the skeleton to render */
  111733. skeleton: Skeleton;
  111734. /** defines the mesh attached to the skeleton */
  111735. mesh: AbstractMesh;
  111736. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111737. autoUpdateBonesMatrices: boolean;
  111738. /** defines the rendering group id to use with the viewer */
  111739. renderingGroupId: number;
  111740. /** Gets or sets the color used to render the skeleton */
  111741. color: Color3;
  111742. private _scene;
  111743. private _debugLines;
  111744. private _debugMesh;
  111745. private _isEnabled;
  111746. private _renderFunction;
  111747. private _utilityLayer;
  111748. /**
  111749. * Returns the mesh used to render the bones
  111750. */
  111751. readonly debugMesh: Nullable<LinesMesh>;
  111752. /**
  111753. * Creates a new SkeletonViewer
  111754. * @param skeleton defines the skeleton to render
  111755. * @param mesh defines the mesh attached to the skeleton
  111756. * @param scene defines the hosting scene
  111757. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  111758. * @param renderingGroupId defines the rendering group id to use with the viewer
  111759. */
  111760. constructor(
  111761. /** defines the skeleton to render */
  111762. skeleton: Skeleton,
  111763. /** defines the mesh attached to the skeleton */
  111764. mesh: AbstractMesh, scene: Scene,
  111765. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111766. autoUpdateBonesMatrices?: boolean,
  111767. /** defines the rendering group id to use with the viewer */
  111768. renderingGroupId?: number);
  111769. /** Gets or sets a boolean indicating if the viewer is enabled */
  111770. isEnabled: boolean;
  111771. private _getBonePosition;
  111772. private _getLinesForBonesWithLength;
  111773. private _getLinesForBonesNoLength;
  111774. /** Update the viewer to sync with current skeleton state */
  111775. update(): void;
  111776. /** Release associated resources */
  111777. dispose(): void;
  111778. }
  111779. }
  111780. declare module BABYLON {
  111781. /**
  111782. * Options to create the null engine
  111783. */
  111784. export class NullEngineOptions {
  111785. /**
  111786. * Render width (Default: 512)
  111787. */
  111788. renderWidth: number;
  111789. /**
  111790. * Render height (Default: 256)
  111791. */
  111792. renderHeight: number;
  111793. /**
  111794. * Texture size (Default: 512)
  111795. */
  111796. textureSize: number;
  111797. /**
  111798. * If delta time between frames should be constant
  111799. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111800. */
  111801. deterministicLockstep: boolean;
  111802. /**
  111803. * Maximum about of steps between frames (Default: 4)
  111804. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111805. */
  111806. lockstepMaxSteps: number;
  111807. }
  111808. /**
  111809. * The null engine class provides support for headless version of babylon.js.
  111810. * This can be used in server side scenario or for testing purposes
  111811. */
  111812. export class NullEngine extends Engine {
  111813. private _options;
  111814. /**
  111815. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  111816. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111817. * @returns true if engine is in deterministic lock step mode
  111818. */
  111819. isDeterministicLockStep(): boolean;
  111820. /**
  111821. * Gets the max steps when engine is running in deterministic lock step
  111822. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111823. * @returns the max steps
  111824. */
  111825. getLockstepMaxSteps(): number;
  111826. /**
  111827. * Gets the current hardware scaling level.
  111828. * By default the hardware scaling level is computed from the window device ratio.
  111829. * 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.
  111830. * @returns a number indicating the current hardware scaling level
  111831. */
  111832. getHardwareScalingLevel(): number;
  111833. constructor(options?: NullEngineOptions);
  111834. /**
  111835. * Creates a vertex buffer
  111836. * @param vertices the data for the vertex buffer
  111837. * @returns the new WebGL static buffer
  111838. */
  111839. createVertexBuffer(vertices: FloatArray): DataBuffer;
  111840. /**
  111841. * Creates a new index buffer
  111842. * @param indices defines the content of the index buffer
  111843. * @param updatable defines if the index buffer must be updatable
  111844. * @returns a new webGL buffer
  111845. */
  111846. createIndexBuffer(indices: IndicesArray): DataBuffer;
  111847. /**
  111848. * Clear the current render buffer or the current render target (if any is set up)
  111849. * @param color defines the color to use
  111850. * @param backBuffer defines if the back buffer must be cleared
  111851. * @param depth defines if the depth buffer must be cleared
  111852. * @param stencil defines if the stencil buffer must be cleared
  111853. */
  111854. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111855. /**
  111856. * Gets the current render width
  111857. * @param useScreen defines if screen size must be used (or the current render target if any)
  111858. * @returns a number defining the current render width
  111859. */
  111860. getRenderWidth(useScreen?: boolean): number;
  111861. /**
  111862. * Gets the current render height
  111863. * @param useScreen defines if screen size must be used (or the current render target if any)
  111864. * @returns a number defining the current render height
  111865. */
  111866. getRenderHeight(useScreen?: boolean): number;
  111867. /**
  111868. * Set the WebGL's viewport
  111869. * @param viewport defines the viewport element to be used
  111870. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111871. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111872. */
  111873. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111874. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  111875. /**
  111876. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111877. * @param pipelineContext defines the pipeline context to use
  111878. * @param uniformsNames defines the list of uniform names
  111879. * @returns an array of webGL uniform locations
  111880. */
  111881. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111882. /**
  111883. * Gets the lsit of active attributes for a given webGL program
  111884. * @param pipelineContext defines the pipeline context to use
  111885. * @param attributesNames defines the list of attribute names to get
  111886. * @returns an array of indices indicating the offset of each attribute
  111887. */
  111888. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111889. /**
  111890. * Binds an effect to the webGL context
  111891. * @param effect defines the effect to bind
  111892. */
  111893. bindSamplers(effect: Effect): void;
  111894. /**
  111895. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111896. * @param effect defines the effect to activate
  111897. */
  111898. enableEffect(effect: Effect): void;
  111899. /**
  111900. * Set various states to the webGL context
  111901. * @param culling defines backface culling state
  111902. * @param zOffset defines the value to apply to zOffset (0 by default)
  111903. * @param force defines if states must be applied even if cache is up to date
  111904. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  111905. */
  111906. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111907. /**
  111908. * Set the value of an uniform to an array of int32
  111909. * @param uniform defines the webGL uniform location where to store the value
  111910. * @param array defines the array of int32 to store
  111911. */
  111912. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111913. /**
  111914. * Set the value of an uniform to an array of int32 (stored as vec2)
  111915. * @param uniform defines the webGL uniform location where to store the value
  111916. * @param array defines the array of int32 to store
  111917. */
  111918. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111919. /**
  111920. * Set the value of an uniform to an array of int32 (stored as vec3)
  111921. * @param uniform defines the webGL uniform location where to store the value
  111922. * @param array defines the array of int32 to store
  111923. */
  111924. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111925. /**
  111926. * Set the value of an uniform to an array of int32 (stored as vec4)
  111927. * @param uniform defines the webGL uniform location where to store the value
  111928. * @param array defines the array of int32 to store
  111929. */
  111930. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111931. /**
  111932. * Set the value of an uniform to an array of float32
  111933. * @param uniform defines the webGL uniform location where to store the value
  111934. * @param array defines the array of float32 to store
  111935. */
  111936. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111937. /**
  111938. * Set the value of an uniform to an array of float32 (stored as vec2)
  111939. * @param uniform defines the webGL uniform location where to store the value
  111940. * @param array defines the array of float32 to store
  111941. */
  111942. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111943. /**
  111944. * Set the value of an uniform to an array of float32 (stored as vec3)
  111945. * @param uniform defines the webGL uniform location where to store the value
  111946. * @param array defines the array of float32 to store
  111947. */
  111948. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111949. /**
  111950. * Set the value of an uniform to an array of float32 (stored as vec4)
  111951. * @param uniform defines the webGL uniform location where to store the value
  111952. * @param array defines the array of float32 to store
  111953. */
  111954. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111955. /**
  111956. * Set the value of an uniform to an array of number
  111957. * @param uniform defines the webGL uniform location where to store the value
  111958. * @param array defines the array of number to store
  111959. */
  111960. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111961. /**
  111962. * Set the value of an uniform to an array of number (stored as vec2)
  111963. * @param uniform defines the webGL uniform location where to store the value
  111964. * @param array defines the array of number to store
  111965. */
  111966. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111967. /**
  111968. * Set the value of an uniform to an array of number (stored as vec3)
  111969. * @param uniform defines the webGL uniform location where to store the value
  111970. * @param array defines the array of number to store
  111971. */
  111972. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111973. /**
  111974. * Set the value of an uniform to an array of number (stored as vec4)
  111975. * @param uniform defines the webGL uniform location where to store the value
  111976. * @param array defines the array of number to store
  111977. */
  111978. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111979. /**
  111980. * Set the value of an uniform to an array of float32 (stored as matrices)
  111981. * @param uniform defines the webGL uniform location where to store the value
  111982. * @param matrices defines the array of float32 to store
  111983. */
  111984. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111985. /**
  111986. * Set the value of an uniform to a matrix (3x3)
  111987. * @param uniform defines the webGL uniform location where to store the value
  111988. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111989. */
  111990. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111991. /**
  111992. * Set the value of an uniform to a matrix (2x2)
  111993. * @param uniform defines the webGL uniform location where to store the value
  111994. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111995. */
  111996. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111997. /**
  111998. * Set the value of an uniform to a number (float)
  111999. * @param uniform defines the webGL uniform location where to store the value
  112000. * @param value defines the float number to store
  112001. */
  112002. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112003. /**
  112004. * Set the value of an uniform to a vec2
  112005. * @param uniform defines the webGL uniform location where to store the value
  112006. * @param x defines the 1st component of the value
  112007. * @param y defines the 2nd component of the value
  112008. */
  112009. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112010. /**
  112011. * Set the value of an uniform to a vec3
  112012. * @param uniform defines the webGL uniform location where to store the value
  112013. * @param x defines the 1st component of the value
  112014. * @param y defines the 2nd component of the value
  112015. * @param z defines the 3rd component of the value
  112016. */
  112017. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112018. /**
  112019. * Set the value of an uniform to a boolean
  112020. * @param uniform defines the webGL uniform location where to store the value
  112021. * @param bool defines the boolean to store
  112022. */
  112023. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112024. /**
  112025. * Set the value of an uniform to a vec4
  112026. * @param uniform defines the webGL uniform location where to store the value
  112027. * @param x defines the 1st component of the value
  112028. * @param y defines the 2nd component of the value
  112029. * @param z defines the 3rd component of the value
  112030. * @param w defines the 4th component of the value
  112031. */
  112032. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112033. /**
  112034. * Sets the current alpha mode
  112035. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112036. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112037. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112038. */
  112039. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112040. /**
  112041. * Bind webGl buffers directly to the webGL context
  112042. * @param vertexBuffers defines the vertex buffer to bind
  112043. * @param indexBuffer defines the index buffer to bind
  112044. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112045. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112046. * @param effect defines the effect associated with the vertex buffer
  112047. */
  112048. bindBuffers(vertexBuffers: {
  112049. [key: string]: VertexBuffer;
  112050. }, indexBuffer: DataBuffer, effect: Effect): void;
  112051. /**
  112052. * Force the entire cache to be cleared
  112053. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112054. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112055. */
  112056. wipeCaches(bruteForce?: boolean): void;
  112057. /**
  112058. * Send a draw order
  112059. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112060. * @param indexStart defines the starting index
  112061. * @param indexCount defines the number of index to draw
  112062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112063. */
  112064. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112065. /**
  112066. * Draw a list of indexed primitives
  112067. * @param fillMode defines the primitive to use
  112068. * @param indexStart defines the starting index
  112069. * @param indexCount defines the number of index to draw
  112070. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112071. */
  112072. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112073. /**
  112074. * Draw a list of unindexed primitives
  112075. * @param fillMode defines the primitive to use
  112076. * @param verticesStart defines the index of first vertex to draw
  112077. * @param verticesCount defines the count of vertices to draw
  112078. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112079. */
  112080. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112081. /** @hidden */
  112082. _createTexture(): WebGLTexture;
  112083. /** @hidden */
  112084. _releaseTexture(texture: InternalTexture): void;
  112085. /**
  112086. * Usually called from Texture.ts.
  112087. * Passed information to create a WebGLTexture
  112088. * @param urlArg defines a value which contains one of the following:
  112089. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112090. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112091. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112092. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112093. * @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)
  112094. * @param scene needed for loading to the correct scene
  112095. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112096. * @param onLoad optional callback to be called upon successful completion
  112097. * @param onError optional callback to be called upon failure
  112098. * @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
  112099. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112100. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112101. * @param forcedExtension defines the extension to use to pick the right loader
  112102. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112103. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112104. */
  112105. 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;
  112106. /**
  112107. * Creates a new render target texture
  112108. * @param size defines the size of the texture
  112109. * @param options defines the options used to create the texture
  112110. * @returns a new render target texture stored in an InternalTexture
  112111. */
  112112. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112113. /**
  112114. * Update the sampling mode of a given texture
  112115. * @param samplingMode defines the required sampling mode
  112116. * @param texture defines the texture to update
  112117. */
  112118. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112119. /**
  112120. * Binds the frame buffer to the specified texture.
  112121. * @param texture The texture to render to or null for the default canvas
  112122. * @param faceIndex The face of the texture to render to in case of cube texture
  112123. * @param requiredWidth The width of the target to render to
  112124. * @param requiredHeight The height of the target to render to
  112125. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112126. * @param depthStencilTexture The depth stencil texture to use to render
  112127. * @param lodLevel defines le lod level to bind to the frame buffer
  112128. */
  112129. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112130. /**
  112131. * Unbind the current render target texture from the webGL context
  112132. * @param texture defines the render target texture to unbind
  112133. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112134. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112135. */
  112136. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112137. /**
  112138. * Creates a dynamic vertex buffer
  112139. * @param vertices the data for the dynamic vertex buffer
  112140. * @returns the new WebGL dynamic buffer
  112141. */
  112142. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112143. /**
  112144. * Update the content of a dynamic texture
  112145. * @param texture defines the texture to update
  112146. * @param canvas defines the canvas containing the source
  112147. * @param invertY defines if data must be stored with Y axis inverted
  112148. * @param premulAlpha defines if alpha is stored as premultiplied
  112149. * @param format defines the format of the data
  112150. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112151. */
  112152. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112153. /**
  112154. * Gets a boolean indicating if all created effects are ready
  112155. * @returns true if all effects are ready
  112156. */
  112157. areAllEffectsReady(): boolean;
  112158. /**
  112159. * @hidden
  112160. * Get the current error code of the webGL context
  112161. * @returns the error code
  112162. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112163. */
  112164. getError(): number;
  112165. /** @hidden */
  112166. _getUnpackAlignement(): number;
  112167. /** @hidden */
  112168. _unpackFlipY(value: boolean): void;
  112169. /**
  112170. * Update a dynamic index buffer
  112171. * @param indexBuffer defines the target index buffer
  112172. * @param indices defines the data to update
  112173. * @param offset defines the offset in the target index buffer where update should start
  112174. */
  112175. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112176. /**
  112177. * Updates a dynamic vertex buffer.
  112178. * @param vertexBuffer the vertex buffer to update
  112179. * @param vertices the data used to update the vertex buffer
  112180. * @param byteOffset the byte offset of the data (optional)
  112181. * @param byteLength the byte length of the data (optional)
  112182. */
  112183. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112184. /** @hidden */
  112185. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112186. /** @hidden */
  112187. _bindTexture(channel: number, texture: InternalTexture): void;
  112188. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112189. /**
  112190. * 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
  112191. */
  112192. releaseEffects(): void;
  112193. displayLoadingUI(): void;
  112194. hideLoadingUI(): void;
  112195. /** @hidden */
  112196. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112197. /** @hidden */
  112198. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112199. /** @hidden */
  112200. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112201. /** @hidden */
  112202. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112203. }
  112204. }
  112205. declare module BABYLON {
  112206. /** @hidden */
  112207. export class _OcclusionDataStorage {
  112208. /** @hidden */
  112209. occlusionInternalRetryCounter: number;
  112210. /** @hidden */
  112211. isOcclusionQueryInProgress: boolean;
  112212. /** @hidden */
  112213. isOccluded: boolean;
  112214. /** @hidden */
  112215. occlusionRetryCount: number;
  112216. /** @hidden */
  112217. occlusionType: number;
  112218. /** @hidden */
  112219. occlusionQueryAlgorithmType: number;
  112220. }
  112221. interface Engine {
  112222. /**
  112223. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112224. * @return the new query
  112225. */
  112226. createQuery(): WebGLQuery;
  112227. /**
  112228. * Delete and release a webGL query
  112229. * @param query defines the query to delete
  112230. * @return the current engine
  112231. */
  112232. deleteQuery(query: WebGLQuery): Engine;
  112233. /**
  112234. * Check if a given query has resolved and got its value
  112235. * @param query defines the query to check
  112236. * @returns true if the query got its value
  112237. */
  112238. isQueryResultAvailable(query: WebGLQuery): boolean;
  112239. /**
  112240. * Gets the value of a given query
  112241. * @param query defines the query to check
  112242. * @returns the value of the query
  112243. */
  112244. getQueryResult(query: WebGLQuery): number;
  112245. /**
  112246. * Initiates an occlusion query
  112247. * @param algorithmType defines the algorithm to use
  112248. * @param query defines the query to use
  112249. * @returns the current engine
  112250. * @see http://doc.babylonjs.com/features/occlusionquery
  112251. */
  112252. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112253. /**
  112254. * Ends an occlusion query
  112255. * @see http://doc.babylonjs.com/features/occlusionquery
  112256. * @param algorithmType defines the algorithm to use
  112257. * @returns the current engine
  112258. */
  112259. endOcclusionQuery(algorithmType: number): Engine;
  112260. /**
  112261. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112262. * Please note that only one query can be issued at a time
  112263. * @returns a time token used to track the time span
  112264. */
  112265. startTimeQuery(): Nullable<_TimeToken>;
  112266. /**
  112267. * Ends a time query
  112268. * @param token defines the token used to measure the time span
  112269. * @returns the time spent (in ns)
  112270. */
  112271. endTimeQuery(token: _TimeToken): int;
  112272. /** @hidden */
  112273. _currentNonTimestampToken: Nullable<_TimeToken>;
  112274. /** @hidden */
  112275. _createTimeQuery(): WebGLQuery;
  112276. /** @hidden */
  112277. _deleteTimeQuery(query: WebGLQuery): void;
  112278. /** @hidden */
  112279. _getGlAlgorithmType(algorithmType: number): number;
  112280. /** @hidden */
  112281. _getTimeQueryResult(query: WebGLQuery): any;
  112282. /** @hidden */
  112283. _getTimeQueryAvailability(query: WebGLQuery): any;
  112284. }
  112285. interface AbstractMesh {
  112286. /**
  112287. * Backing filed
  112288. * @hidden
  112289. */
  112290. __occlusionDataStorage: _OcclusionDataStorage;
  112291. /**
  112292. * Access property
  112293. * @hidden
  112294. */
  112295. _occlusionDataStorage: _OcclusionDataStorage;
  112296. /**
  112297. * 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.
  112298. * The default value is -1 which means don't break the query and wait till the result
  112299. * @see http://doc.babylonjs.com/features/occlusionquery
  112300. */
  112301. occlusionRetryCount: number;
  112302. /**
  112303. * 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:
  112304. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  112305. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  112306. * * 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.
  112307. * @see http://doc.babylonjs.com/features/occlusionquery
  112308. */
  112309. occlusionType: number;
  112310. /**
  112311. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  112312. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  112313. * * 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.
  112314. * @see http://doc.babylonjs.com/features/occlusionquery
  112315. */
  112316. occlusionQueryAlgorithmType: number;
  112317. /**
  112318. * 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
  112319. * @see http://doc.babylonjs.com/features/occlusionquery
  112320. */
  112321. isOccluded: boolean;
  112322. /**
  112323. * Flag to check the progress status of the query
  112324. * @see http://doc.babylonjs.com/features/occlusionquery
  112325. */
  112326. isOcclusionQueryInProgress: boolean;
  112327. }
  112328. }
  112329. declare module BABYLON {
  112330. /** @hidden */
  112331. export var _forceTransformFeedbackToBundle: boolean;
  112332. interface Engine {
  112333. /**
  112334. * Creates a webGL transform feedback object
  112335. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112336. * @returns the webGL transform feedback object
  112337. */
  112338. createTransformFeedback(): WebGLTransformFeedback;
  112339. /**
  112340. * Delete a webGL transform feedback object
  112341. * @param value defines the webGL transform feedback object to delete
  112342. */
  112343. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112344. /**
  112345. * Bind a webGL transform feedback object to the webgl context
  112346. * @param value defines the webGL transform feedback object to bind
  112347. */
  112348. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112349. /**
  112350. * Begins a transform feedback operation
  112351. * @param usePoints defines if points or triangles must be used
  112352. */
  112353. beginTransformFeedback(usePoints: boolean): void;
  112354. /**
  112355. * Ends a transform feedback operation
  112356. */
  112357. endTransformFeedback(): void;
  112358. /**
  112359. * Specify the varyings to use with transform feedback
  112360. * @param program defines the associated webGL program
  112361. * @param value defines the list of strings representing the varying names
  112362. */
  112363. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112364. /**
  112365. * Bind a webGL buffer for a transform feedback operation
  112366. * @param value defines the webGL buffer to bind
  112367. */
  112368. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112369. }
  112370. }
  112371. declare module BABYLON {
  112372. /**
  112373. * Creation options of the multi render target texture.
  112374. */
  112375. export interface IMultiRenderTargetOptions {
  112376. /**
  112377. * Define if the texture needs to create mip maps after render.
  112378. */
  112379. generateMipMaps?: boolean;
  112380. /**
  112381. * Define the types of all the draw buffers we want to create
  112382. */
  112383. types?: number[];
  112384. /**
  112385. * Define the sampling modes of all the draw buffers we want to create
  112386. */
  112387. samplingModes?: number[];
  112388. /**
  112389. * Define if a depth buffer is required
  112390. */
  112391. generateDepthBuffer?: boolean;
  112392. /**
  112393. * Define if a stencil buffer is required
  112394. */
  112395. generateStencilBuffer?: boolean;
  112396. /**
  112397. * Define if a depth texture is required instead of a depth buffer
  112398. */
  112399. generateDepthTexture?: boolean;
  112400. /**
  112401. * Define the number of desired draw buffers
  112402. */
  112403. textureCount?: number;
  112404. /**
  112405. * Define if aspect ratio should be adapted to the texture or stay the scene one
  112406. */
  112407. doNotChangeAspectRatio?: boolean;
  112408. /**
  112409. * Define the default type of the buffers we are creating
  112410. */
  112411. defaultType?: number;
  112412. }
  112413. /**
  112414. * A multi render target, like a render target provides the ability to render to a texture.
  112415. * Unlike the render target, it can render to several draw buffers in one draw.
  112416. * This is specially interesting in deferred rendering or for any effects requiring more than
  112417. * just one color from a single pass.
  112418. */
  112419. export class MultiRenderTarget extends RenderTargetTexture {
  112420. private _internalTextures;
  112421. private _textures;
  112422. private _multiRenderTargetOptions;
  112423. /**
  112424. * Get if draw buffers are currently supported by the used hardware and browser.
  112425. */
  112426. readonly isSupported: boolean;
  112427. /**
  112428. * Get the list of textures generated by the multi render target.
  112429. */
  112430. readonly textures: Texture[];
  112431. /**
  112432. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  112433. */
  112434. readonly depthTexture: Texture;
  112435. /**
  112436. * Set the wrapping mode on U of all the textures we are rendering to.
  112437. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112438. */
  112439. wrapU: number;
  112440. /**
  112441. * Set the wrapping mode on V of all the textures we are rendering to.
  112442. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112443. */
  112444. wrapV: number;
  112445. /**
  112446. * Instantiate a new multi render target texture.
  112447. * A multi render target, like a render target provides the ability to render to a texture.
  112448. * Unlike the render target, it can render to several draw buffers in one draw.
  112449. * This is specially interesting in deferred rendering or for any effects requiring more than
  112450. * just one color from a single pass.
  112451. * @param name Define the name of the texture
  112452. * @param size Define the size of the buffers to render to
  112453. * @param count Define the number of target we are rendering into
  112454. * @param scene Define the scene the texture belongs to
  112455. * @param options Define the options used to create the multi render target
  112456. */
  112457. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  112458. /** @hidden */
  112459. _rebuild(): void;
  112460. private _createInternalTextures;
  112461. private _createTextures;
  112462. /**
  112463. * Define the number of samples used if MSAA is enabled.
  112464. */
  112465. samples: number;
  112466. /**
  112467. * Resize all the textures in the multi render target.
  112468. * Be carrefull as it will recreate all the data in the new texture.
  112469. * @param size Define the new size
  112470. */
  112471. resize(size: any): void;
  112472. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  112473. /**
  112474. * Dispose the render targets and their associated resources
  112475. */
  112476. dispose(): void;
  112477. /**
  112478. * Release all the underlying texture used as draw buffers.
  112479. */
  112480. releaseInternalTextures(): void;
  112481. }
  112482. }
  112483. declare module BABYLON {
  112484. interface ThinEngine {
  112485. /**
  112486. * Unbind a list of render target textures from the webGL context
  112487. * This is used only when drawBuffer extension or webGL2 are active
  112488. * @param textures defines the render target textures to unbind
  112489. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112490. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112491. */
  112492. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  112493. /**
  112494. * Create a multi render target texture
  112495. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  112496. * @param size defines the size of the texture
  112497. * @param options defines the creation options
  112498. * @returns the cube texture as an InternalTexture
  112499. */
  112500. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  112501. /**
  112502. * Update the sample count for a given multiple render target texture
  112503. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  112504. * @param textures defines the textures to update
  112505. * @param samples defines the sample count to set
  112506. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  112507. */
  112508. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  112509. }
  112510. }
  112511. declare module BABYLON {
  112512. /**
  112513. * Class used to define an additional view for the engine
  112514. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112515. */
  112516. export class EngineView {
  112517. /** Defines the canvas where to render the view */
  112518. target: HTMLCanvasElement;
  112519. /** Defines an optional camera used to render the view (will use active camera else) */
  112520. camera?: Camera;
  112521. }
  112522. interface Engine {
  112523. /**
  112524. * Gets or sets the HTML element to use for attaching events
  112525. */
  112526. inputElement: Nullable<HTMLElement>;
  112527. /**
  112528. * Gets the current engine view
  112529. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112530. */
  112531. activeView: Nullable<EngineView>;
  112532. /** Gets or sets the list of views */
  112533. views: EngineView[];
  112534. /**
  112535. * Register a new child canvas
  112536. * @param canvas defines the canvas to register
  112537. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  112538. * @returns the associated view
  112539. */
  112540. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  112541. /**
  112542. * Remove a registered child canvas
  112543. * @param canvas defines the canvas to remove
  112544. * @returns the current engine
  112545. */
  112546. unRegisterView(canvas: HTMLCanvasElement): Engine;
  112547. }
  112548. }
  112549. declare module BABYLON {
  112550. /**
  112551. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  112552. */
  112553. export interface CubeMapInfo {
  112554. /**
  112555. * The pixel array for the front face.
  112556. * This is stored in format, left to right, up to down format.
  112557. */
  112558. front: Nullable<ArrayBufferView>;
  112559. /**
  112560. * The pixel array for the back face.
  112561. * This is stored in format, left to right, up to down format.
  112562. */
  112563. back: Nullable<ArrayBufferView>;
  112564. /**
  112565. * The pixel array for the left face.
  112566. * This is stored in format, left to right, up to down format.
  112567. */
  112568. left: Nullable<ArrayBufferView>;
  112569. /**
  112570. * The pixel array for the right face.
  112571. * This is stored in format, left to right, up to down format.
  112572. */
  112573. right: Nullable<ArrayBufferView>;
  112574. /**
  112575. * The pixel array for the up face.
  112576. * This is stored in format, left to right, up to down format.
  112577. */
  112578. up: Nullable<ArrayBufferView>;
  112579. /**
  112580. * The pixel array for the down face.
  112581. * This is stored in format, left to right, up to down format.
  112582. */
  112583. down: Nullable<ArrayBufferView>;
  112584. /**
  112585. * The size of the cubemap stored.
  112586. *
  112587. * Each faces will be size * size pixels.
  112588. */
  112589. size: number;
  112590. /**
  112591. * The format of the texture.
  112592. *
  112593. * RGBA, RGB.
  112594. */
  112595. format: number;
  112596. /**
  112597. * The type of the texture data.
  112598. *
  112599. * UNSIGNED_INT, FLOAT.
  112600. */
  112601. type: number;
  112602. /**
  112603. * Specifies whether the texture is in gamma space.
  112604. */
  112605. gammaSpace: boolean;
  112606. }
  112607. /**
  112608. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  112609. */
  112610. export class PanoramaToCubeMapTools {
  112611. private static FACE_FRONT;
  112612. private static FACE_BACK;
  112613. private static FACE_RIGHT;
  112614. private static FACE_LEFT;
  112615. private static FACE_DOWN;
  112616. private static FACE_UP;
  112617. /**
  112618. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  112619. *
  112620. * @param float32Array The source data.
  112621. * @param inputWidth The width of the input panorama.
  112622. * @param inputHeight The height of the input panorama.
  112623. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  112624. * @return The cubemap data
  112625. */
  112626. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  112627. private static CreateCubemapTexture;
  112628. private static CalcProjectionSpherical;
  112629. }
  112630. }
  112631. declare module BABYLON {
  112632. /**
  112633. * Helper class dealing with the extraction of spherical polynomial dataArray
  112634. * from a cube map.
  112635. */
  112636. export class CubeMapToSphericalPolynomialTools {
  112637. private static FileFaces;
  112638. /**
  112639. * Converts a texture to the according Spherical Polynomial data.
  112640. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112641. *
  112642. * @param texture The texture to extract the information from.
  112643. * @return The Spherical Polynomial data.
  112644. */
  112645. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  112646. /**
  112647. * Converts a cubemap to the according Spherical Polynomial data.
  112648. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112649. *
  112650. * @param cubeInfo The Cube map to extract the information from.
  112651. * @return The Spherical Polynomial data.
  112652. */
  112653. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  112654. }
  112655. }
  112656. declare module BABYLON {
  112657. interface BaseTexture {
  112658. /**
  112659. * Get the polynomial representation of the texture data.
  112660. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  112661. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  112662. */
  112663. sphericalPolynomial: Nullable<SphericalPolynomial>;
  112664. }
  112665. }
  112666. declare module BABYLON {
  112667. /** @hidden */
  112668. export var rgbdEncodePixelShader: {
  112669. name: string;
  112670. shader: string;
  112671. };
  112672. }
  112673. declare module BABYLON {
  112674. /** @hidden */
  112675. export var rgbdDecodePixelShader: {
  112676. name: string;
  112677. shader: string;
  112678. };
  112679. }
  112680. declare module BABYLON {
  112681. /**
  112682. * Raw texture data and descriptor sufficient for WebGL texture upload
  112683. */
  112684. export interface EnvironmentTextureInfo {
  112685. /**
  112686. * Version of the environment map
  112687. */
  112688. version: number;
  112689. /**
  112690. * Width of image
  112691. */
  112692. width: number;
  112693. /**
  112694. * Irradiance information stored in the file.
  112695. */
  112696. irradiance: any;
  112697. /**
  112698. * Specular information stored in the file.
  112699. */
  112700. specular: any;
  112701. }
  112702. /**
  112703. * Defines One Image in the file. It requires only the position in the file
  112704. * as well as the length.
  112705. */
  112706. interface BufferImageData {
  112707. /**
  112708. * Length of the image data.
  112709. */
  112710. length: number;
  112711. /**
  112712. * Position of the data from the null terminator delimiting the end of the JSON.
  112713. */
  112714. position: number;
  112715. }
  112716. /**
  112717. * Defines the specular data enclosed in the file.
  112718. * This corresponds to the version 1 of the data.
  112719. */
  112720. export interface EnvironmentTextureSpecularInfoV1 {
  112721. /**
  112722. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  112723. */
  112724. specularDataPosition?: number;
  112725. /**
  112726. * This contains all the images data needed to reconstruct the cubemap.
  112727. */
  112728. mipmaps: Array<BufferImageData>;
  112729. /**
  112730. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  112731. */
  112732. lodGenerationScale: number;
  112733. }
  112734. /**
  112735. * Sets of helpers addressing the serialization and deserialization of environment texture
  112736. * stored in a BabylonJS env file.
  112737. * Those files are usually stored as .env files.
  112738. */
  112739. export class EnvironmentTextureTools {
  112740. /**
  112741. * Magic number identifying the env file.
  112742. */
  112743. private static _MagicBytes;
  112744. /**
  112745. * Gets the environment info from an env file.
  112746. * @param data The array buffer containing the .env bytes.
  112747. * @returns the environment file info (the json header) if successfully parsed.
  112748. */
  112749. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112750. /**
  112751. * Creates an environment texture from a loaded cube texture.
  112752. * @param texture defines the cube texture to convert in env file
  112753. * @return a promise containing the environment data if succesfull.
  112754. */
  112755. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112756. /**
  112757. * Creates a JSON representation of the spherical data.
  112758. * @param texture defines the texture containing the polynomials
  112759. * @return the JSON representation of the spherical info
  112760. */
  112761. private static _CreateEnvTextureIrradiance;
  112762. /**
  112763. * Creates the ArrayBufferViews used for initializing environment texture image data.
  112764. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  112765. * @param info parameters that determine what views will be created for accessing the underlying buffer
  112766. * @return the views described by info providing access to the underlying buffer
  112767. */
  112768. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  112769. /**
  112770. * Uploads the texture info contained in the env file to the GPU.
  112771. * @param texture defines the internal texture to upload to
  112772. * @param arrayBuffer defines the buffer cotaining the data to load
  112773. * @param info defines the texture info retrieved through the GetEnvInfo method
  112774. * @returns a promise
  112775. */
  112776. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112777. private static _OnImageReadyAsync;
  112778. /**
  112779. * Uploads the levels of image data to the GPU.
  112780. * @param texture defines the internal texture to upload to
  112781. * @param imageData defines the array buffer views of image data [mipmap][face]
  112782. * @returns a promise
  112783. */
  112784. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112785. /**
  112786. * Uploads spherical polynomials information to the texture.
  112787. * @param texture defines the texture we are trying to upload the information to
  112788. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112789. */
  112790. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112791. /** @hidden */
  112792. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112793. }
  112794. }
  112795. declare module BABYLON {
  112796. /**
  112797. * Contains position and normal vectors for a vertex
  112798. */
  112799. export class PositionNormalVertex {
  112800. /** the position of the vertex (defaut: 0,0,0) */
  112801. position: Vector3;
  112802. /** the normal of the vertex (defaut: 0,1,0) */
  112803. normal: Vector3;
  112804. /**
  112805. * Creates a PositionNormalVertex
  112806. * @param position the position of the vertex (defaut: 0,0,0)
  112807. * @param normal the normal of the vertex (defaut: 0,1,0)
  112808. */
  112809. constructor(
  112810. /** the position of the vertex (defaut: 0,0,0) */
  112811. position?: Vector3,
  112812. /** the normal of the vertex (defaut: 0,1,0) */
  112813. normal?: Vector3);
  112814. /**
  112815. * Clones the PositionNormalVertex
  112816. * @returns the cloned PositionNormalVertex
  112817. */
  112818. clone(): PositionNormalVertex;
  112819. }
  112820. /**
  112821. * Contains position, normal and uv vectors for a vertex
  112822. */
  112823. export class PositionNormalTextureVertex {
  112824. /** the position of the vertex (defaut: 0,0,0) */
  112825. position: Vector3;
  112826. /** the normal of the vertex (defaut: 0,1,0) */
  112827. normal: Vector3;
  112828. /** the uv of the vertex (default: 0,0) */
  112829. uv: Vector2;
  112830. /**
  112831. * Creates a PositionNormalTextureVertex
  112832. * @param position the position of the vertex (defaut: 0,0,0)
  112833. * @param normal the normal of the vertex (defaut: 0,1,0)
  112834. * @param uv the uv of the vertex (default: 0,0)
  112835. */
  112836. constructor(
  112837. /** the position of the vertex (defaut: 0,0,0) */
  112838. position?: Vector3,
  112839. /** the normal of the vertex (defaut: 0,1,0) */
  112840. normal?: Vector3,
  112841. /** the uv of the vertex (default: 0,0) */
  112842. uv?: Vector2);
  112843. /**
  112844. * Clones the PositionNormalTextureVertex
  112845. * @returns the cloned PositionNormalTextureVertex
  112846. */
  112847. clone(): PositionNormalTextureVertex;
  112848. }
  112849. }
  112850. declare module BABYLON {
  112851. /** @hidden */
  112852. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  112853. private _genericAttributeLocation;
  112854. private _varyingLocationCount;
  112855. private _varyingLocationMap;
  112856. private _replacements;
  112857. private _textureCount;
  112858. private _uniforms;
  112859. lineProcessor(line: string): string;
  112860. attributeProcessor(attribute: string): string;
  112861. varyingProcessor(varying: string, isFragment: boolean): string;
  112862. uniformProcessor(uniform: string): string;
  112863. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  112864. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112865. }
  112866. }
  112867. declare module BABYLON {
  112868. /**
  112869. * Container for accessors for natively-stored mesh data buffers.
  112870. */
  112871. class NativeDataBuffer extends DataBuffer {
  112872. /**
  112873. * Accessor value used to identify/retrieve a natively-stored index buffer.
  112874. */
  112875. nativeIndexBuffer?: any;
  112876. /**
  112877. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  112878. */
  112879. nativeVertexBuffer?: any;
  112880. }
  112881. /** @hidden */
  112882. class NativeTexture extends InternalTexture {
  112883. getInternalTexture(): InternalTexture;
  112884. getViewCount(): number;
  112885. }
  112886. /** @hidden */
  112887. export class NativeEngine extends Engine {
  112888. private readonly _native;
  112889. getHardwareScalingLevel(): number;
  112890. constructor();
  112891. /**
  112892. * Can be used to override the current requestAnimationFrame requester.
  112893. * @hidden
  112894. */
  112895. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112896. /**
  112897. * Override default engine behavior.
  112898. * @param color
  112899. * @param backBuffer
  112900. * @param depth
  112901. * @param stencil
  112902. */
  112903. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112904. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112905. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  112906. createVertexBuffer(data: DataArray): NativeDataBuffer;
  112907. recordVertexArrayObject(vertexBuffers: {
  112908. [key: string]: VertexBuffer;
  112909. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112910. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112911. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112912. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112913. /**
  112914. * Draw a list of indexed primitives
  112915. * @param fillMode defines the primitive to use
  112916. * @param indexStart defines the starting index
  112917. * @param indexCount defines the number of index to draw
  112918. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112919. */
  112920. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112921. /**
  112922. * Draw a list of unindexed primitives
  112923. * @param fillMode defines the primitive to use
  112924. * @param verticesStart defines the index of first vertex to draw
  112925. * @param verticesCount defines the count of vertices to draw
  112926. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112927. */
  112928. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112929. createPipelineContext(): IPipelineContext;
  112930. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112931. /** @hidden */
  112932. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112933. /** @hidden */
  112934. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112935. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112936. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112937. protected _setProgram(program: WebGLProgram): void;
  112938. _releaseEffect(effect: Effect): void;
  112939. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112940. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  112941. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  112942. bindSamplers(effect: Effect): void;
  112943. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  112944. getRenderWidth(useScreen?: boolean): number;
  112945. getRenderHeight(useScreen?: boolean): number;
  112946. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  112947. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112948. /**
  112949. * Set the z offset to apply to current rendering
  112950. * @param value defines the offset to apply
  112951. */
  112952. setZOffset(value: number): void;
  112953. /**
  112954. * Gets the current value of the zOffset
  112955. * @returns the current zOffset state
  112956. */
  112957. getZOffset(): number;
  112958. /**
  112959. * Enable or disable depth buffering
  112960. * @param enable defines the state to set
  112961. */
  112962. setDepthBuffer(enable: boolean): void;
  112963. /**
  112964. * Gets a boolean indicating if depth writing is enabled
  112965. * @returns the current depth writing state
  112966. */
  112967. getDepthWrite(): boolean;
  112968. /**
  112969. * Enable or disable depth writing
  112970. * @param enable defines the state to set
  112971. */
  112972. setDepthWrite(enable: boolean): void;
  112973. /**
  112974. * Enable or disable color writing
  112975. * @param enable defines the state to set
  112976. */
  112977. setColorWrite(enable: boolean): void;
  112978. /**
  112979. * Gets a boolean indicating if color writing is enabled
  112980. * @returns the current color writing state
  112981. */
  112982. getColorWrite(): boolean;
  112983. /**
  112984. * Sets alpha constants used by some alpha blending modes
  112985. * @param r defines the red component
  112986. * @param g defines the green component
  112987. * @param b defines the blue component
  112988. * @param a defines the alpha component
  112989. */
  112990. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112991. /**
  112992. * Sets the current alpha mode
  112993. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  112994. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112995. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112996. */
  112997. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112998. /**
  112999. * Gets the current alpha mode
  113000. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113001. * @returns the current alpha mode
  113002. */
  113003. getAlphaMode(): number;
  113004. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113005. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113006. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113007. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113008. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113009. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113010. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113011. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113012. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113013. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113014. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113015. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113016. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113017. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113018. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113019. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113020. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113021. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113022. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113023. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113024. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113025. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113026. wipeCaches(bruteForce?: boolean): void;
  113027. _createTexture(): WebGLTexture;
  113028. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113029. /**
  113030. * Usually called from BABYLON.Texture.ts.
  113031. * Passed information to create a WebGLTexture
  113032. * @param urlArg defines a value which contains one of the following:
  113033. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113034. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113035. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113036. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113037. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113038. * @param scene needed for loading to the correct scene
  113039. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113040. * @param onLoad optional callback to be called upon successful completion
  113041. * @param onError optional callback to be called upon failure
  113042. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113043. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113044. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113045. * @param forcedExtension defines the extension to use to pick the right loader
  113046. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113047. */
  113048. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  113049. /**
  113050. * Creates a cube texture
  113051. * @param rootUrl defines the url where the files to load is located
  113052. * @param scene defines the current scene
  113053. * @param files defines the list of files to load (1 per face)
  113054. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113055. * @param onLoad defines an optional callback raised when the texture is loaded
  113056. * @param onError defines an optional callback raised if there is an issue to load the texture
  113057. * @param format defines the format of the data
  113058. * @param forcedExtension defines the extension to use to pick the right loader
  113059. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113060. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113061. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113062. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113063. * @returns the cube texture as an InternalTexture
  113064. */
  113065. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  113066. private _getSamplingFilter;
  113067. private static _GetNativeTextureFormat;
  113068. createRenderTargetTexture(size: number | {
  113069. width: number;
  113070. height: number;
  113071. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113072. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113073. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113074. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113075. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113076. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113077. /**
  113078. * Updates a dynamic vertex buffer.
  113079. * @param vertexBuffer the vertex buffer to update
  113080. * @param data the data used to update the vertex buffer
  113081. * @param byteOffset the byte offset of the data (optional)
  113082. * @param byteLength the byte length of the data (optional)
  113083. */
  113084. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113085. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113086. private _updateAnisotropicLevel;
  113087. private _getAddressMode;
  113088. /** @hidden */
  113089. _bindTexture(channel: number, texture: InternalTexture): void;
  113090. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113091. releaseEffects(): void;
  113092. /** @hidden */
  113093. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113094. /** @hidden */
  113095. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113096. /** @hidden */
  113097. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113098. /** @hidden */
  113099. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113100. }
  113101. }
  113102. declare module BABYLON {
  113103. /**
  113104. * Gather the list of clipboard event types as constants.
  113105. */
  113106. export class ClipboardEventTypes {
  113107. /**
  113108. * The clipboard event is fired when a copy command is active (pressed).
  113109. */
  113110. static readonly COPY: number;
  113111. /**
  113112. * The clipboard event is fired when a cut command is active (pressed).
  113113. */
  113114. static readonly CUT: number;
  113115. /**
  113116. * The clipboard event is fired when a paste command is active (pressed).
  113117. */
  113118. static readonly PASTE: number;
  113119. }
  113120. /**
  113121. * This class is used to store clipboard related info for the onClipboardObservable event.
  113122. */
  113123. export class ClipboardInfo {
  113124. /**
  113125. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113126. */
  113127. type: number;
  113128. /**
  113129. * Defines the related dom event
  113130. */
  113131. event: ClipboardEvent;
  113132. /**
  113133. *Creates an instance of ClipboardInfo.
  113134. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113135. * @param event Defines the related dom event
  113136. */
  113137. constructor(
  113138. /**
  113139. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113140. */
  113141. type: number,
  113142. /**
  113143. * Defines the related dom event
  113144. */
  113145. event: ClipboardEvent);
  113146. /**
  113147. * Get the clipboard event's type from the keycode.
  113148. * @param keyCode Defines the keyCode for the current keyboard event.
  113149. * @return {number}
  113150. */
  113151. static GetTypeFromCharacter(keyCode: number): number;
  113152. }
  113153. }
  113154. declare module BABYLON {
  113155. /**
  113156. * Google Daydream controller
  113157. */
  113158. export class DaydreamController extends WebVRController {
  113159. /**
  113160. * Base Url for the controller model.
  113161. */
  113162. static MODEL_BASE_URL: string;
  113163. /**
  113164. * File name for the controller model.
  113165. */
  113166. static MODEL_FILENAME: string;
  113167. /**
  113168. * Gamepad Id prefix used to identify Daydream Controller.
  113169. */
  113170. static readonly GAMEPAD_ID_PREFIX: string;
  113171. /**
  113172. * Creates a new DaydreamController from a gamepad
  113173. * @param vrGamepad the gamepad that the controller should be created from
  113174. */
  113175. constructor(vrGamepad: any);
  113176. /**
  113177. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113178. * @param scene scene in which to add meshes
  113179. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113180. */
  113181. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113182. /**
  113183. * Called once for each button that changed state since the last frame
  113184. * @param buttonIdx Which button index changed
  113185. * @param state New state of the button
  113186. * @param changes Which properties on the state changed since last frame
  113187. */
  113188. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113189. }
  113190. }
  113191. declare module BABYLON {
  113192. /**
  113193. * Gear VR Controller
  113194. */
  113195. export class GearVRController extends WebVRController {
  113196. /**
  113197. * Base Url for the controller model.
  113198. */
  113199. static MODEL_BASE_URL: string;
  113200. /**
  113201. * File name for the controller model.
  113202. */
  113203. static MODEL_FILENAME: string;
  113204. /**
  113205. * Gamepad Id prefix used to identify this controller.
  113206. */
  113207. static readonly GAMEPAD_ID_PREFIX: string;
  113208. private readonly _buttonIndexToObservableNameMap;
  113209. /**
  113210. * Creates a new GearVRController from a gamepad
  113211. * @param vrGamepad the gamepad that the controller should be created from
  113212. */
  113213. constructor(vrGamepad: any);
  113214. /**
  113215. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113216. * @param scene scene in which to add meshes
  113217. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113218. */
  113219. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113220. /**
  113221. * Called once for each button that changed state since the last frame
  113222. * @param buttonIdx Which button index changed
  113223. * @param state New state of the button
  113224. * @param changes Which properties on the state changed since last frame
  113225. */
  113226. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113227. }
  113228. }
  113229. declare module BABYLON {
  113230. /**
  113231. * Class containing static functions to help procedurally build meshes
  113232. */
  113233. export class PolyhedronBuilder {
  113234. /**
  113235. * Creates a polyhedron mesh
  113236. * * 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
  113237. * * The parameter `size` (positive float, default 1) sets the polygon size
  113238. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113239. * * 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`
  113240. * * 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
  113241. * * 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)`)
  113242. * * 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
  113243. * * 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
  113244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113247. * @param name defines the name of the mesh
  113248. * @param options defines the options used to create the mesh
  113249. * @param scene defines the hosting scene
  113250. * @returns the polyhedron mesh
  113251. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113252. */
  113253. static CreatePolyhedron(name: string, options: {
  113254. type?: number;
  113255. size?: number;
  113256. sizeX?: number;
  113257. sizeY?: number;
  113258. sizeZ?: number;
  113259. custom?: any;
  113260. faceUV?: Vector4[];
  113261. faceColors?: Color4[];
  113262. flat?: boolean;
  113263. updatable?: boolean;
  113264. sideOrientation?: number;
  113265. frontUVs?: Vector4;
  113266. backUVs?: Vector4;
  113267. }, scene?: Nullable<Scene>): Mesh;
  113268. }
  113269. }
  113270. declare module BABYLON {
  113271. /**
  113272. * Gizmo that enables scaling a mesh along 3 axis
  113273. */
  113274. export class ScaleGizmo extends Gizmo {
  113275. /**
  113276. * Internal gizmo used for interactions on the x axis
  113277. */
  113278. xGizmo: AxisScaleGizmo;
  113279. /**
  113280. * Internal gizmo used for interactions on the y axis
  113281. */
  113282. yGizmo: AxisScaleGizmo;
  113283. /**
  113284. * Internal gizmo used for interactions on the z axis
  113285. */
  113286. zGizmo: AxisScaleGizmo;
  113287. /**
  113288. * Internal gizmo used to scale all axis equally
  113289. */
  113290. uniformScaleGizmo: AxisScaleGizmo;
  113291. private _meshAttached;
  113292. private _updateGizmoRotationToMatchAttachedMesh;
  113293. private _snapDistance;
  113294. private _scaleRatio;
  113295. private _uniformScalingMesh;
  113296. private _octahedron;
  113297. /** Fires an event when any of it's sub gizmos are dragged */
  113298. onDragStartObservable: Observable<unknown>;
  113299. /** Fires an event when any of it's sub gizmos are released from dragging */
  113300. onDragEndObservable: Observable<unknown>;
  113301. attachedMesh: Nullable<AbstractMesh>;
  113302. /**
  113303. * Creates a ScaleGizmo
  113304. * @param gizmoLayer The utility layer the gizmo will be added to
  113305. */
  113306. constructor(gizmoLayer?: UtilityLayerRenderer);
  113307. updateGizmoRotationToMatchAttachedMesh: boolean;
  113308. /**
  113309. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113310. */
  113311. snapDistance: number;
  113312. /**
  113313. * Ratio for the scale of the gizmo (Default: 1)
  113314. */
  113315. scaleRatio: number;
  113316. /**
  113317. * Disposes of the gizmo
  113318. */
  113319. dispose(): void;
  113320. }
  113321. }
  113322. declare module BABYLON {
  113323. /**
  113324. * Single axis scale gizmo
  113325. */
  113326. export class AxisScaleGizmo extends Gizmo {
  113327. /**
  113328. * Drag behavior responsible for the gizmos dragging interactions
  113329. */
  113330. dragBehavior: PointerDragBehavior;
  113331. private _pointerObserver;
  113332. /**
  113333. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113334. */
  113335. snapDistance: number;
  113336. /**
  113337. * Event that fires each time the gizmo snaps to a new location.
  113338. * * snapDistance is the the change in distance
  113339. */
  113340. onSnapObservable: Observable<{
  113341. snapDistance: number;
  113342. }>;
  113343. /**
  113344. * If the scaling operation should be done on all axis (default: false)
  113345. */
  113346. uniformScaling: boolean;
  113347. private _isEnabled;
  113348. private _parent;
  113349. private _arrow;
  113350. private _coloredMaterial;
  113351. private _hoverMaterial;
  113352. /**
  113353. * Creates an AxisScaleGizmo
  113354. * @param gizmoLayer The utility layer the gizmo will be added to
  113355. * @param dragAxis The axis which the gizmo will be able to scale on
  113356. * @param color The color of the gizmo
  113357. */
  113358. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113359. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113360. /**
  113361. * If the gizmo is enabled
  113362. */
  113363. isEnabled: boolean;
  113364. /**
  113365. * Disposes of the gizmo
  113366. */
  113367. dispose(): void;
  113368. /**
  113369. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113370. * @param mesh The mesh to replace the default mesh of the gizmo
  113371. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113372. */
  113373. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113374. }
  113375. }
  113376. declare module BABYLON {
  113377. /**
  113378. * Bounding box gizmo
  113379. */
  113380. export class BoundingBoxGizmo extends Gizmo {
  113381. private _lineBoundingBox;
  113382. private _rotateSpheresParent;
  113383. private _scaleBoxesParent;
  113384. private _boundingDimensions;
  113385. private _renderObserver;
  113386. private _pointerObserver;
  113387. private _scaleDragSpeed;
  113388. private _tmpQuaternion;
  113389. private _tmpVector;
  113390. private _tmpRotationMatrix;
  113391. /**
  113392. * 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)
  113393. */
  113394. ignoreChildren: boolean;
  113395. /**
  113396. * 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)
  113397. */
  113398. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  113399. /**
  113400. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  113401. */
  113402. rotationSphereSize: number;
  113403. /**
  113404. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  113405. */
  113406. scaleBoxSize: number;
  113407. /**
  113408. * 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)
  113409. */
  113410. fixedDragMeshScreenSize: boolean;
  113411. /**
  113412. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  113413. */
  113414. fixedDragMeshScreenSizeDistanceFactor: number;
  113415. /**
  113416. * Fired when a rotation sphere or scale box is dragged
  113417. */
  113418. onDragStartObservable: Observable<{}>;
  113419. /**
  113420. * Fired when a scale box is dragged
  113421. */
  113422. onScaleBoxDragObservable: Observable<{}>;
  113423. /**
  113424. * Fired when a scale box drag is ended
  113425. */
  113426. onScaleBoxDragEndObservable: Observable<{}>;
  113427. /**
  113428. * Fired when a rotation sphere is dragged
  113429. */
  113430. onRotationSphereDragObservable: Observable<{}>;
  113431. /**
  113432. * Fired when a rotation sphere drag is ended
  113433. */
  113434. onRotationSphereDragEndObservable: Observable<{}>;
  113435. /**
  113436. * 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)
  113437. */
  113438. scalePivot: Nullable<Vector3>;
  113439. /**
  113440. * Mesh used as a pivot to rotate the attached mesh
  113441. */
  113442. private _anchorMesh;
  113443. private _existingMeshScale;
  113444. private _dragMesh;
  113445. private pointerDragBehavior;
  113446. private coloredMaterial;
  113447. private hoverColoredMaterial;
  113448. /**
  113449. * Sets the color of the bounding box gizmo
  113450. * @param color the color to set
  113451. */
  113452. setColor(color: Color3): void;
  113453. /**
  113454. * Creates an BoundingBoxGizmo
  113455. * @param gizmoLayer The utility layer the gizmo will be added to
  113456. * @param color The color of the gizmo
  113457. */
  113458. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  113459. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113460. private _selectNode;
  113461. /**
  113462. * Updates the bounding box information for the Gizmo
  113463. */
  113464. updateBoundingBox(): void;
  113465. private _updateRotationSpheres;
  113466. private _updateScaleBoxes;
  113467. /**
  113468. * Enables rotation on the specified axis and disables rotation on the others
  113469. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  113470. */
  113471. setEnabledRotationAxis(axis: string): void;
  113472. /**
  113473. * Enables/disables scaling
  113474. * @param enable if scaling should be enabled
  113475. */
  113476. setEnabledScaling(enable: boolean): void;
  113477. private _updateDummy;
  113478. /**
  113479. * Enables a pointer drag behavior on the bounding box of the gizmo
  113480. */
  113481. enableDragBehavior(): void;
  113482. /**
  113483. * Disposes of the gizmo
  113484. */
  113485. dispose(): void;
  113486. /**
  113487. * 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)
  113488. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  113489. * @returns the bounding box mesh with the passed in mesh as a child
  113490. */
  113491. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  113492. /**
  113493. * CustomMeshes are not supported by this gizmo
  113494. * @param mesh The mesh to replace the default mesh of the gizmo
  113495. */
  113496. setCustomMesh(mesh: Mesh): void;
  113497. }
  113498. }
  113499. declare module BABYLON {
  113500. /**
  113501. * Single plane rotation gizmo
  113502. */
  113503. export class PlaneRotationGizmo extends Gizmo {
  113504. /**
  113505. * Drag behavior responsible for the gizmos dragging interactions
  113506. */
  113507. dragBehavior: PointerDragBehavior;
  113508. private _pointerObserver;
  113509. /**
  113510. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  113511. */
  113512. snapDistance: number;
  113513. /**
  113514. * Event that fires each time the gizmo snaps to a new location.
  113515. * * snapDistance is the the change in distance
  113516. */
  113517. onSnapObservable: Observable<{
  113518. snapDistance: number;
  113519. }>;
  113520. private _isEnabled;
  113521. private _parent;
  113522. /**
  113523. * Creates a PlaneRotationGizmo
  113524. * @param gizmoLayer The utility layer the gizmo will be added to
  113525. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  113526. * @param color The color of the gizmo
  113527. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113528. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113529. */
  113530. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  113531. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113532. /**
  113533. * If the gizmo is enabled
  113534. */
  113535. isEnabled: boolean;
  113536. /**
  113537. * Disposes of the gizmo
  113538. */
  113539. dispose(): void;
  113540. }
  113541. }
  113542. declare module BABYLON {
  113543. /**
  113544. * Gizmo that enables rotating a mesh along 3 axis
  113545. */
  113546. export class RotationGizmo extends Gizmo {
  113547. /**
  113548. * Internal gizmo used for interactions on the x axis
  113549. */
  113550. xGizmo: PlaneRotationGizmo;
  113551. /**
  113552. * Internal gizmo used for interactions on the y axis
  113553. */
  113554. yGizmo: PlaneRotationGizmo;
  113555. /**
  113556. * Internal gizmo used for interactions on the z axis
  113557. */
  113558. zGizmo: PlaneRotationGizmo;
  113559. /** Fires an event when any of it's sub gizmos are dragged */
  113560. onDragStartObservable: Observable<unknown>;
  113561. /** Fires an event when any of it's sub gizmos are released from dragging */
  113562. onDragEndObservable: Observable<unknown>;
  113563. private _meshAttached;
  113564. attachedMesh: Nullable<AbstractMesh>;
  113565. /**
  113566. * Creates a RotationGizmo
  113567. * @param gizmoLayer The utility layer the gizmo will be added to
  113568. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113569. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113570. */
  113571. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  113572. updateGizmoRotationToMatchAttachedMesh: boolean;
  113573. /**
  113574. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113575. */
  113576. snapDistance: number;
  113577. /**
  113578. * Ratio for the scale of the gizmo (Default: 1)
  113579. */
  113580. scaleRatio: number;
  113581. /**
  113582. * Disposes of the gizmo
  113583. */
  113584. dispose(): void;
  113585. /**
  113586. * CustomMeshes are not supported by this gizmo
  113587. * @param mesh The mesh to replace the default mesh of the gizmo
  113588. */
  113589. setCustomMesh(mesh: Mesh): void;
  113590. }
  113591. }
  113592. declare module BABYLON {
  113593. /**
  113594. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  113595. */
  113596. export class GizmoManager implements IDisposable {
  113597. private scene;
  113598. /**
  113599. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  113600. */
  113601. gizmos: {
  113602. positionGizmo: Nullable<PositionGizmo>;
  113603. rotationGizmo: Nullable<RotationGizmo>;
  113604. scaleGizmo: Nullable<ScaleGizmo>;
  113605. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  113606. };
  113607. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  113608. clearGizmoOnEmptyPointerEvent: boolean;
  113609. /** Fires an event when the manager is attached to a mesh */
  113610. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  113611. private _gizmosEnabled;
  113612. private _pointerObserver;
  113613. private _attachedMesh;
  113614. private _boundingBoxColor;
  113615. private _defaultUtilityLayer;
  113616. private _defaultKeepDepthUtilityLayer;
  113617. /**
  113618. * When bounding box gizmo is enabled, this can be used to track drag/end events
  113619. */
  113620. boundingBoxDragBehavior: SixDofDragBehavior;
  113621. /**
  113622. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  113623. */
  113624. attachableMeshes: Nullable<Array<AbstractMesh>>;
  113625. /**
  113626. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  113627. */
  113628. usePointerToAttachGizmos: boolean;
  113629. /**
  113630. * Utility layer that the bounding box gizmo belongs to
  113631. */
  113632. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  113633. /**
  113634. * Utility layer that all gizmos besides bounding box belong to
  113635. */
  113636. readonly utilityLayer: UtilityLayerRenderer;
  113637. /**
  113638. * Instatiates a gizmo manager
  113639. * @param scene the scene to overlay the gizmos on top of
  113640. */
  113641. constructor(scene: Scene);
  113642. /**
  113643. * Attaches a set of gizmos to the specified mesh
  113644. * @param mesh The mesh the gizmo's should be attached to
  113645. */
  113646. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  113647. /**
  113648. * If the position gizmo is enabled
  113649. */
  113650. positionGizmoEnabled: boolean;
  113651. /**
  113652. * If the rotation gizmo is enabled
  113653. */
  113654. rotationGizmoEnabled: boolean;
  113655. /**
  113656. * If the scale gizmo is enabled
  113657. */
  113658. scaleGizmoEnabled: boolean;
  113659. /**
  113660. * If the boundingBox gizmo is enabled
  113661. */
  113662. boundingBoxGizmoEnabled: boolean;
  113663. /**
  113664. * Disposes of the gizmo manager
  113665. */
  113666. dispose(): void;
  113667. }
  113668. }
  113669. declare module BABYLON {
  113670. /**
  113671. * A directional light is defined by a direction (what a surprise!).
  113672. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  113673. * 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.
  113674. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113675. */
  113676. export class DirectionalLight extends ShadowLight {
  113677. private _shadowFrustumSize;
  113678. /**
  113679. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  113680. */
  113681. /**
  113682. * Specifies a fix frustum size for the shadow generation.
  113683. */
  113684. shadowFrustumSize: number;
  113685. private _shadowOrthoScale;
  113686. /**
  113687. * Gets the shadow projection scale against the optimal computed one.
  113688. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113689. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113690. */
  113691. /**
  113692. * Sets the shadow projection scale against the optimal computed one.
  113693. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113694. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113695. */
  113696. shadowOrthoScale: number;
  113697. /**
  113698. * Automatically compute the projection matrix to best fit (including all the casters)
  113699. * on each frame.
  113700. */
  113701. autoUpdateExtends: boolean;
  113702. private _orthoLeft;
  113703. private _orthoRight;
  113704. private _orthoTop;
  113705. private _orthoBottom;
  113706. /**
  113707. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  113708. * The directional light is emitted from everywhere in the given direction.
  113709. * It can cast shadows.
  113710. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113711. * @param name The friendly name of the light
  113712. * @param direction The direction of the light
  113713. * @param scene The scene the light belongs to
  113714. */
  113715. constructor(name: string, direction: Vector3, scene: Scene);
  113716. /**
  113717. * Returns the string "DirectionalLight".
  113718. * @return The class name
  113719. */
  113720. getClassName(): string;
  113721. /**
  113722. * Returns the integer 1.
  113723. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113724. */
  113725. getTypeID(): number;
  113726. /**
  113727. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  113728. * Returns the DirectionalLight Shadow projection matrix.
  113729. */
  113730. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113731. /**
  113732. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  113733. * Returns the DirectionalLight Shadow projection matrix.
  113734. */
  113735. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  113736. /**
  113737. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  113738. * Returns the DirectionalLight Shadow projection matrix.
  113739. */
  113740. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113741. protected _buildUniformLayout(): void;
  113742. /**
  113743. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  113744. * @param effect The effect to update
  113745. * @param lightIndex The index of the light in the effect to update
  113746. * @returns The directional light
  113747. */
  113748. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  113749. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  113750. /**
  113751. * Gets the minZ used for shadow according to both the scene and the light.
  113752. *
  113753. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113754. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113755. * @param activeCamera The camera we are returning the min for
  113756. * @returns the depth min z
  113757. */
  113758. getDepthMinZ(activeCamera: Camera): number;
  113759. /**
  113760. * Gets the maxZ used for shadow according to both the scene and the light.
  113761. *
  113762. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113763. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113764. * @param activeCamera The camera we are returning the max for
  113765. * @returns the depth max z
  113766. */
  113767. getDepthMaxZ(activeCamera: Camera): number;
  113768. /**
  113769. * Prepares the list of defines specific to the light type.
  113770. * @param defines the list of defines
  113771. * @param lightIndex defines the index of the light for the effect
  113772. */
  113773. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113774. }
  113775. }
  113776. declare module BABYLON {
  113777. /**
  113778. * Class containing static functions to help procedurally build meshes
  113779. */
  113780. export class HemisphereBuilder {
  113781. /**
  113782. * Creates a hemisphere mesh
  113783. * @param name defines the name of the mesh
  113784. * @param options defines the options used to create the mesh
  113785. * @param scene defines the hosting scene
  113786. * @returns the hemisphere mesh
  113787. */
  113788. static CreateHemisphere(name: string, options: {
  113789. segments?: number;
  113790. diameter?: number;
  113791. sideOrientation?: number;
  113792. }, scene: any): Mesh;
  113793. }
  113794. }
  113795. declare module BABYLON {
  113796. /**
  113797. * A spot light is defined by a position, a direction, an angle, and an exponent.
  113798. * These values define a cone of light starting from the position, emitting toward the direction.
  113799. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  113800. * and the exponent defines the speed of the decay of the light with distance (reach).
  113801. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113802. */
  113803. export class SpotLight extends ShadowLight {
  113804. private _angle;
  113805. private _innerAngle;
  113806. private _cosHalfAngle;
  113807. private _lightAngleScale;
  113808. private _lightAngleOffset;
  113809. /**
  113810. * Gets the cone angle of the spot light in Radians.
  113811. */
  113812. /**
  113813. * Sets the cone angle of the spot light in Radians.
  113814. */
  113815. angle: number;
  113816. /**
  113817. * Only used in gltf falloff mode, this defines the angle where
  113818. * the directional falloff will start before cutting at angle which could be seen
  113819. * as outer angle.
  113820. */
  113821. /**
  113822. * Only used in gltf falloff mode, this defines the angle where
  113823. * the directional falloff will start before cutting at angle which could be seen
  113824. * as outer angle.
  113825. */
  113826. innerAngle: number;
  113827. private _shadowAngleScale;
  113828. /**
  113829. * Allows scaling the angle of the light for shadow generation only.
  113830. */
  113831. /**
  113832. * Allows scaling the angle of the light for shadow generation only.
  113833. */
  113834. shadowAngleScale: number;
  113835. /**
  113836. * The light decay speed with the distance from the emission spot.
  113837. */
  113838. exponent: number;
  113839. private _projectionTextureMatrix;
  113840. /**
  113841. * Allows reading the projecton texture
  113842. */
  113843. readonly projectionTextureMatrix: Matrix;
  113844. protected _projectionTextureLightNear: number;
  113845. /**
  113846. * Gets the near clip of the Spotlight for texture projection.
  113847. */
  113848. /**
  113849. * Sets the near clip of the Spotlight for texture projection.
  113850. */
  113851. projectionTextureLightNear: number;
  113852. protected _projectionTextureLightFar: number;
  113853. /**
  113854. * Gets the far clip of the Spotlight for texture projection.
  113855. */
  113856. /**
  113857. * Sets the far clip of the Spotlight for texture projection.
  113858. */
  113859. projectionTextureLightFar: number;
  113860. protected _projectionTextureUpDirection: Vector3;
  113861. /**
  113862. * Gets the Up vector of the Spotlight for texture projection.
  113863. */
  113864. /**
  113865. * Sets the Up vector of the Spotlight for texture projection.
  113866. */
  113867. projectionTextureUpDirection: Vector3;
  113868. private _projectionTexture;
  113869. /**
  113870. * Gets the projection texture of the light.
  113871. */
  113872. /**
  113873. * Sets the projection texture of the light.
  113874. */
  113875. projectionTexture: Nullable<BaseTexture>;
  113876. private _projectionTextureViewLightDirty;
  113877. private _projectionTextureProjectionLightDirty;
  113878. private _projectionTextureDirty;
  113879. private _projectionTextureViewTargetVector;
  113880. private _projectionTextureViewLightMatrix;
  113881. private _projectionTextureProjectionLightMatrix;
  113882. private _projectionTextureScalingMatrix;
  113883. /**
  113884. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  113885. * It can cast shadows.
  113886. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113887. * @param name The light friendly name
  113888. * @param position The position of the spot light in the scene
  113889. * @param direction The direction of the light in the scene
  113890. * @param angle The cone angle of the light in Radians
  113891. * @param exponent The light decay speed with the distance from the emission spot
  113892. * @param scene The scene the lights belongs to
  113893. */
  113894. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  113895. /**
  113896. * Returns the string "SpotLight".
  113897. * @returns the class name
  113898. */
  113899. getClassName(): string;
  113900. /**
  113901. * Returns the integer 2.
  113902. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113903. */
  113904. getTypeID(): number;
  113905. /**
  113906. * Overrides the direction setter to recompute the projection texture view light Matrix.
  113907. */
  113908. protected _setDirection(value: Vector3): void;
  113909. /**
  113910. * Overrides the position setter to recompute the projection texture view light Matrix.
  113911. */
  113912. protected _setPosition(value: Vector3): void;
  113913. /**
  113914. * 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.
  113915. * Returns the SpotLight.
  113916. */
  113917. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113918. protected _computeProjectionTextureViewLightMatrix(): void;
  113919. protected _computeProjectionTextureProjectionLightMatrix(): void;
  113920. /**
  113921. * Main function for light texture projection matrix computing.
  113922. */
  113923. protected _computeProjectionTextureMatrix(): void;
  113924. protected _buildUniformLayout(): void;
  113925. private _computeAngleValues;
  113926. /**
  113927. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  113928. * @param effect The effect to update
  113929. * @param lightIndex The index of the light in the effect to update
  113930. * @returns The spot light
  113931. */
  113932. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  113933. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  113934. /**
  113935. * Disposes the light and the associated resources.
  113936. */
  113937. dispose(): void;
  113938. /**
  113939. * Prepares the list of defines specific to the light type.
  113940. * @param defines the list of defines
  113941. * @param lightIndex defines the index of the light for the effect
  113942. */
  113943. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113944. }
  113945. }
  113946. declare module BABYLON {
  113947. /**
  113948. * Gizmo that enables viewing a light
  113949. */
  113950. export class LightGizmo extends Gizmo {
  113951. private _lightMesh;
  113952. private _material;
  113953. private cachedPosition;
  113954. private cachedForward;
  113955. /**
  113956. * Creates a LightGizmo
  113957. * @param gizmoLayer The utility layer the gizmo will be added to
  113958. */
  113959. constructor(gizmoLayer?: UtilityLayerRenderer);
  113960. private _light;
  113961. /**
  113962. * The light that the gizmo is attached to
  113963. */
  113964. light: Nullable<Light>;
  113965. /**
  113966. * Gets the material used to render the light gizmo
  113967. */
  113968. readonly material: StandardMaterial;
  113969. /**
  113970. * @hidden
  113971. * Updates the gizmo to match the attached mesh's position/rotation
  113972. */
  113973. protected _update(): void;
  113974. private static _Scale;
  113975. /**
  113976. * Creates the lines for a light mesh
  113977. */
  113978. private static _createLightLines;
  113979. /**
  113980. * Disposes of the light gizmo
  113981. */
  113982. dispose(): void;
  113983. private static _CreateHemisphericLightMesh;
  113984. private static _CreatePointLightMesh;
  113985. private static _CreateSpotLightMesh;
  113986. private static _CreateDirectionalLightMesh;
  113987. }
  113988. }
  113989. declare module BABYLON {
  113990. /** @hidden */
  113991. export var backgroundFragmentDeclaration: {
  113992. name: string;
  113993. shader: string;
  113994. };
  113995. }
  113996. declare module BABYLON {
  113997. /** @hidden */
  113998. export var backgroundUboDeclaration: {
  113999. name: string;
  114000. shader: string;
  114001. };
  114002. }
  114003. declare module BABYLON {
  114004. /** @hidden */
  114005. export var backgroundPixelShader: {
  114006. name: string;
  114007. shader: string;
  114008. };
  114009. }
  114010. declare module BABYLON {
  114011. /** @hidden */
  114012. export var backgroundVertexDeclaration: {
  114013. name: string;
  114014. shader: string;
  114015. };
  114016. }
  114017. declare module BABYLON {
  114018. /** @hidden */
  114019. export var backgroundVertexShader: {
  114020. name: string;
  114021. shader: string;
  114022. };
  114023. }
  114024. declare module BABYLON {
  114025. /**
  114026. * Background material used to create an efficient environement around your scene.
  114027. */
  114028. export class BackgroundMaterial extends PushMaterial {
  114029. /**
  114030. * Standard reflectance value at parallel view angle.
  114031. */
  114032. static StandardReflectance0: number;
  114033. /**
  114034. * Standard reflectance value at grazing angle.
  114035. */
  114036. static StandardReflectance90: number;
  114037. protected _primaryColor: Color3;
  114038. /**
  114039. * Key light Color (multiply against the environement texture)
  114040. */
  114041. primaryColor: Color3;
  114042. protected __perceptualColor: Nullable<Color3>;
  114043. /**
  114044. * Experimental Internal Use Only.
  114045. *
  114046. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114047. * This acts as a helper to set the primary color to a more "human friendly" value.
  114048. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114049. * output color as close as possible from the chosen value.
  114050. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114051. * part of lighting setup.)
  114052. */
  114053. _perceptualColor: Nullable<Color3>;
  114054. protected _primaryColorShadowLevel: float;
  114055. /**
  114056. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114057. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114058. */
  114059. primaryColorShadowLevel: float;
  114060. protected _primaryColorHighlightLevel: float;
  114061. /**
  114062. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114063. * The primary color is used at the level chosen to define what the white area would look.
  114064. */
  114065. primaryColorHighlightLevel: float;
  114066. protected _reflectionTexture: Nullable<BaseTexture>;
  114067. /**
  114068. * Reflection Texture used in the material.
  114069. * Should be author in a specific way for the best result (refer to the documentation).
  114070. */
  114071. reflectionTexture: Nullable<BaseTexture>;
  114072. protected _reflectionBlur: float;
  114073. /**
  114074. * Reflection Texture level of blur.
  114075. *
  114076. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114077. * texture twice.
  114078. */
  114079. reflectionBlur: float;
  114080. protected _diffuseTexture: Nullable<BaseTexture>;
  114081. /**
  114082. * Diffuse Texture used in the material.
  114083. * Should be author in a specific way for the best result (refer to the documentation).
  114084. */
  114085. diffuseTexture: Nullable<BaseTexture>;
  114086. protected _shadowLights: Nullable<IShadowLight[]>;
  114087. /**
  114088. * Specify the list of lights casting shadow on the material.
  114089. * All scene shadow lights will be included if null.
  114090. */
  114091. shadowLights: Nullable<IShadowLight[]>;
  114092. protected _shadowLevel: float;
  114093. /**
  114094. * Helps adjusting the shadow to a softer level if required.
  114095. * 0 means black shadows and 1 means no shadows.
  114096. */
  114097. shadowLevel: float;
  114098. protected _sceneCenter: Vector3;
  114099. /**
  114100. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114101. * It is usually zero but might be interesting to modify according to your setup.
  114102. */
  114103. sceneCenter: Vector3;
  114104. protected _opacityFresnel: boolean;
  114105. /**
  114106. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114107. * This helps ensuring a nice transition when the camera goes under the ground.
  114108. */
  114109. opacityFresnel: boolean;
  114110. protected _reflectionFresnel: boolean;
  114111. /**
  114112. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114113. * This helps adding a mirror texture on the ground.
  114114. */
  114115. reflectionFresnel: boolean;
  114116. protected _reflectionFalloffDistance: number;
  114117. /**
  114118. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114119. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114120. */
  114121. reflectionFalloffDistance: number;
  114122. protected _reflectionAmount: number;
  114123. /**
  114124. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114125. */
  114126. reflectionAmount: number;
  114127. protected _reflectionReflectance0: number;
  114128. /**
  114129. * This specifies the weight of the reflection at grazing angle.
  114130. */
  114131. reflectionReflectance0: number;
  114132. protected _reflectionReflectance90: number;
  114133. /**
  114134. * This specifies the weight of the reflection at a perpendicular point of view.
  114135. */
  114136. reflectionReflectance90: number;
  114137. /**
  114138. * Sets the reflection reflectance fresnel values according to the default standard
  114139. * empirically know to work well :-)
  114140. */
  114141. reflectionStandardFresnelWeight: number;
  114142. protected _useRGBColor: boolean;
  114143. /**
  114144. * Helps to directly use the maps channels instead of their level.
  114145. */
  114146. useRGBColor: boolean;
  114147. protected _enableNoise: boolean;
  114148. /**
  114149. * This helps reducing the banding effect that could occur on the background.
  114150. */
  114151. enableNoise: boolean;
  114152. /**
  114153. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114154. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114155. * Recommended to be keep at 1.0 except for special cases.
  114156. */
  114157. fovMultiplier: number;
  114158. private _fovMultiplier;
  114159. /**
  114160. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114161. */
  114162. useEquirectangularFOV: boolean;
  114163. private _maxSimultaneousLights;
  114164. /**
  114165. * Number of Simultaneous lights allowed on the material.
  114166. */
  114167. maxSimultaneousLights: int;
  114168. /**
  114169. * Default configuration related to image processing available in the Background Material.
  114170. */
  114171. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114172. /**
  114173. * Keep track of the image processing observer to allow dispose and replace.
  114174. */
  114175. private _imageProcessingObserver;
  114176. /**
  114177. * Attaches a new image processing configuration to the PBR Material.
  114178. * @param configuration (if null the scene configuration will be use)
  114179. */
  114180. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114181. /**
  114182. * Gets the image processing configuration used either in this material.
  114183. */
  114184. /**
  114185. * Sets the Default image processing configuration used either in the this material.
  114186. *
  114187. * If sets to null, the scene one is in use.
  114188. */
  114189. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114190. /**
  114191. * Gets wether the color curves effect is enabled.
  114192. */
  114193. /**
  114194. * Sets wether the color curves effect is enabled.
  114195. */
  114196. cameraColorCurvesEnabled: boolean;
  114197. /**
  114198. * Gets wether the color grading effect is enabled.
  114199. */
  114200. /**
  114201. * Gets wether the color grading effect is enabled.
  114202. */
  114203. cameraColorGradingEnabled: boolean;
  114204. /**
  114205. * Gets wether tonemapping is enabled or not.
  114206. */
  114207. /**
  114208. * Sets wether tonemapping is enabled or not
  114209. */
  114210. cameraToneMappingEnabled: boolean;
  114211. /**
  114212. * The camera exposure used on this material.
  114213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114214. * This corresponds to a photographic exposure.
  114215. */
  114216. /**
  114217. * The camera exposure used on this material.
  114218. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114219. * This corresponds to a photographic exposure.
  114220. */
  114221. cameraExposure: float;
  114222. /**
  114223. * Gets The camera contrast used on this material.
  114224. */
  114225. /**
  114226. * Sets The camera contrast used on this material.
  114227. */
  114228. cameraContrast: float;
  114229. /**
  114230. * Gets the Color Grading 2D Lookup Texture.
  114231. */
  114232. /**
  114233. * Sets the Color Grading 2D Lookup Texture.
  114234. */
  114235. cameraColorGradingTexture: Nullable<BaseTexture>;
  114236. /**
  114237. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114238. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114239. * 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;
  114240. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114241. */
  114242. /**
  114243. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114244. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114245. * 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;
  114246. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114247. */
  114248. cameraColorCurves: Nullable<ColorCurves>;
  114249. /**
  114250. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114251. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114252. */
  114253. switchToBGR: boolean;
  114254. private _renderTargets;
  114255. private _reflectionControls;
  114256. private _white;
  114257. private _primaryShadowColor;
  114258. private _primaryHighlightColor;
  114259. /**
  114260. * Instantiates a Background Material in the given scene
  114261. * @param name The friendly name of the material
  114262. * @param scene The scene to add the material to
  114263. */
  114264. constructor(name: string, scene: Scene);
  114265. /**
  114266. * Gets a boolean indicating that current material needs to register RTT
  114267. */
  114268. readonly hasRenderTargetTextures: boolean;
  114269. /**
  114270. * The entire material has been created in order to prevent overdraw.
  114271. * @returns false
  114272. */
  114273. needAlphaTesting(): boolean;
  114274. /**
  114275. * The entire material has been created in order to prevent overdraw.
  114276. * @returns true if blending is enable
  114277. */
  114278. needAlphaBlending(): boolean;
  114279. /**
  114280. * Checks wether the material is ready to be rendered for a given mesh.
  114281. * @param mesh The mesh to render
  114282. * @param subMesh The submesh to check against
  114283. * @param useInstances Specify wether or not the material is used with instances
  114284. * @returns true if all the dependencies are ready (Textures, Effects...)
  114285. */
  114286. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114287. /**
  114288. * Compute the primary color according to the chosen perceptual color.
  114289. */
  114290. private _computePrimaryColorFromPerceptualColor;
  114291. /**
  114292. * Compute the highlights and shadow colors according to their chosen levels.
  114293. */
  114294. private _computePrimaryColors;
  114295. /**
  114296. * Build the uniform buffer used in the material.
  114297. */
  114298. buildUniformLayout(): void;
  114299. /**
  114300. * Unbind the material.
  114301. */
  114302. unbind(): void;
  114303. /**
  114304. * Bind only the world matrix to the material.
  114305. * @param world The world matrix to bind.
  114306. */
  114307. bindOnlyWorldMatrix(world: Matrix): void;
  114308. /**
  114309. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  114310. * @param world The world matrix to bind.
  114311. * @param subMesh The submesh to bind for.
  114312. */
  114313. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114314. /**
  114315. * Checks to see if a texture is used in the material.
  114316. * @param texture - Base texture to use.
  114317. * @returns - Boolean specifying if a texture is used in the material.
  114318. */
  114319. hasTexture(texture: BaseTexture): boolean;
  114320. /**
  114321. * Dispose the material.
  114322. * @param forceDisposeEffect Force disposal of the associated effect.
  114323. * @param forceDisposeTextures Force disposal of the associated textures.
  114324. */
  114325. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114326. /**
  114327. * Clones the material.
  114328. * @param name The cloned name.
  114329. * @returns The cloned material.
  114330. */
  114331. clone(name: string): BackgroundMaterial;
  114332. /**
  114333. * Serializes the current material to its JSON representation.
  114334. * @returns The JSON representation.
  114335. */
  114336. serialize(): any;
  114337. /**
  114338. * Gets the class name of the material
  114339. * @returns "BackgroundMaterial"
  114340. */
  114341. getClassName(): string;
  114342. /**
  114343. * Parse a JSON input to create back a background material.
  114344. * @param source The JSON data to parse
  114345. * @param scene The scene to create the parsed material in
  114346. * @param rootUrl The root url of the assets the material depends upon
  114347. * @returns the instantiated BackgroundMaterial.
  114348. */
  114349. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  114350. }
  114351. }
  114352. declare module BABYLON {
  114353. /**
  114354. * Represents the different options available during the creation of
  114355. * a Environment helper.
  114356. *
  114357. * This can control the default ground, skybox and image processing setup of your scene.
  114358. */
  114359. export interface IEnvironmentHelperOptions {
  114360. /**
  114361. * Specifies wether or not to create a ground.
  114362. * True by default.
  114363. */
  114364. createGround: boolean;
  114365. /**
  114366. * Specifies the ground size.
  114367. * 15 by default.
  114368. */
  114369. groundSize: number;
  114370. /**
  114371. * The texture used on the ground for the main color.
  114372. * Comes from the BabylonJS CDN by default.
  114373. *
  114374. * Remarks: Can be either a texture or a url.
  114375. */
  114376. groundTexture: string | BaseTexture;
  114377. /**
  114378. * The color mixed in the ground texture by default.
  114379. * BabylonJS clearColor by default.
  114380. */
  114381. groundColor: Color3;
  114382. /**
  114383. * Specifies the ground opacity.
  114384. * 1 by default.
  114385. */
  114386. groundOpacity: number;
  114387. /**
  114388. * Enables the ground to receive shadows.
  114389. * True by default.
  114390. */
  114391. enableGroundShadow: boolean;
  114392. /**
  114393. * Helps preventing the shadow to be fully black on the ground.
  114394. * 0.5 by default.
  114395. */
  114396. groundShadowLevel: number;
  114397. /**
  114398. * Creates a mirror texture attach to the ground.
  114399. * false by default.
  114400. */
  114401. enableGroundMirror: boolean;
  114402. /**
  114403. * Specifies the ground mirror size ratio.
  114404. * 0.3 by default as the default kernel is 64.
  114405. */
  114406. groundMirrorSizeRatio: number;
  114407. /**
  114408. * Specifies the ground mirror blur kernel size.
  114409. * 64 by default.
  114410. */
  114411. groundMirrorBlurKernel: number;
  114412. /**
  114413. * Specifies the ground mirror visibility amount.
  114414. * 1 by default
  114415. */
  114416. groundMirrorAmount: number;
  114417. /**
  114418. * Specifies the ground mirror reflectance weight.
  114419. * This uses the standard weight of the background material to setup the fresnel effect
  114420. * of the mirror.
  114421. * 1 by default.
  114422. */
  114423. groundMirrorFresnelWeight: number;
  114424. /**
  114425. * Specifies the ground mirror Falloff distance.
  114426. * This can helps reducing the size of the reflection.
  114427. * 0 by Default.
  114428. */
  114429. groundMirrorFallOffDistance: number;
  114430. /**
  114431. * Specifies the ground mirror texture type.
  114432. * Unsigned Int by Default.
  114433. */
  114434. groundMirrorTextureType: number;
  114435. /**
  114436. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  114437. * the shown objects.
  114438. */
  114439. groundYBias: number;
  114440. /**
  114441. * Specifies wether or not to create a skybox.
  114442. * True by default.
  114443. */
  114444. createSkybox: boolean;
  114445. /**
  114446. * Specifies the skybox size.
  114447. * 20 by default.
  114448. */
  114449. skyboxSize: number;
  114450. /**
  114451. * The texture used on the skybox for the main color.
  114452. * Comes from the BabylonJS CDN by default.
  114453. *
  114454. * Remarks: Can be either a texture or a url.
  114455. */
  114456. skyboxTexture: string | BaseTexture;
  114457. /**
  114458. * The color mixed in the skybox texture by default.
  114459. * BabylonJS clearColor by default.
  114460. */
  114461. skyboxColor: Color3;
  114462. /**
  114463. * The background rotation around the Y axis of the scene.
  114464. * This helps aligning the key lights of your scene with the background.
  114465. * 0 by default.
  114466. */
  114467. backgroundYRotation: number;
  114468. /**
  114469. * Compute automatically the size of the elements to best fit with the scene.
  114470. */
  114471. sizeAuto: boolean;
  114472. /**
  114473. * Default position of the rootMesh if autoSize is not true.
  114474. */
  114475. rootPosition: Vector3;
  114476. /**
  114477. * Sets up the image processing in the scene.
  114478. * true by default.
  114479. */
  114480. setupImageProcessing: boolean;
  114481. /**
  114482. * The texture used as your environment texture in the scene.
  114483. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  114484. *
  114485. * Remarks: Can be either a texture or a url.
  114486. */
  114487. environmentTexture: string | BaseTexture;
  114488. /**
  114489. * The value of the exposure to apply to the scene.
  114490. * 0.6 by default if setupImageProcessing is true.
  114491. */
  114492. cameraExposure: number;
  114493. /**
  114494. * The value of the contrast to apply to the scene.
  114495. * 1.6 by default if setupImageProcessing is true.
  114496. */
  114497. cameraContrast: number;
  114498. /**
  114499. * Specifies wether or not tonemapping should be enabled in the scene.
  114500. * true by default if setupImageProcessing is true.
  114501. */
  114502. toneMappingEnabled: boolean;
  114503. }
  114504. /**
  114505. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  114506. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  114507. * It also helps with the default setup of your imageProcessing configuration.
  114508. */
  114509. export class EnvironmentHelper {
  114510. /**
  114511. * Default ground texture URL.
  114512. */
  114513. private static _groundTextureCDNUrl;
  114514. /**
  114515. * Default skybox texture URL.
  114516. */
  114517. private static _skyboxTextureCDNUrl;
  114518. /**
  114519. * Default environment texture URL.
  114520. */
  114521. private static _environmentTextureCDNUrl;
  114522. /**
  114523. * Creates the default options for the helper.
  114524. */
  114525. private static _getDefaultOptions;
  114526. private _rootMesh;
  114527. /**
  114528. * Gets the root mesh created by the helper.
  114529. */
  114530. readonly rootMesh: Mesh;
  114531. private _skybox;
  114532. /**
  114533. * Gets the skybox created by the helper.
  114534. */
  114535. readonly skybox: Nullable<Mesh>;
  114536. private _skyboxTexture;
  114537. /**
  114538. * Gets the skybox texture created by the helper.
  114539. */
  114540. readonly skyboxTexture: Nullable<BaseTexture>;
  114541. private _skyboxMaterial;
  114542. /**
  114543. * Gets the skybox material created by the helper.
  114544. */
  114545. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  114546. private _ground;
  114547. /**
  114548. * Gets the ground mesh created by the helper.
  114549. */
  114550. readonly ground: Nullable<Mesh>;
  114551. private _groundTexture;
  114552. /**
  114553. * Gets the ground texture created by the helper.
  114554. */
  114555. readonly groundTexture: Nullable<BaseTexture>;
  114556. private _groundMirror;
  114557. /**
  114558. * Gets the ground mirror created by the helper.
  114559. */
  114560. readonly groundMirror: Nullable<MirrorTexture>;
  114561. /**
  114562. * Gets the ground mirror render list to helps pushing the meshes
  114563. * you wish in the ground reflection.
  114564. */
  114565. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  114566. private _groundMaterial;
  114567. /**
  114568. * Gets the ground material created by the helper.
  114569. */
  114570. readonly groundMaterial: Nullable<BackgroundMaterial>;
  114571. /**
  114572. * Stores the creation options.
  114573. */
  114574. private readonly _scene;
  114575. private _options;
  114576. /**
  114577. * This observable will be notified with any error during the creation of the environment,
  114578. * mainly texture creation errors.
  114579. */
  114580. onErrorObservable: Observable<{
  114581. message?: string;
  114582. exception?: any;
  114583. }>;
  114584. /**
  114585. * constructor
  114586. * @param options Defines the options we want to customize the helper
  114587. * @param scene The scene to add the material to
  114588. */
  114589. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  114590. /**
  114591. * Updates the background according to the new options
  114592. * @param options
  114593. */
  114594. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  114595. /**
  114596. * Sets the primary color of all the available elements.
  114597. * @param color the main color to affect to the ground and the background
  114598. */
  114599. setMainColor(color: Color3): void;
  114600. /**
  114601. * Setup the image processing according to the specified options.
  114602. */
  114603. private _setupImageProcessing;
  114604. /**
  114605. * Setup the environment texture according to the specified options.
  114606. */
  114607. private _setupEnvironmentTexture;
  114608. /**
  114609. * Setup the background according to the specified options.
  114610. */
  114611. private _setupBackground;
  114612. /**
  114613. * Get the scene sizes according to the setup.
  114614. */
  114615. private _getSceneSize;
  114616. /**
  114617. * Setup the ground according to the specified options.
  114618. */
  114619. private _setupGround;
  114620. /**
  114621. * Setup the ground material according to the specified options.
  114622. */
  114623. private _setupGroundMaterial;
  114624. /**
  114625. * Setup the ground diffuse texture according to the specified options.
  114626. */
  114627. private _setupGroundDiffuseTexture;
  114628. /**
  114629. * Setup the ground mirror texture according to the specified options.
  114630. */
  114631. private _setupGroundMirrorTexture;
  114632. /**
  114633. * Setup the ground to receive the mirror texture.
  114634. */
  114635. private _setupMirrorInGroundMaterial;
  114636. /**
  114637. * Setup the skybox according to the specified options.
  114638. */
  114639. private _setupSkybox;
  114640. /**
  114641. * Setup the skybox material according to the specified options.
  114642. */
  114643. private _setupSkyboxMaterial;
  114644. /**
  114645. * Setup the skybox reflection texture according to the specified options.
  114646. */
  114647. private _setupSkyboxReflectionTexture;
  114648. private _errorHandler;
  114649. /**
  114650. * Dispose all the elements created by the Helper.
  114651. */
  114652. dispose(): void;
  114653. }
  114654. }
  114655. declare module BABYLON {
  114656. /**
  114657. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  114658. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  114659. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  114660. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114661. */
  114662. export class PhotoDome extends TransformNode {
  114663. /**
  114664. * Define the image as a Monoscopic panoramic 360 image.
  114665. */
  114666. static readonly MODE_MONOSCOPIC: number;
  114667. /**
  114668. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114669. */
  114670. static readonly MODE_TOPBOTTOM: number;
  114671. /**
  114672. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114673. */
  114674. static readonly MODE_SIDEBYSIDE: number;
  114675. private _useDirectMapping;
  114676. /**
  114677. * The texture being displayed on the sphere
  114678. */
  114679. protected _photoTexture: Texture;
  114680. /**
  114681. * Gets or sets the texture being displayed on the sphere
  114682. */
  114683. photoTexture: Texture;
  114684. /**
  114685. * Observable raised when an error occured while loading the 360 image
  114686. */
  114687. onLoadErrorObservable: Observable<string>;
  114688. /**
  114689. * The skybox material
  114690. */
  114691. protected _material: BackgroundMaterial;
  114692. /**
  114693. * The surface used for the skybox
  114694. */
  114695. protected _mesh: Mesh;
  114696. /**
  114697. * Gets the mesh used for the skybox.
  114698. */
  114699. readonly mesh: Mesh;
  114700. /**
  114701. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114702. * Also see the options.resolution property.
  114703. */
  114704. fovMultiplier: number;
  114705. private _imageMode;
  114706. /**
  114707. * Gets or set the current video mode for the video. It can be:
  114708. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  114709. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114710. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114711. */
  114712. imageMode: number;
  114713. /**
  114714. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  114715. * @param name Element's name, child elements will append suffixes for their own names.
  114716. * @param urlsOfPhoto defines the url of the photo to display
  114717. * @param options defines an object containing optional or exposed sub element properties
  114718. * @param onError defines a callback called when an error occured while loading the texture
  114719. */
  114720. constructor(name: string, urlOfPhoto: string, options: {
  114721. resolution?: number;
  114722. size?: number;
  114723. useDirectMapping?: boolean;
  114724. faceForward?: boolean;
  114725. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  114726. private _onBeforeCameraRenderObserver;
  114727. private _changeImageMode;
  114728. /**
  114729. * Releases resources associated with this node.
  114730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114732. */
  114733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114734. }
  114735. }
  114736. declare module BABYLON {
  114737. /**
  114738. * Class used to host RGBD texture specific utilities
  114739. */
  114740. export class RGBDTextureTools {
  114741. /**
  114742. * Expand the RGBD Texture from RGBD to Half Float if possible.
  114743. * @param texture the texture to expand.
  114744. */
  114745. static ExpandRGBDTexture(texture: Texture): void;
  114746. }
  114747. }
  114748. declare module BABYLON {
  114749. /**
  114750. * Class used to host texture specific utilities
  114751. */
  114752. export class BRDFTextureTools {
  114753. /**
  114754. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  114755. * @param scene defines the hosting scene
  114756. * @returns the environment BRDF texture
  114757. */
  114758. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  114759. private static _environmentBRDFBase64Texture;
  114760. }
  114761. }
  114762. declare module BABYLON {
  114763. /**
  114764. * @hidden
  114765. */
  114766. export interface IMaterialClearCoatDefines {
  114767. CLEARCOAT: boolean;
  114768. CLEARCOAT_DEFAULTIOR: boolean;
  114769. CLEARCOAT_TEXTURE: boolean;
  114770. CLEARCOAT_TEXTUREDIRECTUV: number;
  114771. CLEARCOAT_BUMP: boolean;
  114772. CLEARCOAT_BUMPDIRECTUV: number;
  114773. CLEARCOAT_TINT: boolean;
  114774. CLEARCOAT_TINT_TEXTURE: boolean;
  114775. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114776. /** @hidden */
  114777. _areTexturesDirty: boolean;
  114778. }
  114779. /**
  114780. * Define the code related to the clear coat parameters of the pbr material.
  114781. */
  114782. export class PBRClearCoatConfiguration {
  114783. /**
  114784. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114785. * The default fits with a polyurethane material.
  114786. */
  114787. private static readonly _DefaultIndexOfRefraction;
  114788. private _isEnabled;
  114789. /**
  114790. * Defines if the clear coat is enabled in the material.
  114791. */
  114792. isEnabled: boolean;
  114793. /**
  114794. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  114795. */
  114796. intensity: number;
  114797. /**
  114798. * Defines the clear coat layer roughness.
  114799. */
  114800. roughness: number;
  114801. private _indexOfRefraction;
  114802. /**
  114803. * Defines the index of refraction of the clear coat.
  114804. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114805. * The default fits with a polyurethane material.
  114806. * Changing the default value is more performance intensive.
  114807. */
  114808. indexOfRefraction: number;
  114809. private _texture;
  114810. /**
  114811. * Stores the clear coat values in a texture.
  114812. */
  114813. texture: Nullable<BaseTexture>;
  114814. private _bumpTexture;
  114815. /**
  114816. * Define the clear coat specific bump texture.
  114817. */
  114818. bumpTexture: Nullable<BaseTexture>;
  114819. private _isTintEnabled;
  114820. /**
  114821. * Defines if the clear coat tint is enabled in the material.
  114822. */
  114823. isTintEnabled: boolean;
  114824. /**
  114825. * Defines the clear coat tint of the material.
  114826. * This is only use if tint is enabled
  114827. */
  114828. tintColor: Color3;
  114829. /**
  114830. * Defines the distance at which the tint color should be found in the
  114831. * clear coat media.
  114832. * This is only use if tint is enabled
  114833. */
  114834. tintColorAtDistance: number;
  114835. /**
  114836. * Defines the clear coat layer thickness.
  114837. * This is only use if tint is enabled
  114838. */
  114839. tintThickness: number;
  114840. private _tintTexture;
  114841. /**
  114842. * Stores the clear tint values in a texture.
  114843. * rgb is tint
  114844. * a is a thickness factor
  114845. */
  114846. tintTexture: Nullable<BaseTexture>;
  114847. /** @hidden */
  114848. private _internalMarkAllSubMeshesAsTexturesDirty;
  114849. /** @hidden */
  114850. _markAllSubMeshesAsTexturesDirty(): void;
  114851. /**
  114852. * Instantiate a new istance of clear coat configuration.
  114853. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114854. */
  114855. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114856. /**
  114857. * Gets wehter the submesh is ready to be used or not.
  114858. * @param defines the list of "defines" to update.
  114859. * @param scene defines the scene the material belongs to.
  114860. * @param engine defines the engine the material belongs to.
  114861. * @param disableBumpMap defines wether the material disables bump or not.
  114862. * @returns - boolean indicating that the submesh is ready or not.
  114863. */
  114864. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  114865. /**
  114866. * Checks to see if a texture is used in the material.
  114867. * @param defines the list of "defines" to update.
  114868. * @param scene defines the scene to the material belongs to.
  114869. */
  114870. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  114871. /**
  114872. * Binds the material data.
  114873. * @param uniformBuffer defines the Uniform buffer to fill in.
  114874. * @param scene defines the scene the material belongs to.
  114875. * @param engine defines the engine the material belongs to.
  114876. * @param disableBumpMap defines wether the material disables bump or not.
  114877. * @param isFrozen defines wether the material is frozen or not.
  114878. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114879. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114880. */
  114881. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  114882. /**
  114883. * Checks to see if a texture is used in the material.
  114884. * @param texture - Base texture to use.
  114885. * @returns - Boolean specifying if a texture is used in the material.
  114886. */
  114887. hasTexture(texture: BaseTexture): boolean;
  114888. /**
  114889. * Returns an array of the actively used textures.
  114890. * @param activeTextures Array of BaseTextures
  114891. */
  114892. getActiveTextures(activeTextures: BaseTexture[]): void;
  114893. /**
  114894. * Returns the animatable textures.
  114895. * @param animatables Array of animatable textures.
  114896. */
  114897. getAnimatables(animatables: IAnimatable[]): void;
  114898. /**
  114899. * Disposes the resources of the material.
  114900. * @param forceDisposeTextures - Forces the disposal of all textures.
  114901. */
  114902. dispose(forceDisposeTextures?: boolean): void;
  114903. /**
  114904. * Get the current class name of the texture useful for serialization or dynamic coding.
  114905. * @returns "PBRClearCoatConfiguration"
  114906. */
  114907. getClassName(): string;
  114908. /**
  114909. * Add fallbacks to the effect fallbacks list.
  114910. * @param defines defines the Base texture to use.
  114911. * @param fallbacks defines the current fallback list.
  114912. * @param currentRank defines the current fallback rank.
  114913. * @returns the new fallback rank.
  114914. */
  114915. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114916. /**
  114917. * Add the required uniforms to the current list.
  114918. * @param uniforms defines the current uniform list.
  114919. */
  114920. static AddUniforms(uniforms: string[]): void;
  114921. /**
  114922. * Add the required samplers to the current list.
  114923. * @param samplers defines the current sampler list.
  114924. */
  114925. static AddSamplers(samplers: string[]): void;
  114926. /**
  114927. * Add the required uniforms to the current buffer.
  114928. * @param uniformBuffer defines the current uniform buffer.
  114929. */
  114930. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114931. /**
  114932. * Makes a duplicate of the current configuration into another one.
  114933. * @param clearCoatConfiguration define the config where to copy the info
  114934. */
  114935. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  114936. /**
  114937. * Serializes this clear coat configuration.
  114938. * @returns - An object with the serialized config.
  114939. */
  114940. serialize(): any;
  114941. /**
  114942. * Parses a anisotropy Configuration from a serialized object.
  114943. * @param source - Serialized object.
  114944. * @param scene Defines the scene we are parsing for
  114945. * @param rootUrl Defines the rootUrl to load from
  114946. */
  114947. parse(source: any, scene: Scene, rootUrl: string): void;
  114948. }
  114949. }
  114950. declare module BABYLON {
  114951. /**
  114952. * @hidden
  114953. */
  114954. export interface IMaterialAnisotropicDefines {
  114955. ANISOTROPIC: boolean;
  114956. ANISOTROPIC_TEXTURE: boolean;
  114957. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114958. MAINUV1: boolean;
  114959. _areTexturesDirty: boolean;
  114960. _needUVs: boolean;
  114961. }
  114962. /**
  114963. * Define the code related to the anisotropic parameters of the pbr material.
  114964. */
  114965. export class PBRAnisotropicConfiguration {
  114966. private _isEnabled;
  114967. /**
  114968. * Defines if the anisotropy is enabled in the material.
  114969. */
  114970. isEnabled: boolean;
  114971. /**
  114972. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  114973. */
  114974. intensity: number;
  114975. /**
  114976. * Defines if the effect is along the tangents, bitangents or in between.
  114977. * By default, the effect is "strectching" the highlights along the tangents.
  114978. */
  114979. direction: Vector2;
  114980. private _texture;
  114981. /**
  114982. * Stores the anisotropy values in a texture.
  114983. * rg is direction (like normal from -1 to 1)
  114984. * b is a intensity
  114985. */
  114986. texture: Nullable<BaseTexture>;
  114987. /** @hidden */
  114988. private _internalMarkAllSubMeshesAsTexturesDirty;
  114989. /** @hidden */
  114990. _markAllSubMeshesAsTexturesDirty(): void;
  114991. /**
  114992. * Instantiate a new istance of anisotropy configuration.
  114993. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114994. */
  114995. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114996. /**
  114997. * Specifies that the submesh is ready to be used.
  114998. * @param defines the list of "defines" to update.
  114999. * @param scene defines the scene the material belongs to.
  115000. * @returns - boolean indicating that the submesh is ready or not.
  115001. */
  115002. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115003. /**
  115004. * Checks to see if a texture is used in the material.
  115005. * @param defines the list of "defines" to update.
  115006. * @param mesh the mesh we are preparing the defines for.
  115007. * @param scene defines the scene the material belongs to.
  115008. */
  115009. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115010. /**
  115011. * Binds the material data.
  115012. * @param uniformBuffer defines the Uniform buffer to fill in.
  115013. * @param scene defines the scene the material belongs to.
  115014. * @param isFrozen defines wether the material is frozen or not.
  115015. */
  115016. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115017. /**
  115018. * Checks to see if a texture is used in the material.
  115019. * @param texture - Base texture to use.
  115020. * @returns - Boolean specifying if a texture is used in the material.
  115021. */
  115022. hasTexture(texture: BaseTexture): boolean;
  115023. /**
  115024. * Returns an array of the actively used textures.
  115025. * @param activeTextures Array of BaseTextures
  115026. */
  115027. getActiveTextures(activeTextures: BaseTexture[]): void;
  115028. /**
  115029. * Returns the animatable textures.
  115030. * @param animatables Array of animatable textures.
  115031. */
  115032. getAnimatables(animatables: IAnimatable[]): void;
  115033. /**
  115034. * Disposes the resources of the material.
  115035. * @param forceDisposeTextures - Forces the disposal of all textures.
  115036. */
  115037. dispose(forceDisposeTextures?: boolean): void;
  115038. /**
  115039. * Get the current class name of the texture useful for serialization or dynamic coding.
  115040. * @returns "PBRAnisotropicConfiguration"
  115041. */
  115042. getClassName(): string;
  115043. /**
  115044. * Add fallbacks to the effect fallbacks list.
  115045. * @param defines defines the Base texture to use.
  115046. * @param fallbacks defines the current fallback list.
  115047. * @param currentRank defines the current fallback rank.
  115048. * @returns the new fallback rank.
  115049. */
  115050. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115051. /**
  115052. * Add the required uniforms to the current list.
  115053. * @param uniforms defines the current uniform list.
  115054. */
  115055. static AddUniforms(uniforms: string[]): void;
  115056. /**
  115057. * Add the required uniforms to the current buffer.
  115058. * @param uniformBuffer defines the current uniform buffer.
  115059. */
  115060. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115061. /**
  115062. * Add the required samplers to the current list.
  115063. * @param samplers defines the current sampler list.
  115064. */
  115065. static AddSamplers(samplers: string[]): void;
  115066. /**
  115067. * Makes a duplicate of the current configuration into another one.
  115068. * @param anisotropicConfiguration define the config where to copy the info
  115069. */
  115070. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115071. /**
  115072. * Serializes this anisotropy configuration.
  115073. * @returns - An object with the serialized config.
  115074. */
  115075. serialize(): any;
  115076. /**
  115077. * Parses a anisotropy Configuration from a serialized object.
  115078. * @param source - Serialized object.
  115079. * @param scene Defines the scene we are parsing for
  115080. * @param rootUrl Defines the rootUrl to load from
  115081. */
  115082. parse(source: any, scene: Scene, rootUrl: string): void;
  115083. }
  115084. }
  115085. declare module BABYLON {
  115086. /**
  115087. * @hidden
  115088. */
  115089. export interface IMaterialBRDFDefines {
  115090. BRDF_V_HEIGHT_CORRELATED: boolean;
  115091. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115092. SPHERICAL_HARMONICS: boolean;
  115093. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115094. /** @hidden */
  115095. _areMiscDirty: boolean;
  115096. }
  115097. /**
  115098. * Define the code related to the BRDF parameters of the pbr material.
  115099. */
  115100. export class PBRBRDFConfiguration {
  115101. /**
  115102. * Default value used for the energy conservation.
  115103. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115104. */
  115105. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115106. /**
  115107. * Default value used for the Smith Visibility Height Correlated mode.
  115108. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115109. */
  115110. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115111. /**
  115112. * Default value used for the IBL diffuse part.
  115113. * This can help switching back to the polynomials mode globally which is a tiny bit
  115114. * less GPU intensive at the drawback of a lower quality.
  115115. */
  115116. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115117. /**
  115118. * Default value used for activating energy conservation for the specular workflow.
  115119. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115120. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115121. */
  115122. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115123. private _useEnergyConservation;
  115124. /**
  115125. * Defines if the material uses energy conservation.
  115126. */
  115127. useEnergyConservation: boolean;
  115128. private _useSmithVisibilityHeightCorrelated;
  115129. /**
  115130. * LEGACY Mode set to false
  115131. * Defines if the material uses height smith correlated visibility term.
  115132. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115133. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115134. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115135. * Not relying on height correlated will also disable energy conservation.
  115136. */
  115137. useSmithVisibilityHeightCorrelated: boolean;
  115138. private _useSphericalHarmonics;
  115139. /**
  115140. * LEGACY Mode set to false
  115141. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115142. * diffuse part of the IBL.
  115143. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115144. * to the ground truth.
  115145. */
  115146. useSphericalHarmonics: boolean;
  115147. private _useSpecularGlossinessInputEnergyConservation;
  115148. /**
  115149. * Defines if the material uses energy conservation, when the specular workflow is active.
  115150. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115151. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115152. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115153. */
  115154. useSpecularGlossinessInputEnergyConservation: boolean;
  115155. /** @hidden */
  115156. private _internalMarkAllSubMeshesAsMiscDirty;
  115157. /** @hidden */
  115158. _markAllSubMeshesAsMiscDirty(): void;
  115159. /**
  115160. * Instantiate a new istance of clear coat configuration.
  115161. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115162. */
  115163. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115164. /**
  115165. * Checks to see if a texture is used in the material.
  115166. * @param defines the list of "defines" to update.
  115167. */
  115168. prepareDefines(defines: IMaterialBRDFDefines): void;
  115169. /**
  115170. * Get the current class name of the texture useful for serialization or dynamic coding.
  115171. * @returns "PBRClearCoatConfiguration"
  115172. */
  115173. getClassName(): string;
  115174. /**
  115175. * Makes a duplicate of the current configuration into another one.
  115176. * @param brdfConfiguration define the config where to copy the info
  115177. */
  115178. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115179. /**
  115180. * Serializes this BRDF configuration.
  115181. * @returns - An object with the serialized config.
  115182. */
  115183. serialize(): any;
  115184. /**
  115185. * Parses a anisotropy Configuration from a serialized object.
  115186. * @param source - Serialized object.
  115187. * @param scene Defines the scene we are parsing for
  115188. * @param rootUrl Defines the rootUrl to load from
  115189. */
  115190. parse(source: any, scene: Scene, rootUrl: string): void;
  115191. }
  115192. }
  115193. declare module BABYLON {
  115194. /**
  115195. * @hidden
  115196. */
  115197. export interface IMaterialSheenDefines {
  115198. SHEEN: boolean;
  115199. SHEEN_TEXTURE: boolean;
  115200. SHEEN_TEXTUREDIRECTUV: number;
  115201. SHEEN_LINKWITHALBEDO: boolean;
  115202. /** @hidden */
  115203. _areTexturesDirty: boolean;
  115204. }
  115205. /**
  115206. * Define the code related to the Sheen parameters of the pbr material.
  115207. */
  115208. export class PBRSheenConfiguration {
  115209. private _isEnabled;
  115210. /**
  115211. * Defines if the material uses sheen.
  115212. */
  115213. isEnabled: boolean;
  115214. private _linkSheenWithAlbedo;
  115215. /**
  115216. * Defines if the sheen is linked to the sheen color.
  115217. */
  115218. linkSheenWithAlbedo: boolean;
  115219. /**
  115220. * Defines the sheen intensity.
  115221. */
  115222. intensity: number;
  115223. /**
  115224. * Defines the sheen color.
  115225. */
  115226. color: Color3;
  115227. private _texture;
  115228. /**
  115229. * Stores the sheen tint values in a texture.
  115230. * rgb is tint
  115231. * a is a intensity
  115232. */
  115233. texture: Nullable<BaseTexture>;
  115234. /** @hidden */
  115235. private _internalMarkAllSubMeshesAsTexturesDirty;
  115236. /** @hidden */
  115237. _markAllSubMeshesAsTexturesDirty(): void;
  115238. /**
  115239. * Instantiate a new istance of clear coat configuration.
  115240. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115241. */
  115242. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115243. /**
  115244. * Specifies that the submesh is ready to be used.
  115245. * @param defines the list of "defines" to update.
  115246. * @param scene defines the scene the material belongs to.
  115247. * @returns - boolean indicating that the submesh is ready or not.
  115248. */
  115249. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115250. /**
  115251. * Checks to see if a texture is used in the material.
  115252. * @param defines the list of "defines" to update.
  115253. * @param scene defines the scene the material belongs to.
  115254. */
  115255. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115256. /**
  115257. * Binds the material data.
  115258. * @param uniformBuffer defines the Uniform buffer to fill in.
  115259. * @param scene defines the scene the material belongs to.
  115260. * @param isFrozen defines wether the material is frozen or not.
  115261. */
  115262. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115263. /**
  115264. * Checks to see if a texture is used in the material.
  115265. * @param texture - Base texture to use.
  115266. * @returns - Boolean specifying if a texture is used in the material.
  115267. */
  115268. hasTexture(texture: BaseTexture): boolean;
  115269. /**
  115270. * Returns an array of the actively used textures.
  115271. * @param activeTextures Array of BaseTextures
  115272. */
  115273. getActiveTextures(activeTextures: BaseTexture[]): void;
  115274. /**
  115275. * Returns the animatable textures.
  115276. * @param animatables Array of animatable textures.
  115277. */
  115278. getAnimatables(animatables: IAnimatable[]): void;
  115279. /**
  115280. * Disposes the resources of the material.
  115281. * @param forceDisposeTextures - Forces the disposal of all textures.
  115282. */
  115283. dispose(forceDisposeTextures?: boolean): void;
  115284. /**
  115285. * Get the current class name of the texture useful for serialization or dynamic coding.
  115286. * @returns "PBRSheenConfiguration"
  115287. */
  115288. getClassName(): string;
  115289. /**
  115290. * Add fallbacks to the effect fallbacks list.
  115291. * @param defines defines the Base texture to use.
  115292. * @param fallbacks defines the current fallback list.
  115293. * @param currentRank defines the current fallback rank.
  115294. * @returns the new fallback rank.
  115295. */
  115296. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115297. /**
  115298. * Add the required uniforms to the current list.
  115299. * @param uniforms defines the current uniform list.
  115300. */
  115301. static AddUniforms(uniforms: string[]): void;
  115302. /**
  115303. * Add the required uniforms to the current buffer.
  115304. * @param uniformBuffer defines the current uniform buffer.
  115305. */
  115306. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115307. /**
  115308. * Add the required samplers to the current list.
  115309. * @param samplers defines the current sampler list.
  115310. */
  115311. static AddSamplers(samplers: string[]): void;
  115312. /**
  115313. * Makes a duplicate of the current configuration into another one.
  115314. * @param sheenConfiguration define the config where to copy the info
  115315. */
  115316. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  115317. /**
  115318. * Serializes this BRDF configuration.
  115319. * @returns - An object with the serialized config.
  115320. */
  115321. serialize(): any;
  115322. /**
  115323. * Parses a anisotropy Configuration from a serialized object.
  115324. * @param source - Serialized object.
  115325. * @param scene Defines the scene we are parsing for
  115326. * @param rootUrl Defines the rootUrl to load from
  115327. */
  115328. parse(source: any, scene: Scene, rootUrl: string): void;
  115329. }
  115330. }
  115331. declare module BABYLON {
  115332. /**
  115333. * @hidden
  115334. */
  115335. export interface IMaterialSubSurfaceDefines {
  115336. SUBSURFACE: boolean;
  115337. SS_REFRACTION: boolean;
  115338. SS_TRANSLUCENCY: boolean;
  115339. SS_SCATERRING: boolean;
  115340. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115341. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115342. SS_REFRACTIONMAP_3D: boolean;
  115343. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115344. SS_LODINREFRACTIONALPHA: boolean;
  115345. SS_GAMMAREFRACTION: boolean;
  115346. SS_RGBDREFRACTION: boolean;
  115347. SS_LINEARSPECULARREFRACTION: boolean;
  115348. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115349. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115350. /** @hidden */
  115351. _areTexturesDirty: boolean;
  115352. }
  115353. /**
  115354. * Define the code related to the sub surface parameters of the pbr material.
  115355. */
  115356. export class PBRSubSurfaceConfiguration {
  115357. private _isRefractionEnabled;
  115358. /**
  115359. * Defines if the refraction is enabled in the material.
  115360. */
  115361. isRefractionEnabled: boolean;
  115362. private _isTranslucencyEnabled;
  115363. /**
  115364. * Defines if the translucency is enabled in the material.
  115365. */
  115366. isTranslucencyEnabled: boolean;
  115367. private _isScatteringEnabled;
  115368. /**
  115369. * Defines the refraction intensity of the material.
  115370. * The refraction when enabled replaces the Diffuse part of the material.
  115371. * The intensity helps transitionning between diffuse and refraction.
  115372. */
  115373. refractionIntensity: number;
  115374. /**
  115375. * Defines the translucency intensity of the material.
  115376. * When translucency has been enabled, this defines how much of the "translucency"
  115377. * is addded to the diffuse part of the material.
  115378. */
  115379. translucencyIntensity: number;
  115380. /**
  115381. * Defines the scattering intensity of the material.
  115382. * When scattering has been enabled, this defines how much of the "scattered light"
  115383. * is addded to the diffuse part of the material.
  115384. */
  115385. scatteringIntensity: number;
  115386. private _thicknessTexture;
  115387. /**
  115388. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115389. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115390. * 0 would mean minimumThickness
  115391. * 1 would mean maximumThickness
  115392. * The other channels might be use as a mask to vary the different effects intensity.
  115393. */
  115394. thicknessTexture: Nullable<BaseTexture>;
  115395. private _refractionTexture;
  115396. /**
  115397. * Defines the texture to use for refraction.
  115398. */
  115399. refractionTexture: Nullable<BaseTexture>;
  115400. private _indexOfRefraction;
  115401. /**
  115402. * Defines the index of refraction used in the material.
  115403. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  115404. */
  115405. indexOfRefraction: number;
  115406. private _invertRefractionY;
  115407. /**
  115408. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115409. */
  115410. invertRefractionY: boolean;
  115411. private _linkRefractionWithTransparency;
  115412. /**
  115413. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115414. * Materials half opaque for instance using refraction could benefit from this control.
  115415. */
  115416. linkRefractionWithTransparency: boolean;
  115417. /**
  115418. * Defines the minimum thickness stored in the thickness map.
  115419. * If no thickness map is defined, this value will be used to simulate thickness.
  115420. */
  115421. minimumThickness: number;
  115422. /**
  115423. * Defines the maximum thickness stored in the thickness map.
  115424. */
  115425. maximumThickness: number;
  115426. /**
  115427. * Defines the volume tint of the material.
  115428. * This is used for both translucency and scattering.
  115429. */
  115430. tintColor: Color3;
  115431. /**
  115432. * Defines the distance at which the tint color should be found in the media.
  115433. * This is used for refraction only.
  115434. */
  115435. tintColorAtDistance: number;
  115436. /**
  115437. * Defines how far each channel transmit through the media.
  115438. * It is defined as a color to simplify it selection.
  115439. */
  115440. diffusionDistance: Color3;
  115441. private _useMaskFromThicknessTexture;
  115442. /**
  115443. * Stores the intensity of the different subsurface effects in the thickness texture.
  115444. * * the green channel is the translucency intensity.
  115445. * * the blue channel is the scattering intensity.
  115446. * * the alpha channel is the refraction intensity.
  115447. */
  115448. useMaskFromThicknessTexture: boolean;
  115449. /** @hidden */
  115450. private _internalMarkAllSubMeshesAsTexturesDirty;
  115451. /** @hidden */
  115452. _markAllSubMeshesAsTexturesDirty(): void;
  115453. /**
  115454. * Instantiate a new istance of sub surface configuration.
  115455. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115456. */
  115457. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115458. /**
  115459. * Gets wehter the submesh is ready to be used or not.
  115460. * @param defines the list of "defines" to update.
  115461. * @param scene defines the scene the material belongs to.
  115462. * @returns - boolean indicating that the submesh is ready or not.
  115463. */
  115464. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  115465. /**
  115466. * Checks to see if a texture is used in the material.
  115467. * @param defines the list of "defines" to update.
  115468. * @param scene defines the scene to the material belongs to.
  115469. */
  115470. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  115471. /**
  115472. * Binds the material data.
  115473. * @param uniformBuffer defines the Uniform buffer to fill in.
  115474. * @param scene defines the scene the material belongs to.
  115475. * @param engine defines the engine the material belongs to.
  115476. * @param isFrozen defines wether the material is frozen or not.
  115477. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  115478. */
  115479. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  115480. /**
  115481. * Unbinds the material from the mesh.
  115482. * @param activeEffect defines the effect that should be unbound from.
  115483. * @returns true if unbound, otherwise false
  115484. */
  115485. unbind(activeEffect: Effect): boolean;
  115486. /**
  115487. * Returns the texture used for refraction or null if none is used.
  115488. * @param scene defines the scene the material belongs to.
  115489. * @returns - Refraction texture if present. If no refraction texture and refraction
  115490. * is linked with transparency, returns environment texture. Otherwise, returns null.
  115491. */
  115492. private _getRefractionTexture;
  115493. /**
  115494. * Returns true if alpha blending should be disabled.
  115495. */
  115496. readonly disableAlphaBlending: boolean;
  115497. /**
  115498. * Fills the list of render target textures.
  115499. * @param renderTargets the list of render targets to update
  115500. */
  115501. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  115502. /**
  115503. * Checks to see if a texture is used in the material.
  115504. * @param texture - Base texture to use.
  115505. * @returns - Boolean specifying if a texture is used in the material.
  115506. */
  115507. hasTexture(texture: BaseTexture): boolean;
  115508. /**
  115509. * Gets a boolean indicating that current material needs to register RTT
  115510. * @returns true if this uses a render target otherwise false.
  115511. */
  115512. hasRenderTargetTextures(): boolean;
  115513. /**
  115514. * Returns an array of the actively used textures.
  115515. * @param activeTextures Array of BaseTextures
  115516. */
  115517. getActiveTextures(activeTextures: BaseTexture[]): void;
  115518. /**
  115519. * Returns the animatable textures.
  115520. * @param animatables Array of animatable textures.
  115521. */
  115522. getAnimatables(animatables: IAnimatable[]): void;
  115523. /**
  115524. * Disposes the resources of the material.
  115525. * @param forceDisposeTextures - Forces the disposal of all textures.
  115526. */
  115527. dispose(forceDisposeTextures?: boolean): void;
  115528. /**
  115529. * Get the current class name of the texture useful for serialization or dynamic coding.
  115530. * @returns "PBRSubSurfaceConfiguration"
  115531. */
  115532. getClassName(): string;
  115533. /**
  115534. * Add fallbacks to the effect fallbacks list.
  115535. * @param defines defines the Base texture to use.
  115536. * @param fallbacks defines the current fallback list.
  115537. * @param currentRank defines the current fallback rank.
  115538. * @returns the new fallback rank.
  115539. */
  115540. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115541. /**
  115542. * Add the required uniforms to the current list.
  115543. * @param uniforms defines the current uniform list.
  115544. */
  115545. static AddUniforms(uniforms: string[]): void;
  115546. /**
  115547. * Add the required samplers to the current list.
  115548. * @param samplers defines the current sampler list.
  115549. */
  115550. static AddSamplers(samplers: string[]): void;
  115551. /**
  115552. * Add the required uniforms to the current buffer.
  115553. * @param uniformBuffer defines the current uniform buffer.
  115554. */
  115555. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115556. /**
  115557. * Makes a duplicate of the current configuration into another one.
  115558. * @param configuration define the config where to copy the info
  115559. */
  115560. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  115561. /**
  115562. * Serializes this Sub Surface configuration.
  115563. * @returns - An object with the serialized config.
  115564. */
  115565. serialize(): any;
  115566. /**
  115567. * Parses a anisotropy Configuration from a serialized object.
  115568. * @param source - Serialized object.
  115569. * @param scene Defines the scene we are parsing for
  115570. * @param rootUrl Defines the rootUrl to load from
  115571. */
  115572. parse(source: any, scene: Scene, rootUrl: string): void;
  115573. }
  115574. }
  115575. declare module BABYLON {
  115576. /** @hidden */
  115577. export var pbrFragmentDeclaration: {
  115578. name: string;
  115579. shader: string;
  115580. };
  115581. }
  115582. declare module BABYLON {
  115583. /** @hidden */
  115584. export var pbrUboDeclaration: {
  115585. name: string;
  115586. shader: string;
  115587. };
  115588. }
  115589. declare module BABYLON {
  115590. /** @hidden */
  115591. export var pbrFragmentExtraDeclaration: {
  115592. name: string;
  115593. shader: string;
  115594. };
  115595. }
  115596. declare module BABYLON {
  115597. /** @hidden */
  115598. export var pbrFragmentSamplersDeclaration: {
  115599. name: string;
  115600. shader: string;
  115601. };
  115602. }
  115603. declare module BABYLON {
  115604. /** @hidden */
  115605. export var pbrHelperFunctions: {
  115606. name: string;
  115607. shader: string;
  115608. };
  115609. }
  115610. declare module BABYLON {
  115611. /** @hidden */
  115612. export var harmonicsFunctions: {
  115613. name: string;
  115614. shader: string;
  115615. };
  115616. }
  115617. declare module BABYLON {
  115618. /** @hidden */
  115619. export var pbrDirectLightingSetupFunctions: {
  115620. name: string;
  115621. shader: string;
  115622. };
  115623. }
  115624. declare module BABYLON {
  115625. /** @hidden */
  115626. export var pbrDirectLightingFalloffFunctions: {
  115627. name: string;
  115628. shader: string;
  115629. };
  115630. }
  115631. declare module BABYLON {
  115632. /** @hidden */
  115633. export var pbrBRDFFunctions: {
  115634. name: string;
  115635. shader: string;
  115636. };
  115637. }
  115638. declare module BABYLON {
  115639. /** @hidden */
  115640. export var pbrDirectLightingFunctions: {
  115641. name: string;
  115642. shader: string;
  115643. };
  115644. }
  115645. declare module BABYLON {
  115646. /** @hidden */
  115647. export var pbrIBLFunctions: {
  115648. name: string;
  115649. shader: string;
  115650. };
  115651. }
  115652. declare module BABYLON {
  115653. /** @hidden */
  115654. export var pbrDebug: {
  115655. name: string;
  115656. shader: string;
  115657. };
  115658. }
  115659. declare module BABYLON {
  115660. /** @hidden */
  115661. export var pbrPixelShader: {
  115662. name: string;
  115663. shader: string;
  115664. };
  115665. }
  115666. declare module BABYLON {
  115667. /** @hidden */
  115668. export var pbrVertexDeclaration: {
  115669. name: string;
  115670. shader: string;
  115671. };
  115672. }
  115673. declare module BABYLON {
  115674. /** @hidden */
  115675. export var pbrVertexShader: {
  115676. name: string;
  115677. shader: string;
  115678. };
  115679. }
  115680. declare module BABYLON {
  115681. /**
  115682. * Manages the defines for the PBR Material.
  115683. * @hidden
  115684. */
  115685. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  115686. PBR: boolean;
  115687. MAINUV1: boolean;
  115688. MAINUV2: boolean;
  115689. UV1: boolean;
  115690. UV2: boolean;
  115691. ALBEDO: boolean;
  115692. ALBEDODIRECTUV: number;
  115693. VERTEXCOLOR: boolean;
  115694. AMBIENT: boolean;
  115695. AMBIENTDIRECTUV: number;
  115696. AMBIENTINGRAYSCALE: boolean;
  115697. OPACITY: boolean;
  115698. VERTEXALPHA: boolean;
  115699. OPACITYDIRECTUV: number;
  115700. OPACITYRGB: boolean;
  115701. ALPHATEST: boolean;
  115702. DEPTHPREPASS: boolean;
  115703. ALPHABLEND: boolean;
  115704. ALPHAFROMALBEDO: boolean;
  115705. ALPHATESTVALUE: string;
  115706. SPECULAROVERALPHA: boolean;
  115707. RADIANCEOVERALPHA: boolean;
  115708. ALPHAFRESNEL: boolean;
  115709. LINEARALPHAFRESNEL: boolean;
  115710. PREMULTIPLYALPHA: boolean;
  115711. EMISSIVE: boolean;
  115712. EMISSIVEDIRECTUV: number;
  115713. REFLECTIVITY: boolean;
  115714. REFLECTIVITYDIRECTUV: number;
  115715. SPECULARTERM: boolean;
  115716. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  115717. MICROSURFACEAUTOMATIC: boolean;
  115718. LODBASEDMICROSFURACE: boolean;
  115719. MICROSURFACEMAP: boolean;
  115720. MICROSURFACEMAPDIRECTUV: number;
  115721. METALLICWORKFLOW: boolean;
  115722. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  115723. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  115724. METALLNESSSTOREINMETALMAPBLUE: boolean;
  115725. AOSTOREINMETALMAPRED: boolean;
  115726. METALLICF0FACTORFROMMETALLICMAP: boolean;
  115727. ENVIRONMENTBRDF: boolean;
  115728. ENVIRONMENTBRDF_RGBD: boolean;
  115729. NORMAL: boolean;
  115730. TANGENT: boolean;
  115731. BUMP: boolean;
  115732. BUMPDIRECTUV: number;
  115733. OBJECTSPACE_NORMALMAP: boolean;
  115734. PARALLAX: boolean;
  115735. PARALLAXOCCLUSION: boolean;
  115736. NORMALXYSCALE: boolean;
  115737. LIGHTMAP: boolean;
  115738. LIGHTMAPDIRECTUV: number;
  115739. USELIGHTMAPASSHADOWMAP: boolean;
  115740. GAMMALIGHTMAP: boolean;
  115741. RGBDLIGHTMAP: boolean;
  115742. REFLECTION: boolean;
  115743. REFLECTIONMAP_3D: boolean;
  115744. REFLECTIONMAP_SPHERICAL: boolean;
  115745. REFLECTIONMAP_PLANAR: boolean;
  115746. REFLECTIONMAP_CUBIC: boolean;
  115747. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115748. REFLECTIONMAP_PROJECTION: boolean;
  115749. REFLECTIONMAP_SKYBOX: boolean;
  115750. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  115751. REFLECTIONMAP_EXPLICIT: boolean;
  115752. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  115753. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  115754. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  115755. INVERTCUBICMAP: boolean;
  115756. USESPHERICALFROMREFLECTIONMAP: boolean;
  115757. USEIRRADIANCEMAP: boolean;
  115758. SPHERICAL_HARMONICS: boolean;
  115759. USESPHERICALINVERTEX: boolean;
  115760. REFLECTIONMAP_OPPOSITEZ: boolean;
  115761. LODINREFLECTIONALPHA: boolean;
  115762. GAMMAREFLECTION: boolean;
  115763. RGBDREFLECTION: boolean;
  115764. LINEARSPECULARREFLECTION: boolean;
  115765. RADIANCEOCCLUSION: boolean;
  115766. HORIZONOCCLUSION: boolean;
  115767. INSTANCES: boolean;
  115768. NUM_BONE_INFLUENCERS: number;
  115769. BonesPerMesh: number;
  115770. BONETEXTURE: boolean;
  115771. NONUNIFORMSCALING: boolean;
  115772. MORPHTARGETS: boolean;
  115773. MORPHTARGETS_NORMAL: boolean;
  115774. MORPHTARGETS_TANGENT: boolean;
  115775. MORPHTARGETS_UV: boolean;
  115776. NUM_MORPH_INFLUENCERS: number;
  115777. IMAGEPROCESSING: boolean;
  115778. VIGNETTE: boolean;
  115779. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115780. VIGNETTEBLENDMODEOPAQUE: boolean;
  115781. TONEMAPPING: boolean;
  115782. TONEMAPPING_ACES: boolean;
  115783. CONTRAST: boolean;
  115784. COLORCURVES: boolean;
  115785. COLORGRADING: boolean;
  115786. COLORGRADING3D: boolean;
  115787. SAMPLER3DGREENDEPTH: boolean;
  115788. SAMPLER3DBGRMAP: boolean;
  115789. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115790. EXPOSURE: boolean;
  115791. MULTIVIEW: boolean;
  115792. USEPHYSICALLIGHTFALLOFF: boolean;
  115793. USEGLTFLIGHTFALLOFF: boolean;
  115794. TWOSIDEDLIGHTING: boolean;
  115795. SHADOWFLOAT: boolean;
  115796. CLIPPLANE: boolean;
  115797. CLIPPLANE2: boolean;
  115798. CLIPPLANE3: boolean;
  115799. CLIPPLANE4: boolean;
  115800. POINTSIZE: boolean;
  115801. FOG: boolean;
  115802. LOGARITHMICDEPTH: boolean;
  115803. FORCENORMALFORWARD: boolean;
  115804. SPECULARAA: boolean;
  115805. CLEARCOAT: boolean;
  115806. CLEARCOAT_DEFAULTIOR: boolean;
  115807. CLEARCOAT_TEXTURE: boolean;
  115808. CLEARCOAT_TEXTUREDIRECTUV: number;
  115809. CLEARCOAT_BUMP: boolean;
  115810. CLEARCOAT_BUMPDIRECTUV: number;
  115811. CLEARCOAT_TINT: boolean;
  115812. CLEARCOAT_TINT_TEXTURE: boolean;
  115813. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115814. ANISOTROPIC: boolean;
  115815. ANISOTROPIC_TEXTURE: boolean;
  115816. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115817. BRDF_V_HEIGHT_CORRELATED: boolean;
  115818. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115819. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115820. SHEEN: boolean;
  115821. SHEEN_TEXTURE: boolean;
  115822. SHEEN_TEXTUREDIRECTUV: number;
  115823. SHEEN_LINKWITHALBEDO: boolean;
  115824. SUBSURFACE: boolean;
  115825. SS_REFRACTION: boolean;
  115826. SS_TRANSLUCENCY: boolean;
  115827. SS_SCATERRING: boolean;
  115828. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115829. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115830. SS_REFRACTIONMAP_3D: boolean;
  115831. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115832. SS_LODINREFRACTIONALPHA: boolean;
  115833. SS_GAMMAREFRACTION: boolean;
  115834. SS_RGBDREFRACTION: boolean;
  115835. SS_LINEARSPECULARREFRACTION: boolean;
  115836. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115837. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115838. UNLIT: boolean;
  115839. DEBUGMODE: number;
  115840. /**
  115841. * Initializes the PBR Material defines.
  115842. */
  115843. constructor();
  115844. /**
  115845. * Resets the PBR Material defines.
  115846. */
  115847. reset(): void;
  115848. }
  115849. /**
  115850. * The Physically based material base class of BJS.
  115851. *
  115852. * This offers the main features of a standard PBR material.
  115853. * For more information, please refer to the documentation :
  115854. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115855. */
  115856. export abstract class PBRBaseMaterial extends PushMaterial {
  115857. /**
  115858. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115859. */
  115860. static readonly PBRMATERIAL_OPAQUE: number;
  115861. /**
  115862. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115863. */
  115864. static readonly PBRMATERIAL_ALPHATEST: number;
  115865. /**
  115866. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115867. */
  115868. static readonly PBRMATERIAL_ALPHABLEND: number;
  115869. /**
  115870. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115871. * They are also discarded below the alpha cutoff threshold to improve performances.
  115872. */
  115873. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115874. /**
  115875. * Defines the default value of how much AO map is occluding the analytical lights
  115876. * (point spot...).
  115877. */
  115878. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115879. /**
  115880. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  115881. */
  115882. static readonly LIGHTFALLOFF_PHYSICAL: number;
  115883. /**
  115884. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  115885. * to enhance interoperability with other engines.
  115886. */
  115887. static readonly LIGHTFALLOFF_GLTF: number;
  115888. /**
  115889. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  115890. * to enhance interoperability with other materials.
  115891. */
  115892. static readonly LIGHTFALLOFF_STANDARD: number;
  115893. /**
  115894. * Intensity of the direct lights e.g. the four lights available in your scene.
  115895. * This impacts both the direct diffuse and specular highlights.
  115896. */
  115897. protected _directIntensity: number;
  115898. /**
  115899. * Intensity of the emissive part of the material.
  115900. * This helps controlling the emissive effect without modifying the emissive color.
  115901. */
  115902. protected _emissiveIntensity: number;
  115903. /**
  115904. * Intensity of the environment e.g. how much the environment will light the object
  115905. * either through harmonics for rough material or through the refelction for shiny ones.
  115906. */
  115907. protected _environmentIntensity: number;
  115908. /**
  115909. * This is a special control allowing the reduction of the specular highlights coming from the
  115910. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115911. */
  115912. protected _specularIntensity: number;
  115913. /**
  115914. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  115915. */
  115916. private _lightingInfos;
  115917. /**
  115918. * Debug Control allowing disabling the bump map on this material.
  115919. */
  115920. protected _disableBumpMap: boolean;
  115921. /**
  115922. * AKA Diffuse Texture in standard nomenclature.
  115923. */
  115924. protected _albedoTexture: Nullable<BaseTexture>;
  115925. /**
  115926. * AKA Occlusion Texture in other nomenclature.
  115927. */
  115928. protected _ambientTexture: Nullable<BaseTexture>;
  115929. /**
  115930. * AKA Occlusion Texture Intensity in other nomenclature.
  115931. */
  115932. protected _ambientTextureStrength: number;
  115933. /**
  115934. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115935. * 1 means it completely occludes it
  115936. * 0 mean it has no impact
  115937. */
  115938. protected _ambientTextureImpactOnAnalyticalLights: number;
  115939. /**
  115940. * Stores the alpha values in a texture.
  115941. */
  115942. protected _opacityTexture: Nullable<BaseTexture>;
  115943. /**
  115944. * Stores the reflection values in a texture.
  115945. */
  115946. protected _reflectionTexture: Nullable<BaseTexture>;
  115947. /**
  115948. * Stores the emissive values in a texture.
  115949. */
  115950. protected _emissiveTexture: Nullable<BaseTexture>;
  115951. /**
  115952. * AKA Specular texture in other nomenclature.
  115953. */
  115954. protected _reflectivityTexture: Nullable<BaseTexture>;
  115955. /**
  115956. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115957. */
  115958. protected _metallicTexture: Nullable<BaseTexture>;
  115959. /**
  115960. * Specifies the metallic scalar of the metallic/roughness workflow.
  115961. * Can also be used to scale the metalness values of the metallic texture.
  115962. */
  115963. protected _metallic: Nullable<number>;
  115964. /**
  115965. * Specifies the roughness scalar of the metallic/roughness workflow.
  115966. * Can also be used to scale the roughness values of the metallic texture.
  115967. */
  115968. protected _roughness: Nullable<number>;
  115969. /**
  115970. * Specifies the an F0 factor to help configuring the material F0.
  115971. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  115972. * to 0.5 the previously hard coded value stays the same.
  115973. * Can also be used to scale the F0 values of the metallic texture.
  115974. */
  115975. protected _metallicF0Factor: number;
  115976. /**
  115977. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  115978. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  115979. * your expectation as it multiplies with the texture data.
  115980. */
  115981. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  115982. /**
  115983. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115984. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115985. */
  115986. protected _microSurfaceTexture: Nullable<BaseTexture>;
  115987. /**
  115988. * Stores surface normal data used to displace a mesh in a texture.
  115989. */
  115990. protected _bumpTexture: Nullable<BaseTexture>;
  115991. /**
  115992. * Stores the pre-calculated light information of a mesh in a texture.
  115993. */
  115994. protected _lightmapTexture: Nullable<BaseTexture>;
  115995. /**
  115996. * The color of a material in ambient lighting.
  115997. */
  115998. protected _ambientColor: Color3;
  115999. /**
  116000. * AKA Diffuse Color in other nomenclature.
  116001. */
  116002. protected _albedoColor: Color3;
  116003. /**
  116004. * AKA Specular Color in other nomenclature.
  116005. */
  116006. protected _reflectivityColor: Color3;
  116007. /**
  116008. * The color applied when light is reflected from a material.
  116009. */
  116010. protected _reflectionColor: Color3;
  116011. /**
  116012. * The color applied when light is emitted from a material.
  116013. */
  116014. protected _emissiveColor: Color3;
  116015. /**
  116016. * AKA Glossiness in other nomenclature.
  116017. */
  116018. protected _microSurface: number;
  116019. /**
  116020. * Specifies that the material will use the light map as a show map.
  116021. */
  116022. protected _useLightmapAsShadowmap: boolean;
  116023. /**
  116024. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116025. * makes the reflect vector face the model (under horizon).
  116026. */
  116027. protected _useHorizonOcclusion: boolean;
  116028. /**
  116029. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116030. * too much the area relying on ambient texture to define their ambient occlusion.
  116031. */
  116032. protected _useRadianceOcclusion: boolean;
  116033. /**
  116034. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116035. */
  116036. protected _useAlphaFromAlbedoTexture: boolean;
  116037. /**
  116038. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116039. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116040. */
  116041. protected _useSpecularOverAlpha: boolean;
  116042. /**
  116043. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116044. */
  116045. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116046. /**
  116047. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116048. */
  116049. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116050. /**
  116051. * Specifies if the metallic texture contains the roughness information in its green channel.
  116052. */
  116053. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116054. /**
  116055. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116056. */
  116057. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116058. /**
  116059. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116060. */
  116061. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116062. /**
  116063. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116064. */
  116065. protected _useAmbientInGrayScale: boolean;
  116066. /**
  116067. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116068. * The material will try to infer what glossiness each pixel should be.
  116069. */
  116070. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116071. /**
  116072. * Defines the falloff type used in this material.
  116073. * It by default is Physical.
  116074. */
  116075. protected _lightFalloff: number;
  116076. /**
  116077. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116078. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116079. */
  116080. protected _useRadianceOverAlpha: boolean;
  116081. /**
  116082. * Allows using an object space normal map (instead of tangent space).
  116083. */
  116084. protected _useObjectSpaceNormalMap: boolean;
  116085. /**
  116086. * Allows using the bump map in parallax mode.
  116087. */
  116088. protected _useParallax: boolean;
  116089. /**
  116090. * Allows using the bump map in parallax occlusion mode.
  116091. */
  116092. protected _useParallaxOcclusion: boolean;
  116093. /**
  116094. * Controls the scale bias of the parallax mode.
  116095. */
  116096. protected _parallaxScaleBias: number;
  116097. /**
  116098. * If sets to true, disables all the lights affecting the material.
  116099. */
  116100. protected _disableLighting: boolean;
  116101. /**
  116102. * Number of Simultaneous lights allowed on the material.
  116103. */
  116104. protected _maxSimultaneousLights: number;
  116105. /**
  116106. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116107. */
  116108. protected _invertNormalMapX: boolean;
  116109. /**
  116110. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116111. */
  116112. protected _invertNormalMapY: boolean;
  116113. /**
  116114. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116115. */
  116116. protected _twoSidedLighting: boolean;
  116117. /**
  116118. * Defines the alpha limits in alpha test mode.
  116119. */
  116120. protected _alphaCutOff: number;
  116121. /**
  116122. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116123. */
  116124. protected _forceAlphaTest: boolean;
  116125. /**
  116126. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116127. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116128. */
  116129. protected _useAlphaFresnel: boolean;
  116130. /**
  116131. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116132. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116133. */
  116134. protected _useLinearAlphaFresnel: boolean;
  116135. /**
  116136. * The transparency mode of the material.
  116137. */
  116138. protected _transparencyMode: Nullable<number>;
  116139. /**
  116140. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116141. * from cos thetav and roughness:
  116142. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116143. */
  116144. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116145. /**
  116146. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116147. */
  116148. protected _forceIrradianceInFragment: boolean;
  116149. /**
  116150. * Force normal to face away from face.
  116151. */
  116152. protected _forceNormalForward: boolean;
  116153. /**
  116154. * Enables specular anti aliasing in the PBR shader.
  116155. * It will both interacts on the Geometry for analytical and IBL lighting.
  116156. * It also prefilter the roughness map based on the bump values.
  116157. */
  116158. protected _enableSpecularAntiAliasing: boolean;
  116159. /**
  116160. * Default configuration related to image processing available in the PBR Material.
  116161. */
  116162. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116163. /**
  116164. * Keep track of the image processing observer to allow dispose and replace.
  116165. */
  116166. private _imageProcessingObserver;
  116167. /**
  116168. * Attaches a new image processing configuration to the PBR Material.
  116169. * @param configuration
  116170. */
  116171. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116172. /**
  116173. * Stores the available render targets.
  116174. */
  116175. private _renderTargets;
  116176. /**
  116177. * Sets the global ambient color for the material used in lighting calculations.
  116178. */
  116179. private _globalAmbientColor;
  116180. /**
  116181. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116182. */
  116183. private _useLogarithmicDepth;
  116184. /**
  116185. * If set to true, no lighting calculations will be applied.
  116186. */
  116187. private _unlit;
  116188. private _debugMode;
  116189. /**
  116190. * @hidden
  116191. * This is reserved for the inspector.
  116192. * Defines the material debug mode.
  116193. * It helps seeing only some components of the material while troubleshooting.
  116194. */
  116195. debugMode: number;
  116196. /**
  116197. * @hidden
  116198. * This is reserved for the inspector.
  116199. * Specify from where on screen the debug mode should start.
  116200. * The value goes from -1 (full screen) to 1 (not visible)
  116201. * It helps with side by side comparison against the final render
  116202. * This defaults to -1
  116203. */
  116204. private debugLimit;
  116205. /**
  116206. * @hidden
  116207. * This is reserved for the inspector.
  116208. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116209. * You can use the factor to better multiply the final value.
  116210. */
  116211. private debugFactor;
  116212. /**
  116213. * Defines the clear coat layer parameters for the material.
  116214. */
  116215. readonly clearCoat: PBRClearCoatConfiguration;
  116216. /**
  116217. * Defines the anisotropic parameters for the material.
  116218. */
  116219. readonly anisotropy: PBRAnisotropicConfiguration;
  116220. /**
  116221. * Defines the BRDF parameters for the material.
  116222. */
  116223. readonly brdf: PBRBRDFConfiguration;
  116224. /**
  116225. * Defines the Sheen parameters for the material.
  116226. */
  116227. readonly sheen: PBRSheenConfiguration;
  116228. /**
  116229. * Defines the SubSurface parameters for the material.
  116230. */
  116231. readonly subSurface: PBRSubSurfaceConfiguration;
  116232. /**
  116233. * Custom callback helping to override the default shader used in the material.
  116234. */
  116235. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116236. protected _rebuildInParallel: boolean;
  116237. /**
  116238. * Instantiates a new PBRMaterial instance.
  116239. *
  116240. * @param name The material name
  116241. * @param scene The scene the material will be use in.
  116242. */
  116243. constructor(name: string, scene: Scene);
  116244. /**
  116245. * Gets a boolean indicating that current material needs to register RTT
  116246. */
  116247. readonly hasRenderTargetTextures: boolean;
  116248. /**
  116249. * Gets the name of the material class.
  116250. */
  116251. getClassName(): string;
  116252. /**
  116253. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116254. */
  116255. /**
  116256. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116257. */
  116258. useLogarithmicDepth: boolean;
  116259. /**
  116260. * Gets the current transparency mode.
  116261. */
  116262. /**
  116263. * Sets the transparency mode of the material.
  116264. *
  116265. * | Value | Type | Description |
  116266. * | ----- | ----------------------------------- | ----------- |
  116267. * | 0 | OPAQUE | |
  116268. * | 1 | ALPHATEST | |
  116269. * | 2 | ALPHABLEND | |
  116270. * | 3 | ALPHATESTANDBLEND | |
  116271. *
  116272. */
  116273. transparencyMode: Nullable<number>;
  116274. /**
  116275. * Returns true if alpha blending should be disabled.
  116276. */
  116277. private readonly _disableAlphaBlending;
  116278. /**
  116279. * Specifies whether or not this material should be rendered in alpha blend mode.
  116280. */
  116281. needAlphaBlending(): boolean;
  116282. /**
  116283. * Specifies if the mesh will require alpha blending.
  116284. * @param mesh - BJS mesh.
  116285. */
  116286. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116287. /**
  116288. * Specifies whether or not this material should be rendered in alpha test mode.
  116289. */
  116290. needAlphaTesting(): boolean;
  116291. /**
  116292. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116293. */
  116294. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116295. /**
  116296. * Gets the texture used for the alpha test.
  116297. */
  116298. getAlphaTestTexture(): Nullable<BaseTexture>;
  116299. /**
  116300. * Specifies that the submesh is ready to be used.
  116301. * @param mesh - BJS mesh.
  116302. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  116303. * @param useInstances - Specifies that instances should be used.
  116304. * @returns - boolean indicating that the submesh is ready or not.
  116305. */
  116306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116307. /**
  116308. * Specifies if the material uses metallic roughness workflow.
  116309. * @returns boolean specifiying if the material uses metallic roughness workflow.
  116310. */
  116311. isMetallicWorkflow(): boolean;
  116312. private _prepareEffect;
  116313. private _prepareDefines;
  116314. /**
  116315. * Force shader compilation
  116316. */
  116317. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  116318. /**
  116319. * Initializes the uniform buffer layout for the shader.
  116320. */
  116321. buildUniformLayout(): void;
  116322. /**
  116323. * Unbinds the material from the mesh
  116324. */
  116325. unbind(): void;
  116326. /**
  116327. * Binds the submesh data.
  116328. * @param world - The world matrix.
  116329. * @param mesh - The BJS mesh.
  116330. * @param subMesh - A submesh of the BJS mesh.
  116331. */
  116332. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116333. /**
  116334. * Returns the animatable textures.
  116335. * @returns - Array of animatable textures.
  116336. */
  116337. getAnimatables(): IAnimatable[];
  116338. /**
  116339. * Returns the texture used for reflections.
  116340. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  116341. */
  116342. private _getReflectionTexture;
  116343. /**
  116344. * Returns an array of the actively used textures.
  116345. * @returns - Array of BaseTextures
  116346. */
  116347. getActiveTextures(): BaseTexture[];
  116348. /**
  116349. * Checks to see if a texture is used in the material.
  116350. * @param texture - Base texture to use.
  116351. * @returns - Boolean specifying if a texture is used in the material.
  116352. */
  116353. hasTexture(texture: BaseTexture): boolean;
  116354. /**
  116355. * Disposes the resources of the material.
  116356. * @param forceDisposeEffect - Forces the disposal of effects.
  116357. * @param forceDisposeTextures - Forces the disposal of all textures.
  116358. */
  116359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116360. }
  116361. }
  116362. declare module BABYLON {
  116363. /**
  116364. * The Physically based material of BJS.
  116365. *
  116366. * This offers the main features of a standard PBR material.
  116367. * For more information, please refer to the documentation :
  116368. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116369. */
  116370. export class PBRMaterial extends PBRBaseMaterial {
  116371. /**
  116372. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116373. */
  116374. static readonly PBRMATERIAL_OPAQUE: number;
  116375. /**
  116376. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116377. */
  116378. static readonly PBRMATERIAL_ALPHATEST: number;
  116379. /**
  116380. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116381. */
  116382. static readonly PBRMATERIAL_ALPHABLEND: number;
  116383. /**
  116384. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116385. * They are also discarded below the alpha cutoff threshold to improve performances.
  116386. */
  116387. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116388. /**
  116389. * Defines the default value of how much AO map is occluding the analytical lights
  116390. * (point spot...).
  116391. */
  116392. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116393. /**
  116394. * Intensity of the direct lights e.g. the four lights available in your scene.
  116395. * This impacts both the direct diffuse and specular highlights.
  116396. */
  116397. directIntensity: number;
  116398. /**
  116399. * Intensity of the emissive part of the material.
  116400. * This helps controlling the emissive effect without modifying the emissive color.
  116401. */
  116402. emissiveIntensity: number;
  116403. /**
  116404. * Intensity of the environment e.g. how much the environment will light the object
  116405. * either through harmonics for rough material or through the refelction for shiny ones.
  116406. */
  116407. environmentIntensity: number;
  116408. /**
  116409. * This is a special control allowing the reduction of the specular highlights coming from the
  116410. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116411. */
  116412. specularIntensity: number;
  116413. /**
  116414. * Debug Control allowing disabling the bump map on this material.
  116415. */
  116416. disableBumpMap: boolean;
  116417. /**
  116418. * AKA Diffuse Texture in standard nomenclature.
  116419. */
  116420. albedoTexture: BaseTexture;
  116421. /**
  116422. * AKA Occlusion Texture in other nomenclature.
  116423. */
  116424. ambientTexture: BaseTexture;
  116425. /**
  116426. * AKA Occlusion Texture Intensity in other nomenclature.
  116427. */
  116428. ambientTextureStrength: number;
  116429. /**
  116430. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116431. * 1 means it completely occludes it
  116432. * 0 mean it has no impact
  116433. */
  116434. ambientTextureImpactOnAnalyticalLights: number;
  116435. /**
  116436. * Stores the alpha values in a texture.
  116437. */
  116438. opacityTexture: BaseTexture;
  116439. /**
  116440. * Stores the reflection values in a texture.
  116441. */
  116442. reflectionTexture: Nullable<BaseTexture>;
  116443. /**
  116444. * Stores the emissive values in a texture.
  116445. */
  116446. emissiveTexture: BaseTexture;
  116447. /**
  116448. * AKA Specular texture in other nomenclature.
  116449. */
  116450. reflectivityTexture: BaseTexture;
  116451. /**
  116452. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116453. */
  116454. metallicTexture: BaseTexture;
  116455. /**
  116456. * Specifies the metallic scalar of the metallic/roughness workflow.
  116457. * Can also be used to scale the metalness values of the metallic texture.
  116458. */
  116459. metallic: Nullable<number>;
  116460. /**
  116461. * Specifies the roughness scalar of the metallic/roughness workflow.
  116462. * Can also be used to scale the roughness values of the metallic texture.
  116463. */
  116464. roughness: Nullable<number>;
  116465. /**
  116466. * Specifies the an F0 factor to help configuring the material F0.
  116467. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116468. * to 0.5 the previously hard coded value stays the same.
  116469. * Can also be used to scale the F0 values of the metallic texture.
  116470. */
  116471. metallicF0Factor: number;
  116472. /**
  116473. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116474. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116475. * your expectation as it multiplies with the texture data.
  116476. */
  116477. useMetallicF0FactorFromMetallicTexture: boolean;
  116478. /**
  116479. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116480. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116481. */
  116482. microSurfaceTexture: BaseTexture;
  116483. /**
  116484. * Stores surface normal data used to displace a mesh in a texture.
  116485. */
  116486. bumpTexture: BaseTexture;
  116487. /**
  116488. * Stores the pre-calculated light information of a mesh in a texture.
  116489. */
  116490. lightmapTexture: BaseTexture;
  116491. /**
  116492. * Stores the refracted light information in a texture.
  116493. */
  116494. refractionTexture: Nullable<BaseTexture>;
  116495. /**
  116496. * The color of a material in ambient lighting.
  116497. */
  116498. ambientColor: Color3;
  116499. /**
  116500. * AKA Diffuse Color in other nomenclature.
  116501. */
  116502. albedoColor: Color3;
  116503. /**
  116504. * AKA Specular Color in other nomenclature.
  116505. */
  116506. reflectivityColor: Color3;
  116507. /**
  116508. * The color reflected from the material.
  116509. */
  116510. reflectionColor: Color3;
  116511. /**
  116512. * The color emitted from the material.
  116513. */
  116514. emissiveColor: Color3;
  116515. /**
  116516. * AKA Glossiness in other nomenclature.
  116517. */
  116518. microSurface: number;
  116519. /**
  116520. * source material index of refraction (IOR)' / 'destination material IOR.
  116521. */
  116522. indexOfRefraction: number;
  116523. /**
  116524. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116525. */
  116526. invertRefractionY: boolean;
  116527. /**
  116528. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116529. * Materials half opaque for instance using refraction could benefit from this control.
  116530. */
  116531. linkRefractionWithTransparency: boolean;
  116532. /**
  116533. * If true, the light map contains occlusion information instead of lighting info.
  116534. */
  116535. useLightmapAsShadowmap: boolean;
  116536. /**
  116537. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116538. */
  116539. useAlphaFromAlbedoTexture: boolean;
  116540. /**
  116541. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116542. */
  116543. forceAlphaTest: boolean;
  116544. /**
  116545. * Defines the alpha limits in alpha test mode.
  116546. */
  116547. alphaCutOff: number;
  116548. /**
  116549. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  116550. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116551. */
  116552. useSpecularOverAlpha: boolean;
  116553. /**
  116554. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116555. */
  116556. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116557. /**
  116558. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116559. */
  116560. useRoughnessFromMetallicTextureAlpha: boolean;
  116561. /**
  116562. * Specifies if the metallic texture contains the roughness information in its green channel.
  116563. */
  116564. useRoughnessFromMetallicTextureGreen: boolean;
  116565. /**
  116566. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116567. */
  116568. useMetallnessFromMetallicTextureBlue: boolean;
  116569. /**
  116570. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116571. */
  116572. useAmbientOcclusionFromMetallicTextureRed: boolean;
  116573. /**
  116574. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116575. */
  116576. useAmbientInGrayScale: boolean;
  116577. /**
  116578. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116579. * The material will try to infer what glossiness each pixel should be.
  116580. */
  116581. useAutoMicroSurfaceFromReflectivityMap: boolean;
  116582. /**
  116583. * BJS is using an harcoded light falloff based on a manually sets up range.
  116584. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116585. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116586. */
  116587. /**
  116588. * BJS is using an harcoded light falloff based on a manually sets up range.
  116589. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116590. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116591. */
  116592. usePhysicalLightFalloff: boolean;
  116593. /**
  116594. * In order to support the falloff compatibility with gltf, a special mode has been added
  116595. * to reproduce the gltf light falloff.
  116596. */
  116597. /**
  116598. * In order to support the falloff compatibility with gltf, a special mode has been added
  116599. * to reproduce the gltf light falloff.
  116600. */
  116601. useGLTFLightFalloff: boolean;
  116602. /**
  116603. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116604. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116605. */
  116606. useRadianceOverAlpha: boolean;
  116607. /**
  116608. * Allows using an object space normal map (instead of tangent space).
  116609. */
  116610. useObjectSpaceNormalMap: boolean;
  116611. /**
  116612. * Allows using the bump map in parallax mode.
  116613. */
  116614. useParallax: boolean;
  116615. /**
  116616. * Allows using the bump map in parallax occlusion mode.
  116617. */
  116618. useParallaxOcclusion: boolean;
  116619. /**
  116620. * Controls the scale bias of the parallax mode.
  116621. */
  116622. parallaxScaleBias: number;
  116623. /**
  116624. * If sets to true, disables all the lights affecting the material.
  116625. */
  116626. disableLighting: boolean;
  116627. /**
  116628. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116629. */
  116630. forceIrradianceInFragment: boolean;
  116631. /**
  116632. * Number of Simultaneous lights allowed on the material.
  116633. */
  116634. maxSimultaneousLights: number;
  116635. /**
  116636. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116637. */
  116638. invertNormalMapX: boolean;
  116639. /**
  116640. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116641. */
  116642. invertNormalMapY: boolean;
  116643. /**
  116644. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116645. */
  116646. twoSidedLighting: boolean;
  116647. /**
  116648. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116649. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116650. */
  116651. useAlphaFresnel: boolean;
  116652. /**
  116653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116654. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116655. */
  116656. useLinearAlphaFresnel: boolean;
  116657. /**
  116658. * Let user defines the brdf lookup texture used for IBL.
  116659. * A default 8bit version is embedded but you could point at :
  116660. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  116661. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116662. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  116663. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116664. */
  116665. environmentBRDFTexture: Nullable<BaseTexture>;
  116666. /**
  116667. * Force normal to face away from face.
  116668. */
  116669. forceNormalForward: boolean;
  116670. /**
  116671. * Enables specular anti aliasing in the PBR shader.
  116672. * It will both interacts on the Geometry for analytical and IBL lighting.
  116673. * It also prefilter the roughness map based on the bump values.
  116674. */
  116675. enableSpecularAntiAliasing: boolean;
  116676. /**
  116677. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116678. * makes the reflect vector face the model (under horizon).
  116679. */
  116680. useHorizonOcclusion: boolean;
  116681. /**
  116682. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116683. * too much the area relying on ambient texture to define their ambient occlusion.
  116684. */
  116685. useRadianceOcclusion: boolean;
  116686. /**
  116687. * If set to true, no lighting calculations will be applied.
  116688. */
  116689. unlit: boolean;
  116690. /**
  116691. * Gets the image processing configuration used either in this material.
  116692. */
  116693. /**
  116694. * Sets the Default image processing configuration used either in the this material.
  116695. *
  116696. * If sets to null, the scene one is in use.
  116697. */
  116698. imageProcessingConfiguration: ImageProcessingConfiguration;
  116699. /**
  116700. * Gets wether the color curves effect is enabled.
  116701. */
  116702. /**
  116703. * Sets wether the color curves effect is enabled.
  116704. */
  116705. cameraColorCurvesEnabled: boolean;
  116706. /**
  116707. * Gets wether the color grading effect is enabled.
  116708. */
  116709. /**
  116710. * Gets wether the color grading effect is enabled.
  116711. */
  116712. cameraColorGradingEnabled: boolean;
  116713. /**
  116714. * Gets wether tonemapping is enabled or not.
  116715. */
  116716. /**
  116717. * Sets wether tonemapping is enabled or not
  116718. */
  116719. cameraToneMappingEnabled: boolean;
  116720. /**
  116721. * The camera exposure used on this material.
  116722. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116723. * This corresponds to a photographic exposure.
  116724. */
  116725. /**
  116726. * The camera exposure used on this material.
  116727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116728. * This corresponds to a photographic exposure.
  116729. */
  116730. cameraExposure: number;
  116731. /**
  116732. * Gets The camera contrast used on this material.
  116733. */
  116734. /**
  116735. * Sets The camera contrast used on this material.
  116736. */
  116737. cameraContrast: number;
  116738. /**
  116739. * Gets the Color Grading 2D Lookup Texture.
  116740. */
  116741. /**
  116742. * Sets the Color Grading 2D Lookup Texture.
  116743. */
  116744. cameraColorGradingTexture: Nullable<BaseTexture>;
  116745. /**
  116746. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116747. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116748. * 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;
  116749. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116750. */
  116751. /**
  116752. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116753. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116754. * 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;
  116755. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116756. */
  116757. cameraColorCurves: Nullable<ColorCurves>;
  116758. /**
  116759. * Instantiates a new PBRMaterial instance.
  116760. *
  116761. * @param name The material name
  116762. * @param scene The scene the material will be use in.
  116763. */
  116764. constructor(name: string, scene: Scene);
  116765. /**
  116766. * Returns the name of this material class.
  116767. */
  116768. getClassName(): string;
  116769. /**
  116770. * Makes a duplicate of the current material.
  116771. * @param name - name to use for the new material.
  116772. */
  116773. clone(name: string): PBRMaterial;
  116774. /**
  116775. * Serializes this PBR Material.
  116776. * @returns - An object with the serialized material.
  116777. */
  116778. serialize(): any;
  116779. /**
  116780. * Parses a PBR Material from a serialized object.
  116781. * @param source - Serialized object.
  116782. * @param scene - BJS scene instance.
  116783. * @param rootUrl - url for the scene object
  116784. * @returns - PBRMaterial
  116785. */
  116786. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  116787. }
  116788. }
  116789. declare module BABYLON {
  116790. /**
  116791. * Direct draw surface info
  116792. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  116793. */
  116794. export interface DDSInfo {
  116795. /**
  116796. * Width of the texture
  116797. */
  116798. width: number;
  116799. /**
  116800. * Width of the texture
  116801. */
  116802. height: number;
  116803. /**
  116804. * Number of Mipmaps for the texture
  116805. * @see https://en.wikipedia.org/wiki/Mipmap
  116806. */
  116807. mipmapCount: number;
  116808. /**
  116809. * If the textures format is a known fourCC format
  116810. * @see https://www.fourcc.org/
  116811. */
  116812. isFourCC: boolean;
  116813. /**
  116814. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  116815. */
  116816. isRGB: boolean;
  116817. /**
  116818. * If the texture is a lumincance format
  116819. */
  116820. isLuminance: boolean;
  116821. /**
  116822. * If this is a cube texture
  116823. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  116824. */
  116825. isCube: boolean;
  116826. /**
  116827. * If the texture is a compressed format eg. FOURCC_DXT1
  116828. */
  116829. isCompressed: boolean;
  116830. /**
  116831. * The dxgiFormat of the texture
  116832. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  116833. */
  116834. dxgiFormat: number;
  116835. /**
  116836. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  116837. */
  116838. textureType: number;
  116839. /**
  116840. * Sphericle polynomial created for the dds texture
  116841. */
  116842. sphericalPolynomial?: SphericalPolynomial;
  116843. }
  116844. /**
  116845. * Class used to provide DDS decompression tools
  116846. */
  116847. export class DDSTools {
  116848. /**
  116849. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  116850. */
  116851. static StoreLODInAlphaChannel: boolean;
  116852. /**
  116853. * Gets DDS information from an array buffer
  116854. * @param arrayBuffer defines the array buffer to read data from
  116855. * @returns the DDS information
  116856. */
  116857. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  116858. private static _FloatView;
  116859. private static _Int32View;
  116860. private static _ToHalfFloat;
  116861. private static _FromHalfFloat;
  116862. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  116863. private static _GetHalfFloatRGBAArrayBuffer;
  116864. private static _GetFloatRGBAArrayBuffer;
  116865. private static _GetFloatAsUIntRGBAArrayBuffer;
  116866. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  116867. private static _GetRGBAArrayBuffer;
  116868. private static _ExtractLongWordOrder;
  116869. private static _GetRGBArrayBuffer;
  116870. private static _GetLuminanceArrayBuffer;
  116871. /**
  116872. * Uploads DDS Levels to a Babylon Texture
  116873. * @hidden
  116874. */
  116875. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  116876. }
  116877. interface ThinEngine {
  116878. /**
  116879. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  116880. * @param rootUrl defines the url where the file to load is located
  116881. * @param scene defines the current scene
  116882. * @param lodScale defines scale to apply to the mip map selection
  116883. * @param lodOffset defines offset to apply to the mip map selection
  116884. * @param onLoad defines an optional callback raised when the texture is loaded
  116885. * @param onError defines an optional callback raised if there is an issue to load the texture
  116886. * @param format defines the format of the data
  116887. * @param forcedExtension defines the extension to use to pick the right loader
  116888. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  116889. * @returns the cube texture as an InternalTexture
  116890. */
  116891. 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;
  116892. }
  116893. }
  116894. declare module BABYLON {
  116895. /**
  116896. * Implementation of the DDS Texture Loader.
  116897. * @hidden
  116898. */
  116899. export class _DDSTextureLoader implements IInternalTextureLoader {
  116900. /**
  116901. * Defines wether the loader supports cascade loading the different faces.
  116902. */
  116903. readonly supportCascades: boolean;
  116904. /**
  116905. * This returns if the loader support the current file information.
  116906. * @param extension defines the file extension of the file being loaded
  116907. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116908. * @param fallback defines the fallback internal texture if any
  116909. * @param isBase64 defines whether the texture is encoded as a base64
  116910. * @param isBuffer defines whether the texture data are stored as a buffer
  116911. * @returns true if the loader can load the specified file
  116912. */
  116913. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116914. /**
  116915. * Transform the url before loading if required.
  116916. * @param rootUrl the url of the texture
  116917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116918. * @returns the transformed texture
  116919. */
  116920. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116921. /**
  116922. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116923. * @param rootUrl the url of the texture
  116924. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116925. * @returns the fallback texture
  116926. */
  116927. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116928. /**
  116929. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116930. * @param data contains the texture data
  116931. * @param texture defines the BabylonJS internal texture
  116932. * @param createPolynomials will be true if polynomials have been requested
  116933. * @param onLoad defines the callback to trigger once the texture is ready
  116934. * @param onError defines the callback to trigger in case of error
  116935. */
  116936. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116937. /**
  116938. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116939. * @param data contains the texture data
  116940. * @param texture defines the BabylonJS internal texture
  116941. * @param callback defines the method to call once ready to upload
  116942. */
  116943. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116944. }
  116945. }
  116946. declare module BABYLON {
  116947. /**
  116948. * Implementation of the ENV Texture Loader.
  116949. * @hidden
  116950. */
  116951. export class _ENVTextureLoader implements IInternalTextureLoader {
  116952. /**
  116953. * Defines wether the loader supports cascade loading the different faces.
  116954. */
  116955. readonly supportCascades: boolean;
  116956. /**
  116957. * This returns if the loader support the current file information.
  116958. * @param extension defines the file extension of the file being loaded
  116959. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116960. * @param fallback defines the fallback internal texture if any
  116961. * @param isBase64 defines whether the texture is encoded as a base64
  116962. * @param isBuffer defines whether the texture data are stored as a buffer
  116963. * @returns true if the loader can load the specified file
  116964. */
  116965. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116966. /**
  116967. * Transform the url before loading if required.
  116968. * @param rootUrl the url of the texture
  116969. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116970. * @returns the transformed texture
  116971. */
  116972. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116973. /**
  116974. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116975. * @param rootUrl the url of the texture
  116976. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116977. * @returns the fallback texture
  116978. */
  116979. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116980. /**
  116981. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116982. * @param data contains the texture data
  116983. * @param texture defines the BabylonJS internal texture
  116984. * @param createPolynomials will be true if polynomials have been requested
  116985. * @param onLoad defines the callback to trigger once the texture is ready
  116986. * @param onError defines the callback to trigger in case of error
  116987. */
  116988. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116989. /**
  116990. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116991. * @param data contains the texture data
  116992. * @param texture defines the BabylonJS internal texture
  116993. * @param callback defines the method to call once ready to upload
  116994. */
  116995. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116996. }
  116997. }
  116998. declare module BABYLON {
  116999. /**
  117000. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117001. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117002. */
  117003. export class KhronosTextureContainer {
  117004. /** contents of the KTX container file */
  117005. arrayBuffer: any;
  117006. private static HEADER_LEN;
  117007. private static COMPRESSED_2D;
  117008. private static COMPRESSED_3D;
  117009. private static TEX_2D;
  117010. private static TEX_3D;
  117011. /**
  117012. * Gets the openGL type
  117013. */
  117014. glType: number;
  117015. /**
  117016. * Gets the openGL type size
  117017. */
  117018. glTypeSize: number;
  117019. /**
  117020. * Gets the openGL format
  117021. */
  117022. glFormat: number;
  117023. /**
  117024. * Gets the openGL internal format
  117025. */
  117026. glInternalFormat: number;
  117027. /**
  117028. * Gets the base internal format
  117029. */
  117030. glBaseInternalFormat: number;
  117031. /**
  117032. * Gets image width in pixel
  117033. */
  117034. pixelWidth: number;
  117035. /**
  117036. * Gets image height in pixel
  117037. */
  117038. pixelHeight: number;
  117039. /**
  117040. * Gets image depth in pixels
  117041. */
  117042. pixelDepth: number;
  117043. /**
  117044. * Gets the number of array elements
  117045. */
  117046. numberOfArrayElements: number;
  117047. /**
  117048. * Gets the number of faces
  117049. */
  117050. numberOfFaces: number;
  117051. /**
  117052. * Gets the number of mipmap levels
  117053. */
  117054. numberOfMipmapLevels: number;
  117055. /**
  117056. * Gets the bytes of key value data
  117057. */
  117058. bytesOfKeyValueData: number;
  117059. /**
  117060. * Gets the load type
  117061. */
  117062. loadType: number;
  117063. /**
  117064. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117065. */
  117066. isInvalid: boolean;
  117067. /**
  117068. * Creates a new KhronosTextureContainer
  117069. * @param arrayBuffer contents of the KTX container file
  117070. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117071. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117072. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117073. */
  117074. constructor(
  117075. /** contents of the KTX container file */
  117076. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117077. /**
  117078. * Uploads KTX content to a Babylon Texture.
  117079. * It is assumed that the texture has already been created & is currently bound
  117080. * @hidden
  117081. */
  117082. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117083. private _upload2DCompressedLevels;
  117084. }
  117085. }
  117086. declare module BABYLON {
  117087. /**
  117088. * Implementation of the KTX Texture Loader.
  117089. * @hidden
  117090. */
  117091. export class _KTXTextureLoader implements IInternalTextureLoader {
  117092. /**
  117093. * Defines wether the loader supports cascade loading the different faces.
  117094. */
  117095. readonly supportCascades: boolean;
  117096. /**
  117097. * This returns if the loader support the current file information.
  117098. * @param extension defines the file extension of the file being loaded
  117099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117100. * @param fallback defines the fallback internal texture if any
  117101. * @param isBase64 defines whether the texture is encoded as a base64
  117102. * @param isBuffer defines whether the texture data are stored as a buffer
  117103. * @returns true if the loader can load the specified file
  117104. */
  117105. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117106. /**
  117107. * Transform the url before loading if required.
  117108. * @param rootUrl the url of the texture
  117109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117110. * @returns the transformed texture
  117111. */
  117112. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117113. /**
  117114. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117115. * @param rootUrl the url of the texture
  117116. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117117. * @returns the fallback texture
  117118. */
  117119. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117120. /**
  117121. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117122. * @param data contains the texture data
  117123. * @param texture defines the BabylonJS internal texture
  117124. * @param createPolynomials will be true if polynomials have been requested
  117125. * @param onLoad defines the callback to trigger once the texture is ready
  117126. * @param onError defines the callback to trigger in case of error
  117127. */
  117128. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117129. /**
  117130. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117131. * @param data contains the texture data
  117132. * @param texture defines the BabylonJS internal texture
  117133. * @param callback defines the method to call once ready to upload
  117134. */
  117135. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117136. }
  117137. }
  117138. declare module BABYLON {
  117139. /**
  117140. * Options for the default xr helper
  117141. */
  117142. export class WebXRDefaultExperienceOptions {
  117143. /**
  117144. * Floor meshes that should be used for teleporting
  117145. */
  117146. floorMeshes: Array<AbstractMesh>;
  117147. /**
  117148. * Enable or disable default UI to enter XR
  117149. */
  117150. disableDefaultUI: boolean;
  117151. }
  117152. /**
  117153. * Default experience which provides a similar setup to the previous webVRExperience
  117154. */
  117155. export class WebXRDefaultExperience {
  117156. /**
  117157. * Base experience
  117158. */
  117159. baseExperience: WebXRExperienceHelper;
  117160. /**
  117161. * Input experience extension
  117162. */
  117163. input: WebXRInput;
  117164. /**
  117165. * Loads the controller models
  117166. */
  117167. controllerModelLoader: WebXRControllerModelLoader;
  117168. /**
  117169. * Enables laser pointer and selection
  117170. */
  117171. pointerSelection: WebXRControllerPointerSelection;
  117172. /**
  117173. * Enables teleportation
  117174. */
  117175. teleportation: WebXRControllerTeleportation;
  117176. /**
  117177. * Enables ui for enetering/exiting xr
  117178. */
  117179. enterExitUI: WebXREnterExitUI;
  117180. /**
  117181. * Default target xr should render to
  117182. */
  117183. renderTarget: WebXRRenderTarget;
  117184. /**
  117185. * Creates the default xr experience
  117186. * @param scene scene
  117187. * @param options options for basic configuration
  117188. * @returns resulting WebXRDefaultExperience
  117189. */
  117190. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117191. private constructor();
  117192. /**
  117193. * DIsposes of the experience helper
  117194. */
  117195. dispose(): void;
  117196. }
  117197. }
  117198. declare module BABYLON {
  117199. /** @hidden */
  117200. export var _forceSceneHelpersToBundle: boolean;
  117201. interface Scene {
  117202. /**
  117203. * Creates a default light for the scene.
  117204. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117205. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117206. */
  117207. createDefaultLight(replace?: boolean): void;
  117208. /**
  117209. * Creates a default camera for the scene.
  117210. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117211. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117212. * @param replace has default false, when true replaces the active camera in the scene
  117213. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117214. */
  117215. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117216. /**
  117217. * Creates a default camera and a default light.
  117218. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117219. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117220. * @param replace has the default false, when true replaces the active camera/light in the scene
  117221. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117222. */
  117223. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117224. /**
  117225. * Creates a new sky box
  117226. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117227. * @param environmentTexture defines the texture to use as environment texture
  117228. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117229. * @param scale defines the overall scale of the skybox
  117230. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117231. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117232. * @returns a new mesh holding the sky box
  117233. */
  117234. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117235. /**
  117236. * Creates a new environment
  117237. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117238. * @param options defines the options you can use to configure the environment
  117239. * @returns the new EnvironmentHelper
  117240. */
  117241. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117242. /**
  117243. * Creates a new VREXperienceHelper
  117244. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117245. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117246. * @returns a new VREXperienceHelper
  117247. */
  117248. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117249. /**
  117250. * Creates a new WebXRDefaultExperience
  117251. * @see http://doc.babylonjs.com/how_to/webxr
  117252. * @param options experience options
  117253. * @returns a promise for a new WebXRDefaultExperience
  117254. */
  117255. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117256. }
  117257. }
  117258. declare module BABYLON {
  117259. /**
  117260. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117261. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117262. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117263. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117264. */
  117265. export class VideoDome extends TransformNode {
  117266. /**
  117267. * Define the video source as a Monoscopic panoramic 360 video.
  117268. */
  117269. static readonly MODE_MONOSCOPIC: number;
  117270. /**
  117271. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117272. */
  117273. static readonly MODE_TOPBOTTOM: number;
  117274. /**
  117275. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117276. */
  117277. static readonly MODE_SIDEBYSIDE: number;
  117278. private _halfDome;
  117279. private _useDirectMapping;
  117280. /**
  117281. * The video texture being displayed on the sphere
  117282. */
  117283. protected _videoTexture: VideoTexture;
  117284. /**
  117285. * Gets the video texture being displayed on the sphere
  117286. */
  117287. readonly videoTexture: VideoTexture;
  117288. /**
  117289. * The skybox material
  117290. */
  117291. protected _material: BackgroundMaterial;
  117292. /**
  117293. * The surface used for the skybox
  117294. */
  117295. protected _mesh: Mesh;
  117296. /**
  117297. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117298. */
  117299. private _halfDomeMask;
  117300. /**
  117301. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117302. * Also see the options.resolution property.
  117303. */
  117304. fovMultiplier: number;
  117305. private _videoMode;
  117306. /**
  117307. * Gets or set the current video mode for the video. It can be:
  117308. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117309. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117310. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117311. */
  117312. videoMode: number;
  117313. /**
  117314. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117315. *
  117316. */
  117317. /**
  117318. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117319. */
  117320. halfDome: boolean;
  117321. /**
  117322. * Oberserver used in Stereoscopic VR Mode.
  117323. */
  117324. private _onBeforeCameraRenderObserver;
  117325. /**
  117326. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117327. * @param name Element's name, child elements will append suffixes for their own names.
  117328. * @param urlsOrVideo defines the url(s) or the video element to use
  117329. * @param options An object containing optional or exposed sub element properties
  117330. */
  117331. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117332. resolution?: number;
  117333. clickToPlay?: boolean;
  117334. autoPlay?: boolean;
  117335. loop?: boolean;
  117336. size?: number;
  117337. poster?: string;
  117338. faceForward?: boolean;
  117339. useDirectMapping?: boolean;
  117340. halfDomeMode?: boolean;
  117341. }, scene: Scene);
  117342. private _changeVideoMode;
  117343. /**
  117344. * Releases resources associated with this node.
  117345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117347. */
  117348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117349. }
  117350. }
  117351. declare module BABYLON {
  117352. /**
  117353. * This class can be used to get instrumentation data from a Babylon engine
  117354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117355. */
  117356. export class EngineInstrumentation implements IDisposable {
  117357. /**
  117358. * Define the instrumented engine.
  117359. */
  117360. engine: Engine;
  117361. private _captureGPUFrameTime;
  117362. private _gpuFrameTimeToken;
  117363. private _gpuFrameTime;
  117364. private _captureShaderCompilationTime;
  117365. private _shaderCompilationTime;
  117366. private _onBeginFrameObserver;
  117367. private _onEndFrameObserver;
  117368. private _onBeforeShaderCompilationObserver;
  117369. private _onAfterShaderCompilationObserver;
  117370. /**
  117371. * Gets the perf counter used for GPU frame time
  117372. */
  117373. readonly gpuFrameTimeCounter: PerfCounter;
  117374. /**
  117375. * Gets the GPU frame time capture status
  117376. */
  117377. /**
  117378. * Enable or disable the GPU frame time capture
  117379. */
  117380. captureGPUFrameTime: boolean;
  117381. /**
  117382. * Gets the perf counter used for shader compilation time
  117383. */
  117384. readonly shaderCompilationTimeCounter: PerfCounter;
  117385. /**
  117386. * Gets the shader compilation time capture status
  117387. */
  117388. /**
  117389. * Enable or disable the shader compilation time capture
  117390. */
  117391. captureShaderCompilationTime: boolean;
  117392. /**
  117393. * Instantiates a new engine instrumentation.
  117394. * This class can be used to get instrumentation data from a Babylon engine
  117395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117396. * @param engine Defines the engine to instrument
  117397. */
  117398. constructor(
  117399. /**
  117400. * Define the instrumented engine.
  117401. */
  117402. engine: Engine);
  117403. /**
  117404. * Dispose and release associated resources.
  117405. */
  117406. dispose(): void;
  117407. }
  117408. }
  117409. declare module BABYLON {
  117410. /**
  117411. * This class can be used to get instrumentation data from a Babylon engine
  117412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117413. */
  117414. export class SceneInstrumentation implements IDisposable {
  117415. /**
  117416. * Defines the scene to instrument
  117417. */
  117418. scene: Scene;
  117419. private _captureActiveMeshesEvaluationTime;
  117420. private _activeMeshesEvaluationTime;
  117421. private _captureRenderTargetsRenderTime;
  117422. private _renderTargetsRenderTime;
  117423. private _captureFrameTime;
  117424. private _frameTime;
  117425. private _captureRenderTime;
  117426. private _renderTime;
  117427. private _captureInterFrameTime;
  117428. private _interFrameTime;
  117429. private _captureParticlesRenderTime;
  117430. private _particlesRenderTime;
  117431. private _captureSpritesRenderTime;
  117432. private _spritesRenderTime;
  117433. private _capturePhysicsTime;
  117434. private _physicsTime;
  117435. private _captureAnimationsTime;
  117436. private _animationsTime;
  117437. private _captureCameraRenderTime;
  117438. private _cameraRenderTime;
  117439. private _onBeforeActiveMeshesEvaluationObserver;
  117440. private _onAfterActiveMeshesEvaluationObserver;
  117441. private _onBeforeRenderTargetsRenderObserver;
  117442. private _onAfterRenderTargetsRenderObserver;
  117443. private _onAfterRenderObserver;
  117444. private _onBeforeDrawPhaseObserver;
  117445. private _onAfterDrawPhaseObserver;
  117446. private _onBeforeAnimationsObserver;
  117447. private _onBeforeParticlesRenderingObserver;
  117448. private _onAfterParticlesRenderingObserver;
  117449. private _onBeforeSpritesRenderingObserver;
  117450. private _onAfterSpritesRenderingObserver;
  117451. private _onBeforePhysicsObserver;
  117452. private _onAfterPhysicsObserver;
  117453. private _onAfterAnimationsObserver;
  117454. private _onBeforeCameraRenderObserver;
  117455. private _onAfterCameraRenderObserver;
  117456. /**
  117457. * Gets the perf counter used for active meshes evaluation time
  117458. */
  117459. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  117460. /**
  117461. * Gets the active meshes evaluation time capture status
  117462. */
  117463. /**
  117464. * Enable or disable the active meshes evaluation time capture
  117465. */
  117466. captureActiveMeshesEvaluationTime: boolean;
  117467. /**
  117468. * Gets the perf counter used for render targets render time
  117469. */
  117470. readonly renderTargetsRenderTimeCounter: PerfCounter;
  117471. /**
  117472. * Gets the render targets render time capture status
  117473. */
  117474. /**
  117475. * Enable or disable the render targets render time capture
  117476. */
  117477. captureRenderTargetsRenderTime: boolean;
  117478. /**
  117479. * Gets the perf counter used for particles render time
  117480. */
  117481. readonly particlesRenderTimeCounter: PerfCounter;
  117482. /**
  117483. * Gets the particles render time capture status
  117484. */
  117485. /**
  117486. * Enable or disable the particles render time capture
  117487. */
  117488. captureParticlesRenderTime: boolean;
  117489. /**
  117490. * Gets the perf counter used for sprites render time
  117491. */
  117492. readonly spritesRenderTimeCounter: PerfCounter;
  117493. /**
  117494. * Gets the sprites render time capture status
  117495. */
  117496. /**
  117497. * Enable or disable the sprites render time capture
  117498. */
  117499. captureSpritesRenderTime: boolean;
  117500. /**
  117501. * Gets the perf counter used for physics time
  117502. */
  117503. readonly physicsTimeCounter: PerfCounter;
  117504. /**
  117505. * Gets the physics time capture status
  117506. */
  117507. /**
  117508. * Enable or disable the physics time capture
  117509. */
  117510. capturePhysicsTime: boolean;
  117511. /**
  117512. * Gets the perf counter used for animations time
  117513. */
  117514. readonly animationsTimeCounter: PerfCounter;
  117515. /**
  117516. * Gets the animations time capture status
  117517. */
  117518. /**
  117519. * Enable or disable the animations time capture
  117520. */
  117521. captureAnimationsTime: boolean;
  117522. /**
  117523. * Gets the perf counter used for frame time capture
  117524. */
  117525. readonly frameTimeCounter: PerfCounter;
  117526. /**
  117527. * Gets the frame time capture status
  117528. */
  117529. /**
  117530. * Enable or disable the frame time capture
  117531. */
  117532. captureFrameTime: boolean;
  117533. /**
  117534. * Gets the perf counter used for inter-frames time capture
  117535. */
  117536. readonly interFrameTimeCounter: PerfCounter;
  117537. /**
  117538. * Gets the inter-frames time capture status
  117539. */
  117540. /**
  117541. * Enable or disable the inter-frames time capture
  117542. */
  117543. captureInterFrameTime: boolean;
  117544. /**
  117545. * Gets the perf counter used for render time capture
  117546. */
  117547. readonly renderTimeCounter: PerfCounter;
  117548. /**
  117549. * Gets the render time capture status
  117550. */
  117551. /**
  117552. * Enable or disable the render time capture
  117553. */
  117554. captureRenderTime: boolean;
  117555. /**
  117556. * Gets the perf counter used for camera render time capture
  117557. */
  117558. readonly cameraRenderTimeCounter: PerfCounter;
  117559. /**
  117560. * Gets the camera render time capture status
  117561. */
  117562. /**
  117563. * Enable or disable the camera render time capture
  117564. */
  117565. captureCameraRenderTime: boolean;
  117566. /**
  117567. * Gets the perf counter used for draw calls
  117568. */
  117569. readonly drawCallsCounter: PerfCounter;
  117570. /**
  117571. * Instantiates a new scene instrumentation.
  117572. * This class can be used to get instrumentation data from a Babylon engine
  117573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117574. * @param scene Defines the scene to instrument
  117575. */
  117576. constructor(
  117577. /**
  117578. * Defines the scene to instrument
  117579. */
  117580. scene: Scene);
  117581. /**
  117582. * Dispose and release associated resources.
  117583. */
  117584. dispose(): void;
  117585. }
  117586. }
  117587. declare module BABYLON {
  117588. /** @hidden */
  117589. export var glowMapGenerationPixelShader: {
  117590. name: string;
  117591. shader: string;
  117592. };
  117593. }
  117594. declare module BABYLON {
  117595. /** @hidden */
  117596. export var glowMapGenerationVertexShader: {
  117597. name: string;
  117598. shader: string;
  117599. };
  117600. }
  117601. declare module BABYLON {
  117602. /**
  117603. * Effect layer options. This helps customizing the behaviour
  117604. * of the effect layer.
  117605. */
  117606. export interface IEffectLayerOptions {
  117607. /**
  117608. * Multiplication factor apply to the canvas size to compute the render target size
  117609. * used to generated the objects (the smaller the faster).
  117610. */
  117611. mainTextureRatio: number;
  117612. /**
  117613. * Enforces a fixed size texture to ensure effect stability across devices.
  117614. */
  117615. mainTextureFixedSize?: number;
  117616. /**
  117617. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  117618. */
  117619. alphaBlendingMode: number;
  117620. /**
  117621. * The camera attached to the layer.
  117622. */
  117623. camera: Nullable<Camera>;
  117624. /**
  117625. * The rendering group to draw the layer in.
  117626. */
  117627. renderingGroupId: number;
  117628. }
  117629. /**
  117630. * The effect layer Helps adding post process effect blended with the main pass.
  117631. *
  117632. * This can be for instance use to generate glow or higlight effects on the scene.
  117633. *
  117634. * The effect layer class can not be used directly and is intented to inherited from to be
  117635. * customized per effects.
  117636. */
  117637. export abstract class EffectLayer {
  117638. private _vertexBuffers;
  117639. private _indexBuffer;
  117640. private _cachedDefines;
  117641. private _effectLayerMapGenerationEffect;
  117642. private _effectLayerOptions;
  117643. private _mergeEffect;
  117644. protected _scene: Scene;
  117645. protected _engine: Engine;
  117646. protected _maxSize: number;
  117647. protected _mainTextureDesiredSize: ISize;
  117648. protected _mainTexture: RenderTargetTexture;
  117649. protected _shouldRender: boolean;
  117650. protected _postProcesses: PostProcess[];
  117651. protected _textures: BaseTexture[];
  117652. protected _emissiveTextureAndColor: {
  117653. texture: Nullable<BaseTexture>;
  117654. color: Color4;
  117655. };
  117656. /**
  117657. * The name of the layer
  117658. */
  117659. name: string;
  117660. /**
  117661. * The clear color of the texture used to generate the glow map.
  117662. */
  117663. neutralColor: Color4;
  117664. /**
  117665. * Specifies wether the highlight layer is enabled or not.
  117666. */
  117667. isEnabled: boolean;
  117668. /**
  117669. * Gets the camera attached to the layer.
  117670. */
  117671. readonly camera: Nullable<Camera>;
  117672. /**
  117673. * Gets the rendering group id the layer should render in.
  117674. */
  117675. renderingGroupId: number;
  117676. /**
  117677. * An event triggered when the effect layer has been disposed.
  117678. */
  117679. onDisposeObservable: Observable<EffectLayer>;
  117680. /**
  117681. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  117682. */
  117683. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  117684. /**
  117685. * An event triggered when the generated texture is being merged in the scene.
  117686. */
  117687. onBeforeComposeObservable: Observable<EffectLayer>;
  117688. /**
  117689. * An event triggered when the mesh is rendered into the effect render target.
  117690. */
  117691. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  117692. /**
  117693. * An event triggered after the mesh has been rendered into the effect render target.
  117694. */
  117695. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  117696. /**
  117697. * An event triggered when the generated texture has been merged in the scene.
  117698. */
  117699. onAfterComposeObservable: Observable<EffectLayer>;
  117700. /**
  117701. * An event triggered when the efffect layer changes its size.
  117702. */
  117703. onSizeChangedObservable: Observable<EffectLayer>;
  117704. /** @hidden */
  117705. static _SceneComponentInitialization: (scene: Scene) => void;
  117706. /**
  117707. * Instantiates a new effect Layer and references it in the scene.
  117708. * @param name The name of the layer
  117709. * @param scene The scene to use the layer in
  117710. */
  117711. constructor(
  117712. /** The Friendly of the effect in the scene */
  117713. name: string, scene: Scene);
  117714. /**
  117715. * Get the effect name of the layer.
  117716. * @return The effect name
  117717. */
  117718. abstract getEffectName(): string;
  117719. /**
  117720. * Checks for the readiness of the element composing the layer.
  117721. * @param subMesh the mesh to check for
  117722. * @param useInstances specify wether or not to use instances to render the mesh
  117723. * @return true if ready otherwise, false
  117724. */
  117725. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117726. /**
  117727. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117728. * @returns true if the effect requires stencil during the main canvas render pass.
  117729. */
  117730. abstract needStencil(): boolean;
  117731. /**
  117732. * Create the merge effect. This is the shader use to blit the information back
  117733. * to the main canvas at the end of the scene rendering.
  117734. * @returns The effect containing the shader used to merge the effect on the main canvas
  117735. */
  117736. protected abstract _createMergeEffect(): Effect;
  117737. /**
  117738. * Creates the render target textures and post processes used in the effect layer.
  117739. */
  117740. protected abstract _createTextureAndPostProcesses(): void;
  117741. /**
  117742. * Implementation specific of rendering the generating effect on the main canvas.
  117743. * @param effect The effect used to render through
  117744. */
  117745. protected abstract _internalRender(effect: Effect): void;
  117746. /**
  117747. * Sets the required values for both the emissive texture and and the main color.
  117748. */
  117749. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117750. /**
  117751. * Free any resources and references associated to a mesh.
  117752. * Internal use
  117753. * @param mesh The mesh to free.
  117754. */
  117755. abstract _disposeMesh(mesh: Mesh): void;
  117756. /**
  117757. * Serializes this layer (Glow or Highlight for example)
  117758. * @returns a serialized layer object
  117759. */
  117760. abstract serialize?(): any;
  117761. /**
  117762. * Initializes the effect layer with the required options.
  117763. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  117764. */
  117765. protected _init(options: Partial<IEffectLayerOptions>): void;
  117766. /**
  117767. * Generates the index buffer of the full screen quad blending to the main canvas.
  117768. */
  117769. private _generateIndexBuffer;
  117770. /**
  117771. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  117772. */
  117773. private _generateVertexBuffer;
  117774. /**
  117775. * Sets the main texture desired size which is the closest power of two
  117776. * of the engine canvas size.
  117777. */
  117778. private _setMainTextureSize;
  117779. /**
  117780. * Creates the main texture for the effect layer.
  117781. */
  117782. protected _createMainTexture(): void;
  117783. /**
  117784. * Adds specific effects defines.
  117785. * @param defines The defines to add specifics to.
  117786. */
  117787. protected _addCustomEffectDefines(defines: string[]): void;
  117788. /**
  117789. * Checks for the readiness of the element composing the layer.
  117790. * @param subMesh the mesh to check for
  117791. * @param useInstances specify wether or not to use instances to render the mesh
  117792. * @param emissiveTexture the associated emissive texture used to generate the glow
  117793. * @return true if ready otherwise, false
  117794. */
  117795. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  117796. /**
  117797. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  117798. */
  117799. render(): void;
  117800. /**
  117801. * Determine if a given mesh will be used in the current effect.
  117802. * @param mesh mesh to test
  117803. * @returns true if the mesh will be used
  117804. */
  117805. hasMesh(mesh: AbstractMesh): boolean;
  117806. /**
  117807. * Returns true if the layer contains information to display, otherwise false.
  117808. * @returns true if the glow layer should be rendered
  117809. */
  117810. shouldRender(): boolean;
  117811. /**
  117812. * Returns true if the mesh should render, otherwise false.
  117813. * @param mesh The mesh to render
  117814. * @returns true if it should render otherwise false
  117815. */
  117816. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  117817. /**
  117818. * Returns true if the mesh can be rendered, otherwise false.
  117819. * @param mesh The mesh to render
  117820. * @param material The material used on the mesh
  117821. * @returns true if it can be rendered otherwise false
  117822. */
  117823. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117824. /**
  117825. * Returns true if the mesh should render, otherwise false.
  117826. * @param mesh The mesh to render
  117827. * @returns true if it should render otherwise false
  117828. */
  117829. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  117830. /**
  117831. * Renders the submesh passed in parameter to the generation map.
  117832. */
  117833. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  117834. /**
  117835. * Defines wether the current material of the mesh should be use to render the effect.
  117836. * @param mesh defines the current mesh to render
  117837. */
  117838. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  117839. /**
  117840. * Rebuild the required buffers.
  117841. * @hidden Internal use only.
  117842. */
  117843. _rebuild(): void;
  117844. /**
  117845. * Dispose only the render target textures and post process.
  117846. */
  117847. private _disposeTextureAndPostProcesses;
  117848. /**
  117849. * Dispose the highlight layer and free resources.
  117850. */
  117851. dispose(): void;
  117852. /**
  117853. * Gets the class name of the effect layer
  117854. * @returns the string with the class name of the effect layer
  117855. */
  117856. getClassName(): string;
  117857. /**
  117858. * Creates an effect layer from parsed effect layer data
  117859. * @param parsedEffectLayer defines effect layer data
  117860. * @param scene defines the current scene
  117861. * @param rootUrl defines the root URL containing the effect layer information
  117862. * @returns a parsed effect Layer
  117863. */
  117864. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  117865. }
  117866. }
  117867. declare module BABYLON {
  117868. interface AbstractScene {
  117869. /**
  117870. * The list of effect layers (highlights/glow) added to the scene
  117871. * @see http://doc.babylonjs.com/how_to/highlight_layer
  117872. * @see http://doc.babylonjs.com/how_to/glow_layer
  117873. */
  117874. effectLayers: Array<EffectLayer>;
  117875. /**
  117876. * Removes the given effect layer from this scene.
  117877. * @param toRemove defines the effect layer to remove
  117878. * @returns the index of the removed effect layer
  117879. */
  117880. removeEffectLayer(toRemove: EffectLayer): number;
  117881. /**
  117882. * Adds the given effect layer to this scene
  117883. * @param newEffectLayer defines the effect layer to add
  117884. */
  117885. addEffectLayer(newEffectLayer: EffectLayer): void;
  117886. }
  117887. /**
  117888. * Defines the layer scene component responsible to manage any effect layers
  117889. * in a given scene.
  117890. */
  117891. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  117892. /**
  117893. * The component name helpfull to identify the component in the list of scene components.
  117894. */
  117895. readonly name: string;
  117896. /**
  117897. * The scene the component belongs to.
  117898. */
  117899. scene: Scene;
  117900. private _engine;
  117901. private _renderEffects;
  117902. private _needStencil;
  117903. private _previousStencilState;
  117904. /**
  117905. * Creates a new instance of the component for the given scene
  117906. * @param scene Defines the scene to register the component in
  117907. */
  117908. constructor(scene: Scene);
  117909. /**
  117910. * Registers the component in a given scene
  117911. */
  117912. register(): void;
  117913. /**
  117914. * Rebuilds the elements related to this component in case of
  117915. * context lost for instance.
  117916. */
  117917. rebuild(): void;
  117918. /**
  117919. * Serializes the component data to the specified json object
  117920. * @param serializationObject The object to serialize to
  117921. */
  117922. serialize(serializationObject: any): void;
  117923. /**
  117924. * Adds all the elements from the container to the scene
  117925. * @param container the container holding the elements
  117926. */
  117927. addFromContainer(container: AbstractScene): void;
  117928. /**
  117929. * Removes all the elements in the container from the scene
  117930. * @param container contains the elements to remove
  117931. * @param dispose if the removed element should be disposed (default: false)
  117932. */
  117933. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117934. /**
  117935. * Disposes the component and the associated ressources.
  117936. */
  117937. dispose(): void;
  117938. private _isReadyForMesh;
  117939. private _renderMainTexture;
  117940. private _setStencil;
  117941. private _setStencilBack;
  117942. private _draw;
  117943. private _drawCamera;
  117944. private _drawRenderingGroup;
  117945. }
  117946. }
  117947. declare module BABYLON {
  117948. /** @hidden */
  117949. export var glowMapMergePixelShader: {
  117950. name: string;
  117951. shader: string;
  117952. };
  117953. }
  117954. declare module BABYLON {
  117955. /** @hidden */
  117956. export var glowMapMergeVertexShader: {
  117957. name: string;
  117958. shader: string;
  117959. };
  117960. }
  117961. declare module BABYLON {
  117962. interface AbstractScene {
  117963. /**
  117964. * Return a the first highlight layer of the scene with a given name.
  117965. * @param name The name of the highlight layer to look for.
  117966. * @return The highlight layer if found otherwise null.
  117967. */
  117968. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  117969. }
  117970. /**
  117971. * Glow layer options. This helps customizing the behaviour
  117972. * of the glow layer.
  117973. */
  117974. export interface IGlowLayerOptions {
  117975. /**
  117976. * Multiplication factor apply to the canvas size to compute the render target size
  117977. * used to generated the glowing objects (the smaller the faster).
  117978. */
  117979. mainTextureRatio: number;
  117980. /**
  117981. * Enforces a fixed size texture to ensure resize independant blur.
  117982. */
  117983. mainTextureFixedSize?: number;
  117984. /**
  117985. * How big is the kernel of the blur texture.
  117986. */
  117987. blurKernelSize: number;
  117988. /**
  117989. * The camera attached to the layer.
  117990. */
  117991. camera: Nullable<Camera>;
  117992. /**
  117993. * Enable MSAA by chosing the number of samples.
  117994. */
  117995. mainTextureSamples?: number;
  117996. /**
  117997. * The rendering group to draw the layer in.
  117998. */
  117999. renderingGroupId: number;
  118000. }
  118001. /**
  118002. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118003. *
  118004. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118005. *
  118006. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118007. */
  118008. export class GlowLayer extends EffectLayer {
  118009. /**
  118010. * Effect Name of the layer.
  118011. */
  118012. static readonly EffectName: string;
  118013. /**
  118014. * The default blur kernel size used for the glow.
  118015. */
  118016. static DefaultBlurKernelSize: number;
  118017. /**
  118018. * The default texture size ratio used for the glow.
  118019. */
  118020. static DefaultTextureRatio: number;
  118021. /**
  118022. * Sets the kernel size of the blur.
  118023. */
  118024. /**
  118025. * Gets the kernel size of the blur.
  118026. */
  118027. blurKernelSize: number;
  118028. /**
  118029. * Sets the glow intensity.
  118030. */
  118031. /**
  118032. * Gets the glow intensity.
  118033. */
  118034. intensity: number;
  118035. private _options;
  118036. private _intensity;
  118037. private _horizontalBlurPostprocess1;
  118038. private _verticalBlurPostprocess1;
  118039. private _horizontalBlurPostprocess2;
  118040. private _verticalBlurPostprocess2;
  118041. private _blurTexture1;
  118042. private _blurTexture2;
  118043. private _postProcesses1;
  118044. private _postProcesses2;
  118045. private _includedOnlyMeshes;
  118046. private _excludedMeshes;
  118047. private _meshesUsingTheirOwnMaterials;
  118048. /**
  118049. * Callback used to let the user override the color selection on a per mesh basis
  118050. */
  118051. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118052. /**
  118053. * Callback used to let the user override the texture selection on a per mesh basis
  118054. */
  118055. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118056. /**
  118057. * Instantiates a new glow Layer and references it to the scene.
  118058. * @param name The name of the layer
  118059. * @param scene The scene to use the layer in
  118060. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118061. */
  118062. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118063. /**
  118064. * Get the effect name of the layer.
  118065. * @return The effect name
  118066. */
  118067. getEffectName(): string;
  118068. /**
  118069. * Create the merge effect. This is the shader use to blit the information back
  118070. * to the main canvas at the end of the scene rendering.
  118071. */
  118072. protected _createMergeEffect(): Effect;
  118073. /**
  118074. * Creates the render target textures and post processes used in the glow layer.
  118075. */
  118076. protected _createTextureAndPostProcesses(): void;
  118077. /**
  118078. * Checks for the readiness of the element composing the layer.
  118079. * @param subMesh the mesh to check for
  118080. * @param useInstances specify wether or not to use instances to render the mesh
  118081. * @param emissiveTexture the associated emissive texture used to generate the glow
  118082. * @return true if ready otherwise, false
  118083. */
  118084. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118085. /**
  118086. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118087. */
  118088. needStencil(): boolean;
  118089. /**
  118090. * Returns true if the mesh can be rendered, otherwise false.
  118091. * @param mesh The mesh to render
  118092. * @param material The material used on the mesh
  118093. * @returns true if it can be rendered otherwise false
  118094. */
  118095. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118096. /**
  118097. * Implementation specific of rendering the generating effect on the main canvas.
  118098. * @param effect The effect used to render through
  118099. */
  118100. protected _internalRender(effect: Effect): void;
  118101. /**
  118102. * Sets the required values for both the emissive texture and and the main color.
  118103. */
  118104. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118105. /**
  118106. * Returns true if the mesh should render, otherwise false.
  118107. * @param mesh The mesh to render
  118108. * @returns true if it should render otherwise false
  118109. */
  118110. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118111. /**
  118112. * Adds specific effects defines.
  118113. * @param defines The defines to add specifics to.
  118114. */
  118115. protected _addCustomEffectDefines(defines: string[]): void;
  118116. /**
  118117. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118118. * @param mesh The mesh to exclude from the glow layer
  118119. */
  118120. addExcludedMesh(mesh: Mesh): void;
  118121. /**
  118122. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118123. * @param mesh The mesh to remove
  118124. */
  118125. removeExcludedMesh(mesh: Mesh): void;
  118126. /**
  118127. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118128. * @param mesh The mesh to include in the glow layer
  118129. */
  118130. addIncludedOnlyMesh(mesh: Mesh): void;
  118131. /**
  118132. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118133. * @param mesh The mesh to remove
  118134. */
  118135. removeIncludedOnlyMesh(mesh: Mesh): void;
  118136. /**
  118137. * Determine if a given mesh will be used in the glow layer
  118138. * @param mesh The mesh to test
  118139. * @returns true if the mesh will be highlighted by the current glow layer
  118140. */
  118141. hasMesh(mesh: AbstractMesh): boolean;
  118142. /**
  118143. * Defines wether the current material of the mesh should be use to render the effect.
  118144. * @param mesh defines the current mesh to render
  118145. */
  118146. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118147. /**
  118148. * Add a mesh to be rendered through its own material and not with emissive only.
  118149. * @param mesh The mesh for which we need to use its material
  118150. */
  118151. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118152. /**
  118153. * Remove a mesh from being rendered through its own material and not with emissive only.
  118154. * @param mesh The mesh for which we need to not use its material
  118155. */
  118156. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118157. /**
  118158. * Free any resources and references associated to a mesh.
  118159. * Internal use
  118160. * @param mesh The mesh to free.
  118161. * @hidden
  118162. */
  118163. _disposeMesh(mesh: Mesh): void;
  118164. /**
  118165. * Gets the class name of the effect layer
  118166. * @returns the string with the class name of the effect layer
  118167. */
  118168. getClassName(): string;
  118169. /**
  118170. * Serializes this glow layer
  118171. * @returns a serialized glow layer object
  118172. */
  118173. serialize(): any;
  118174. /**
  118175. * Creates a Glow Layer from parsed glow layer data
  118176. * @param parsedGlowLayer defines glow layer data
  118177. * @param scene defines the current scene
  118178. * @param rootUrl defines the root URL containing the glow layer information
  118179. * @returns a parsed Glow Layer
  118180. */
  118181. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118182. }
  118183. }
  118184. declare module BABYLON {
  118185. /** @hidden */
  118186. export var glowBlurPostProcessPixelShader: {
  118187. name: string;
  118188. shader: string;
  118189. };
  118190. }
  118191. declare module BABYLON {
  118192. interface AbstractScene {
  118193. /**
  118194. * Return a the first highlight layer of the scene with a given name.
  118195. * @param name The name of the highlight layer to look for.
  118196. * @return The highlight layer if found otherwise null.
  118197. */
  118198. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118199. }
  118200. /**
  118201. * Highlight layer options. This helps customizing the behaviour
  118202. * of the highlight layer.
  118203. */
  118204. export interface IHighlightLayerOptions {
  118205. /**
  118206. * Multiplication factor apply to the canvas size to compute the render target size
  118207. * used to generated the glowing objects (the smaller the faster).
  118208. */
  118209. mainTextureRatio: number;
  118210. /**
  118211. * Enforces a fixed size texture to ensure resize independant blur.
  118212. */
  118213. mainTextureFixedSize?: number;
  118214. /**
  118215. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118216. * of the picture to blur (the smaller the faster).
  118217. */
  118218. blurTextureSizeRatio: number;
  118219. /**
  118220. * How big in texel of the blur texture is the vertical blur.
  118221. */
  118222. blurVerticalSize: number;
  118223. /**
  118224. * How big in texel of the blur texture is the horizontal blur.
  118225. */
  118226. blurHorizontalSize: number;
  118227. /**
  118228. * Alpha blending mode used to apply the blur. Default is combine.
  118229. */
  118230. alphaBlendingMode: number;
  118231. /**
  118232. * The camera attached to the layer.
  118233. */
  118234. camera: Nullable<Camera>;
  118235. /**
  118236. * Should we display highlight as a solid stroke?
  118237. */
  118238. isStroke?: boolean;
  118239. /**
  118240. * The rendering group to draw the layer in.
  118241. */
  118242. renderingGroupId: number;
  118243. }
  118244. /**
  118245. * The highlight layer Helps adding a glow effect around a mesh.
  118246. *
  118247. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118248. * glowy meshes to your scene.
  118249. *
  118250. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118251. */
  118252. export class HighlightLayer extends EffectLayer {
  118253. name: string;
  118254. /**
  118255. * Effect Name of the highlight layer.
  118256. */
  118257. static readonly EffectName: string;
  118258. /**
  118259. * The neutral color used during the preparation of the glow effect.
  118260. * This is black by default as the blend operation is a blend operation.
  118261. */
  118262. static NeutralColor: Color4;
  118263. /**
  118264. * Stencil value used for glowing meshes.
  118265. */
  118266. static GlowingMeshStencilReference: number;
  118267. /**
  118268. * Stencil value used for the other meshes in the scene.
  118269. */
  118270. static NormalMeshStencilReference: number;
  118271. /**
  118272. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118273. */
  118274. innerGlow: boolean;
  118275. /**
  118276. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118277. */
  118278. outerGlow: boolean;
  118279. /**
  118280. * Specifies the horizontal size of the blur.
  118281. */
  118282. /**
  118283. * Gets the horizontal size of the blur.
  118284. */
  118285. blurHorizontalSize: number;
  118286. /**
  118287. * Specifies the vertical size of the blur.
  118288. */
  118289. /**
  118290. * Gets the vertical size of the blur.
  118291. */
  118292. blurVerticalSize: number;
  118293. /**
  118294. * An event triggered when the highlight layer is being blurred.
  118295. */
  118296. onBeforeBlurObservable: Observable<HighlightLayer>;
  118297. /**
  118298. * An event triggered when the highlight layer has been blurred.
  118299. */
  118300. onAfterBlurObservable: Observable<HighlightLayer>;
  118301. private _instanceGlowingMeshStencilReference;
  118302. private _options;
  118303. private _downSamplePostprocess;
  118304. private _horizontalBlurPostprocess;
  118305. private _verticalBlurPostprocess;
  118306. private _blurTexture;
  118307. private _meshes;
  118308. private _excludedMeshes;
  118309. /**
  118310. * Instantiates a new highlight Layer and references it to the scene..
  118311. * @param name The name of the layer
  118312. * @param scene The scene to use the layer in
  118313. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118314. */
  118315. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118316. /**
  118317. * Get the effect name of the layer.
  118318. * @return The effect name
  118319. */
  118320. getEffectName(): string;
  118321. /**
  118322. * Create the merge effect. This is the shader use to blit the information back
  118323. * to the main canvas at the end of the scene rendering.
  118324. */
  118325. protected _createMergeEffect(): Effect;
  118326. /**
  118327. * Creates the render target textures and post processes used in the highlight layer.
  118328. */
  118329. protected _createTextureAndPostProcesses(): void;
  118330. /**
  118331. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118332. */
  118333. needStencil(): boolean;
  118334. /**
  118335. * Checks for the readiness of the element composing the layer.
  118336. * @param subMesh the mesh to check for
  118337. * @param useInstances specify wether or not to use instances to render the mesh
  118338. * @param emissiveTexture the associated emissive texture used to generate the glow
  118339. * @return true if ready otherwise, false
  118340. */
  118341. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118342. /**
  118343. * Implementation specific of rendering the generating effect on the main canvas.
  118344. * @param effect The effect used to render through
  118345. */
  118346. protected _internalRender(effect: Effect): void;
  118347. /**
  118348. * Returns true if the layer contains information to display, otherwise false.
  118349. */
  118350. shouldRender(): boolean;
  118351. /**
  118352. * Returns true if the mesh should render, otherwise false.
  118353. * @param mesh The mesh to render
  118354. * @returns true if it should render otherwise false
  118355. */
  118356. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118357. /**
  118358. * Sets the required values for both the emissive texture and and the main color.
  118359. */
  118360. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118361. /**
  118362. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  118363. * @param mesh The mesh to exclude from the highlight layer
  118364. */
  118365. addExcludedMesh(mesh: Mesh): void;
  118366. /**
  118367. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  118368. * @param mesh The mesh to highlight
  118369. */
  118370. removeExcludedMesh(mesh: Mesh): void;
  118371. /**
  118372. * Determine if a given mesh will be highlighted by the current HighlightLayer
  118373. * @param mesh mesh to test
  118374. * @returns true if the mesh will be highlighted by the current HighlightLayer
  118375. */
  118376. hasMesh(mesh: AbstractMesh): boolean;
  118377. /**
  118378. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  118379. * @param mesh The mesh to highlight
  118380. * @param color The color of the highlight
  118381. * @param glowEmissiveOnly Extract the glow from the emissive texture
  118382. */
  118383. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  118384. /**
  118385. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118386. * @param mesh The mesh to highlight
  118387. */
  118388. removeMesh(mesh: Mesh): void;
  118389. /**
  118390. * Force the stencil to the normal expected value for none glowing parts
  118391. */
  118392. private _defaultStencilReference;
  118393. /**
  118394. * Free any resources and references associated to a mesh.
  118395. * Internal use
  118396. * @param mesh The mesh to free.
  118397. * @hidden
  118398. */
  118399. _disposeMesh(mesh: Mesh): void;
  118400. /**
  118401. * Dispose the highlight layer and free resources.
  118402. */
  118403. dispose(): void;
  118404. /**
  118405. * Gets the class name of the effect layer
  118406. * @returns the string with the class name of the effect layer
  118407. */
  118408. getClassName(): string;
  118409. /**
  118410. * Serializes this Highlight layer
  118411. * @returns a serialized Highlight layer object
  118412. */
  118413. serialize(): any;
  118414. /**
  118415. * Creates a Highlight layer from parsed Highlight layer data
  118416. * @param parsedHightlightLayer defines the Highlight layer data
  118417. * @param scene defines the current scene
  118418. * @param rootUrl defines the root URL containing the Highlight layer information
  118419. * @returns a parsed Highlight layer
  118420. */
  118421. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118422. }
  118423. }
  118424. declare module BABYLON {
  118425. interface AbstractScene {
  118426. /**
  118427. * The list of layers (background and foreground) of the scene
  118428. */
  118429. layers: Array<Layer>;
  118430. }
  118431. /**
  118432. * Defines the layer scene component responsible to manage any layers
  118433. * in a given scene.
  118434. */
  118435. export class LayerSceneComponent implements ISceneComponent {
  118436. /**
  118437. * The component name helpfull to identify the component in the list of scene components.
  118438. */
  118439. readonly name: string;
  118440. /**
  118441. * The scene the component belongs to.
  118442. */
  118443. scene: Scene;
  118444. private _engine;
  118445. /**
  118446. * Creates a new instance of the component for the given scene
  118447. * @param scene Defines the scene to register the component in
  118448. */
  118449. constructor(scene: Scene);
  118450. /**
  118451. * Registers the component in a given scene
  118452. */
  118453. register(): void;
  118454. /**
  118455. * Rebuilds the elements related to this component in case of
  118456. * context lost for instance.
  118457. */
  118458. rebuild(): void;
  118459. /**
  118460. * Disposes the component and the associated ressources.
  118461. */
  118462. dispose(): void;
  118463. private _draw;
  118464. private _drawCameraPredicate;
  118465. private _drawCameraBackground;
  118466. private _drawCameraForeground;
  118467. private _drawRenderTargetPredicate;
  118468. private _drawRenderTargetBackground;
  118469. private _drawRenderTargetForeground;
  118470. /**
  118471. * Adds all the elements from the container to the scene
  118472. * @param container the container holding the elements
  118473. */
  118474. addFromContainer(container: AbstractScene): void;
  118475. /**
  118476. * Removes all the elements in the container from the scene
  118477. * @param container contains the elements to remove
  118478. * @param dispose if the removed element should be disposed (default: false)
  118479. */
  118480. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118481. }
  118482. }
  118483. declare module BABYLON {
  118484. /** @hidden */
  118485. export var layerPixelShader: {
  118486. name: string;
  118487. shader: string;
  118488. };
  118489. }
  118490. declare module BABYLON {
  118491. /** @hidden */
  118492. export var layerVertexShader: {
  118493. name: string;
  118494. shader: string;
  118495. };
  118496. }
  118497. declare module BABYLON {
  118498. /**
  118499. * This represents a full screen 2d layer.
  118500. * This can be useful to display a picture in the background of your scene for instance.
  118501. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118502. */
  118503. export class Layer {
  118504. /**
  118505. * Define the name of the layer.
  118506. */
  118507. name: string;
  118508. /**
  118509. * Define the texture the layer should display.
  118510. */
  118511. texture: Nullable<Texture>;
  118512. /**
  118513. * Is the layer in background or foreground.
  118514. */
  118515. isBackground: boolean;
  118516. /**
  118517. * Define the color of the layer (instead of texture).
  118518. */
  118519. color: Color4;
  118520. /**
  118521. * Define the scale of the layer in order to zoom in out of the texture.
  118522. */
  118523. scale: Vector2;
  118524. /**
  118525. * Define an offset for the layer in order to shift the texture.
  118526. */
  118527. offset: Vector2;
  118528. /**
  118529. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  118530. */
  118531. alphaBlendingMode: number;
  118532. /**
  118533. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  118534. * Alpha test will not mix with the background color in case of transparency.
  118535. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  118536. */
  118537. alphaTest: boolean;
  118538. /**
  118539. * Define a mask to restrict the layer to only some of the scene cameras.
  118540. */
  118541. layerMask: number;
  118542. /**
  118543. * Define the list of render target the layer is visible into.
  118544. */
  118545. renderTargetTextures: RenderTargetTexture[];
  118546. /**
  118547. * Define if the layer is only used in renderTarget or if it also
  118548. * renders in the main frame buffer of the canvas.
  118549. */
  118550. renderOnlyInRenderTargetTextures: boolean;
  118551. private _scene;
  118552. private _vertexBuffers;
  118553. private _indexBuffer;
  118554. private _effect;
  118555. private _alphaTestEffect;
  118556. /**
  118557. * An event triggered when the layer is disposed.
  118558. */
  118559. onDisposeObservable: Observable<Layer>;
  118560. private _onDisposeObserver;
  118561. /**
  118562. * Back compatibility with callback before the onDisposeObservable existed.
  118563. * The set callback will be triggered when the layer has been disposed.
  118564. */
  118565. onDispose: () => void;
  118566. /**
  118567. * An event triggered before rendering the scene
  118568. */
  118569. onBeforeRenderObservable: Observable<Layer>;
  118570. private _onBeforeRenderObserver;
  118571. /**
  118572. * Back compatibility with callback before the onBeforeRenderObservable existed.
  118573. * The set callback will be triggered just before rendering the layer.
  118574. */
  118575. onBeforeRender: () => void;
  118576. /**
  118577. * An event triggered after rendering the scene
  118578. */
  118579. onAfterRenderObservable: Observable<Layer>;
  118580. private _onAfterRenderObserver;
  118581. /**
  118582. * Back compatibility with callback before the onAfterRenderObservable existed.
  118583. * The set callback will be triggered just after rendering the layer.
  118584. */
  118585. onAfterRender: () => void;
  118586. /**
  118587. * Instantiates a new layer.
  118588. * This represents a full screen 2d layer.
  118589. * This can be useful to display a picture in the background of your scene for instance.
  118590. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118591. * @param name Define the name of the layer in the scene
  118592. * @param imgUrl Define the url of the texture to display in the layer
  118593. * @param scene Define the scene the layer belongs to
  118594. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  118595. * @param color Defines a color for the layer
  118596. */
  118597. constructor(
  118598. /**
  118599. * Define the name of the layer.
  118600. */
  118601. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  118602. private _createIndexBuffer;
  118603. /** @hidden */
  118604. _rebuild(): void;
  118605. /**
  118606. * Renders the layer in the scene.
  118607. */
  118608. render(): void;
  118609. /**
  118610. * Disposes and releases the associated ressources.
  118611. */
  118612. dispose(): void;
  118613. }
  118614. }
  118615. declare module BABYLON {
  118616. /** @hidden */
  118617. export var lensFlarePixelShader: {
  118618. name: string;
  118619. shader: string;
  118620. };
  118621. }
  118622. declare module BABYLON {
  118623. /** @hidden */
  118624. export var lensFlareVertexShader: {
  118625. name: string;
  118626. shader: string;
  118627. };
  118628. }
  118629. declare module BABYLON {
  118630. /**
  118631. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118632. * It is usually composed of several `lensFlare`.
  118633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118634. */
  118635. export class LensFlareSystem {
  118636. /**
  118637. * Define the name of the lens flare system
  118638. */
  118639. name: string;
  118640. /**
  118641. * List of lens flares used in this system.
  118642. */
  118643. lensFlares: LensFlare[];
  118644. /**
  118645. * Define a limit from the border the lens flare can be visible.
  118646. */
  118647. borderLimit: number;
  118648. /**
  118649. * Define a viewport border we do not want to see the lens flare in.
  118650. */
  118651. viewportBorder: number;
  118652. /**
  118653. * Define a predicate which could limit the list of meshes able to occlude the effect.
  118654. */
  118655. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118656. /**
  118657. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  118658. */
  118659. layerMask: number;
  118660. /**
  118661. * Define the id of the lens flare system in the scene.
  118662. * (equal to name by default)
  118663. */
  118664. id: string;
  118665. private _scene;
  118666. private _emitter;
  118667. private _vertexBuffers;
  118668. private _indexBuffer;
  118669. private _effect;
  118670. private _positionX;
  118671. private _positionY;
  118672. private _isEnabled;
  118673. /** @hidden */
  118674. static _SceneComponentInitialization: (scene: Scene) => void;
  118675. /**
  118676. * Instantiates a lens flare system.
  118677. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118678. * It is usually composed of several `lensFlare`.
  118679. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118680. * @param name Define the name of the lens flare system in the scene
  118681. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  118682. * @param scene Define the scene the lens flare system belongs to
  118683. */
  118684. constructor(
  118685. /**
  118686. * Define the name of the lens flare system
  118687. */
  118688. name: string, emitter: any, scene: Scene);
  118689. /**
  118690. * Define if the lens flare system is enabled.
  118691. */
  118692. isEnabled: boolean;
  118693. /**
  118694. * Get the scene the effects belongs to.
  118695. * @returns the scene holding the lens flare system
  118696. */
  118697. getScene(): Scene;
  118698. /**
  118699. * Get the emitter of the lens flare system.
  118700. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118701. * @returns the emitter of the lens flare system
  118702. */
  118703. getEmitter(): any;
  118704. /**
  118705. * Set the emitter of the lens flare system.
  118706. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118707. * @param newEmitter Define the new emitter of the system
  118708. */
  118709. setEmitter(newEmitter: any): void;
  118710. /**
  118711. * Get the lens flare system emitter position.
  118712. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  118713. * @returns the position
  118714. */
  118715. getEmitterPosition(): Vector3;
  118716. /**
  118717. * @hidden
  118718. */
  118719. computeEffectivePosition(globalViewport: Viewport): boolean;
  118720. /** @hidden */
  118721. _isVisible(): boolean;
  118722. /**
  118723. * @hidden
  118724. */
  118725. render(): boolean;
  118726. /**
  118727. * Dispose and release the lens flare with its associated resources.
  118728. */
  118729. dispose(): void;
  118730. /**
  118731. * Parse a lens flare system from a JSON repressentation
  118732. * @param parsedLensFlareSystem Define the JSON to parse
  118733. * @param scene Define the scene the parsed system should be instantiated in
  118734. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  118735. * @returns the parsed system
  118736. */
  118737. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  118738. /**
  118739. * Serialize the current Lens Flare System into a JSON representation.
  118740. * @returns the serialized JSON
  118741. */
  118742. serialize(): any;
  118743. }
  118744. }
  118745. declare module BABYLON {
  118746. /**
  118747. * This represents one of the lens effect in a `lensFlareSystem`.
  118748. * It controls one of the indiviual texture used in the effect.
  118749. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118750. */
  118751. export class LensFlare {
  118752. /**
  118753. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118754. */
  118755. size: number;
  118756. /**
  118757. * 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.
  118758. */
  118759. position: number;
  118760. /**
  118761. * Define the lens color.
  118762. */
  118763. color: Color3;
  118764. /**
  118765. * Define the lens texture.
  118766. */
  118767. texture: Nullable<Texture>;
  118768. /**
  118769. * Define the alpha mode to render this particular lens.
  118770. */
  118771. alphaMode: number;
  118772. private _system;
  118773. /**
  118774. * Creates a new Lens Flare.
  118775. * This represents one of the lens effect in a `lensFlareSystem`.
  118776. * It controls one of the indiviual texture used in the effect.
  118777. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118778. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  118779. * @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.
  118780. * @param color Define the lens color
  118781. * @param imgUrl Define the lens texture url
  118782. * @param system Define the `lensFlareSystem` this flare is part of
  118783. * @returns The newly created Lens Flare
  118784. */
  118785. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  118786. /**
  118787. * Instantiates a new Lens Flare.
  118788. * This represents one of the lens effect in a `lensFlareSystem`.
  118789. * It controls one of the indiviual texture used in the effect.
  118790. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118791. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  118792. * @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.
  118793. * @param color Define the lens color
  118794. * @param imgUrl Define the lens texture url
  118795. * @param system Define the `lensFlareSystem` this flare is part of
  118796. */
  118797. constructor(
  118798. /**
  118799. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118800. */
  118801. size: number,
  118802. /**
  118803. * 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.
  118804. */
  118805. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  118806. /**
  118807. * Dispose and release the lens flare with its associated resources.
  118808. */
  118809. dispose(): void;
  118810. }
  118811. }
  118812. declare module BABYLON {
  118813. interface AbstractScene {
  118814. /**
  118815. * The list of lens flare system added to the scene
  118816. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118817. */
  118818. lensFlareSystems: Array<LensFlareSystem>;
  118819. /**
  118820. * Removes the given lens flare system from this scene.
  118821. * @param toRemove The lens flare system to remove
  118822. * @returns The index of the removed lens flare system
  118823. */
  118824. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  118825. /**
  118826. * Adds the given lens flare system to this scene
  118827. * @param newLensFlareSystem The lens flare system to add
  118828. */
  118829. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  118830. /**
  118831. * Gets a lens flare system using its name
  118832. * @param name defines the name to look for
  118833. * @returns the lens flare system or null if not found
  118834. */
  118835. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  118836. /**
  118837. * Gets a lens flare system using its id
  118838. * @param id defines the id to look for
  118839. * @returns the lens flare system or null if not found
  118840. */
  118841. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  118842. }
  118843. /**
  118844. * Defines the lens flare scene component responsible to manage any lens flares
  118845. * in a given scene.
  118846. */
  118847. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  118848. /**
  118849. * The component name helpfull to identify the component in the list of scene components.
  118850. */
  118851. readonly name: string;
  118852. /**
  118853. * The scene the component belongs to.
  118854. */
  118855. scene: Scene;
  118856. /**
  118857. * Creates a new instance of the component for the given scene
  118858. * @param scene Defines the scene to register the component in
  118859. */
  118860. constructor(scene: Scene);
  118861. /**
  118862. * Registers the component in a given scene
  118863. */
  118864. register(): void;
  118865. /**
  118866. * Rebuilds the elements related to this component in case of
  118867. * context lost for instance.
  118868. */
  118869. rebuild(): void;
  118870. /**
  118871. * Adds all the elements from the container to the scene
  118872. * @param container the container holding the elements
  118873. */
  118874. addFromContainer(container: AbstractScene): void;
  118875. /**
  118876. * Removes all the elements in the container from the scene
  118877. * @param container contains the elements to remove
  118878. * @param dispose if the removed element should be disposed (default: false)
  118879. */
  118880. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118881. /**
  118882. * Serializes the component data to the specified json object
  118883. * @param serializationObject The object to serialize to
  118884. */
  118885. serialize(serializationObject: any): void;
  118886. /**
  118887. * Disposes the component and the associated ressources.
  118888. */
  118889. dispose(): void;
  118890. private _draw;
  118891. }
  118892. }
  118893. declare module BABYLON {
  118894. /**
  118895. * Defines the shadow generator component responsible to manage any shadow generators
  118896. * in a given scene.
  118897. */
  118898. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  118899. /**
  118900. * The component name helpfull to identify the component in the list of scene components.
  118901. */
  118902. readonly name: string;
  118903. /**
  118904. * The scene the component belongs to.
  118905. */
  118906. scene: Scene;
  118907. /**
  118908. * Creates a new instance of the component for the given scene
  118909. * @param scene Defines the scene to register the component in
  118910. */
  118911. constructor(scene: Scene);
  118912. /**
  118913. * Registers the component in a given scene
  118914. */
  118915. register(): void;
  118916. /**
  118917. * Rebuilds the elements related to this component in case of
  118918. * context lost for instance.
  118919. */
  118920. rebuild(): void;
  118921. /**
  118922. * Serializes the component data to the specified json object
  118923. * @param serializationObject The object to serialize to
  118924. */
  118925. serialize(serializationObject: any): void;
  118926. /**
  118927. * Adds all the elements from the container to the scene
  118928. * @param container the container holding the elements
  118929. */
  118930. addFromContainer(container: AbstractScene): void;
  118931. /**
  118932. * Removes all the elements in the container from the scene
  118933. * @param container contains the elements to remove
  118934. * @param dispose if the removed element should be disposed (default: false)
  118935. */
  118936. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118937. /**
  118938. * Rebuilds the elements related to this component in case of
  118939. * context lost for instance.
  118940. */
  118941. dispose(): void;
  118942. private _gatherRenderTargets;
  118943. }
  118944. }
  118945. declare module BABYLON {
  118946. /**
  118947. * A point light is a light defined by an unique point in world space.
  118948. * The light is emitted in every direction from this point.
  118949. * A good example of a point light is a standard light bulb.
  118950. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118951. */
  118952. export class PointLight extends ShadowLight {
  118953. private _shadowAngle;
  118954. /**
  118955. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118956. * This specifies what angle the shadow will use to be created.
  118957. *
  118958. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118959. */
  118960. /**
  118961. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118962. * This specifies what angle the shadow will use to be created.
  118963. *
  118964. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118965. */
  118966. shadowAngle: number;
  118967. /**
  118968. * Gets the direction if it has been set.
  118969. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118970. */
  118971. /**
  118972. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118973. */
  118974. direction: Vector3;
  118975. /**
  118976. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  118977. * A PointLight emits the light in every direction.
  118978. * It can cast shadows.
  118979. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  118980. * ```javascript
  118981. * var pointLight = new PointLight("pl", camera.position, scene);
  118982. * ```
  118983. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118984. * @param name The light friendly name
  118985. * @param position The position of the point light in the scene
  118986. * @param scene The scene the lights belongs to
  118987. */
  118988. constructor(name: string, position: Vector3, scene: Scene);
  118989. /**
  118990. * Returns the string "PointLight"
  118991. * @returns the class name
  118992. */
  118993. getClassName(): string;
  118994. /**
  118995. * Returns the integer 0.
  118996. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118997. */
  118998. getTypeID(): number;
  118999. /**
  119000. * Specifies wether or not the shadowmap should be a cube texture.
  119001. * @returns true if the shadowmap needs to be a cube texture.
  119002. */
  119003. needCube(): boolean;
  119004. /**
  119005. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119006. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119007. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119008. */
  119009. getShadowDirection(faceIndex?: number): Vector3;
  119010. /**
  119011. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119012. * - fov = PI / 2
  119013. * - aspect ratio : 1.0
  119014. * - z-near and far equal to the active camera minZ and maxZ.
  119015. * Returns the PointLight.
  119016. */
  119017. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119018. protected _buildUniformLayout(): void;
  119019. /**
  119020. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119021. * @param effect The effect to update
  119022. * @param lightIndex The index of the light in the effect to update
  119023. * @returns The point light
  119024. */
  119025. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119026. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119027. /**
  119028. * Prepares the list of defines specific to the light type.
  119029. * @param defines the list of defines
  119030. * @param lightIndex defines the index of the light for the effect
  119031. */
  119032. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119033. }
  119034. }
  119035. declare module BABYLON {
  119036. /**
  119037. * Header information of HDR texture files.
  119038. */
  119039. export interface HDRInfo {
  119040. /**
  119041. * The height of the texture in pixels.
  119042. */
  119043. height: number;
  119044. /**
  119045. * The width of the texture in pixels.
  119046. */
  119047. width: number;
  119048. /**
  119049. * The index of the beginning of the data in the binary file.
  119050. */
  119051. dataPosition: number;
  119052. }
  119053. /**
  119054. * This groups tools to convert HDR texture to native colors array.
  119055. */
  119056. export class HDRTools {
  119057. private static Ldexp;
  119058. private static Rgbe2float;
  119059. private static readStringLine;
  119060. /**
  119061. * Reads header information from an RGBE texture stored in a native array.
  119062. * More information on this format are available here:
  119063. * https://en.wikipedia.org/wiki/RGBE_image_format
  119064. *
  119065. * @param uint8array The binary file stored in native array.
  119066. * @return The header information.
  119067. */
  119068. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119069. /**
  119070. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119071. * This RGBE texture needs to store the information as a panorama.
  119072. *
  119073. * More information on this format are available here:
  119074. * https://en.wikipedia.org/wiki/RGBE_image_format
  119075. *
  119076. * @param buffer The binary file stored in an array buffer.
  119077. * @param size The expected size of the extracted cubemap.
  119078. * @return The Cube Map information.
  119079. */
  119080. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119081. /**
  119082. * Returns the pixels data extracted from an RGBE texture.
  119083. * This pixels will be stored left to right up to down in the R G B order in one array.
  119084. *
  119085. * More information on this format are available here:
  119086. * https://en.wikipedia.org/wiki/RGBE_image_format
  119087. *
  119088. * @param uint8array The binary file stored in an array buffer.
  119089. * @param hdrInfo The header information of the file.
  119090. * @return The pixels data in RGB right to left up to down order.
  119091. */
  119092. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119093. private static RGBE_ReadPixels_RLE;
  119094. }
  119095. }
  119096. declare module BABYLON {
  119097. /**
  119098. * This represents a texture coming from an HDR input.
  119099. *
  119100. * The only supported format is currently panorama picture stored in RGBE format.
  119101. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119102. */
  119103. export class HDRCubeTexture extends BaseTexture {
  119104. private static _facesMapping;
  119105. private _generateHarmonics;
  119106. private _noMipmap;
  119107. private _textureMatrix;
  119108. private _size;
  119109. private _onLoad;
  119110. private _onError;
  119111. /**
  119112. * The texture URL.
  119113. */
  119114. url: string;
  119115. /**
  119116. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119117. */
  119118. coordinatesMode: number;
  119119. protected _isBlocking: boolean;
  119120. /**
  119121. * Sets wether or not the texture is blocking during loading.
  119122. */
  119123. /**
  119124. * Gets wether or not the texture is blocking during loading.
  119125. */
  119126. isBlocking: boolean;
  119127. protected _rotationY: number;
  119128. /**
  119129. * Sets texture matrix rotation angle around Y axis in radians.
  119130. */
  119131. /**
  119132. * Gets texture matrix rotation angle around Y axis radians.
  119133. */
  119134. rotationY: number;
  119135. /**
  119136. * Gets or sets the center of the bounding box associated with the cube texture
  119137. * It must define where the camera used to render the texture was set
  119138. */
  119139. boundingBoxPosition: Vector3;
  119140. private _boundingBoxSize;
  119141. /**
  119142. * Gets or sets the size of the bounding box associated with the cube texture
  119143. * When defined, the cubemap will switch to local mode
  119144. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119145. * @example https://www.babylonjs-playground.com/#RNASML
  119146. */
  119147. boundingBoxSize: Vector3;
  119148. /**
  119149. * Instantiates an HDRTexture from the following parameters.
  119150. *
  119151. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119152. * @param scene The scene the texture will be used in
  119153. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119154. * @param noMipmap Forces to not generate the mipmap if true
  119155. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119156. * @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)
  119157. * @param reserved Reserved flag for internal use.
  119158. */
  119159. 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>);
  119160. /**
  119161. * Get the current class name of the texture useful for serialization or dynamic coding.
  119162. * @returns "HDRCubeTexture"
  119163. */
  119164. getClassName(): string;
  119165. /**
  119166. * Occurs when the file is raw .hdr file.
  119167. */
  119168. private loadTexture;
  119169. clone(): HDRCubeTexture;
  119170. delayLoad(): void;
  119171. /**
  119172. * Get the texture reflection matrix used to rotate/transform the reflection.
  119173. * @returns the reflection matrix
  119174. */
  119175. getReflectionTextureMatrix(): Matrix;
  119176. /**
  119177. * Set the texture reflection matrix used to rotate/transform the reflection.
  119178. * @param value Define the reflection matrix to set
  119179. */
  119180. setReflectionTextureMatrix(value: Matrix): void;
  119181. /**
  119182. * Parses a JSON representation of an HDR Texture in order to create the texture
  119183. * @param parsedTexture Define the JSON representation
  119184. * @param scene Define the scene the texture should be created in
  119185. * @param rootUrl Define the root url in case we need to load relative dependencies
  119186. * @returns the newly created texture after parsing
  119187. */
  119188. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119189. serialize(): any;
  119190. }
  119191. }
  119192. declare module BABYLON {
  119193. /**
  119194. * Class used to control physics engine
  119195. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119196. */
  119197. export class PhysicsEngine implements IPhysicsEngine {
  119198. private _physicsPlugin;
  119199. /**
  119200. * Global value used to control the smallest number supported by the simulation
  119201. */
  119202. static Epsilon: number;
  119203. private _impostors;
  119204. private _joints;
  119205. /**
  119206. * Gets the gravity vector used by the simulation
  119207. */
  119208. gravity: Vector3;
  119209. /**
  119210. * Factory used to create the default physics plugin.
  119211. * @returns The default physics plugin
  119212. */
  119213. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119214. /**
  119215. * Creates a new Physics Engine
  119216. * @param gravity defines the gravity vector used by the simulation
  119217. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119218. */
  119219. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119220. /**
  119221. * Sets the gravity vector used by the simulation
  119222. * @param gravity defines the gravity vector to use
  119223. */
  119224. setGravity(gravity: Vector3): void;
  119225. /**
  119226. * Set the time step of the physics engine.
  119227. * Default is 1/60.
  119228. * To slow it down, enter 1/600 for example.
  119229. * To speed it up, 1/30
  119230. * @param newTimeStep defines the new timestep to apply to this world.
  119231. */
  119232. setTimeStep(newTimeStep?: number): void;
  119233. /**
  119234. * Get the time step of the physics engine.
  119235. * @returns the current time step
  119236. */
  119237. getTimeStep(): number;
  119238. /**
  119239. * Release all resources
  119240. */
  119241. dispose(): void;
  119242. /**
  119243. * Gets the name of the current physics plugin
  119244. * @returns the name of the plugin
  119245. */
  119246. getPhysicsPluginName(): string;
  119247. /**
  119248. * Adding a new impostor for the impostor tracking.
  119249. * This will be done by the impostor itself.
  119250. * @param impostor the impostor to add
  119251. */
  119252. addImpostor(impostor: PhysicsImpostor): void;
  119253. /**
  119254. * Remove an impostor from the engine.
  119255. * This impostor and its mesh will not longer be updated by the physics engine.
  119256. * @param impostor the impostor to remove
  119257. */
  119258. removeImpostor(impostor: PhysicsImpostor): void;
  119259. /**
  119260. * Add a joint to the physics engine
  119261. * @param mainImpostor defines the main impostor to which the joint is added.
  119262. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119263. * @param joint defines the joint that will connect both impostors.
  119264. */
  119265. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119266. /**
  119267. * Removes a joint from the simulation
  119268. * @param mainImpostor defines the impostor used with the joint
  119269. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119270. * @param joint defines the joint to remove
  119271. */
  119272. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119273. /**
  119274. * Called by the scene. No need to call it.
  119275. * @param delta defines the timespam between frames
  119276. */
  119277. _step(delta: number): void;
  119278. /**
  119279. * Gets the current plugin used to run the simulation
  119280. * @returns current plugin
  119281. */
  119282. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119283. /**
  119284. * Gets the list of physic impostors
  119285. * @returns an array of PhysicsImpostor
  119286. */
  119287. getImpostors(): Array<PhysicsImpostor>;
  119288. /**
  119289. * Gets the impostor for a physics enabled object
  119290. * @param object defines the object impersonated by the impostor
  119291. * @returns the PhysicsImpostor or null if not found
  119292. */
  119293. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119294. /**
  119295. * Gets the impostor for a physics body object
  119296. * @param body defines physics body used by the impostor
  119297. * @returns the PhysicsImpostor or null if not found
  119298. */
  119299. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119300. /**
  119301. * Does a raycast in the physics world
  119302. * @param from when should the ray start?
  119303. * @param to when should the ray end?
  119304. * @returns PhysicsRaycastResult
  119305. */
  119306. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119307. }
  119308. }
  119309. declare module BABYLON {
  119310. /** @hidden */
  119311. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119312. private _useDeltaForWorldStep;
  119313. world: any;
  119314. name: string;
  119315. private _physicsMaterials;
  119316. private _fixedTimeStep;
  119317. private _cannonRaycastResult;
  119318. private _raycastResult;
  119319. private _physicsBodysToRemoveAfterStep;
  119320. BJSCANNON: any;
  119321. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119322. setGravity(gravity: Vector3): void;
  119323. setTimeStep(timeStep: number): void;
  119324. getTimeStep(): number;
  119325. executeStep(delta: number): void;
  119326. private _removeMarkedPhysicsBodiesFromWorld;
  119327. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119328. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119329. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119330. private _processChildMeshes;
  119331. removePhysicsBody(impostor: PhysicsImpostor): void;
  119332. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119333. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119334. private _addMaterial;
  119335. private _checkWithEpsilon;
  119336. private _createShape;
  119337. private _createHeightmap;
  119338. private _minus90X;
  119339. private _plus90X;
  119340. private _tmpPosition;
  119341. private _tmpDeltaPosition;
  119342. private _tmpUnityRotation;
  119343. private _updatePhysicsBodyTransformation;
  119344. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119346. isSupported(): boolean;
  119347. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119348. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119349. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119350. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119351. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119352. getBodyMass(impostor: PhysicsImpostor): number;
  119353. getBodyFriction(impostor: PhysicsImpostor): number;
  119354. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119355. getBodyRestitution(impostor: PhysicsImpostor): number;
  119356. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119357. sleepBody(impostor: PhysicsImpostor): void;
  119358. wakeUpBody(impostor: PhysicsImpostor): void;
  119359. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119360. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119361. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119362. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119363. getRadius(impostor: PhysicsImpostor): number;
  119364. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119365. dispose(): void;
  119366. private _extendNamespace;
  119367. /**
  119368. * Does a raycast in the physics world
  119369. * @param from when should the ray start?
  119370. * @param to when should the ray end?
  119371. * @returns PhysicsRaycastResult
  119372. */
  119373. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119374. }
  119375. }
  119376. declare module BABYLON {
  119377. /** @hidden */
  119378. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  119379. world: any;
  119380. name: string;
  119381. BJSOIMO: any;
  119382. private _raycastResult;
  119383. constructor(iterations?: number, oimoInjection?: any);
  119384. setGravity(gravity: Vector3): void;
  119385. setTimeStep(timeStep: number): void;
  119386. getTimeStep(): number;
  119387. private _tmpImpostorsArray;
  119388. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119389. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119390. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119391. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119392. private _tmpPositionVector;
  119393. removePhysicsBody(impostor: PhysicsImpostor): void;
  119394. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119395. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119396. isSupported(): boolean;
  119397. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119398. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119399. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119400. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119401. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119402. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119403. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119404. getBodyMass(impostor: PhysicsImpostor): number;
  119405. getBodyFriction(impostor: PhysicsImpostor): number;
  119406. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119407. getBodyRestitution(impostor: PhysicsImpostor): number;
  119408. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119409. sleepBody(impostor: PhysicsImpostor): void;
  119410. wakeUpBody(impostor: PhysicsImpostor): void;
  119411. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119412. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119413. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119414. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119415. getRadius(impostor: PhysicsImpostor): number;
  119416. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119417. dispose(): void;
  119418. /**
  119419. * Does a raycast in the physics world
  119420. * @param from when should the ray start?
  119421. * @param to when should the ray end?
  119422. * @returns PhysicsRaycastResult
  119423. */
  119424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119425. }
  119426. }
  119427. declare module BABYLON {
  119428. /**
  119429. * Class containing static functions to help procedurally build meshes
  119430. */
  119431. export class RibbonBuilder {
  119432. /**
  119433. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119434. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119435. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119436. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119437. * * 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
  119438. * * 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
  119439. * * 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
  119440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119443. * * 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
  119444. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119445. * * 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
  119446. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119448. * @param name defines the name of the mesh
  119449. * @param options defines the options used to create the mesh
  119450. * @param scene defines the hosting scene
  119451. * @returns the ribbon mesh
  119452. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119453. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119454. */
  119455. static CreateRibbon(name: string, options: {
  119456. pathArray: Vector3[][];
  119457. closeArray?: boolean;
  119458. closePath?: boolean;
  119459. offset?: number;
  119460. updatable?: boolean;
  119461. sideOrientation?: number;
  119462. frontUVs?: Vector4;
  119463. backUVs?: Vector4;
  119464. instance?: Mesh;
  119465. invertUV?: boolean;
  119466. uvs?: Vector2[];
  119467. colors?: Color4[];
  119468. }, scene?: Nullable<Scene>): Mesh;
  119469. }
  119470. }
  119471. declare module BABYLON {
  119472. /**
  119473. * Class containing static functions to help procedurally build meshes
  119474. */
  119475. export class ShapeBuilder {
  119476. /**
  119477. * 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.
  119478. * * 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.
  119479. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119480. * * 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.
  119481. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119482. * * 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
  119483. * * 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
  119484. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119489. * @param name defines the name of the mesh
  119490. * @param options defines the options used to create the mesh
  119491. * @param scene defines the hosting scene
  119492. * @returns the extruded shape mesh
  119493. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119495. */
  119496. static ExtrudeShape(name: string, options: {
  119497. shape: Vector3[];
  119498. path: Vector3[];
  119499. scale?: number;
  119500. rotation?: number;
  119501. cap?: number;
  119502. updatable?: boolean;
  119503. sideOrientation?: number;
  119504. frontUVs?: Vector4;
  119505. backUVs?: Vector4;
  119506. instance?: Mesh;
  119507. invertUV?: boolean;
  119508. }, scene?: Nullable<Scene>): Mesh;
  119509. /**
  119510. * Creates an custom extruded shape mesh.
  119511. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119512. * * 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.
  119513. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119514. * * 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
  119515. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119516. * * 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
  119517. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119518. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119519. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119520. * * 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
  119521. * * 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
  119522. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119525. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119527. * @param name defines the name of the mesh
  119528. * @param options defines the options used to create the mesh
  119529. * @param scene defines the hosting scene
  119530. * @returns the custom extruded shape mesh
  119531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119532. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119534. */
  119535. static ExtrudeShapeCustom(name: string, options: {
  119536. shape: Vector3[];
  119537. path: Vector3[];
  119538. scaleFunction?: any;
  119539. rotationFunction?: any;
  119540. ribbonCloseArray?: boolean;
  119541. ribbonClosePath?: boolean;
  119542. cap?: number;
  119543. updatable?: boolean;
  119544. sideOrientation?: number;
  119545. frontUVs?: Vector4;
  119546. backUVs?: Vector4;
  119547. instance?: Mesh;
  119548. invertUV?: boolean;
  119549. }, scene?: Nullable<Scene>): Mesh;
  119550. private static _ExtrudeShapeGeneric;
  119551. }
  119552. }
  119553. declare module BABYLON {
  119554. /**
  119555. * AmmoJS Physics plugin
  119556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  119557. * @see https://github.com/kripken/ammo.js/
  119558. */
  119559. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  119560. private _useDeltaForWorldStep;
  119561. /**
  119562. * Reference to the Ammo library
  119563. */
  119564. bjsAMMO: any;
  119565. /**
  119566. * Created ammoJS world which physics bodies are added to
  119567. */
  119568. world: any;
  119569. /**
  119570. * Name of the plugin
  119571. */
  119572. name: string;
  119573. private _timeStep;
  119574. private _fixedTimeStep;
  119575. private _maxSteps;
  119576. private _tmpQuaternion;
  119577. private _tmpAmmoTransform;
  119578. private _tmpAmmoQuaternion;
  119579. private _tmpAmmoConcreteContactResultCallback;
  119580. private _collisionConfiguration;
  119581. private _dispatcher;
  119582. private _overlappingPairCache;
  119583. private _solver;
  119584. private _softBodySolver;
  119585. private _tmpAmmoVectorA;
  119586. private _tmpAmmoVectorB;
  119587. private _tmpAmmoVectorC;
  119588. private _tmpAmmoVectorD;
  119589. private _tmpContactCallbackResult;
  119590. private _tmpAmmoVectorRCA;
  119591. private _tmpAmmoVectorRCB;
  119592. private _raycastResult;
  119593. private static readonly DISABLE_COLLISION_FLAG;
  119594. private static readonly KINEMATIC_FLAG;
  119595. private static readonly DISABLE_DEACTIVATION_FLAG;
  119596. /**
  119597. * Initializes the ammoJS plugin
  119598. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  119599. * @param ammoInjection can be used to inject your own ammo reference
  119600. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  119601. */
  119602. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  119603. /**
  119604. * Sets the gravity of the physics world (m/(s^2))
  119605. * @param gravity Gravity to set
  119606. */
  119607. setGravity(gravity: Vector3): void;
  119608. /**
  119609. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  119610. * @param timeStep timestep to use in seconds
  119611. */
  119612. setTimeStep(timeStep: number): void;
  119613. /**
  119614. * 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)
  119615. * @param fixedTimeStep fixedTimeStep to use in seconds
  119616. */
  119617. setFixedTimeStep(fixedTimeStep: number): void;
  119618. /**
  119619. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  119620. * @param maxSteps the maximum number of steps by the physics engine per frame
  119621. */
  119622. setMaxSteps(maxSteps: number): void;
  119623. /**
  119624. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  119625. * @returns the current timestep in seconds
  119626. */
  119627. getTimeStep(): number;
  119628. private _isImpostorInContact;
  119629. private _isImpostorPairInContact;
  119630. private _stepSimulation;
  119631. /**
  119632. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  119633. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  119634. * After the step the babylon meshes are set to the position of the physics imposters
  119635. * @param delta amount of time to step forward
  119636. * @param impostors array of imposters to update before/after the step
  119637. */
  119638. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119639. /**
  119640. * Update babylon mesh to match physics world object
  119641. * @param impostor imposter to match
  119642. */
  119643. private _afterSoftStep;
  119644. /**
  119645. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119646. * @param impostor imposter to match
  119647. */
  119648. private _ropeStep;
  119649. /**
  119650. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119651. * @param impostor imposter to match
  119652. */
  119653. private _softbodyOrClothStep;
  119654. private _tmpVector;
  119655. private _tmpMatrix;
  119656. /**
  119657. * Applies an impulse on the imposter
  119658. * @param impostor imposter to apply impulse to
  119659. * @param force amount of force to be applied to the imposter
  119660. * @param contactPoint the location to apply the impulse on the imposter
  119661. */
  119662. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119663. /**
  119664. * Applies a force on the imposter
  119665. * @param impostor imposter to apply force
  119666. * @param force amount of force to be applied to the imposter
  119667. * @param contactPoint the location to apply the force on the imposter
  119668. */
  119669. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119670. /**
  119671. * Creates a physics body using the plugin
  119672. * @param impostor the imposter to create the physics body on
  119673. */
  119674. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119675. /**
  119676. * Removes the physics body from the imposter and disposes of the body's memory
  119677. * @param impostor imposter to remove the physics body from
  119678. */
  119679. removePhysicsBody(impostor: PhysicsImpostor): void;
  119680. /**
  119681. * Generates a joint
  119682. * @param impostorJoint the imposter joint to create the joint with
  119683. */
  119684. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119685. /**
  119686. * Removes a joint
  119687. * @param impostorJoint the imposter joint to remove the joint from
  119688. */
  119689. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119690. private _addMeshVerts;
  119691. /**
  119692. * Initialise the soft body vertices to match its object's (mesh) vertices
  119693. * Softbody vertices (nodes) are in world space and to match this
  119694. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  119695. * @param impostor to create the softbody for
  119696. */
  119697. private _softVertexData;
  119698. /**
  119699. * Create an impostor's soft body
  119700. * @param impostor to create the softbody for
  119701. */
  119702. private _createSoftbody;
  119703. /**
  119704. * Create cloth for an impostor
  119705. * @param impostor to create the softbody for
  119706. */
  119707. private _createCloth;
  119708. /**
  119709. * Create rope for an impostor
  119710. * @param impostor to create the softbody for
  119711. */
  119712. private _createRope;
  119713. private _addHullVerts;
  119714. private _createShape;
  119715. /**
  119716. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  119717. * @param impostor imposter containing the physics body and babylon object
  119718. */
  119719. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119720. /**
  119721. * Sets the babylon object's position/rotation from the physics body's position/rotation
  119722. * @param impostor imposter containing the physics body and babylon object
  119723. * @param newPosition new position
  119724. * @param newRotation new rotation
  119725. */
  119726. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119727. /**
  119728. * If this plugin is supported
  119729. * @returns true if its supported
  119730. */
  119731. isSupported(): boolean;
  119732. /**
  119733. * Sets the linear velocity of the physics body
  119734. * @param impostor imposter to set the velocity on
  119735. * @param velocity velocity to set
  119736. */
  119737. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119738. /**
  119739. * Sets the angular velocity of the physics body
  119740. * @param impostor imposter to set the velocity on
  119741. * @param velocity velocity to set
  119742. */
  119743. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119744. /**
  119745. * gets the linear velocity
  119746. * @param impostor imposter to get linear velocity from
  119747. * @returns linear velocity
  119748. */
  119749. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119750. /**
  119751. * gets the angular velocity
  119752. * @param impostor imposter to get angular velocity from
  119753. * @returns angular velocity
  119754. */
  119755. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119756. /**
  119757. * Sets the mass of physics body
  119758. * @param impostor imposter to set the mass on
  119759. * @param mass mass to set
  119760. */
  119761. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119762. /**
  119763. * Gets the mass of the physics body
  119764. * @param impostor imposter to get the mass from
  119765. * @returns mass
  119766. */
  119767. getBodyMass(impostor: PhysicsImpostor): number;
  119768. /**
  119769. * Gets friction of the impostor
  119770. * @param impostor impostor to get friction from
  119771. * @returns friction value
  119772. */
  119773. getBodyFriction(impostor: PhysicsImpostor): number;
  119774. /**
  119775. * Sets friction of the impostor
  119776. * @param impostor impostor to set friction on
  119777. * @param friction friction value
  119778. */
  119779. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119780. /**
  119781. * Gets restitution of the impostor
  119782. * @param impostor impostor to get restitution from
  119783. * @returns restitution value
  119784. */
  119785. getBodyRestitution(impostor: PhysicsImpostor): number;
  119786. /**
  119787. * Sets resitution of the impostor
  119788. * @param impostor impostor to set resitution on
  119789. * @param restitution resitution value
  119790. */
  119791. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119792. /**
  119793. * Gets pressure inside the impostor
  119794. * @param impostor impostor to get pressure from
  119795. * @returns pressure value
  119796. */
  119797. getBodyPressure(impostor: PhysicsImpostor): number;
  119798. /**
  119799. * Sets pressure inside a soft body impostor
  119800. * Cloth and rope must remain 0 pressure
  119801. * @param impostor impostor to set pressure on
  119802. * @param pressure pressure value
  119803. */
  119804. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  119805. /**
  119806. * Gets stiffness of the impostor
  119807. * @param impostor impostor to get stiffness from
  119808. * @returns pressure value
  119809. */
  119810. getBodyStiffness(impostor: PhysicsImpostor): number;
  119811. /**
  119812. * Sets stiffness of the impostor
  119813. * @param impostor impostor to set stiffness on
  119814. * @param stiffness stiffness value from 0 to 1
  119815. */
  119816. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  119817. /**
  119818. * Gets velocityIterations of the impostor
  119819. * @param impostor impostor to get velocity iterations from
  119820. * @returns velocityIterations value
  119821. */
  119822. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  119823. /**
  119824. * Sets velocityIterations of the impostor
  119825. * @param impostor impostor to set velocity iterations on
  119826. * @param velocityIterations velocityIterations value
  119827. */
  119828. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  119829. /**
  119830. * Gets positionIterations of the impostor
  119831. * @param impostor impostor to get position iterations from
  119832. * @returns positionIterations value
  119833. */
  119834. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  119835. /**
  119836. * Sets positionIterations of the impostor
  119837. * @param impostor impostor to set position on
  119838. * @param positionIterations positionIterations value
  119839. */
  119840. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  119841. /**
  119842. * Append an anchor to a cloth object
  119843. * @param impostor is the cloth impostor to add anchor to
  119844. * @param otherImpostor is the rigid impostor to anchor to
  119845. * @param width ratio across width from 0 to 1
  119846. * @param height ratio up height from 0 to 1
  119847. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  119848. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119849. */
  119850. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119851. /**
  119852. * Append an hook to a rope object
  119853. * @param impostor is the rope impostor to add hook to
  119854. * @param otherImpostor is the rigid impostor to hook to
  119855. * @param length ratio along the rope from 0 to 1
  119856. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  119857. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119858. */
  119859. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119860. /**
  119861. * Sleeps the physics body and stops it from being active
  119862. * @param impostor impostor to sleep
  119863. */
  119864. sleepBody(impostor: PhysicsImpostor): void;
  119865. /**
  119866. * Activates the physics body
  119867. * @param impostor impostor to activate
  119868. */
  119869. wakeUpBody(impostor: PhysicsImpostor): void;
  119870. /**
  119871. * Updates the distance parameters of the joint
  119872. * @param joint joint to update
  119873. * @param maxDistance maximum distance of the joint
  119874. * @param minDistance minimum distance of the joint
  119875. */
  119876. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119877. /**
  119878. * Sets a motor on the joint
  119879. * @param joint joint to set motor on
  119880. * @param speed speed of the motor
  119881. * @param maxForce maximum force of the motor
  119882. * @param motorIndex index of the motor
  119883. */
  119884. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119885. /**
  119886. * Sets the motors limit
  119887. * @param joint joint to set limit on
  119888. * @param upperLimit upper limit
  119889. * @param lowerLimit lower limit
  119890. */
  119891. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119892. /**
  119893. * Syncs the position and rotation of a mesh with the impostor
  119894. * @param mesh mesh to sync
  119895. * @param impostor impostor to update the mesh with
  119896. */
  119897. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119898. /**
  119899. * Gets the radius of the impostor
  119900. * @param impostor impostor to get radius from
  119901. * @returns the radius
  119902. */
  119903. getRadius(impostor: PhysicsImpostor): number;
  119904. /**
  119905. * Gets the box size of the impostor
  119906. * @param impostor impostor to get box size from
  119907. * @param result the resulting box size
  119908. */
  119909. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119910. /**
  119911. * Disposes of the impostor
  119912. */
  119913. dispose(): void;
  119914. /**
  119915. * Does a raycast in the physics world
  119916. * @param from when should the ray start?
  119917. * @param to when should the ray end?
  119918. * @returns PhysicsRaycastResult
  119919. */
  119920. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119921. }
  119922. }
  119923. declare module BABYLON {
  119924. interface AbstractScene {
  119925. /**
  119926. * The list of reflection probes added to the scene
  119927. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119928. */
  119929. reflectionProbes: Array<ReflectionProbe>;
  119930. /**
  119931. * Removes the given reflection probe from this scene.
  119932. * @param toRemove The reflection probe to remove
  119933. * @returns The index of the removed reflection probe
  119934. */
  119935. removeReflectionProbe(toRemove: ReflectionProbe): number;
  119936. /**
  119937. * Adds the given reflection probe to this scene.
  119938. * @param newReflectionProbe The reflection probe to add
  119939. */
  119940. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  119941. }
  119942. /**
  119943. * Class used to generate realtime reflection / refraction cube textures
  119944. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119945. */
  119946. export class ReflectionProbe {
  119947. /** defines the name of the probe */
  119948. name: string;
  119949. private _scene;
  119950. private _renderTargetTexture;
  119951. private _projectionMatrix;
  119952. private _viewMatrix;
  119953. private _target;
  119954. private _add;
  119955. private _attachedMesh;
  119956. private _invertYAxis;
  119957. /** Gets or sets probe position (center of the cube map) */
  119958. position: Vector3;
  119959. /**
  119960. * Creates a new reflection probe
  119961. * @param name defines the name of the probe
  119962. * @param size defines the texture resolution (for each face)
  119963. * @param scene defines the hosting scene
  119964. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119965. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119966. */
  119967. constructor(
  119968. /** defines the name of the probe */
  119969. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  119970. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119971. samples: number;
  119972. /** Gets or sets the refresh rate to use (on every frame by default) */
  119973. refreshRate: number;
  119974. /**
  119975. * Gets the hosting scene
  119976. * @returns a Scene
  119977. */
  119978. getScene(): Scene;
  119979. /** Gets the internal CubeTexture used to render to */
  119980. readonly cubeTexture: RenderTargetTexture;
  119981. /** Gets the list of meshes to render */
  119982. readonly renderList: Nullable<AbstractMesh[]>;
  119983. /**
  119984. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119985. * @param mesh defines the mesh to attach to
  119986. */
  119987. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119988. /**
  119989. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119990. * @param renderingGroupId The rendering group id corresponding to its index
  119991. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119992. */
  119993. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119994. /**
  119995. * Clean all associated resources
  119996. */
  119997. dispose(): void;
  119998. /**
  119999. * Converts the reflection probe information to a readable string for debug purpose.
  120000. * @param fullDetails Supports for multiple levels of logging within scene loading
  120001. * @returns the human readable reflection probe info
  120002. */
  120003. toString(fullDetails?: boolean): string;
  120004. /**
  120005. * Get the class name of the relfection probe.
  120006. * @returns "ReflectionProbe"
  120007. */
  120008. getClassName(): string;
  120009. /**
  120010. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120011. * @returns The JSON representation of the texture
  120012. */
  120013. serialize(): any;
  120014. /**
  120015. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120016. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120017. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120018. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120019. * @returns The parsed reflection probe if successful
  120020. */
  120021. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120022. }
  120023. }
  120024. declare module BABYLON {
  120025. /** @hidden */
  120026. export var _BabylonLoaderRegistered: boolean;
  120027. /**
  120028. * Helps setting up some configuration for the babylon file loader.
  120029. */
  120030. export class BabylonFileLoaderConfiguration {
  120031. /**
  120032. * The loader does not allow injecting custom physix engine into the plugins.
  120033. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120034. * So you could set this variable to your engine import to make it work.
  120035. */
  120036. static LoaderInjectedPhysicsEngine: any;
  120037. }
  120038. }
  120039. declare module BABYLON {
  120040. /**
  120041. * The Physically based simple base material of BJS.
  120042. *
  120043. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120044. * It is used as the base class for both the specGloss and metalRough conventions.
  120045. */
  120046. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120047. /**
  120048. * Number of Simultaneous lights allowed on the material.
  120049. */
  120050. maxSimultaneousLights: number;
  120051. /**
  120052. * If sets to true, disables all the lights affecting the material.
  120053. */
  120054. disableLighting: boolean;
  120055. /**
  120056. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120057. */
  120058. environmentTexture: BaseTexture;
  120059. /**
  120060. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120061. */
  120062. invertNormalMapX: boolean;
  120063. /**
  120064. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120065. */
  120066. invertNormalMapY: boolean;
  120067. /**
  120068. * Normal map used in the model.
  120069. */
  120070. normalTexture: BaseTexture;
  120071. /**
  120072. * Emissivie color used to self-illuminate the model.
  120073. */
  120074. emissiveColor: Color3;
  120075. /**
  120076. * Emissivie texture used to self-illuminate the model.
  120077. */
  120078. emissiveTexture: BaseTexture;
  120079. /**
  120080. * Occlusion Channel Strenght.
  120081. */
  120082. occlusionStrength: number;
  120083. /**
  120084. * Occlusion Texture of the material (adding extra occlusion effects).
  120085. */
  120086. occlusionTexture: BaseTexture;
  120087. /**
  120088. * Defines the alpha limits in alpha test mode.
  120089. */
  120090. alphaCutOff: number;
  120091. /**
  120092. * Gets the current double sided mode.
  120093. */
  120094. /**
  120095. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120096. */
  120097. doubleSided: boolean;
  120098. /**
  120099. * Stores the pre-calculated light information of a mesh in a texture.
  120100. */
  120101. lightmapTexture: BaseTexture;
  120102. /**
  120103. * If true, the light map contains occlusion information instead of lighting info.
  120104. */
  120105. useLightmapAsShadowmap: boolean;
  120106. /**
  120107. * Instantiates a new PBRMaterial instance.
  120108. *
  120109. * @param name The material name
  120110. * @param scene The scene the material will be use in.
  120111. */
  120112. constructor(name: string, scene: Scene);
  120113. getClassName(): string;
  120114. }
  120115. }
  120116. declare module BABYLON {
  120117. /**
  120118. * The PBR material of BJS following the metal roughness convention.
  120119. *
  120120. * This fits to the PBR convention in the GLTF definition:
  120121. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120122. */
  120123. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120124. /**
  120125. * The base color has two different interpretations depending on the value of metalness.
  120126. * When the material is a metal, the base color is the specific measured reflectance value
  120127. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120128. * of the material.
  120129. */
  120130. baseColor: Color3;
  120131. /**
  120132. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120133. * well as opacity information in the alpha channel.
  120134. */
  120135. baseTexture: BaseTexture;
  120136. /**
  120137. * Specifies the metallic scalar value of the material.
  120138. * Can also be used to scale the metalness values of the metallic texture.
  120139. */
  120140. metallic: number;
  120141. /**
  120142. * Specifies the roughness scalar value of the material.
  120143. * Can also be used to scale the roughness values of the metallic texture.
  120144. */
  120145. roughness: number;
  120146. /**
  120147. * Texture containing both the metallic value in the B channel and the
  120148. * roughness value in the G channel to keep better precision.
  120149. */
  120150. metallicRoughnessTexture: BaseTexture;
  120151. /**
  120152. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120153. *
  120154. * @param name The material name
  120155. * @param scene The scene the material will be use in.
  120156. */
  120157. constructor(name: string, scene: Scene);
  120158. /**
  120159. * Return the currrent class name of the material.
  120160. */
  120161. getClassName(): string;
  120162. /**
  120163. * Makes a duplicate of the current material.
  120164. * @param name - name to use for the new material.
  120165. */
  120166. clone(name: string): PBRMetallicRoughnessMaterial;
  120167. /**
  120168. * Serialize the material to a parsable JSON object.
  120169. */
  120170. serialize(): any;
  120171. /**
  120172. * Parses a JSON object correponding to the serialize function.
  120173. */
  120174. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120175. }
  120176. }
  120177. declare module BABYLON {
  120178. /**
  120179. * The PBR material of BJS following the specular glossiness convention.
  120180. *
  120181. * This fits to the PBR convention in the GLTF definition:
  120182. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120183. */
  120184. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120185. /**
  120186. * Specifies the diffuse color of the material.
  120187. */
  120188. diffuseColor: Color3;
  120189. /**
  120190. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120191. * channel.
  120192. */
  120193. diffuseTexture: BaseTexture;
  120194. /**
  120195. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120196. */
  120197. specularColor: Color3;
  120198. /**
  120199. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120200. */
  120201. glossiness: number;
  120202. /**
  120203. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120204. */
  120205. specularGlossinessTexture: BaseTexture;
  120206. /**
  120207. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120208. *
  120209. * @param name The material name
  120210. * @param scene The scene the material will be use in.
  120211. */
  120212. constructor(name: string, scene: Scene);
  120213. /**
  120214. * Return the currrent class name of the material.
  120215. */
  120216. getClassName(): string;
  120217. /**
  120218. * Makes a duplicate of the current material.
  120219. * @param name - name to use for the new material.
  120220. */
  120221. clone(name: string): PBRSpecularGlossinessMaterial;
  120222. /**
  120223. * Serialize the material to a parsable JSON object.
  120224. */
  120225. serialize(): any;
  120226. /**
  120227. * Parses a JSON object correponding to the serialize function.
  120228. */
  120229. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120230. }
  120231. }
  120232. declare module BABYLON {
  120233. /**
  120234. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120235. * It can help converting any input color in a desired output one. This can then be used to create effects
  120236. * from sepia, black and white to sixties or futuristic rendering...
  120237. *
  120238. * The only supported format is currently 3dl.
  120239. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120240. */
  120241. export class ColorGradingTexture extends BaseTexture {
  120242. /**
  120243. * The current texture matrix. (will always be identity in color grading texture)
  120244. */
  120245. private _textureMatrix;
  120246. /**
  120247. * The texture URL.
  120248. */
  120249. url: string;
  120250. /**
  120251. * Empty line regex stored for GC.
  120252. */
  120253. private static _noneEmptyLineRegex;
  120254. private _engine;
  120255. /**
  120256. * Instantiates a ColorGradingTexture from the following parameters.
  120257. *
  120258. * @param url The location of the color gradind data (currently only supporting 3dl)
  120259. * @param scene The scene the texture will be used in
  120260. */
  120261. constructor(url: string, scene: Scene);
  120262. /**
  120263. * Returns the texture matrix used in most of the material.
  120264. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120265. */
  120266. getTextureMatrix(): Matrix;
  120267. /**
  120268. * Occurs when the file being loaded is a .3dl LUT file.
  120269. */
  120270. private load3dlTexture;
  120271. /**
  120272. * Starts the loading process of the texture.
  120273. */
  120274. private loadTexture;
  120275. /**
  120276. * Clones the color gradind texture.
  120277. */
  120278. clone(): ColorGradingTexture;
  120279. /**
  120280. * Called during delayed load for textures.
  120281. */
  120282. delayLoad(): void;
  120283. /**
  120284. * Parses a color grading texture serialized by Babylon.
  120285. * @param parsedTexture The texture information being parsedTexture
  120286. * @param scene The scene to load the texture in
  120287. * @param rootUrl The root url of the data assets to load
  120288. * @return A color gradind texture
  120289. */
  120290. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120291. /**
  120292. * Serializes the LUT texture to json format.
  120293. */
  120294. serialize(): any;
  120295. }
  120296. }
  120297. declare module BABYLON {
  120298. /**
  120299. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120300. */
  120301. export class EquiRectangularCubeTexture extends BaseTexture {
  120302. /** The six faces of the cube. */
  120303. private static _FacesMapping;
  120304. private _noMipmap;
  120305. private _onLoad;
  120306. private _onError;
  120307. /** The size of the cubemap. */
  120308. private _size;
  120309. /** The buffer of the image. */
  120310. private _buffer;
  120311. /** The width of the input image. */
  120312. private _width;
  120313. /** The height of the input image. */
  120314. private _height;
  120315. /** The URL to the image. */
  120316. url: string;
  120317. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120318. coordinatesMode: number;
  120319. /**
  120320. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120321. * @param url The location of the image
  120322. * @param scene The scene the texture will be used in
  120323. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120324. * @param noMipmap Forces to not generate the mipmap if true
  120325. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120326. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120327. * @param onLoad — defines a callback called when texture is loaded
  120328. * @param onError — defines a callback called if there is an error
  120329. */
  120330. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120331. /**
  120332. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120333. */
  120334. private loadImage;
  120335. /**
  120336. * Convert the image buffer into a cubemap and create a CubeTexture.
  120337. */
  120338. private loadTexture;
  120339. /**
  120340. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120341. * @param buffer The ArrayBuffer that should be converted.
  120342. * @returns The buffer as Float32Array.
  120343. */
  120344. private getFloat32ArrayFromArrayBuffer;
  120345. /**
  120346. * Get the current class name of the texture useful for serialization or dynamic coding.
  120347. * @returns "EquiRectangularCubeTexture"
  120348. */
  120349. getClassName(): string;
  120350. /**
  120351. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120352. * @returns A clone of the current EquiRectangularCubeTexture.
  120353. */
  120354. clone(): EquiRectangularCubeTexture;
  120355. }
  120356. }
  120357. declare module BABYLON {
  120358. /**
  120359. * Based on jsTGALoader - Javascript loader for TGA file
  120360. * By Vincent Thibault
  120361. * @see http://blog.robrowser.com/javascript-tga-loader.html
  120362. */
  120363. export class TGATools {
  120364. private static _TYPE_INDEXED;
  120365. private static _TYPE_RGB;
  120366. private static _TYPE_GREY;
  120367. private static _TYPE_RLE_INDEXED;
  120368. private static _TYPE_RLE_RGB;
  120369. private static _TYPE_RLE_GREY;
  120370. private static _ORIGIN_MASK;
  120371. private static _ORIGIN_SHIFT;
  120372. private static _ORIGIN_BL;
  120373. private static _ORIGIN_BR;
  120374. private static _ORIGIN_UL;
  120375. private static _ORIGIN_UR;
  120376. /**
  120377. * Gets the header of a TGA file
  120378. * @param data defines the TGA data
  120379. * @returns the header
  120380. */
  120381. static GetTGAHeader(data: Uint8Array): any;
  120382. /**
  120383. * Uploads TGA content to a Babylon Texture
  120384. * @hidden
  120385. */
  120386. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  120387. /** @hidden */
  120388. 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;
  120389. /** @hidden */
  120390. 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;
  120391. /** @hidden */
  120392. 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;
  120393. /** @hidden */
  120394. 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;
  120395. /** @hidden */
  120396. 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;
  120397. /** @hidden */
  120398. 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;
  120399. }
  120400. }
  120401. declare module BABYLON {
  120402. /**
  120403. * Implementation of the TGA Texture Loader.
  120404. * @hidden
  120405. */
  120406. export class _TGATextureLoader implements IInternalTextureLoader {
  120407. /**
  120408. * Defines wether the loader supports cascade loading the different faces.
  120409. */
  120410. readonly supportCascades: boolean;
  120411. /**
  120412. * This returns if the loader support the current file information.
  120413. * @param extension defines the file extension of the file being loaded
  120414. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120415. * @param fallback defines the fallback internal texture if any
  120416. * @param isBase64 defines whether the texture is encoded as a base64
  120417. * @param isBuffer defines whether the texture data are stored as a buffer
  120418. * @returns true if the loader can load the specified file
  120419. */
  120420. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120421. /**
  120422. * Transform the url before loading if required.
  120423. * @param rootUrl the url of the texture
  120424. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120425. * @returns the transformed texture
  120426. */
  120427. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120428. /**
  120429. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120430. * @param rootUrl the url of the texture
  120431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120432. * @returns the fallback texture
  120433. */
  120434. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120435. /**
  120436. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120437. * @param data contains the texture data
  120438. * @param texture defines the BabylonJS internal texture
  120439. * @param createPolynomials will be true if polynomials have been requested
  120440. * @param onLoad defines the callback to trigger once the texture is ready
  120441. * @param onError defines the callback to trigger in case of error
  120442. */
  120443. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120444. /**
  120445. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120446. * @param data contains the texture data
  120447. * @param texture defines the BabylonJS internal texture
  120448. * @param callback defines the method to call once ready to upload
  120449. */
  120450. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120451. }
  120452. }
  120453. declare module BABYLON {
  120454. /**
  120455. * Info about the .basis files
  120456. */
  120457. class BasisFileInfo {
  120458. /**
  120459. * If the file has alpha
  120460. */
  120461. hasAlpha: boolean;
  120462. /**
  120463. * Info about each image of the basis file
  120464. */
  120465. images: Array<{
  120466. levels: Array<{
  120467. width: number;
  120468. height: number;
  120469. transcodedPixels: ArrayBufferView;
  120470. }>;
  120471. }>;
  120472. }
  120473. /**
  120474. * Result of transcoding a basis file
  120475. */
  120476. class TranscodeResult {
  120477. /**
  120478. * Info about the .basis file
  120479. */
  120480. fileInfo: BasisFileInfo;
  120481. /**
  120482. * Format to use when loading the file
  120483. */
  120484. format: number;
  120485. }
  120486. /**
  120487. * Configuration options for the Basis transcoder
  120488. */
  120489. export class BasisTranscodeConfiguration {
  120490. /**
  120491. * Supported compression formats used to determine the supported output format of the transcoder
  120492. */
  120493. supportedCompressionFormats?: {
  120494. /**
  120495. * etc1 compression format
  120496. */
  120497. etc1?: boolean;
  120498. /**
  120499. * s3tc compression format
  120500. */
  120501. s3tc?: boolean;
  120502. /**
  120503. * pvrtc compression format
  120504. */
  120505. pvrtc?: boolean;
  120506. /**
  120507. * etc2 compression format
  120508. */
  120509. etc2?: boolean;
  120510. };
  120511. /**
  120512. * If mipmap levels should be loaded for transcoded images (Default: true)
  120513. */
  120514. loadMipmapLevels?: boolean;
  120515. /**
  120516. * Index of a single image to load (Default: all images)
  120517. */
  120518. loadSingleImage?: number;
  120519. }
  120520. /**
  120521. * Used to load .Basis files
  120522. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  120523. */
  120524. export class BasisTools {
  120525. private static _IgnoreSupportedFormats;
  120526. /**
  120527. * URL to use when loading the basis transcoder
  120528. */
  120529. static JSModuleURL: string;
  120530. /**
  120531. * URL to use when loading the wasm module for the transcoder
  120532. */
  120533. static WasmModuleURL: string;
  120534. /**
  120535. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  120536. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  120537. * @returns internal format corresponding to the Basis format
  120538. */
  120539. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  120540. private static _WorkerPromise;
  120541. private static _Worker;
  120542. private static _actionId;
  120543. private static _CreateWorkerAsync;
  120544. /**
  120545. * Transcodes a loaded image file to compressed pixel data
  120546. * @param imageData image data to transcode
  120547. * @param config configuration options for the transcoding
  120548. * @returns a promise resulting in the transcoded image
  120549. */
  120550. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  120551. /**
  120552. * Loads a texture from the transcode result
  120553. * @param texture texture load to
  120554. * @param transcodeResult the result of transcoding the basis file to load from
  120555. */
  120556. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  120557. }
  120558. }
  120559. declare module BABYLON {
  120560. /**
  120561. * Loader for .basis file format
  120562. */
  120563. export class _BasisTextureLoader implements IInternalTextureLoader {
  120564. /**
  120565. * Defines whether the loader supports cascade loading the different faces.
  120566. */
  120567. readonly supportCascades: boolean;
  120568. /**
  120569. * This returns if the loader support the current file information.
  120570. * @param extension defines the file extension of the file being loaded
  120571. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120572. * @param fallback defines the fallback internal texture if any
  120573. * @param isBase64 defines whether the texture is encoded as a base64
  120574. * @param isBuffer defines whether the texture data are stored as a buffer
  120575. * @returns true if the loader can load the specified file
  120576. */
  120577. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120578. /**
  120579. * Transform the url before loading if required.
  120580. * @param rootUrl the url of the texture
  120581. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120582. * @returns the transformed texture
  120583. */
  120584. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120585. /**
  120586. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120587. * @param rootUrl the url of the texture
  120588. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120589. * @returns the fallback texture
  120590. */
  120591. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120592. /**
  120593. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  120594. * @param data contains the texture data
  120595. * @param texture defines the BabylonJS internal texture
  120596. * @param createPolynomials will be true if polynomials have been requested
  120597. * @param onLoad defines the callback to trigger once the texture is ready
  120598. * @param onError defines the callback to trigger in case of error
  120599. */
  120600. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120601. /**
  120602. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120603. * @param data contains the texture data
  120604. * @param texture defines the BabylonJS internal texture
  120605. * @param callback defines the method to call once ready to upload
  120606. */
  120607. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120608. }
  120609. }
  120610. declare module BABYLON {
  120611. /**
  120612. * 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.
  120613. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120614. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120615. */
  120616. export class CustomProceduralTexture extends ProceduralTexture {
  120617. private _animate;
  120618. private _time;
  120619. private _config;
  120620. private _texturePath;
  120621. /**
  120622. * Instantiates a new Custom Procedural Texture.
  120623. * 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.
  120624. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120625. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120626. * @param name Define the name of the texture
  120627. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  120628. * @param size Define the size of the texture to create
  120629. * @param scene Define the scene the texture belongs to
  120630. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  120631. * @param generateMipMaps Define if the texture should creates mip maps or not
  120632. */
  120633. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120634. private _loadJson;
  120635. /**
  120636. * Is the texture ready to be used ? (rendered at least once)
  120637. * @returns true if ready, otherwise, false.
  120638. */
  120639. isReady(): boolean;
  120640. /**
  120641. * Render the texture to its associated render target.
  120642. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  120643. */
  120644. render(useCameraPostProcess?: boolean): void;
  120645. /**
  120646. * Update the list of dependant textures samplers in the shader.
  120647. */
  120648. updateTextures(): void;
  120649. /**
  120650. * Update the uniform values of the procedural texture in the shader.
  120651. */
  120652. updateShaderUniforms(): void;
  120653. /**
  120654. * Define if the texture animates or not.
  120655. */
  120656. animate: boolean;
  120657. }
  120658. }
  120659. declare module BABYLON {
  120660. /** @hidden */
  120661. export var noisePixelShader: {
  120662. name: string;
  120663. shader: string;
  120664. };
  120665. }
  120666. declare module BABYLON {
  120667. /**
  120668. * Class used to generate noise procedural textures
  120669. */
  120670. export class NoiseProceduralTexture extends ProceduralTexture {
  120671. private _time;
  120672. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  120673. brightness: number;
  120674. /** Defines the number of octaves to process */
  120675. octaves: number;
  120676. /** Defines the level of persistence (0.8 by default) */
  120677. persistence: number;
  120678. /** Gets or sets animation speed factor (default is 1) */
  120679. animationSpeedFactor: number;
  120680. /**
  120681. * Creates a new NoiseProceduralTexture
  120682. * @param name defines the name fo the texture
  120683. * @param size defines the size of the texture (default is 256)
  120684. * @param scene defines the hosting scene
  120685. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  120686. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  120687. */
  120688. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120689. private _updateShaderUniforms;
  120690. protected _getDefines(): string;
  120691. /** Generate the current state of the procedural texture */
  120692. render(useCameraPostProcess?: boolean): void;
  120693. /**
  120694. * Serializes this noise procedural texture
  120695. * @returns a serialized noise procedural texture object
  120696. */
  120697. serialize(): any;
  120698. /**
  120699. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  120700. * @param parsedTexture defines parsed texture data
  120701. * @param scene defines the current scene
  120702. * @param rootUrl defines the root URL containing noise procedural texture information
  120703. * @returns a parsed NoiseProceduralTexture
  120704. */
  120705. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  120706. }
  120707. }
  120708. declare module BABYLON {
  120709. /**
  120710. * Raw cube texture where the raw buffers are passed in
  120711. */
  120712. export class RawCubeTexture extends CubeTexture {
  120713. /**
  120714. * Creates a cube texture where the raw buffers are passed in.
  120715. * @param scene defines the scene the texture is attached to
  120716. * @param data defines the array of data to use to create each face
  120717. * @param size defines the size of the textures
  120718. * @param format defines the format of the data
  120719. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  120720. * @param generateMipMaps defines if the engine should generate the mip levels
  120721. * @param invertY defines if data must be stored with Y axis inverted
  120722. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  120723. * @param compression defines the compression used (null by default)
  120724. */
  120725. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  120726. /**
  120727. * Updates the raw cube texture.
  120728. * @param data defines the data to store
  120729. * @param format defines the data format
  120730. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120731. * @param invertY defines if data must be stored with Y axis inverted
  120732. * @param compression defines the compression used (null by default)
  120733. * @param level defines which level of the texture to update
  120734. */
  120735. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  120736. /**
  120737. * Updates a raw cube texture with RGBD encoded data.
  120738. * @param data defines the array of data [mipmap][face] to use to create each face
  120739. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  120740. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120741. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120742. * @returns a promsie that resolves when the operation is complete
  120743. */
  120744. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  120745. /**
  120746. * Clones the raw cube texture.
  120747. * @return a new cube texture
  120748. */
  120749. clone(): CubeTexture;
  120750. /** @hidden */
  120751. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120752. }
  120753. }
  120754. declare module BABYLON {
  120755. /**
  120756. * Class used to store 3D textures containing user data
  120757. */
  120758. export class RawTexture3D extends Texture {
  120759. /** Gets or sets the texture format to use */
  120760. format: number;
  120761. private _engine;
  120762. /**
  120763. * Create a new RawTexture3D
  120764. * @param data defines the data of the texture
  120765. * @param width defines the width of the texture
  120766. * @param height defines the height of the texture
  120767. * @param depth defines the depth of the texture
  120768. * @param format defines the texture format to use
  120769. * @param scene defines the hosting scene
  120770. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  120771. * @param invertY defines if texture must be stored with Y axis inverted
  120772. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120773. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  120774. */
  120775. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  120776. /** Gets or sets the texture format to use */
  120777. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  120778. /**
  120779. * Update the texture with new data
  120780. * @param data defines the data to store in the texture
  120781. */
  120782. update(data: ArrayBufferView): void;
  120783. }
  120784. }
  120785. declare module BABYLON {
  120786. /**
  120787. * Class used to store 2D array textures containing user data
  120788. */
  120789. export class RawTexture2DArray extends Texture {
  120790. /** Gets or sets the texture format to use */
  120791. format: number;
  120792. private _engine;
  120793. /**
  120794. * Create a new RawTexture2DArray
  120795. * @param data defines the data of the texture
  120796. * @param width defines the width of the texture
  120797. * @param height defines the height of the texture
  120798. * @param depth defines the number of layers of the texture
  120799. * @param format defines the texture format to use
  120800. * @param scene defines the hosting scene
  120801. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  120802. * @param invertY defines if texture must be stored with Y axis inverted
  120803. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120804. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  120805. */
  120806. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  120807. /** Gets or sets the texture format to use */
  120808. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  120809. /**
  120810. * Update the texture with new data
  120811. * @param data defines the data to store in the texture
  120812. */
  120813. update(data: ArrayBufferView): void;
  120814. }
  120815. }
  120816. declare module BABYLON {
  120817. /**
  120818. * Creates a refraction texture used by refraction channel of the standard material.
  120819. * It is like a mirror but to see through a material.
  120820. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120821. */
  120822. export class RefractionTexture extends RenderTargetTexture {
  120823. /**
  120824. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  120825. * 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.
  120826. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120827. */
  120828. refractionPlane: Plane;
  120829. /**
  120830. * Define how deep under the surface we should see.
  120831. */
  120832. depth: number;
  120833. /**
  120834. * Creates a refraction texture used by refraction channel of the standard material.
  120835. * It is like a mirror but to see through a material.
  120836. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120837. * @param name Define the texture name
  120838. * @param size Define the size of the underlying texture
  120839. * @param scene Define the scene the refraction belongs to
  120840. * @param generateMipMaps Define if we need to generate mips level for the refraction
  120841. */
  120842. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  120843. /**
  120844. * Clone the refraction texture.
  120845. * @returns the cloned texture
  120846. */
  120847. clone(): RefractionTexture;
  120848. /**
  120849. * Serialize the texture to a JSON representation you could use in Parse later on
  120850. * @returns the serialized JSON representation
  120851. */
  120852. serialize(): any;
  120853. }
  120854. }
  120855. declare module BABYLON {
  120856. /**
  120857. * Defines the options related to the creation of an HtmlElementTexture
  120858. */
  120859. export interface IHtmlElementTextureOptions {
  120860. /**
  120861. * Defines wether mip maps should be created or not.
  120862. */
  120863. generateMipMaps?: boolean;
  120864. /**
  120865. * Defines the sampling mode of the texture.
  120866. */
  120867. samplingMode?: number;
  120868. /**
  120869. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  120870. */
  120871. engine: Nullable<ThinEngine>;
  120872. /**
  120873. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  120874. */
  120875. scene: Nullable<Scene>;
  120876. }
  120877. /**
  120878. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  120879. * To be as efficient as possible depending on your constraints nothing aside the first upload
  120880. * is automatically managed.
  120881. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  120882. * in your application.
  120883. *
  120884. * As the update is not automatic, you need to call them manually.
  120885. */
  120886. export class HtmlElementTexture extends BaseTexture {
  120887. /**
  120888. * The texture URL.
  120889. */
  120890. element: HTMLVideoElement | HTMLCanvasElement;
  120891. private static readonly DefaultOptions;
  120892. private _textureMatrix;
  120893. private _engine;
  120894. private _isVideo;
  120895. private _generateMipMaps;
  120896. private _samplingMode;
  120897. /**
  120898. * Instantiates a HtmlElementTexture from the following parameters.
  120899. *
  120900. * @param name Defines the name of the texture
  120901. * @param element Defines the video or canvas the texture is filled with
  120902. * @param options Defines the other none mandatory texture creation options
  120903. */
  120904. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  120905. private _createInternalTexture;
  120906. /**
  120907. * Returns the texture matrix used in most of the material.
  120908. */
  120909. getTextureMatrix(): Matrix;
  120910. /**
  120911. * Updates the content of the texture.
  120912. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  120913. */
  120914. update(invertY?: Nullable<boolean>): void;
  120915. }
  120916. }
  120917. declare module BABYLON {
  120918. /**
  120919. * Enum used to define the target of a block
  120920. */
  120921. export enum NodeMaterialBlockTargets {
  120922. /** Vertex shader */
  120923. Vertex = 1,
  120924. /** Fragment shader */
  120925. Fragment = 2,
  120926. /** Neutral */
  120927. Neutral = 4,
  120928. /** Vertex and Fragment */
  120929. VertexAndFragment = 3
  120930. }
  120931. }
  120932. declare module BABYLON {
  120933. /**
  120934. * Defines the kind of connection point for node based material
  120935. */
  120936. export enum NodeMaterialBlockConnectionPointTypes {
  120937. /** Float */
  120938. Float = 1,
  120939. /** Int */
  120940. Int = 2,
  120941. /** Vector2 */
  120942. Vector2 = 4,
  120943. /** Vector3 */
  120944. Vector3 = 8,
  120945. /** Vector4 */
  120946. Vector4 = 16,
  120947. /** Color3 */
  120948. Color3 = 32,
  120949. /** Color4 */
  120950. Color4 = 64,
  120951. /** Matrix */
  120952. Matrix = 128,
  120953. /** Detect type based on connection */
  120954. AutoDetect = 1024,
  120955. /** Output type that will be defined by input type */
  120956. BasedOnInput = 2048
  120957. }
  120958. }
  120959. declare module BABYLON {
  120960. /**
  120961. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  120962. */
  120963. export enum NodeMaterialBlockConnectionPointMode {
  120964. /** Value is an uniform */
  120965. Uniform = 0,
  120966. /** Value is a mesh attribute */
  120967. Attribute = 1,
  120968. /** Value is a varying between vertex and fragment shaders */
  120969. Varying = 2,
  120970. /** Mode is undefined */
  120971. Undefined = 3
  120972. }
  120973. }
  120974. declare module BABYLON {
  120975. /**
  120976. * Enum used to define system values e.g. values automatically provided by the system
  120977. */
  120978. export enum NodeMaterialSystemValues {
  120979. /** World */
  120980. World = 1,
  120981. /** View */
  120982. View = 2,
  120983. /** Projection */
  120984. Projection = 3,
  120985. /** ViewProjection */
  120986. ViewProjection = 4,
  120987. /** WorldView */
  120988. WorldView = 5,
  120989. /** WorldViewProjection */
  120990. WorldViewProjection = 6,
  120991. /** CameraPosition */
  120992. CameraPosition = 7,
  120993. /** Fog Color */
  120994. FogColor = 8,
  120995. /** Delta time */
  120996. DeltaTime = 9
  120997. }
  120998. }
  120999. declare module BABYLON {
  121000. /**
  121001. * Root class for all node material optimizers
  121002. */
  121003. export class NodeMaterialOptimizer {
  121004. /**
  121005. * Function used to optimize a NodeMaterial graph
  121006. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121007. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121008. */
  121009. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121010. }
  121011. }
  121012. declare module BABYLON {
  121013. /**
  121014. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121015. */
  121016. export class TransformBlock extends NodeMaterialBlock {
  121017. /**
  121018. * Defines the value to use to complement W value to transform it to a Vector4
  121019. */
  121020. complementW: number;
  121021. /**
  121022. * Defines the value to use to complement z value to transform it to a Vector4
  121023. */
  121024. complementZ: number;
  121025. /**
  121026. * Creates a new TransformBlock
  121027. * @param name defines the block name
  121028. */
  121029. constructor(name: string);
  121030. /**
  121031. * Gets the current class name
  121032. * @returns the class name
  121033. */
  121034. getClassName(): string;
  121035. /**
  121036. * Gets the vector input
  121037. */
  121038. readonly vector: NodeMaterialConnectionPoint;
  121039. /**
  121040. * Gets the output component
  121041. */
  121042. readonly output: NodeMaterialConnectionPoint;
  121043. /**
  121044. * Gets the matrix transform input
  121045. */
  121046. readonly transform: NodeMaterialConnectionPoint;
  121047. protected _buildBlock(state: NodeMaterialBuildState): this;
  121048. serialize(): any;
  121049. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121050. protected _dumpPropertiesCode(): string;
  121051. }
  121052. }
  121053. declare module BABYLON {
  121054. /**
  121055. * Block used to output the vertex position
  121056. */
  121057. export class VertexOutputBlock extends NodeMaterialBlock {
  121058. /**
  121059. * Creates a new VertexOutputBlock
  121060. * @param name defines the block name
  121061. */
  121062. constructor(name: string);
  121063. /**
  121064. * Gets the current class name
  121065. * @returns the class name
  121066. */
  121067. getClassName(): string;
  121068. /**
  121069. * Gets the vector input component
  121070. */
  121071. readonly vector: NodeMaterialConnectionPoint;
  121072. protected _buildBlock(state: NodeMaterialBuildState): this;
  121073. }
  121074. }
  121075. declare module BABYLON {
  121076. /**
  121077. * Block used to output the final color
  121078. */
  121079. export class FragmentOutputBlock extends NodeMaterialBlock {
  121080. /**
  121081. * Create a new FragmentOutputBlock
  121082. * @param name defines the block name
  121083. */
  121084. constructor(name: string);
  121085. /**
  121086. * Gets the current class name
  121087. * @returns the class name
  121088. */
  121089. getClassName(): string;
  121090. /**
  121091. * Gets the rgba input component
  121092. */
  121093. readonly rgba: NodeMaterialConnectionPoint;
  121094. /**
  121095. * Gets the rgb input component
  121096. */
  121097. readonly rgb: NodeMaterialConnectionPoint;
  121098. /**
  121099. * Gets the a input component
  121100. */
  121101. readonly a: NodeMaterialConnectionPoint;
  121102. protected _buildBlock(state: NodeMaterialBuildState): this;
  121103. }
  121104. }
  121105. declare module BABYLON {
  121106. /**
  121107. * Block used to read a reflection texture from a sampler
  121108. */
  121109. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121110. private _define3DName;
  121111. private _defineCubicName;
  121112. private _defineExplicitName;
  121113. private _defineProjectionName;
  121114. private _defineLocalCubicName;
  121115. private _defineSphericalName;
  121116. private _definePlanarName;
  121117. private _defineEquirectangularName;
  121118. private _defineMirroredEquirectangularFixedName;
  121119. private _defineEquirectangularFixedName;
  121120. private _defineSkyboxName;
  121121. private _cubeSamplerName;
  121122. private _2DSamplerName;
  121123. private _positionUVWName;
  121124. private _directionWName;
  121125. private _reflectionCoordsName;
  121126. private _reflection2DCoordsName;
  121127. private _reflectionColorName;
  121128. private _reflectionMatrixName;
  121129. /**
  121130. * Gets or sets the texture associated with the node
  121131. */
  121132. texture: Nullable<BaseTexture>;
  121133. /**
  121134. * Create a new TextureBlock
  121135. * @param name defines the block name
  121136. */
  121137. constructor(name: string);
  121138. /**
  121139. * Gets the current class name
  121140. * @returns the class name
  121141. */
  121142. getClassName(): string;
  121143. /**
  121144. * Gets the world position input component
  121145. */
  121146. readonly position: NodeMaterialConnectionPoint;
  121147. /**
  121148. * Gets the world position input component
  121149. */
  121150. readonly worldPosition: NodeMaterialConnectionPoint;
  121151. /**
  121152. * Gets the world normal input component
  121153. */
  121154. readonly worldNormal: NodeMaterialConnectionPoint;
  121155. /**
  121156. * Gets the world input component
  121157. */
  121158. readonly world: NodeMaterialConnectionPoint;
  121159. /**
  121160. * Gets the camera (or eye) position component
  121161. */
  121162. readonly cameraPosition: NodeMaterialConnectionPoint;
  121163. /**
  121164. * Gets the view input component
  121165. */
  121166. readonly view: NodeMaterialConnectionPoint;
  121167. /**
  121168. * Gets the rgb output component
  121169. */
  121170. readonly rgb: NodeMaterialConnectionPoint;
  121171. /**
  121172. * Gets the r output component
  121173. */
  121174. readonly r: NodeMaterialConnectionPoint;
  121175. /**
  121176. * Gets the g output component
  121177. */
  121178. readonly g: NodeMaterialConnectionPoint;
  121179. /**
  121180. * Gets the b output component
  121181. */
  121182. readonly b: NodeMaterialConnectionPoint;
  121183. autoConfigure(material: NodeMaterial): void;
  121184. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121185. isReady(): boolean;
  121186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121187. private _injectVertexCode;
  121188. private _writeOutput;
  121189. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121190. protected _dumpPropertiesCode(): string;
  121191. serialize(): any;
  121192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121193. }
  121194. }
  121195. declare module BABYLON {
  121196. /**
  121197. * Interface used to configure the node material editor
  121198. */
  121199. export interface INodeMaterialEditorOptions {
  121200. /** Define the URl to load node editor script */
  121201. editorURL?: string;
  121202. }
  121203. /** @hidden */
  121204. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121205. /** BONES */
  121206. NUM_BONE_INFLUENCERS: number;
  121207. BonesPerMesh: number;
  121208. BONETEXTURE: boolean;
  121209. /** MORPH TARGETS */
  121210. MORPHTARGETS: boolean;
  121211. MORPHTARGETS_NORMAL: boolean;
  121212. MORPHTARGETS_TANGENT: boolean;
  121213. MORPHTARGETS_UV: boolean;
  121214. NUM_MORPH_INFLUENCERS: number;
  121215. /** IMAGE PROCESSING */
  121216. IMAGEPROCESSING: boolean;
  121217. VIGNETTE: boolean;
  121218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121219. VIGNETTEBLENDMODEOPAQUE: boolean;
  121220. TONEMAPPING: boolean;
  121221. TONEMAPPING_ACES: boolean;
  121222. CONTRAST: boolean;
  121223. EXPOSURE: boolean;
  121224. COLORCURVES: boolean;
  121225. COLORGRADING: boolean;
  121226. COLORGRADING3D: boolean;
  121227. SAMPLER3DGREENDEPTH: boolean;
  121228. SAMPLER3DBGRMAP: boolean;
  121229. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121230. /** MISC. */
  121231. BUMPDIRECTUV: number;
  121232. constructor();
  121233. setValue(name: string, value: boolean): void;
  121234. }
  121235. /**
  121236. * Class used to configure NodeMaterial
  121237. */
  121238. export interface INodeMaterialOptions {
  121239. /**
  121240. * Defines if blocks should emit comments
  121241. */
  121242. emitComments: boolean;
  121243. }
  121244. /**
  121245. * Class used to create a node based material built by assembling shader blocks
  121246. */
  121247. export class NodeMaterial extends PushMaterial {
  121248. private static _BuildIdGenerator;
  121249. private _options;
  121250. private _vertexCompilationState;
  121251. private _fragmentCompilationState;
  121252. private _sharedData;
  121253. private _buildId;
  121254. private _buildWasSuccessful;
  121255. private _cachedWorldViewMatrix;
  121256. private _cachedWorldViewProjectionMatrix;
  121257. private _optimizers;
  121258. private _animationFrame;
  121259. /** Define the URl to load node editor script */
  121260. static EditorURL: string;
  121261. private BJSNODEMATERIALEDITOR;
  121262. /** Get the inspector from bundle or global */
  121263. private _getGlobalNodeMaterialEditor;
  121264. /**
  121265. * 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)
  121266. */
  121267. ignoreAlpha: boolean;
  121268. /**
  121269. * Defines the maximum number of lights that can be used in the material
  121270. */
  121271. maxSimultaneousLights: number;
  121272. /**
  121273. * Observable raised when the material is built
  121274. */
  121275. onBuildObservable: Observable<NodeMaterial>;
  121276. /**
  121277. * Gets or sets the root nodes of the material vertex shader
  121278. */
  121279. _vertexOutputNodes: NodeMaterialBlock[];
  121280. /**
  121281. * Gets or sets the root nodes of the material fragment (pixel) shader
  121282. */
  121283. _fragmentOutputNodes: NodeMaterialBlock[];
  121284. /** Gets or sets options to control the node material overall behavior */
  121285. options: INodeMaterialOptions;
  121286. /**
  121287. * Default configuration related to image processing available in the standard Material.
  121288. */
  121289. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121290. /**
  121291. * Gets the image processing configuration used either in this material.
  121292. */
  121293. /**
  121294. * Sets the Default image processing configuration used either in the this material.
  121295. *
  121296. * If sets to null, the scene one is in use.
  121297. */
  121298. imageProcessingConfiguration: ImageProcessingConfiguration;
  121299. /**
  121300. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121301. */
  121302. attachedBlocks: NodeMaterialBlock[];
  121303. /**
  121304. * Create a new node based material
  121305. * @param name defines the material name
  121306. * @param scene defines the hosting scene
  121307. * @param options defines creation option
  121308. */
  121309. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121310. /**
  121311. * Gets the current class name of the material e.g. "NodeMaterial"
  121312. * @returns the class name
  121313. */
  121314. getClassName(): string;
  121315. /**
  121316. * Keep track of the image processing observer to allow dispose and replace.
  121317. */
  121318. private _imageProcessingObserver;
  121319. /**
  121320. * Attaches a new image processing configuration to the Standard Material.
  121321. * @param configuration
  121322. */
  121323. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121324. /**
  121325. * Get a block by its name
  121326. * @param name defines the name of the block to retrieve
  121327. * @returns the required block or null if not found
  121328. */
  121329. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121330. /**
  121331. * Get a block by its name
  121332. * @param predicate defines the predicate used to find the good candidate
  121333. * @returns the required block or null if not found
  121334. */
  121335. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121336. /**
  121337. * Get an input block by its name
  121338. * @param predicate defines the predicate used to find the good candidate
  121339. * @returns the required input block or null if not found
  121340. */
  121341. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121342. /**
  121343. * Gets the list of input blocks attached to this material
  121344. * @returns an array of InputBlocks
  121345. */
  121346. getInputBlocks(): InputBlock[];
  121347. /**
  121348. * Adds a new optimizer to the list of optimizers
  121349. * @param optimizer defines the optimizers to add
  121350. * @returns the current material
  121351. */
  121352. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121353. /**
  121354. * Remove an optimizer from the list of optimizers
  121355. * @param optimizer defines the optimizers to remove
  121356. * @returns the current material
  121357. */
  121358. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121359. /**
  121360. * Add a new block to the list of output nodes
  121361. * @param node defines the node to add
  121362. * @returns the current material
  121363. */
  121364. addOutputNode(node: NodeMaterialBlock): this;
  121365. /**
  121366. * Remove a block from the list of root nodes
  121367. * @param node defines the node to remove
  121368. * @returns the current material
  121369. */
  121370. removeOutputNode(node: NodeMaterialBlock): this;
  121371. private _addVertexOutputNode;
  121372. private _removeVertexOutputNode;
  121373. private _addFragmentOutputNode;
  121374. private _removeFragmentOutputNode;
  121375. /**
  121376. * Specifies if the material will require alpha blending
  121377. * @returns a boolean specifying if alpha blending is needed
  121378. */
  121379. needAlphaBlending(): boolean;
  121380. /**
  121381. * Specifies if this material should be rendered in alpha test mode
  121382. * @returns a boolean specifying if an alpha test is needed.
  121383. */
  121384. needAlphaTesting(): boolean;
  121385. private _initializeBlock;
  121386. private _resetDualBlocks;
  121387. /**
  121388. * Build the material and generates the inner effect
  121389. * @param verbose defines if the build should log activity
  121390. */
  121391. build(verbose?: boolean): void;
  121392. /**
  121393. * Runs an otpimization phase to try to improve the shader code
  121394. */
  121395. optimize(): void;
  121396. private _prepareDefinesForAttributes;
  121397. /**
  121398. * Get if the submesh is ready to be used and all its information available.
  121399. * Child classes can use it to update shaders
  121400. * @param mesh defines the mesh to check
  121401. * @param subMesh defines which submesh to check
  121402. * @param useInstances specifies that instances should be used
  121403. * @returns a boolean indicating that the submesh is ready or not
  121404. */
  121405. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121406. /**
  121407. * Get a string representing the shaders built by the current node graph
  121408. */
  121409. readonly compiledShaders: string;
  121410. /**
  121411. * Binds the world matrix to the material
  121412. * @param world defines the world transformation matrix
  121413. */
  121414. bindOnlyWorldMatrix(world: Matrix): void;
  121415. /**
  121416. * Binds the submesh to this material by preparing the effect and shader to draw
  121417. * @param world defines the world transformation matrix
  121418. * @param mesh defines the mesh containing the submesh
  121419. * @param subMesh defines the submesh to bind the material to
  121420. */
  121421. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121422. /**
  121423. * Gets the active textures from the material
  121424. * @returns an array of textures
  121425. */
  121426. getActiveTextures(): BaseTexture[];
  121427. /**
  121428. * Gets the list of texture blocks
  121429. * @returns an array of texture blocks
  121430. */
  121431. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121432. /**
  121433. * Specifies if the material uses a texture
  121434. * @param texture defines the texture to check against the material
  121435. * @returns a boolean specifying if the material uses the texture
  121436. */
  121437. hasTexture(texture: BaseTexture): boolean;
  121438. /**
  121439. * Disposes the material
  121440. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121441. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121442. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121443. */
  121444. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121445. /** Creates the node editor window. */
  121446. private _createNodeEditor;
  121447. /**
  121448. * Launch the node material editor
  121449. * @param config Define the configuration of the editor
  121450. * @return a promise fulfilled when the node editor is visible
  121451. */
  121452. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  121453. /**
  121454. * Clear the current material
  121455. */
  121456. clear(): void;
  121457. /**
  121458. * Clear the current material and set it to a default state
  121459. */
  121460. setToDefault(): void;
  121461. /**
  121462. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  121463. * @param url defines the url to load from
  121464. * @returns a promise that will fullfil when the material is fully loaded
  121465. */
  121466. loadAsync(url: string): Promise<void>;
  121467. private _gatherBlocks;
  121468. /**
  121469. * Generate a string containing the code declaration required to create an equivalent of this material
  121470. * @returns a string
  121471. */
  121472. generateCode(): string;
  121473. /**
  121474. * Serializes this material in a JSON representation
  121475. * @returns the serialized material object
  121476. */
  121477. serialize(): any;
  121478. private _restoreConnections;
  121479. /**
  121480. * Clear the current graph and load a new one from a serialization object
  121481. * @param source defines the JSON representation of the material
  121482. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121483. */
  121484. loadFromSerialization(source: any, rootUrl?: string): void;
  121485. /**
  121486. * Creates a node material from parsed material data
  121487. * @param source defines the JSON representation of the material
  121488. * @param scene defines the hosting scene
  121489. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121490. * @returns a new node material
  121491. */
  121492. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  121493. /**
  121494. * Creates a new node material set to default basic configuration
  121495. * @param name defines the name of the material
  121496. * @param scene defines the hosting scene
  121497. * @returns a new NodeMaterial
  121498. */
  121499. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  121500. }
  121501. }
  121502. declare module BABYLON {
  121503. /**
  121504. * Block used to read a texture from a sampler
  121505. */
  121506. export class TextureBlock extends NodeMaterialBlock {
  121507. private _defineName;
  121508. private _linearDefineName;
  121509. private _samplerName;
  121510. private _transformedUVName;
  121511. private _textureTransformName;
  121512. private _textureInfoName;
  121513. private _mainUVName;
  121514. private _mainUVDefineName;
  121515. /**
  121516. * Gets or sets the texture associated with the node
  121517. */
  121518. texture: Nullable<Texture>;
  121519. /**
  121520. * Create a new TextureBlock
  121521. * @param name defines the block name
  121522. */
  121523. constructor(name: string);
  121524. /**
  121525. * Gets the current class name
  121526. * @returns the class name
  121527. */
  121528. getClassName(): string;
  121529. /**
  121530. * Gets the uv input component
  121531. */
  121532. readonly uv: NodeMaterialConnectionPoint;
  121533. /**
  121534. * Gets the rgba output component
  121535. */
  121536. readonly rgba: NodeMaterialConnectionPoint;
  121537. /**
  121538. * Gets the rgb output component
  121539. */
  121540. readonly rgb: NodeMaterialConnectionPoint;
  121541. /**
  121542. * Gets the r output component
  121543. */
  121544. readonly r: NodeMaterialConnectionPoint;
  121545. /**
  121546. * Gets the g output component
  121547. */
  121548. readonly g: NodeMaterialConnectionPoint;
  121549. /**
  121550. * Gets the b output component
  121551. */
  121552. readonly b: NodeMaterialConnectionPoint;
  121553. /**
  121554. * Gets the a output component
  121555. */
  121556. readonly a: NodeMaterialConnectionPoint;
  121557. readonly target: NodeMaterialBlockTargets;
  121558. autoConfigure(material: NodeMaterial): void;
  121559. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121561. isReady(): boolean;
  121562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121563. private readonly _isMixed;
  121564. private _injectVertexCode;
  121565. private _writeOutput;
  121566. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121567. protected _dumpPropertiesCode(): string;
  121568. serialize(): any;
  121569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121570. }
  121571. }
  121572. declare module BABYLON {
  121573. /**
  121574. * Class used to store shared data between 2 NodeMaterialBuildState
  121575. */
  121576. export class NodeMaterialBuildStateSharedData {
  121577. /**
  121578. * Gets the list of emitted varyings
  121579. */
  121580. temps: string[];
  121581. /**
  121582. * Gets the list of emitted varyings
  121583. */
  121584. varyings: string[];
  121585. /**
  121586. * Gets the varying declaration string
  121587. */
  121588. varyingDeclaration: string;
  121589. /**
  121590. * Input blocks
  121591. */
  121592. inputBlocks: InputBlock[];
  121593. /**
  121594. * Input blocks
  121595. */
  121596. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  121597. /**
  121598. * Bindable blocks (Blocks that need to set data to the effect)
  121599. */
  121600. bindableBlocks: NodeMaterialBlock[];
  121601. /**
  121602. * List of blocks that can provide a compilation fallback
  121603. */
  121604. blocksWithFallbacks: NodeMaterialBlock[];
  121605. /**
  121606. * List of blocks that can provide a define update
  121607. */
  121608. blocksWithDefines: NodeMaterialBlock[];
  121609. /**
  121610. * List of blocks that can provide a repeatable content
  121611. */
  121612. repeatableContentBlocks: NodeMaterialBlock[];
  121613. /**
  121614. * List of blocks that can provide a dynamic list of uniforms
  121615. */
  121616. dynamicUniformBlocks: NodeMaterialBlock[];
  121617. /**
  121618. * List of blocks that can block the isReady function for the material
  121619. */
  121620. blockingBlocks: NodeMaterialBlock[];
  121621. /**
  121622. * Gets the list of animated inputs
  121623. */
  121624. animatedInputs: InputBlock[];
  121625. /**
  121626. * Build Id used to avoid multiple recompilations
  121627. */
  121628. buildId: number;
  121629. /** List of emitted variables */
  121630. variableNames: {
  121631. [key: string]: number;
  121632. };
  121633. /** List of emitted defines */
  121634. defineNames: {
  121635. [key: string]: number;
  121636. };
  121637. /** Should emit comments? */
  121638. emitComments: boolean;
  121639. /** Emit build activity */
  121640. verbose: boolean;
  121641. /** Gets or sets the hosting scene */
  121642. scene: Scene;
  121643. /**
  121644. * Gets the compilation hints emitted at compilation time
  121645. */
  121646. hints: {
  121647. needWorldViewMatrix: boolean;
  121648. needWorldViewProjectionMatrix: boolean;
  121649. needAlphaBlending: boolean;
  121650. needAlphaTesting: boolean;
  121651. };
  121652. /**
  121653. * List of compilation checks
  121654. */
  121655. checks: {
  121656. emitVertex: boolean;
  121657. emitFragment: boolean;
  121658. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  121659. };
  121660. /** Creates a new shared data */
  121661. constructor();
  121662. /**
  121663. * Emits console errors and exceptions if there is a failing check
  121664. */
  121665. emitErrors(): void;
  121666. }
  121667. }
  121668. declare module BABYLON {
  121669. /**
  121670. * Class used to store node based material build state
  121671. */
  121672. export class NodeMaterialBuildState {
  121673. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  121674. supportUniformBuffers: boolean;
  121675. /**
  121676. * Gets the list of emitted attributes
  121677. */
  121678. attributes: string[];
  121679. /**
  121680. * Gets the list of emitted uniforms
  121681. */
  121682. uniforms: string[];
  121683. /**
  121684. * Gets the list of emitted constants
  121685. */
  121686. constants: string[];
  121687. /**
  121688. * Gets the list of emitted samplers
  121689. */
  121690. samplers: string[];
  121691. /**
  121692. * Gets the list of emitted functions
  121693. */
  121694. functions: {
  121695. [key: string]: string;
  121696. };
  121697. /**
  121698. * Gets the list of emitted extensions
  121699. */
  121700. extensions: {
  121701. [key: string]: string;
  121702. };
  121703. /**
  121704. * Gets the target of the compilation state
  121705. */
  121706. target: NodeMaterialBlockTargets;
  121707. /**
  121708. * Gets the list of emitted counters
  121709. */
  121710. counters: {
  121711. [key: string]: number;
  121712. };
  121713. /**
  121714. * Shared data between multiple NodeMaterialBuildState instances
  121715. */
  121716. sharedData: NodeMaterialBuildStateSharedData;
  121717. /** @hidden */
  121718. _vertexState: NodeMaterialBuildState;
  121719. /** @hidden */
  121720. _attributeDeclaration: string;
  121721. /** @hidden */
  121722. _uniformDeclaration: string;
  121723. /** @hidden */
  121724. _constantDeclaration: string;
  121725. /** @hidden */
  121726. _samplerDeclaration: string;
  121727. /** @hidden */
  121728. _varyingTransfer: string;
  121729. private _repeatableContentAnchorIndex;
  121730. /** @hidden */
  121731. _builtCompilationString: string;
  121732. /**
  121733. * Gets the emitted compilation strings
  121734. */
  121735. compilationString: string;
  121736. /**
  121737. * Finalize the compilation strings
  121738. * @param state defines the current compilation state
  121739. */
  121740. finalize(state: NodeMaterialBuildState): void;
  121741. /** @hidden */
  121742. readonly _repeatableContentAnchor: string;
  121743. /** @hidden */
  121744. _getFreeVariableName(prefix: string): string;
  121745. /** @hidden */
  121746. _getFreeDefineName(prefix: string): string;
  121747. /** @hidden */
  121748. _excludeVariableName(name: string): void;
  121749. /** @hidden */
  121750. _emit2DSampler(name: string): void;
  121751. /** @hidden */
  121752. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  121753. /** @hidden */
  121754. _emitExtension(name: string, extension: string): void;
  121755. /** @hidden */
  121756. _emitFunction(name: string, code: string, comments: string): void;
  121757. /** @hidden */
  121758. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  121759. replaceStrings?: {
  121760. search: RegExp;
  121761. replace: string;
  121762. }[];
  121763. repeatKey?: string;
  121764. }): string;
  121765. /** @hidden */
  121766. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  121767. repeatKey?: string;
  121768. removeAttributes?: boolean;
  121769. removeUniforms?: boolean;
  121770. removeVaryings?: boolean;
  121771. removeIfDef?: boolean;
  121772. replaceStrings?: {
  121773. search: RegExp;
  121774. replace: string;
  121775. }[];
  121776. }, storeKey?: string): void;
  121777. /** @hidden */
  121778. _registerTempVariable(name: string): boolean;
  121779. /** @hidden */
  121780. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  121781. /** @hidden */
  121782. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  121783. /** @hidden */
  121784. _emitFloat(value: number): string;
  121785. }
  121786. }
  121787. declare module BABYLON {
  121788. /**
  121789. * Defines a block that can be used inside a node based material
  121790. */
  121791. export class NodeMaterialBlock {
  121792. private _buildId;
  121793. private _buildTarget;
  121794. private _target;
  121795. private _isFinalMerger;
  121796. private _isInput;
  121797. /** @hidden */
  121798. _codeVariableName: string;
  121799. /** @hidden */
  121800. _inputs: NodeMaterialConnectionPoint[];
  121801. /** @hidden */
  121802. _outputs: NodeMaterialConnectionPoint[];
  121803. /** @hidden */
  121804. _preparationId: number;
  121805. /**
  121806. * Gets or sets the name of the block
  121807. */
  121808. name: string;
  121809. /**
  121810. * Gets or sets the unique id of the node
  121811. */
  121812. uniqueId: number;
  121813. /**
  121814. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  121815. */
  121816. readonly isFinalMerger: boolean;
  121817. /**
  121818. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  121819. */
  121820. readonly isInput: boolean;
  121821. /**
  121822. * Gets or sets the build Id
  121823. */
  121824. buildId: number;
  121825. /**
  121826. * Gets or sets the target of the block
  121827. */
  121828. target: NodeMaterialBlockTargets;
  121829. /**
  121830. * Gets the list of input points
  121831. */
  121832. readonly inputs: NodeMaterialConnectionPoint[];
  121833. /** Gets the list of output points */
  121834. readonly outputs: NodeMaterialConnectionPoint[];
  121835. /**
  121836. * Find an input by its name
  121837. * @param name defines the name of the input to look for
  121838. * @returns the input or null if not found
  121839. */
  121840. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121841. /**
  121842. * Find an output by its name
  121843. * @param name defines the name of the outputto look for
  121844. * @returns the output or null if not found
  121845. */
  121846. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121847. /**
  121848. * Creates a new NodeMaterialBlock
  121849. * @param name defines the block name
  121850. * @param target defines the target of that block (Vertex by default)
  121851. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  121852. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  121853. */
  121854. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  121855. /**
  121856. * Initialize the block and prepare the context for build
  121857. * @param state defines the state that will be used for the build
  121858. */
  121859. initialize(state: NodeMaterialBuildState): void;
  121860. /**
  121861. * Bind data to effect. Will only be called for blocks with isBindable === true
  121862. * @param effect defines the effect to bind data to
  121863. * @param nodeMaterial defines the hosting NodeMaterial
  121864. * @param mesh defines the mesh that will be rendered
  121865. */
  121866. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121867. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  121868. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  121869. protected _writeFloat(value: number): string;
  121870. /**
  121871. * Gets the current class name e.g. "NodeMaterialBlock"
  121872. * @returns the class name
  121873. */
  121874. getClassName(): string;
  121875. /**
  121876. * Register a new input. Must be called inside a block constructor
  121877. * @param name defines the connection point name
  121878. * @param type defines the connection point type
  121879. * @param isOptional defines a boolean indicating that this input can be omitted
  121880. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121881. * @returns the current block
  121882. */
  121883. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  121884. /**
  121885. * Register a new output. Must be called inside a block constructor
  121886. * @param name defines the connection point name
  121887. * @param type defines the connection point type
  121888. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121889. * @returns the current block
  121890. */
  121891. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  121892. /**
  121893. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  121894. * @param forOutput defines an optional connection point to check compatibility with
  121895. * @returns the first available input or null
  121896. */
  121897. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  121898. /**
  121899. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  121900. * @param forBlock defines an optional block to check compatibility with
  121901. * @returns the first available input or null
  121902. */
  121903. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  121904. /**
  121905. * Gets the sibling of the given output
  121906. * @param current defines the current output
  121907. * @returns the next output in the list or null
  121908. */
  121909. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  121910. /**
  121911. * Connect current block with another block
  121912. * @param other defines the block to connect with
  121913. * @param options define the various options to help pick the right connections
  121914. * @returns the current block
  121915. */
  121916. connectTo(other: NodeMaterialBlock, options?: {
  121917. input?: string;
  121918. output?: string;
  121919. outputSwizzle?: string;
  121920. }): this | undefined;
  121921. protected _buildBlock(state: NodeMaterialBuildState): void;
  121922. /**
  121923. * Add uniforms, samplers and uniform buffers at compilation time
  121924. * @param state defines the state to update
  121925. * @param nodeMaterial defines the node material requesting the update
  121926. * @param defines defines the material defines to update
  121927. * @param uniformBuffers defines the list of uniform buffer names
  121928. */
  121929. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121930. /**
  121931. * Add potential fallbacks if shader compilation fails
  121932. * @param mesh defines the mesh to be rendered
  121933. * @param fallbacks defines the current prioritized list of fallbacks
  121934. */
  121935. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121936. /**
  121937. * Initialize defines for shader compilation
  121938. * @param mesh defines the mesh to be rendered
  121939. * @param nodeMaterial defines the node material requesting the update
  121940. * @param defines defines the material defines to update
  121941. * @param useInstances specifies that instances should be used
  121942. */
  121943. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121944. /**
  121945. * Update defines for shader compilation
  121946. * @param mesh defines the mesh to be rendered
  121947. * @param nodeMaterial defines the node material requesting the update
  121948. * @param defines defines the material defines to update
  121949. * @param useInstances specifies that instances should be used
  121950. */
  121951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121952. /**
  121953. * Lets the block try to connect some inputs automatically
  121954. * @param material defines the hosting NodeMaterial
  121955. */
  121956. autoConfigure(material: NodeMaterial): void;
  121957. /**
  121958. * Function called when a block is declared as repeatable content generator
  121959. * @param vertexShaderState defines the current compilation state for the vertex shader
  121960. * @param fragmentShaderState defines the current compilation state for the fragment shader
  121961. * @param mesh defines the mesh to be rendered
  121962. * @param defines defines the material defines to update
  121963. */
  121964. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121965. /**
  121966. * Checks if the block is ready
  121967. * @param mesh defines the mesh to be rendered
  121968. * @param nodeMaterial defines the node material requesting the update
  121969. * @param defines defines the material defines to update
  121970. * @param useInstances specifies that instances should be used
  121971. * @returns true if the block is ready
  121972. */
  121973. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  121974. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  121975. private _processBuild;
  121976. /**
  121977. * Compile the current node and generate the shader code
  121978. * @param state defines the current compilation state (uniforms, samplers, current string)
  121979. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  121980. * @returns true if already built
  121981. */
  121982. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  121983. protected _inputRename(name: string): string;
  121984. protected _outputRename(name: string): string;
  121985. protected _dumpPropertiesCode(): string;
  121986. /** @hidden */
  121987. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  121988. /** @hidden */
  121989. _dumpCodeForOutputConnections(): string;
  121990. /**
  121991. * Clone the current block to a new identical block
  121992. * @param scene defines the hosting scene
  121993. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121994. * @returns a copy of the current block
  121995. */
  121996. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  121997. /**
  121998. * Serializes this block in a JSON representation
  121999. * @returns the serialized block object
  122000. */
  122001. serialize(): any;
  122002. /** @hidden */
  122003. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122004. /**
  122005. * Release resources
  122006. */
  122007. dispose(): void;
  122008. }
  122009. }
  122010. declare module BABYLON {
  122011. /**
  122012. * Enum defining the type of animations supported by InputBlock
  122013. */
  122014. export enum AnimatedInputBlockTypes {
  122015. /** No animation */
  122016. None = 0,
  122017. /** Time based animation. Will only work for floats */
  122018. Time = 1
  122019. }
  122020. }
  122021. declare module BABYLON {
  122022. /**
  122023. * Block used to expose an input value
  122024. */
  122025. export class InputBlock extends NodeMaterialBlock {
  122026. private _mode;
  122027. private _associatedVariableName;
  122028. private _storedValue;
  122029. private _valueCallback;
  122030. private _type;
  122031. private _animationType;
  122032. /** Gets or set a value used to limit the range of float values */
  122033. min: number;
  122034. /** Gets or set a value used to limit the range of float values */
  122035. max: number;
  122036. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122037. matrixMode: number;
  122038. /** @hidden */
  122039. _systemValue: Nullable<NodeMaterialSystemValues>;
  122040. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122041. visibleInInspector: boolean;
  122042. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122043. isConstant: boolean;
  122044. /**
  122045. * Gets or sets the connection point type (default is float)
  122046. */
  122047. readonly type: NodeMaterialBlockConnectionPointTypes;
  122048. /**
  122049. * Creates a new InputBlock
  122050. * @param name defines the block name
  122051. * @param target defines the target of that block (Vertex by default)
  122052. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122053. */
  122054. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122055. /**
  122056. * Gets the output component
  122057. */
  122058. readonly output: NodeMaterialConnectionPoint;
  122059. /**
  122060. * Set the source of this connection point to a vertex attribute
  122061. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122062. * @returns the current connection point
  122063. */
  122064. setAsAttribute(attributeName?: string): InputBlock;
  122065. /**
  122066. * Set the source of this connection point to a system value
  122067. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122068. * @returns the current connection point
  122069. */
  122070. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122071. /**
  122072. * Gets or sets the value of that point.
  122073. * Please note that this value will be ignored if valueCallback is defined
  122074. */
  122075. value: any;
  122076. /**
  122077. * Gets or sets a callback used to get the value of that point.
  122078. * Please note that setting this value will force the connection point to ignore the value property
  122079. */
  122080. valueCallback: () => any;
  122081. /**
  122082. * Gets or sets the associated variable name in the shader
  122083. */
  122084. associatedVariableName: string;
  122085. /** Gets or sets the type of animation applied to the input */
  122086. animationType: AnimatedInputBlockTypes;
  122087. /**
  122088. * Gets a boolean indicating that this connection point not defined yet
  122089. */
  122090. readonly isUndefined: boolean;
  122091. /**
  122092. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122093. * In this case the connection point name must be the name of the uniform to use.
  122094. * Can only be set on inputs
  122095. */
  122096. isUniform: boolean;
  122097. /**
  122098. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122099. * In this case the connection point name must be the name of the attribute to use
  122100. * Can only be set on inputs
  122101. */
  122102. isAttribute: boolean;
  122103. /**
  122104. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122105. * Can only be set on exit points
  122106. */
  122107. isVarying: boolean;
  122108. /**
  122109. * Gets a boolean indicating that the current connection point is a system value
  122110. */
  122111. readonly isSystemValue: boolean;
  122112. /**
  122113. * Gets or sets the current well known value or null if not defined as a system value
  122114. */
  122115. systemValue: Nullable<NodeMaterialSystemValues>;
  122116. /**
  122117. * Gets the current class name
  122118. * @returns the class name
  122119. */
  122120. getClassName(): string;
  122121. /**
  122122. * Animate the input if animationType !== None
  122123. * @param scene defines the rendering scene
  122124. */
  122125. animate(scene: Scene): void;
  122126. private _emitDefine;
  122127. initialize(state: NodeMaterialBuildState): void;
  122128. /**
  122129. * Set the input block to its default value (based on its type)
  122130. */
  122131. setDefaultValue(): void;
  122132. private _emitConstant;
  122133. private _emit;
  122134. /** @hidden */
  122135. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122136. /** @hidden */
  122137. _transmit(effect: Effect, scene: Scene): void;
  122138. protected _buildBlock(state: NodeMaterialBuildState): void;
  122139. protected _dumpPropertiesCode(): string;
  122140. serialize(): any;
  122141. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122142. }
  122143. }
  122144. declare module BABYLON {
  122145. /**
  122146. * Defines a connection point for a block
  122147. */
  122148. export class NodeMaterialConnectionPoint {
  122149. /** @hidden */
  122150. _ownerBlock: NodeMaterialBlock;
  122151. /** @hidden */
  122152. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122153. private _endpoints;
  122154. private _associatedVariableName;
  122155. /** @hidden */
  122156. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122157. /** @hidden */
  122158. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122159. private _type;
  122160. /** @hidden */
  122161. _enforceAssociatedVariableName: boolean;
  122162. /**
  122163. * Gets or sets the additional types supported by this connection point
  122164. */
  122165. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122166. /**
  122167. * Gets or sets the additional types excluded by this connection point
  122168. */
  122169. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122170. /**
  122171. * Observable triggered when this point is connected
  122172. */
  122173. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122174. /**
  122175. * Gets or sets the associated variable name in the shader
  122176. */
  122177. associatedVariableName: string;
  122178. /**
  122179. * Gets or sets the connection point type (default is float)
  122180. */
  122181. type: NodeMaterialBlockConnectionPointTypes;
  122182. /**
  122183. * Gets or sets the connection point name
  122184. */
  122185. name: string;
  122186. /**
  122187. * Gets or sets a boolean indicating that this connection point can be omitted
  122188. */
  122189. isOptional: boolean;
  122190. /**
  122191. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122192. */
  122193. define: string;
  122194. /** @hidden */
  122195. _prioritizeVertex: boolean;
  122196. private _target;
  122197. /** Gets or sets the target of that connection point */
  122198. target: NodeMaterialBlockTargets;
  122199. /**
  122200. * Gets a boolean indicating that the current point is connected
  122201. */
  122202. readonly isConnected: boolean;
  122203. /**
  122204. * Gets a boolean indicating that the current point is connected to an input block
  122205. */
  122206. readonly isConnectedToInputBlock: boolean;
  122207. /**
  122208. * Gets a the connected input block (if any)
  122209. */
  122210. readonly connectInputBlock: Nullable<InputBlock>;
  122211. /** Get the other side of the connection (if any) */
  122212. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122213. /** Get the block that owns this connection point */
  122214. readonly ownerBlock: NodeMaterialBlock;
  122215. /** Get the block connected on the other side of this connection (if any) */
  122216. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122217. /** Get the block connected on the endpoints of this connection (if any) */
  122218. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122219. /** Gets the list of connected endpoints */
  122220. readonly endpoints: NodeMaterialConnectionPoint[];
  122221. /** Gets a boolean indicating if that output point is connected to at least one input */
  122222. readonly hasEndpoints: boolean;
  122223. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122224. readonly isConnectedInVertexShader: boolean;
  122225. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122226. readonly isConnectedInFragmentShader: boolean;
  122227. /**
  122228. * Creates a new connection point
  122229. * @param name defines the connection point name
  122230. * @param ownerBlock defines the block hosting this connection point
  122231. */
  122232. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122233. /**
  122234. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122235. * @returns the class name
  122236. */
  122237. getClassName(): string;
  122238. /**
  122239. * Gets an boolean indicating if the current point can be connected to another point
  122240. * @param connectionPoint defines the other connection point
  122241. * @returns true if the connection is possible
  122242. */
  122243. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122244. /**
  122245. * Connect this point to another connection point
  122246. * @param connectionPoint defines the other connection point
  122247. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122248. * @returns the current connection point
  122249. */
  122250. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122251. /**
  122252. * Disconnect this point from one of his endpoint
  122253. * @param endpoint defines the other connection point
  122254. * @returns the current connection point
  122255. */
  122256. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122257. /**
  122258. * Serializes this point in a JSON representation
  122259. * @returns the serialized point object
  122260. */
  122261. serialize(): any;
  122262. /**
  122263. * Release resources
  122264. */
  122265. dispose(): void;
  122266. }
  122267. }
  122268. declare module BABYLON {
  122269. /**
  122270. * Block used to add support for vertex skinning (bones)
  122271. */
  122272. export class BonesBlock extends NodeMaterialBlock {
  122273. /**
  122274. * Creates a new BonesBlock
  122275. * @param name defines the block name
  122276. */
  122277. constructor(name: string);
  122278. /**
  122279. * Initialize the block and prepare the context for build
  122280. * @param state defines the state that will be used for the build
  122281. */
  122282. initialize(state: NodeMaterialBuildState): void;
  122283. /**
  122284. * Gets the current class name
  122285. * @returns the class name
  122286. */
  122287. getClassName(): string;
  122288. /**
  122289. * Gets the matrix indices input component
  122290. */
  122291. readonly matricesIndices: NodeMaterialConnectionPoint;
  122292. /**
  122293. * Gets the matrix weights input component
  122294. */
  122295. readonly matricesWeights: NodeMaterialConnectionPoint;
  122296. /**
  122297. * Gets the extra matrix indices input component
  122298. */
  122299. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122300. /**
  122301. * Gets the extra matrix weights input component
  122302. */
  122303. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122304. /**
  122305. * Gets the world input component
  122306. */
  122307. readonly world: NodeMaterialConnectionPoint;
  122308. /**
  122309. * Gets the output component
  122310. */
  122311. readonly output: NodeMaterialConnectionPoint;
  122312. autoConfigure(material: NodeMaterial): void;
  122313. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122316. protected _buildBlock(state: NodeMaterialBuildState): this;
  122317. }
  122318. }
  122319. declare module BABYLON {
  122320. /**
  122321. * Block used to add support for instances
  122322. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122323. */
  122324. export class InstancesBlock extends NodeMaterialBlock {
  122325. /**
  122326. * Creates a new InstancesBlock
  122327. * @param name defines the block name
  122328. */
  122329. constructor(name: string);
  122330. /**
  122331. * Gets the current class name
  122332. * @returns the class name
  122333. */
  122334. getClassName(): string;
  122335. /**
  122336. * Gets the first world row input component
  122337. */
  122338. readonly world0: NodeMaterialConnectionPoint;
  122339. /**
  122340. * Gets the second world row input component
  122341. */
  122342. readonly world1: NodeMaterialConnectionPoint;
  122343. /**
  122344. * Gets the third world row input component
  122345. */
  122346. readonly world2: NodeMaterialConnectionPoint;
  122347. /**
  122348. * Gets the forth world row input component
  122349. */
  122350. readonly world3: NodeMaterialConnectionPoint;
  122351. /**
  122352. * Gets the world input component
  122353. */
  122354. readonly world: NodeMaterialConnectionPoint;
  122355. /**
  122356. * Gets the output component
  122357. */
  122358. readonly output: NodeMaterialConnectionPoint;
  122359. autoConfigure(material: NodeMaterial): void;
  122360. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122361. protected _buildBlock(state: NodeMaterialBuildState): this;
  122362. }
  122363. }
  122364. declare module BABYLON {
  122365. /**
  122366. * Block used to add morph targets support to vertex shader
  122367. */
  122368. export class MorphTargetsBlock extends NodeMaterialBlock {
  122369. private _repeatableContentAnchor;
  122370. private _repeatebleContentGenerated;
  122371. /**
  122372. * Create a new MorphTargetsBlock
  122373. * @param name defines the block name
  122374. */
  122375. constructor(name: string);
  122376. /**
  122377. * Gets the current class name
  122378. * @returns the class name
  122379. */
  122380. getClassName(): string;
  122381. /**
  122382. * Gets the position input component
  122383. */
  122384. readonly position: NodeMaterialConnectionPoint;
  122385. /**
  122386. * Gets the normal input component
  122387. */
  122388. readonly normal: NodeMaterialConnectionPoint;
  122389. /**
  122390. * Gets the tangent input component
  122391. */
  122392. readonly tangent: NodeMaterialConnectionPoint;
  122393. /**
  122394. * Gets the tangent input component
  122395. */
  122396. readonly uv: NodeMaterialConnectionPoint;
  122397. /**
  122398. * Gets the position output component
  122399. */
  122400. readonly positionOutput: NodeMaterialConnectionPoint;
  122401. /**
  122402. * Gets the normal output component
  122403. */
  122404. readonly normalOutput: NodeMaterialConnectionPoint;
  122405. /**
  122406. * Gets the tangent output component
  122407. */
  122408. readonly tangentOutput: NodeMaterialConnectionPoint;
  122409. /**
  122410. * Gets the tangent output component
  122411. */
  122412. readonly uvOutput: NodeMaterialConnectionPoint;
  122413. initialize(state: NodeMaterialBuildState): void;
  122414. autoConfigure(material: NodeMaterial): void;
  122415. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122416. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122417. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122418. protected _buildBlock(state: NodeMaterialBuildState): this;
  122419. }
  122420. }
  122421. declare module BABYLON {
  122422. /**
  122423. * Block used to get data information from a light
  122424. */
  122425. export class LightInformationBlock extends NodeMaterialBlock {
  122426. private _lightDataUniformName;
  122427. private _lightColorUniformName;
  122428. private _lightTypeDefineName;
  122429. /**
  122430. * Gets or sets the light associated with this block
  122431. */
  122432. light: Nullable<Light>;
  122433. /**
  122434. * Creates a new LightInformationBlock
  122435. * @param name defines the block name
  122436. */
  122437. constructor(name: string);
  122438. /**
  122439. * Gets the current class name
  122440. * @returns the class name
  122441. */
  122442. getClassName(): string;
  122443. /**
  122444. * Gets the world position input component
  122445. */
  122446. readonly worldPosition: NodeMaterialConnectionPoint;
  122447. /**
  122448. * Gets the direction output component
  122449. */
  122450. readonly direction: NodeMaterialConnectionPoint;
  122451. /**
  122452. * Gets the direction output component
  122453. */
  122454. readonly color: NodeMaterialConnectionPoint;
  122455. /**
  122456. * Gets the direction output component
  122457. */
  122458. readonly intensity: NodeMaterialConnectionPoint;
  122459. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122460. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122461. protected _buildBlock(state: NodeMaterialBuildState): this;
  122462. serialize(): any;
  122463. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122464. }
  122465. }
  122466. declare module BABYLON {
  122467. /**
  122468. * Block used to add image processing support to fragment shader
  122469. */
  122470. export class ImageProcessingBlock extends NodeMaterialBlock {
  122471. /**
  122472. * Create a new ImageProcessingBlock
  122473. * @param name defines the block name
  122474. */
  122475. constructor(name: string);
  122476. /**
  122477. * Gets the current class name
  122478. * @returns the class name
  122479. */
  122480. getClassName(): string;
  122481. /**
  122482. * Gets the color input component
  122483. */
  122484. readonly color: NodeMaterialConnectionPoint;
  122485. /**
  122486. * Gets the output component
  122487. */
  122488. readonly output: NodeMaterialConnectionPoint;
  122489. /**
  122490. * Initialize the block and prepare the context for build
  122491. * @param state defines the state that will be used for the build
  122492. */
  122493. initialize(state: NodeMaterialBuildState): void;
  122494. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  122495. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122496. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122497. protected _buildBlock(state: NodeMaterialBuildState): this;
  122498. }
  122499. }
  122500. declare module BABYLON {
  122501. /**
  122502. * Block used to pertub normals based on a normal map
  122503. */
  122504. export class PerturbNormalBlock extends NodeMaterialBlock {
  122505. private _tangentSpaceParameterName;
  122506. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  122507. invertX: boolean;
  122508. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  122509. invertY: boolean;
  122510. /**
  122511. * Create a new PerturbNormalBlock
  122512. * @param name defines the block name
  122513. */
  122514. constructor(name: string);
  122515. /**
  122516. * Gets the current class name
  122517. * @returns the class name
  122518. */
  122519. getClassName(): string;
  122520. /**
  122521. * Gets the world position input component
  122522. */
  122523. readonly worldPosition: NodeMaterialConnectionPoint;
  122524. /**
  122525. * Gets the world normal input component
  122526. */
  122527. readonly worldNormal: NodeMaterialConnectionPoint;
  122528. /**
  122529. * Gets the uv input component
  122530. */
  122531. readonly uv: NodeMaterialConnectionPoint;
  122532. /**
  122533. * Gets the normal map color input component
  122534. */
  122535. readonly normalMapColor: NodeMaterialConnectionPoint;
  122536. /**
  122537. * Gets the strength input component
  122538. */
  122539. readonly strength: NodeMaterialConnectionPoint;
  122540. /**
  122541. * Gets the output component
  122542. */
  122543. readonly output: NodeMaterialConnectionPoint;
  122544. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122545. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122546. autoConfigure(material: NodeMaterial): void;
  122547. protected _buildBlock(state: NodeMaterialBuildState): this;
  122548. protected _dumpPropertiesCode(): string;
  122549. serialize(): any;
  122550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122551. }
  122552. }
  122553. declare module BABYLON {
  122554. /**
  122555. * Block used to discard a pixel if a value is smaller than a cutoff
  122556. */
  122557. export class DiscardBlock extends NodeMaterialBlock {
  122558. /**
  122559. * Create a new DiscardBlock
  122560. * @param name defines the block name
  122561. */
  122562. constructor(name: string);
  122563. /**
  122564. * Gets the current class name
  122565. * @returns the class name
  122566. */
  122567. getClassName(): string;
  122568. /**
  122569. * Gets the color input component
  122570. */
  122571. readonly value: NodeMaterialConnectionPoint;
  122572. /**
  122573. * Gets the cutoff input component
  122574. */
  122575. readonly cutoff: NodeMaterialConnectionPoint;
  122576. protected _buildBlock(state: NodeMaterialBuildState): this;
  122577. }
  122578. }
  122579. declare module BABYLON {
  122580. /**
  122581. * Block used to add support for scene fog
  122582. */
  122583. export class FogBlock extends NodeMaterialBlock {
  122584. private _fogDistanceName;
  122585. private _fogParameters;
  122586. /**
  122587. * Create a new FogBlock
  122588. * @param name defines the block name
  122589. */
  122590. constructor(name: string);
  122591. /**
  122592. * Gets the current class name
  122593. * @returns the class name
  122594. */
  122595. getClassName(): string;
  122596. /**
  122597. * Gets the world position input component
  122598. */
  122599. readonly worldPosition: NodeMaterialConnectionPoint;
  122600. /**
  122601. * Gets the view input component
  122602. */
  122603. readonly view: NodeMaterialConnectionPoint;
  122604. /**
  122605. * Gets the color input component
  122606. */
  122607. readonly input: NodeMaterialConnectionPoint;
  122608. /**
  122609. * Gets the fog color input component
  122610. */
  122611. readonly fogColor: NodeMaterialConnectionPoint;
  122612. /**
  122613. * Gets the output component
  122614. */
  122615. readonly output: NodeMaterialConnectionPoint;
  122616. autoConfigure(material: NodeMaterial): void;
  122617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122619. protected _buildBlock(state: NodeMaterialBuildState): this;
  122620. }
  122621. }
  122622. declare module BABYLON {
  122623. /**
  122624. * Block used to add light in the fragment shader
  122625. */
  122626. export class LightBlock extends NodeMaterialBlock {
  122627. private _lightId;
  122628. /**
  122629. * Gets or sets the light associated with this block
  122630. */
  122631. light: Nullable<Light>;
  122632. /**
  122633. * Create a new LightBlock
  122634. * @param name defines the block name
  122635. */
  122636. constructor(name: string);
  122637. /**
  122638. * Gets the current class name
  122639. * @returns the class name
  122640. */
  122641. getClassName(): string;
  122642. /**
  122643. * Gets the world position input component
  122644. */
  122645. readonly worldPosition: NodeMaterialConnectionPoint;
  122646. /**
  122647. * Gets the world normal input component
  122648. */
  122649. readonly worldNormal: NodeMaterialConnectionPoint;
  122650. /**
  122651. * Gets the camera (or eye) position component
  122652. */
  122653. readonly cameraPosition: NodeMaterialConnectionPoint;
  122654. /**
  122655. * Gets the glossiness component
  122656. */
  122657. readonly glossiness: NodeMaterialConnectionPoint;
  122658. /**
  122659. * Gets the glossinness power component
  122660. */
  122661. readonly glossPower: NodeMaterialConnectionPoint;
  122662. /**
  122663. * Gets the diffuse color component
  122664. */
  122665. readonly diffuseColor: NodeMaterialConnectionPoint;
  122666. /**
  122667. * Gets the specular color component
  122668. */
  122669. readonly specularColor: NodeMaterialConnectionPoint;
  122670. /**
  122671. * Gets the diffuse output component
  122672. */
  122673. readonly diffuseOutput: NodeMaterialConnectionPoint;
  122674. /**
  122675. * Gets the specular output component
  122676. */
  122677. readonly specularOutput: NodeMaterialConnectionPoint;
  122678. autoConfigure(material: NodeMaterial): void;
  122679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122680. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122681. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122682. private _injectVertexCode;
  122683. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122684. serialize(): any;
  122685. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122686. }
  122687. }
  122688. declare module BABYLON {
  122689. /**
  122690. * Block used to multiply 2 values
  122691. */
  122692. export class MultiplyBlock extends NodeMaterialBlock {
  122693. /**
  122694. * Creates a new MultiplyBlock
  122695. * @param name defines the block name
  122696. */
  122697. constructor(name: string);
  122698. /**
  122699. * Gets the current class name
  122700. * @returns the class name
  122701. */
  122702. getClassName(): string;
  122703. /**
  122704. * Gets the left operand input component
  122705. */
  122706. readonly left: NodeMaterialConnectionPoint;
  122707. /**
  122708. * Gets the right operand input component
  122709. */
  122710. readonly right: NodeMaterialConnectionPoint;
  122711. /**
  122712. * Gets the output component
  122713. */
  122714. readonly output: NodeMaterialConnectionPoint;
  122715. protected _buildBlock(state: NodeMaterialBuildState): this;
  122716. }
  122717. }
  122718. declare module BABYLON {
  122719. /**
  122720. * Block used to add 2 vectors
  122721. */
  122722. export class AddBlock extends NodeMaterialBlock {
  122723. /**
  122724. * Creates a new AddBlock
  122725. * @param name defines the block name
  122726. */
  122727. constructor(name: string);
  122728. /**
  122729. * Gets the current class name
  122730. * @returns the class name
  122731. */
  122732. getClassName(): string;
  122733. /**
  122734. * Gets the left operand input component
  122735. */
  122736. readonly left: NodeMaterialConnectionPoint;
  122737. /**
  122738. * Gets the right operand input component
  122739. */
  122740. readonly right: NodeMaterialConnectionPoint;
  122741. /**
  122742. * Gets the output component
  122743. */
  122744. readonly output: NodeMaterialConnectionPoint;
  122745. protected _buildBlock(state: NodeMaterialBuildState): this;
  122746. }
  122747. }
  122748. declare module BABYLON {
  122749. /**
  122750. * Block used to scale a vector by a float
  122751. */
  122752. export class ScaleBlock extends NodeMaterialBlock {
  122753. /**
  122754. * Creates a new ScaleBlock
  122755. * @param name defines the block name
  122756. */
  122757. constructor(name: string);
  122758. /**
  122759. * Gets the current class name
  122760. * @returns the class name
  122761. */
  122762. getClassName(): string;
  122763. /**
  122764. * Gets the input component
  122765. */
  122766. readonly input: NodeMaterialConnectionPoint;
  122767. /**
  122768. * Gets the factor input component
  122769. */
  122770. readonly factor: NodeMaterialConnectionPoint;
  122771. /**
  122772. * Gets the output component
  122773. */
  122774. readonly output: NodeMaterialConnectionPoint;
  122775. protected _buildBlock(state: NodeMaterialBuildState): this;
  122776. }
  122777. }
  122778. declare module BABYLON {
  122779. /**
  122780. * Block used to clamp a float
  122781. */
  122782. export class ClampBlock extends NodeMaterialBlock {
  122783. /** Gets or sets the minimum range */
  122784. minimum: number;
  122785. /** Gets or sets the maximum range */
  122786. maximum: number;
  122787. /**
  122788. * Creates a new ClampBlock
  122789. * @param name defines the block name
  122790. */
  122791. constructor(name: string);
  122792. /**
  122793. * Gets the current class name
  122794. * @returns the class name
  122795. */
  122796. getClassName(): string;
  122797. /**
  122798. * Gets the value input component
  122799. */
  122800. readonly value: NodeMaterialConnectionPoint;
  122801. /**
  122802. * Gets the output component
  122803. */
  122804. readonly output: NodeMaterialConnectionPoint;
  122805. protected _buildBlock(state: NodeMaterialBuildState): this;
  122806. protected _dumpPropertiesCode(): string;
  122807. serialize(): any;
  122808. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122809. }
  122810. }
  122811. declare module BABYLON {
  122812. /**
  122813. * Block used to apply a cross product between 2 vectors
  122814. */
  122815. export class CrossBlock extends NodeMaterialBlock {
  122816. /**
  122817. * Creates a new CrossBlock
  122818. * @param name defines the block name
  122819. */
  122820. constructor(name: string);
  122821. /**
  122822. * Gets the current class name
  122823. * @returns the class name
  122824. */
  122825. getClassName(): string;
  122826. /**
  122827. * Gets the left operand input component
  122828. */
  122829. readonly left: NodeMaterialConnectionPoint;
  122830. /**
  122831. * Gets the right operand input component
  122832. */
  122833. readonly right: NodeMaterialConnectionPoint;
  122834. /**
  122835. * Gets the output component
  122836. */
  122837. readonly output: NodeMaterialConnectionPoint;
  122838. protected _buildBlock(state: NodeMaterialBuildState): this;
  122839. }
  122840. }
  122841. declare module BABYLON {
  122842. /**
  122843. * Block used to apply a dot product between 2 vectors
  122844. */
  122845. export class DotBlock extends NodeMaterialBlock {
  122846. /**
  122847. * Creates a new DotBlock
  122848. * @param name defines the block name
  122849. */
  122850. constructor(name: string);
  122851. /**
  122852. * Gets the current class name
  122853. * @returns the class name
  122854. */
  122855. getClassName(): string;
  122856. /**
  122857. * Gets the left operand input component
  122858. */
  122859. readonly left: NodeMaterialConnectionPoint;
  122860. /**
  122861. * Gets the right operand input component
  122862. */
  122863. readonly right: NodeMaterialConnectionPoint;
  122864. /**
  122865. * Gets the output component
  122866. */
  122867. readonly output: NodeMaterialConnectionPoint;
  122868. protected _buildBlock(state: NodeMaterialBuildState): this;
  122869. }
  122870. }
  122871. declare module BABYLON {
  122872. /**
  122873. * Block used to remap a float from a range to a new one
  122874. */
  122875. export class RemapBlock extends NodeMaterialBlock {
  122876. /**
  122877. * Gets or sets the source range
  122878. */
  122879. sourceRange: Vector2;
  122880. /**
  122881. * Gets or sets the target range
  122882. */
  122883. targetRange: Vector2;
  122884. /**
  122885. * Creates a new RemapBlock
  122886. * @param name defines the block name
  122887. */
  122888. constructor(name: string);
  122889. /**
  122890. * Gets the current class name
  122891. * @returns the class name
  122892. */
  122893. getClassName(): string;
  122894. /**
  122895. * Gets the input component
  122896. */
  122897. readonly input: NodeMaterialConnectionPoint;
  122898. /**
  122899. * Gets the source min input component
  122900. */
  122901. readonly sourceMin: NodeMaterialConnectionPoint;
  122902. /**
  122903. * Gets the source max input component
  122904. */
  122905. readonly sourceMax: NodeMaterialConnectionPoint;
  122906. /**
  122907. * Gets the target min input component
  122908. */
  122909. readonly targetMin: NodeMaterialConnectionPoint;
  122910. /**
  122911. * Gets the target max input component
  122912. */
  122913. readonly targetMax: NodeMaterialConnectionPoint;
  122914. /**
  122915. * Gets the output component
  122916. */
  122917. readonly output: NodeMaterialConnectionPoint;
  122918. protected _buildBlock(state: NodeMaterialBuildState): this;
  122919. protected _dumpPropertiesCode(): string;
  122920. serialize(): any;
  122921. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122922. }
  122923. }
  122924. declare module BABYLON {
  122925. /**
  122926. * Block used to normalize a vector
  122927. */
  122928. export class NormalizeBlock extends NodeMaterialBlock {
  122929. /**
  122930. * Creates a new NormalizeBlock
  122931. * @param name defines the block name
  122932. */
  122933. constructor(name: string);
  122934. /**
  122935. * Gets the current class name
  122936. * @returns the class name
  122937. */
  122938. getClassName(): string;
  122939. /**
  122940. * Gets the input component
  122941. */
  122942. readonly input: NodeMaterialConnectionPoint;
  122943. /**
  122944. * Gets the output component
  122945. */
  122946. readonly output: NodeMaterialConnectionPoint;
  122947. protected _buildBlock(state: NodeMaterialBuildState): this;
  122948. }
  122949. }
  122950. declare module BABYLON {
  122951. /**
  122952. * Operations supported by the Trigonometry block
  122953. */
  122954. export enum TrigonometryBlockOperations {
  122955. /** Cos */
  122956. Cos = 0,
  122957. /** Sin */
  122958. Sin = 1,
  122959. /** Abs */
  122960. Abs = 2,
  122961. /** Exp */
  122962. Exp = 3,
  122963. /** Exp2 */
  122964. Exp2 = 4,
  122965. /** Round */
  122966. Round = 5,
  122967. /** Floor */
  122968. Floor = 6,
  122969. /** Ceiling */
  122970. Ceiling = 7,
  122971. /** Square root */
  122972. Sqrt = 8,
  122973. /** Log */
  122974. Log = 9,
  122975. /** Tangent */
  122976. Tan = 10,
  122977. /** Arc tangent */
  122978. ArcTan = 11,
  122979. /** Arc cosinus */
  122980. ArcCos = 12,
  122981. /** Arc sinus */
  122982. ArcSin = 13,
  122983. /** Fraction */
  122984. Fract = 14,
  122985. /** Sign */
  122986. Sign = 15,
  122987. /** To radians (from degrees) */
  122988. Radians = 16,
  122989. /** To degrees (from radians) */
  122990. Degrees = 17
  122991. }
  122992. /**
  122993. * Block used to apply trigonometry operation to floats
  122994. */
  122995. export class TrigonometryBlock extends NodeMaterialBlock {
  122996. /**
  122997. * Gets or sets the operation applied by the block
  122998. */
  122999. operation: TrigonometryBlockOperations;
  123000. /**
  123001. * Creates a new TrigonometryBlock
  123002. * @param name defines the block name
  123003. */
  123004. constructor(name: string);
  123005. /**
  123006. * Gets the current class name
  123007. * @returns the class name
  123008. */
  123009. getClassName(): string;
  123010. /**
  123011. * Gets the input component
  123012. */
  123013. readonly input: NodeMaterialConnectionPoint;
  123014. /**
  123015. * Gets the output component
  123016. */
  123017. readonly output: NodeMaterialConnectionPoint;
  123018. protected _buildBlock(state: NodeMaterialBuildState): this;
  123019. serialize(): any;
  123020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123021. }
  123022. }
  123023. declare module BABYLON {
  123024. /**
  123025. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123026. */
  123027. export class ColorMergerBlock extends NodeMaterialBlock {
  123028. /**
  123029. * Create a new ColorMergerBlock
  123030. * @param name defines the block name
  123031. */
  123032. constructor(name: string);
  123033. /**
  123034. * Gets the current class name
  123035. * @returns the class name
  123036. */
  123037. getClassName(): string;
  123038. /**
  123039. * Gets the r component (input)
  123040. */
  123041. readonly r: NodeMaterialConnectionPoint;
  123042. /**
  123043. * Gets the g component (input)
  123044. */
  123045. readonly g: NodeMaterialConnectionPoint;
  123046. /**
  123047. * Gets the b component (input)
  123048. */
  123049. readonly b: NodeMaterialConnectionPoint;
  123050. /**
  123051. * Gets the a component (input)
  123052. */
  123053. readonly a: NodeMaterialConnectionPoint;
  123054. /**
  123055. * Gets the rgba component (output)
  123056. */
  123057. readonly rgba: NodeMaterialConnectionPoint;
  123058. /**
  123059. * Gets the rgb component (output)
  123060. */
  123061. readonly rgb: NodeMaterialConnectionPoint;
  123062. protected _buildBlock(state: NodeMaterialBuildState): this;
  123063. }
  123064. }
  123065. declare module BABYLON {
  123066. /**
  123067. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123068. */
  123069. export class VectorMergerBlock extends NodeMaterialBlock {
  123070. /**
  123071. * Create a new VectorMergerBlock
  123072. * @param name defines the block name
  123073. */
  123074. constructor(name: string);
  123075. /**
  123076. * Gets the current class name
  123077. * @returns the class name
  123078. */
  123079. getClassName(): string;
  123080. /**
  123081. * Gets the x component (input)
  123082. */
  123083. readonly x: NodeMaterialConnectionPoint;
  123084. /**
  123085. * Gets the y component (input)
  123086. */
  123087. readonly y: NodeMaterialConnectionPoint;
  123088. /**
  123089. * Gets the z component (input)
  123090. */
  123091. readonly z: NodeMaterialConnectionPoint;
  123092. /**
  123093. * Gets the w component (input)
  123094. */
  123095. readonly w: NodeMaterialConnectionPoint;
  123096. /**
  123097. * Gets the xyzw component (output)
  123098. */
  123099. readonly xyzw: NodeMaterialConnectionPoint;
  123100. /**
  123101. * Gets the xyz component (output)
  123102. */
  123103. readonly xyz: NodeMaterialConnectionPoint;
  123104. /**
  123105. * Gets the xy component (output)
  123106. */
  123107. readonly xy: NodeMaterialConnectionPoint;
  123108. protected _buildBlock(state: NodeMaterialBuildState): this;
  123109. }
  123110. }
  123111. declare module BABYLON {
  123112. /**
  123113. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123114. */
  123115. export class ColorSplitterBlock extends NodeMaterialBlock {
  123116. /**
  123117. * Create a new ColorSplitterBlock
  123118. * @param name defines the block name
  123119. */
  123120. constructor(name: string);
  123121. /**
  123122. * Gets the current class name
  123123. * @returns the class name
  123124. */
  123125. getClassName(): string;
  123126. /**
  123127. * Gets the rgba component (input)
  123128. */
  123129. readonly rgba: NodeMaterialConnectionPoint;
  123130. /**
  123131. * Gets the rgb component (input)
  123132. */
  123133. readonly rgbIn: NodeMaterialConnectionPoint;
  123134. /**
  123135. * Gets the rgb component (output)
  123136. */
  123137. readonly rgbOut: NodeMaterialConnectionPoint;
  123138. /**
  123139. * Gets the r component (output)
  123140. */
  123141. readonly r: NodeMaterialConnectionPoint;
  123142. /**
  123143. * Gets the g component (output)
  123144. */
  123145. readonly g: NodeMaterialConnectionPoint;
  123146. /**
  123147. * Gets the b component (output)
  123148. */
  123149. readonly b: NodeMaterialConnectionPoint;
  123150. /**
  123151. * Gets the a component (output)
  123152. */
  123153. readonly a: NodeMaterialConnectionPoint;
  123154. protected _inputRename(name: string): string;
  123155. protected _outputRename(name: string): string;
  123156. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123157. }
  123158. }
  123159. declare module BABYLON {
  123160. /**
  123161. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123162. */
  123163. export class VectorSplitterBlock extends NodeMaterialBlock {
  123164. /**
  123165. * Create a new VectorSplitterBlock
  123166. * @param name defines the block name
  123167. */
  123168. constructor(name: string);
  123169. /**
  123170. * Gets the current class name
  123171. * @returns the class name
  123172. */
  123173. getClassName(): string;
  123174. /**
  123175. * Gets the xyzw component (input)
  123176. */
  123177. readonly xyzw: NodeMaterialConnectionPoint;
  123178. /**
  123179. * Gets the xyz component (input)
  123180. */
  123181. readonly xyzIn: NodeMaterialConnectionPoint;
  123182. /**
  123183. * Gets the xy component (input)
  123184. */
  123185. readonly xyIn: NodeMaterialConnectionPoint;
  123186. /**
  123187. * Gets the xyz component (output)
  123188. */
  123189. readonly xyzOut: NodeMaterialConnectionPoint;
  123190. /**
  123191. * Gets the xy component (output)
  123192. */
  123193. readonly xyOut: NodeMaterialConnectionPoint;
  123194. /**
  123195. * Gets the x component (output)
  123196. */
  123197. readonly x: NodeMaterialConnectionPoint;
  123198. /**
  123199. * Gets the y component (output)
  123200. */
  123201. readonly y: NodeMaterialConnectionPoint;
  123202. /**
  123203. * Gets the z component (output)
  123204. */
  123205. readonly z: NodeMaterialConnectionPoint;
  123206. /**
  123207. * Gets the w component (output)
  123208. */
  123209. readonly w: NodeMaterialConnectionPoint;
  123210. protected _inputRename(name: string): string;
  123211. protected _outputRename(name: string): string;
  123212. protected _buildBlock(state: NodeMaterialBuildState): this;
  123213. }
  123214. }
  123215. declare module BABYLON {
  123216. /**
  123217. * Block used to lerp between 2 values
  123218. */
  123219. export class LerpBlock extends NodeMaterialBlock {
  123220. /**
  123221. * Creates a new LerpBlock
  123222. * @param name defines the block name
  123223. */
  123224. constructor(name: string);
  123225. /**
  123226. * Gets the current class name
  123227. * @returns the class name
  123228. */
  123229. getClassName(): string;
  123230. /**
  123231. * Gets the left operand input component
  123232. */
  123233. readonly left: NodeMaterialConnectionPoint;
  123234. /**
  123235. * Gets the right operand input component
  123236. */
  123237. readonly right: NodeMaterialConnectionPoint;
  123238. /**
  123239. * Gets the gradient operand input component
  123240. */
  123241. readonly gradient: NodeMaterialConnectionPoint;
  123242. /**
  123243. * Gets the output component
  123244. */
  123245. readonly output: NodeMaterialConnectionPoint;
  123246. protected _buildBlock(state: NodeMaterialBuildState): this;
  123247. }
  123248. }
  123249. declare module BABYLON {
  123250. /**
  123251. * Block used to divide 2 vectors
  123252. */
  123253. export class DivideBlock extends NodeMaterialBlock {
  123254. /**
  123255. * Creates a new DivideBlock
  123256. * @param name defines the block name
  123257. */
  123258. constructor(name: string);
  123259. /**
  123260. * Gets the current class name
  123261. * @returns the class name
  123262. */
  123263. getClassName(): string;
  123264. /**
  123265. * Gets the left operand input component
  123266. */
  123267. readonly left: NodeMaterialConnectionPoint;
  123268. /**
  123269. * Gets the right operand input component
  123270. */
  123271. readonly right: NodeMaterialConnectionPoint;
  123272. /**
  123273. * Gets the output component
  123274. */
  123275. readonly output: NodeMaterialConnectionPoint;
  123276. protected _buildBlock(state: NodeMaterialBuildState): this;
  123277. }
  123278. }
  123279. declare module BABYLON {
  123280. /**
  123281. * Block used to subtract 2 vectors
  123282. */
  123283. export class SubtractBlock extends NodeMaterialBlock {
  123284. /**
  123285. * Creates a new SubtractBlock
  123286. * @param name defines the block name
  123287. */
  123288. constructor(name: string);
  123289. /**
  123290. * Gets the current class name
  123291. * @returns the class name
  123292. */
  123293. getClassName(): string;
  123294. /**
  123295. * Gets the left operand input component
  123296. */
  123297. readonly left: NodeMaterialConnectionPoint;
  123298. /**
  123299. * Gets the right operand input component
  123300. */
  123301. readonly right: NodeMaterialConnectionPoint;
  123302. /**
  123303. * Gets the output component
  123304. */
  123305. readonly output: NodeMaterialConnectionPoint;
  123306. protected _buildBlock(state: NodeMaterialBuildState): this;
  123307. }
  123308. }
  123309. declare module BABYLON {
  123310. /**
  123311. * Block used to step a value
  123312. */
  123313. export class StepBlock extends NodeMaterialBlock {
  123314. /**
  123315. * Creates a new StepBlock
  123316. * @param name defines the block name
  123317. */
  123318. constructor(name: string);
  123319. /**
  123320. * Gets the current class name
  123321. * @returns the class name
  123322. */
  123323. getClassName(): string;
  123324. /**
  123325. * Gets the value operand input component
  123326. */
  123327. readonly value: NodeMaterialConnectionPoint;
  123328. /**
  123329. * Gets the edge operand input component
  123330. */
  123331. readonly edge: NodeMaterialConnectionPoint;
  123332. /**
  123333. * Gets the output component
  123334. */
  123335. readonly output: NodeMaterialConnectionPoint;
  123336. protected _buildBlock(state: NodeMaterialBuildState): this;
  123337. }
  123338. }
  123339. declare module BABYLON {
  123340. /**
  123341. * Block used to get the opposite (1 - x) of a value
  123342. */
  123343. export class OneMinusBlock extends NodeMaterialBlock {
  123344. /**
  123345. * Creates a new OneMinusBlock
  123346. * @param name defines the block name
  123347. */
  123348. constructor(name: string);
  123349. /**
  123350. * Gets the current class name
  123351. * @returns the class name
  123352. */
  123353. getClassName(): string;
  123354. /**
  123355. * Gets the input component
  123356. */
  123357. readonly input: NodeMaterialConnectionPoint;
  123358. /**
  123359. * Gets the output component
  123360. */
  123361. readonly output: NodeMaterialConnectionPoint;
  123362. protected _buildBlock(state: NodeMaterialBuildState): this;
  123363. }
  123364. }
  123365. declare module BABYLON {
  123366. /**
  123367. * Block used to get the view direction
  123368. */
  123369. export class ViewDirectionBlock extends NodeMaterialBlock {
  123370. /**
  123371. * Creates a new ViewDirectionBlock
  123372. * @param name defines the block name
  123373. */
  123374. constructor(name: string);
  123375. /**
  123376. * Gets the current class name
  123377. * @returns the class name
  123378. */
  123379. getClassName(): string;
  123380. /**
  123381. * Gets the world position component
  123382. */
  123383. readonly worldPosition: NodeMaterialConnectionPoint;
  123384. /**
  123385. * Gets the camera position component
  123386. */
  123387. readonly cameraPosition: NodeMaterialConnectionPoint;
  123388. /**
  123389. * Gets the output component
  123390. */
  123391. readonly output: NodeMaterialConnectionPoint;
  123392. autoConfigure(material: NodeMaterial): void;
  123393. protected _buildBlock(state: NodeMaterialBuildState): this;
  123394. }
  123395. }
  123396. declare module BABYLON {
  123397. /**
  123398. * Block used to compute fresnel value
  123399. */
  123400. export class FresnelBlock extends NodeMaterialBlock {
  123401. /**
  123402. * Create a new FresnelBlock
  123403. * @param name defines the block name
  123404. */
  123405. constructor(name: string);
  123406. /**
  123407. * Gets the current class name
  123408. * @returns the class name
  123409. */
  123410. getClassName(): string;
  123411. /**
  123412. * Gets the world normal input component
  123413. */
  123414. readonly worldNormal: NodeMaterialConnectionPoint;
  123415. /**
  123416. * Gets the view direction input component
  123417. */
  123418. readonly viewDirection: NodeMaterialConnectionPoint;
  123419. /**
  123420. * Gets the bias input component
  123421. */
  123422. readonly bias: NodeMaterialConnectionPoint;
  123423. /**
  123424. * Gets the camera (or eye) position component
  123425. */
  123426. readonly power: NodeMaterialConnectionPoint;
  123427. /**
  123428. * Gets the fresnel output component
  123429. */
  123430. readonly fresnel: NodeMaterialConnectionPoint;
  123431. autoConfigure(material: NodeMaterial): void;
  123432. protected _buildBlock(state: NodeMaterialBuildState): this;
  123433. }
  123434. }
  123435. declare module BABYLON {
  123436. /**
  123437. * Block used to get the max of 2 values
  123438. */
  123439. export class MaxBlock extends NodeMaterialBlock {
  123440. /**
  123441. * Creates a new MaxBlock
  123442. * @param name defines the block name
  123443. */
  123444. constructor(name: string);
  123445. /**
  123446. * Gets the current class name
  123447. * @returns the class name
  123448. */
  123449. getClassName(): string;
  123450. /**
  123451. * Gets the left operand input component
  123452. */
  123453. readonly left: NodeMaterialConnectionPoint;
  123454. /**
  123455. * Gets the right operand input component
  123456. */
  123457. readonly right: NodeMaterialConnectionPoint;
  123458. /**
  123459. * Gets the output component
  123460. */
  123461. readonly output: NodeMaterialConnectionPoint;
  123462. protected _buildBlock(state: NodeMaterialBuildState): this;
  123463. }
  123464. }
  123465. declare module BABYLON {
  123466. /**
  123467. * Block used to get the min of 2 values
  123468. */
  123469. export class MinBlock extends NodeMaterialBlock {
  123470. /**
  123471. * Creates a new MinBlock
  123472. * @param name defines the block name
  123473. */
  123474. constructor(name: string);
  123475. /**
  123476. * Gets the current class name
  123477. * @returns the class name
  123478. */
  123479. getClassName(): string;
  123480. /**
  123481. * Gets the left operand input component
  123482. */
  123483. readonly left: NodeMaterialConnectionPoint;
  123484. /**
  123485. * Gets the right operand input component
  123486. */
  123487. readonly right: NodeMaterialConnectionPoint;
  123488. /**
  123489. * Gets the output component
  123490. */
  123491. readonly output: NodeMaterialConnectionPoint;
  123492. protected _buildBlock(state: NodeMaterialBuildState): this;
  123493. }
  123494. }
  123495. declare module BABYLON {
  123496. /**
  123497. * Block used to get the distance between 2 values
  123498. */
  123499. export class DistanceBlock extends NodeMaterialBlock {
  123500. /**
  123501. * Creates a new DistanceBlock
  123502. * @param name defines the block name
  123503. */
  123504. constructor(name: string);
  123505. /**
  123506. * Gets the current class name
  123507. * @returns the class name
  123508. */
  123509. getClassName(): string;
  123510. /**
  123511. * Gets the left operand input component
  123512. */
  123513. readonly left: NodeMaterialConnectionPoint;
  123514. /**
  123515. * Gets the right operand input component
  123516. */
  123517. readonly right: NodeMaterialConnectionPoint;
  123518. /**
  123519. * Gets the output component
  123520. */
  123521. readonly output: NodeMaterialConnectionPoint;
  123522. protected _buildBlock(state: NodeMaterialBuildState): this;
  123523. }
  123524. }
  123525. declare module BABYLON {
  123526. /**
  123527. * Block used to get the length of a vector
  123528. */
  123529. export class LengthBlock extends NodeMaterialBlock {
  123530. /**
  123531. * Creates a new LengthBlock
  123532. * @param name defines the block name
  123533. */
  123534. constructor(name: string);
  123535. /**
  123536. * Gets the current class name
  123537. * @returns the class name
  123538. */
  123539. getClassName(): string;
  123540. /**
  123541. * Gets the value input component
  123542. */
  123543. readonly value: NodeMaterialConnectionPoint;
  123544. /**
  123545. * Gets the output component
  123546. */
  123547. readonly output: NodeMaterialConnectionPoint;
  123548. protected _buildBlock(state: NodeMaterialBuildState): this;
  123549. }
  123550. }
  123551. declare module BABYLON {
  123552. /**
  123553. * Block used to get negative version of a value (i.e. x * -1)
  123554. */
  123555. export class NegateBlock extends NodeMaterialBlock {
  123556. /**
  123557. * Creates a new NegateBlock
  123558. * @param name defines the block name
  123559. */
  123560. constructor(name: string);
  123561. /**
  123562. * Gets the current class name
  123563. * @returns the class name
  123564. */
  123565. getClassName(): string;
  123566. /**
  123567. * Gets the value input component
  123568. */
  123569. readonly value: NodeMaterialConnectionPoint;
  123570. /**
  123571. * Gets the output component
  123572. */
  123573. readonly output: NodeMaterialConnectionPoint;
  123574. protected _buildBlock(state: NodeMaterialBuildState): this;
  123575. }
  123576. }
  123577. declare module BABYLON {
  123578. /**
  123579. * Block used to get the value of the first parameter raised to the power of the second
  123580. */
  123581. export class PowBlock extends NodeMaterialBlock {
  123582. /**
  123583. * Creates a new PowBlock
  123584. * @param name defines the block name
  123585. */
  123586. constructor(name: string);
  123587. /**
  123588. * Gets the current class name
  123589. * @returns the class name
  123590. */
  123591. getClassName(): string;
  123592. /**
  123593. * Gets the value operand input component
  123594. */
  123595. readonly value: NodeMaterialConnectionPoint;
  123596. /**
  123597. * Gets the power operand input component
  123598. */
  123599. readonly power: NodeMaterialConnectionPoint;
  123600. /**
  123601. * Gets the output component
  123602. */
  123603. readonly output: NodeMaterialConnectionPoint;
  123604. protected _buildBlock(state: NodeMaterialBuildState): this;
  123605. }
  123606. }
  123607. declare module BABYLON {
  123608. /**
  123609. * Block used to get a random number
  123610. */
  123611. export class RandomNumberBlock extends NodeMaterialBlock {
  123612. /**
  123613. * Creates a new RandomNumberBlock
  123614. * @param name defines the block name
  123615. */
  123616. constructor(name: string);
  123617. /**
  123618. * Gets the current class name
  123619. * @returns the class name
  123620. */
  123621. getClassName(): string;
  123622. /**
  123623. * Gets the seed input component
  123624. */
  123625. readonly seed: NodeMaterialConnectionPoint;
  123626. /**
  123627. * Gets the output component
  123628. */
  123629. readonly output: NodeMaterialConnectionPoint;
  123630. protected _buildBlock(state: NodeMaterialBuildState): this;
  123631. }
  123632. }
  123633. declare module BABYLON {
  123634. /**
  123635. * Block used to compute arc tangent of 2 values
  123636. */
  123637. export class ArcTan2Block extends NodeMaterialBlock {
  123638. /**
  123639. * Creates a new ArcTan2Block
  123640. * @param name defines the block name
  123641. */
  123642. constructor(name: string);
  123643. /**
  123644. * Gets the current class name
  123645. * @returns the class name
  123646. */
  123647. getClassName(): string;
  123648. /**
  123649. * Gets the x operand input component
  123650. */
  123651. readonly x: NodeMaterialConnectionPoint;
  123652. /**
  123653. * Gets the y operand input component
  123654. */
  123655. readonly y: NodeMaterialConnectionPoint;
  123656. /**
  123657. * Gets the output component
  123658. */
  123659. readonly output: NodeMaterialConnectionPoint;
  123660. protected _buildBlock(state: NodeMaterialBuildState): this;
  123661. }
  123662. }
  123663. declare module BABYLON {
  123664. /**
  123665. * Block used to smooth step a value
  123666. */
  123667. export class SmoothStepBlock extends NodeMaterialBlock {
  123668. /**
  123669. * Creates a new SmoothStepBlock
  123670. * @param name defines the block name
  123671. */
  123672. constructor(name: string);
  123673. /**
  123674. * Gets the current class name
  123675. * @returns the class name
  123676. */
  123677. getClassName(): string;
  123678. /**
  123679. * Gets the value operand input component
  123680. */
  123681. readonly value: NodeMaterialConnectionPoint;
  123682. /**
  123683. * Gets the first edge operand input component
  123684. */
  123685. readonly edge0: NodeMaterialConnectionPoint;
  123686. /**
  123687. * Gets the second edge operand input component
  123688. */
  123689. readonly edge1: NodeMaterialConnectionPoint;
  123690. /**
  123691. * Gets the output component
  123692. */
  123693. readonly output: NodeMaterialConnectionPoint;
  123694. protected _buildBlock(state: NodeMaterialBuildState): this;
  123695. }
  123696. }
  123697. declare module BABYLON {
  123698. /**
  123699. * Block used to get the reciprocal (1 / x) of a value
  123700. */
  123701. export class ReciprocalBlock extends NodeMaterialBlock {
  123702. /**
  123703. * Creates a new ReciprocalBlock
  123704. * @param name defines the block name
  123705. */
  123706. constructor(name: string);
  123707. /**
  123708. * Gets the current class name
  123709. * @returns the class name
  123710. */
  123711. getClassName(): string;
  123712. /**
  123713. * Gets the input component
  123714. */
  123715. readonly input: NodeMaterialConnectionPoint;
  123716. /**
  123717. * Gets the output component
  123718. */
  123719. readonly output: NodeMaterialConnectionPoint;
  123720. protected _buildBlock(state: NodeMaterialBuildState): this;
  123721. }
  123722. }
  123723. declare module BABYLON {
  123724. /**
  123725. * Block used to replace a color by another one
  123726. */
  123727. export class ReplaceColorBlock extends NodeMaterialBlock {
  123728. /**
  123729. * Creates a new ReplaceColorBlock
  123730. * @param name defines the block name
  123731. */
  123732. constructor(name: string);
  123733. /**
  123734. * Gets the current class name
  123735. * @returns the class name
  123736. */
  123737. getClassName(): string;
  123738. /**
  123739. * Gets the value input component
  123740. */
  123741. readonly value: NodeMaterialConnectionPoint;
  123742. /**
  123743. * Gets the reference input component
  123744. */
  123745. readonly reference: NodeMaterialConnectionPoint;
  123746. /**
  123747. * Gets the distance input component
  123748. */
  123749. readonly distance: NodeMaterialConnectionPoint;
  123750. /**
  123751. * Gets the replacement input component
  123752. */
  123753. readonly replacement: NodeMaterialConnectionPoint;
  123754. /**
  123755. * Gets the output component
  123756. */
  123757. readonly output: NodeMaterialConnectionPoint;
  123758. protected _buildBlock(state: NodeMaterialBuildState): this;
  123759. }
  123760. }
  123761. declare module BABYLON {
  123762. /**
  123763. * Block used to posterize a value
  123764. * @see https://en.wikipedia.org/wiki/Posterization
  123765. */
  123766. export class PosterizeBlock extends NodeMaterialBlock {
  123767. /**
  123768. * Creates a new PosterizeBlock
  123769. * @param name defines the block name
  123770. */
  123771. constructor(name: string);
  123772. /**
  123773. * Gets the current class name
  123774. * @returns the class name
  123775. */
  123776. getClassName(): string;
  123777. /**
  123778. * Gets the value input component
  123779. */
  123780. readonly value: NodeMaterialConnectionPoint;
  123781. /**
  123782. * Gets the steps input component
  123783. */
  123784. readonly steps: NodeMaterialConnectionPoint;
  123785. /**
  123786. * Gets the output component
  123787. */
  123788. readonly output: NodeMaterialConnectionPoint;
  123789. protected _buildBlock(state: NodeMaterialBuildState): this;
  123790. }
  123791. }
  123792. declare module BABYLON {
  123793. /**
  123794. * Operations supported by the Wave block
  123795. */
  123796. export enum WaveBlockKind {
  123797. /** SawTooth */
  123798. SawTooth = 0,
  123799. /** Square */
  123800. Square = 1,
  123801. /** Triangle */
  123802. Triangle = 2
  123803. }
  123804. /**
  123805. * Block used to apply wave operation to floats
  123806. */
  123807. export class WaveBlock extends NodeMaterialBlock {
  123808. /**
  123809. * Gets or sets the kibnd of wave to be applied by the block
  123810. */
  123811. kind: WaveBlockKind;
  123812. /**
  123813. * Creates a new WaveBlock
  123814. * @param name defines the block name
  123815. */
  123816. constructor(name: string);
  123817. /**
  123818. * Gets the current class name
  123819. * @returns the class name
  123820. */
  123821. getClassName(): string;
  123822. /**
  123823. * Gets the input component
  123824. */
  123825. readonly input: NodeMaterialConnectionPoint;
  123826. /**
  123827. * Gets the output component
  123828. */
  123829. readonly output: NodeMaterialConnectionPoint;
  123830. protected _buildBlock(state: NodeMaterialBuildState): this;
  123831. serialize(): any;
  123832. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123833. }
  123834. }
  123835. declare module BABYLON {
  123836. /**
  123837. * Class used to store a color step for the GradientBlock
  123838. */
  123839. export class GradientBlockColorStep {
  123840. /**
  123841. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123842. */
  123843. step: number;
  123844. /**
  123845. * Gets or sets the color associated with this step
  123846. */
  123847. color: Color3;
  123848. /**
  123849. * Creates a new GradientBlockColorStep
  123850. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  123851. * @param color defines the color associated with this step
  123852. */
  123853. constructor(
  123854. /**
  123855. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123856. */
  123857. step: number,
  123858. /**
  123859. * Gets or sets the color associated with this step
  123860. */
  123861. color: Color3);
  123862. }
  123863. /**
  123864. * Block used to return a color from a gradient based on an input value between 0 and 1
  123865. */
  123866. export class GradientBlock extends NodeMaterialBlock {
  123867. /**
  123868. * Gets or sets the list of color steps
  123869. */
  123870. colorSteps: GradientBlockColorStep[];
  123871. /**
  123872. * Creates a new GradientBlock
  123873. * @param name defines the block name
  123874. */
  123875. constructor(name: string);
  123876. /**
  123877. * Gets the current class name
  123878. * @returns the class name
  123879. */
  123880. getClassName(): string;
  123881. /**
  123882. * Gets the gradient input component
  123883. */
  123884. readonly gradient: NodeMaterialConnectionPoint;
  123885. /**
  123886. * Gets the output component
  123887. */
  123888. readonly output: NodeMaterialConnectionPoint;
  123889. private _writeColorConstant;
  123890. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123891. serialize(): any;
  123892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123893. protected _dumpPropertiesCode(): string;
  123894. }
  123895. }
  123896. declare module BABYLON {
  123897. /**
  123898. * Block used to normalize lerp between 2 values
  123899. */
  123900. export class NLerpBlock extends NodeMaterialBlock {
  123901. /**
  123902. * Creates a new NLerpBlock
  123903. * @param name defines the block name
  123904. */
  123905. constructor(name: string);
  123906. /**
  123907. * Gets the current class name
  123908. * @returns the class name
  123909. */
  123910. getClassName(): string;
  123911. /**
  123912. * Gets the left operand input component
  123913. */
  123914. readonly left: NodeMaterialConnectionPoint;
  123915. /**
  123916. * Gets the right operand input component
  123917. */
  123918. readonly right: NodeMaterialConnectionPoint;
  123919. /**
  123920. * Gets the gradient operand input component
  123921. */
  123922. readonly gradient: NodeMaterialConnectionPoint;
  123923. /**
  123924. * Gets the output component
  123925. */
  123926. readonly output: NodeMaterialConnectionPoint;
  123927. protected _buildBlock(state: NodeMaterialBuildState): this;
  123928. }
  123929. }
  123930. declare module BABYLON {
  123931. /**
  123932. * Block used to test if the fragment shader is front facing
  123933. */
  123934. export class FrontFacingBlock extends NodeMaterialBlock {
  123935. /**
  123936. * Creates a new FrontFacingBlock
  123937. * @param name defines the block name
  123938. */
  123939. constructor(name: string);
  123940. /**
  123941. * Gets the current class name
  123942. * @returns the class name
  123943. */
  123944. getClassName(): string;
  123945. /**
  123946. * Gets the world normal component
  123947. */
  123948. readonly worldNormal: NodeMaterialConnectionPoint;
  123949. /**
  123950. * Gets the view direction input component
  123951. */
  123952. readonly viewDirection: NodeMaterialConnectionPoint;
  123953. /**
  123954. * Gets the output component
  123955. */
  123956. readonly output: NodeMaterialConnectionPoint;
  123957. autoConfigure(material: NodeMaterial): void;
  123958. protected _buildBlock(state: NodeMaterialBuildState): this;
  123959. }
  123960. }
  123961. declare module BABYLON {
  123962. /**
  123963. * Effect Render Options
  123964. */
  123965. export interface IEffectRendererOptions {
  123966. /**
  123967. * Defines the vertices positions.
  123968. */
  123969. positions?: number[];
  123970. /**
  123971. * Defines the indices.
  123972. */
  123973. indices?: number[];
  123974. }
  123975. /**
  123976. * Helper class to render one or more effects
  123977. */
  123978. export class EffectRenderer {
  123979. private engine;
  123980. private static _DefaultOptions;
  123981. private _vertexBuffers;
  123982. private _indexBuffer;
  123983. private _ringBufferIndex;
  123984. private _ringScreenBuffer;
  123985. private _fullscreenViewport;
  123986. private _getNextFrameBuffer;
  123987. /**
  123988. * Creates an effect renderer
  123989. * @param engine the engine to use for rendering
  123990. * @param options defines the options of the effect renderer
  123991. */
  123992. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  123993. /**
  123994. * Sets the current viewport in normalized coordinates 0-1
  123995. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  123996. */
  123997. setViewport(viewport?: Viewport): void;
  123998. /**
  123999. * Binds the embedded attributes buffer to the effect.
  124000. * @param effect Defines the effect to bind the attributes for
  124001. */
  124002. bindBuffers(effect: Effect): void;
  124003. /**
  124004. * Sets the current effect wrapper to use during draw.
  124005. * The effect needs to be ready before calling this api.
  124006. * This also sets the default full screen position attribute.
  124007. * @param effectWrapper Defines the effect to draw with
  124008. */
  124009. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124010. /**
  124011. * Draws a full screen quad.
  124012. */
  124013. draw(): void;
  124014. /**
  124015. * renders one or more effects to a specified texture
  124016. * @param effectWrappers list of effects to renderer
  124017. * @param outputTexture texture to draw to, if null it will render to the screen
  124018. */
  124019. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124020. /**
  124021. * Disposes of the effect renderer
  124022. */
  124023. dispose(): void;
  124024. }
  124025. /**
  124026. * Options to create an EffectWrapper
  124027. */
  124028. interface EffectWrapperCreationOptions {
  124029. /**
  124030. * Engine to use to create the effect
  124031. */
  124032. engine: ThinEngine;
  124033. /**
  124034. * Fragment shader for the effect
  124035. */
  124036. fragmentShader: string;
  124037. /**
  124038. * Vertex shader for the effect
  124039. */
  124040. vertexShader?: string;
  124041. /**
  124042. * Attributes to use in the shader
  124043. */
  124044. attributeNames?: Array<string>;
  124045. /**
  124046. * Uniforms to use in the shader
  124047. */
  124048. uniformNames?: Array<string>;
  124049. /**
  124050. * Texture sampler names to use in the shader
  124051. */
  124052. samplerNames?: Array<string>;
  124053. /**
  124054. * The friendly name of the effect displayed in Spector.
  124055. */
  124056. name?: string;
  124057. }
  124058. /**
  124059. * Wraps an effect to be used for rendering
  124060. */
  124061. export class EffectWrapper {
  124062. /**
  124063. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124064. */
  124065. onApplyObservable: Observable<{}>;
  124066. /**
  124067. * The underlying effect
  124068. */
  124069. effect: Effect;
  124070. /**
  124071. * Creates an effect to be renderer
  124072. * @param creationOptions options to create the effect
  124073. */
  124074. constructor(creationOptions: EffectWrapperCreationOptions);
  124075. /**
  124076. * Disposes of the effect wrapper
  124077. */
  124078. dispose(): void;
  124079. }
  124080. }
  124081. declare module BABYLON {
  124082. /**
  124083. * Helper class to push actions to a pool of workers.
  124084. */
  124085. export class WorkerPool implements IDisposable {
  124086. private _workerInfos;
  124087. private _pendingActions;
  124088. /**
  124089. * Constructor
  124090. * @param workers Array of workers to use for actions
  124091. */
  124092. constructor(workers: Array<Worker>);
  124093. /**
  124094. * Terminates all workers and clears any pending actions.
  124095. */
  124096. dispose(): void;
  124097. /**
  124098. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124099. * pended until a worker has completed its action.
  124100. * @param action The action to perform. Call onComplete when the action is complete.
  124101. */
  124102. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124103. private _execute;
  124104. }
  124105. }
  124106. declare module BABYLON {
  124107. /**
  124108. * Configuration for Draco compression
  124109. */
  124110. export interface IDracoCompressionConfiguration {
  124111. /**
  124112. * Configuration for the decoder.
  124113. */
  124114. decoder: {
  124115. /**
  124116. * The url to the WebAssembly module.
  124117. */
  124118. wasmUrl?: string;
  124119. /**
  124120. * The url to the WebAssembly binary.
  124121. */
  124122. wasmBinaryUrl?: string;
  124123. /**
  124124. * The url to the fallback JavaScript module.
  124125. */
  124126. fallbackUrl?: string;
  124127. };
  124128. }
  124129. /**
  124130. * Draco compression (https://google.github.io/draco/)
  124131. *
  124132. * This class wraps the Draco module.
  124133. *
  124134. * **Encoder**
  124135. *
  124136. * The encoder is not currently implemented.
  124137. *
  124138. * **Decoder**
  124139. *
  124140. * 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.
  124141. *
  124142. * To update the configuration, use the following code:
  124143. * ```javascript
  124144. * DracoCompression.Configuration = {
  124145. * decoder: {
  124146. * wasmUrl: "<url to the WebAssembly library>",
  124147. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124148. * fallbackUrl: "<url to the fallback JavaScript library>",
  124149. * }
  124150. * };
  124151. * ```
  124152. *
  124153. * 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.
  124154. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124155. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124156. *
  124157. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124158. * ```javascript
  124159. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124160. * ```
  124161. *
  124162. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124163. */
  124164. export class DracoCompression implements IDisposable {
  124165. private _workerPoolPromise?;
  124166. private _decoderModulePromise?;
  124167. /**
  124168. * The configuration. Defaults to the following urls:
  124169. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124170. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124171. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124172. */
  124173. static Configuration: IDracoCompressionConfiguration;
  124174. /**
  124175. * Returns true if the decoder configuration is available.
  124176. */
  124177. static readonly DecoderAvailable: boolean;
  124178. /**
  124179. * Default number of workers to create when creating the draco compression object.
  124180. */
  124181. static DefaultNumWorkers: number;
  124182. private static GetDefaultNumWorkers;
  124183. private static _Default;
  124184. /**
  124185. * Default instance for the draco compression object.
  124186. */
  124187. static readonly Default: DracoCompression;
  124188. /**
  124189. * Constructor
  124190. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  124191. */
  124192. constructor(numWorkers?: number);
  124193. /**
  124194. * Stop all async operations and release resources.
  124195. */
  124196. dispose(): void;
  124197. /**
  124198. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124199. * @returns a promise that resolves when ready
  124200. */
  124201. whenReadyAsync(): Promise<void>;
  124202. /**
  124203. * Decode Draco compressed mesh data to vertex data.
  124204. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124205. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124206. * @returns A promise that resolves with the decoded vertex data
  124207. */
  124208. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124209. [kind: string]: number;
  124210. }): Promise<VertexData>;
  124211. }
  124212. }
  124213. declare module BABYLON {
  124214. /**
  124215. * Class for building Constructive Solid Geometry
  124216. */
  124217. export class CSG {
  124218. private polygons;
  124219. /**
  124220. * The world matrix
  124221. */
  124222. matrix: Matrix;
  124223. /**
  124224. * Stores the position
  124225. */
  124226. position: Vector3;
  124227. /**
  124228. * Stores the rotation
  124229. */
  124230. rotation: Vector3;
  124231. /**
  124232. * Stores the rotation quaternion
  124233. */
  124234. rotationQuaternion: Nullable<Quaternion>;
  124235. /**
  124236. * Stores the scaling vector
  124237. */
  124238. scaling: Vector3;
  124239. /**
  124240. * Convert the Mesh to CSG
  124241. * @param mesh The Mesh to convert to CSG
  124242. * @returns A new CSG from the Mesh
  124243. */
  124244. static FromMesh(mesh: Mesh): CSG;
  124245. /**
  124246. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124247. * @param polygons Polygons used to construct a CSG solid
  124248. */
  124249. private static FromPolygons;
  124250. /**
  124251. * Clones, or makes a deep copy, of the CSG
  124252. * @returns A new CSG
  124253. */
  124254. clone(): CSG;
  124255. /**
  124256. * Unions this CSG with another CSG
  124257. * @param csg The CSG to union against this CSG
  124258. * @returns The unioned CSG
  124259. */
  124260. union(csg: CSG): CSG;
  124261. /**
  124262. * Unions this CSG with another CSG in place
  124263. * @param csg The CSG to union against this CSG
  124264. */
  124265. unionInPlace(csg: CSG): void;
  124266. /**
  124267. * Subtracts this CSG with another CSG
  124268. * @param csg The CSG to subtract against this CSG
  124269. * @returns A new CSG
  124270. */
  124271. subtract(csg: CSG): CSG;
  124272. /**
  124273. * Subtracts this CSG with another CSG in place
  124274. * @param csg The CSG to subtact against this CSG
  124275. */
  124276. subtractInPlace(csg: CSG): void;
  124277. /**
  124278. * Intersect this CSG with another CSG
  124279. * @param csg The CSG to intersect against this CSG
  124280. * @returns A new CSG
  124281. */
  124282. intersect(csg: CSG): CSG;
  124283. /**
  124284. * Intersects this CSG with another CSG in place
  124285. * @param csg The CSG to intersect against this CSG
  124286. */
  124287. intersectInPlace(csg: CSG): void;
  124288. /**
  124289. * Return a new CSG solid with solid and empty space switched. This solid is
  124290. * not modified.
  124291. * @returns A new CSG solid with solid and empty space switched
  124292. */
  124293. inverse(): CSG;
  124294. /**
  124295. * Inverses the CSG in place
  124296. */
  124297. inverseInPlace(): void;
  124298. /**
  124299. * This is used to keep meshes transformations so they can be restored
  124300. * when we build back a Babylon Mesh
  124301. * NB : All CSG operations are performed in world coordinates
  124302. * @param csg The CSG to copy the transform attributes from
  124303. * @returns This CSG
  124304. */
  124305. copyTransformAttributes(csg: CSG): CSG;
  124306. /**
  124307. * Build Raw mesh from CSG
  124308. * Coordinates here are in world space
  124309. * @param name The name of the mesh geometry
  124310. * @param scene The Scene
  124311. * @param keepSubMeshes Specifies if the submeshes should be kept
  124312. * @returns A new Mesh
  124313. */
  124314. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124315. /**
  124316. * Build Mesh from CSG taking material and transforms into account
  124317. * @param name The name of the Mesh
  124318. * @param material The material of the Mesh
  124319. * @param scene The Scene
  124320. * @param keepSubMeshes Specifies if submeshes should be kept
  124321. * @returns The new Mesh
  124322. */
  124323. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124324. }
  124325. }
  124326. declare module BABYLON {
  124327. /**
  124328. * Class used to create a trail following a mesh
  124329. */
  124330. export class TrailMesh extends Mesh {
  124331. private _generator;
  124332. private _autoStart;
  124333. private _running;
  124334. private _diameter;
  124335. private _length;
  124336. private _sectionPolygonPointsCount;
  124337. private _sectionVectors;
  124338. private _sectionNormalVectors;
  124339. private _beforeRenderObserver;
  124340. /**
  124341. * @constructor
  124342. * @param name The value used by scene.getMeshByName() to do a lookup.
  124343. * @param generator The mesh to generate a trail.
  124344. * @param scene The scene to add this mesh to.
  124345. * @param diameter Diameter of trailing mesh. Default is 1.
  124346. * @param length Length of trailing mesh. Default is 60.
  124347. * @param autoStart Automatically start trailing mesh. Default true.
  124348. */
  124349. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  124350. /**
  124351. * "TrailMesh"
  124352. * @returns "TrailMesh"
  124353. */
  124354. getClassName(): string;
  124355. private _createMesh;
  124356. /**
  124357. * Start trailing mesh.
  124358. */
  124359. start(): void;
  124360. /**
  124361. * Stop trailing mesh.
  124362. */
  124363. stop(): void;
  124364. /**
  124365. * Update trailing mesh geometry.
  124366. */
  124367. update(): void;
  124368. /**
  124369. * Returns a new TrailMesh object.
  124370. * @param name is a string, the name given to the new mesh
  124371. * @param newGenerator use new generator object for cloned trail mesh
  124372. * @returns a new mesh
  124373. */
  124374. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  124375. /**
  124376. * Serializes this trail mesh
  124377. * @param serializationObject object to write serialization to
  124378. */
  124379. serialize(serializationObject: any): void;
  124380. /**
  124381. * Parses a serialized trail mesh
  124382. * @param parsedMesh the serialized mesh
  124383. * @param scene the scene to create the trail mesh in
  124384. * @returns the created trail mesh
  124385. */
  124386. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  124387. }
  124388. }
  124389. declare module BABYLON {
  124390. /**
  124391. * Class containing static functions to help procedurally build meshes
  124392. */
  124393. export class TiledBoxBuilder {
  124394. /**
  124395. * Creates a box mesh
  124396. * 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)
  124397. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124401. * @param name defines the name of the mesh
  124402. * @param options defines the options used to create the mesh
  124403. * @param scene defines the hosting scene
  124404. * @returns the box mesh
  124405. */
  124406. static CreateTiledBox(name: string, options: {
  124407. pattern?: number;
  124408. width?: number;
  124409. height?: number;
  124410. depth?: number;
  124411. tileSize?: number;
  124412. tileWidth?: number;
  124413. tileHeight?: number;
  124414. alignHorizontal?: number;
  124415. alignVertical?: number;
  124416. faceUV?: Vector4[];
  124417. faceColors?: Color4[];
  124418. sideOrientation?: number;
  124419. updatable?: boolean;
  124420. }, scene?: Nullable<Scene>): Mesh;
  124421. }
  124422. }
  124423. declare module BABYLON {
  124424. /**
  124425. * Class containing static functions to help procedurally build meshes
  124426. */
  124427. export class TorusKnotBuilder {
  124428. /**
  124429. * Creates a torus knot mesh
  124430. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124431. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124432. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124433. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124437. * @param name defines the name of the mesh
  124438. * @param options defines the options used to create the mesh
  124439. * @param scene defines the hosting scene
  124440. * @returns the torus knot mesh
  124441. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124442. */
  124443. static CreateTorusKnot(name: string, options: {
  124444. radius?: number;
  124445. tube?: number;
  124446. radialSegments?: number;
  124447. tubularSegments?: number;
  124448. p?: number;
  124449. q?: number;
  124450. updatable?: boolean;
  124451. sideOrientation?: number;
  124452. frontUVs?: Vector4;
  124453. backUVs?: Vector4;
  124454. }, scene: any): Mesh;
  124455. }
  124456. }
  124457. declare module BABYLON {
  124458. /**
  124459. * Polygon
  124460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  124461. */
  124462. export class Polygon {
  124463. /**
  124464. * Creates a rectangle
  124465. * @param xmin bottom X coord
  124466. * @param ymin bottom Y coord
  124467. * @param xmax top X coord
  124468. * @param ymax top Y coord
  124469. * @returns points that make the resulting rectation
  124470. */
  124471. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  124472. /**
  124473. * Creates a circle
  124474. * @param radius radius of circle
  124475. * @param cx scale in x
  124476. * @param cy scale in y
  124477. * @param numberOfSides number of sides that make up the circle
  124478. * @returns points that make the resulting circle
  124479. */
  124480. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  124481. /**
  124482. * Creates a polygon from input string
  124483. * @param input Input polygon data
  124484. * @returns the parsed points
  124485. */
  124486. static Parse(input: string): Vector2[];
  124487. /**
  124488. * Starts building a polygon from x and y coordinates
  124489. * @param x x coordinate
  124490. * @param y y coordinate
  124491. * @returns the started path2
  124492. */
  124493. static StartingAt(x: number, y: number): Path2;
  124494. }
  124495. /**
  124496. * Builds a polygon
  124497. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  124498. */
  124499. export class PolygonMeshBuilder {
  124500. private _points;
  124501. private _outlinepoints;
  124502. private _holes;
  124503. private _name;
  124504. private _scene;
  124505. private _epoints;
  124506. private _eholes;
  124507. private _addToepoint;
  124508. /**
  124509. * Babylon reference to the earcut plugin.
  124510. */
  124511. bjsEarcut: any;
  124512. /**
  124513. * Creates a PolygonMeshBuilder
  124514. * @param name name of the builder
  124515. * @param contours Path of the polygon
  124516. * @param scene scene to add to when creating the mesh
  124517. * @param earcutInjection can be used to inject your own earcut reference
  124518. */
  124519. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  124520. /**
  124521. * Adds a whole within the polygon
  124522. * @param hole Array of points defining the hole
  124523. * @returns this
  124524. */
  124525. addHole(hole: Vector2[]): PolygonMeshBuilder;
  124526. /**
  124527. * Creates the polygon
  124528. * @param updatable If the mesh should be updatable
  124529. * @param depth The depth of the mesh created
  124530. * @returns the created mesh
  124531. */
  124532. build(updatable?: boolean, depth?: number): Mesh;
  124533. /**
  124534. * Creates the polygon
  124535. * @param depth The depth of the mesh created
  124536. * @returns the created VertexData
  124537. */
  124538. buildVertexData(depth?: number): VertexData;
  124539. /**
  124540. * Adds a side to the polygon
  124541. * @param positions points that make the polygon
  124542. * @param normals normals of the polygon
  124543. * @param uvs uvs of the polygon
  124544. * @param indices indices of the polygon
  124545. * @param bounds bounds of the polygon
  124546. * @param points points of the polygon
  124547. * @param depth depth of the polygon
  124548. * @param flip flip of the polygon
  124549. */
  124550. private addSide;
  124551. }
  124552. }
  124553. declare module BABYLON {
  124554. /**
  124555. * Class containing static functions to help procedurally build meshes
  124556. */
  124557. export class PolygonBuilder {
  124558. /**
  124559. * Creates a polygon mesh
  124560. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124561. * * 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
  124562. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124565. * * Remember you can only change the shape positions, not their number when updating a polygon
  124566. * @param name defines the name of the mesh
  124567. * @param options defines the options used to create the mesh
  124568. * @param scene defines the hosting scene
  124569. * @param earcutInjection can be used to inject your own earcut reference
  124570. * @returns the polygon mesh
  124571. */
  124572. static CreatePolygon(name: string, options: {
  124573. shape: Vector3[];
  124574. holes?: Vector3[][];
  124575. depth?: number;
  124576. faceUV?: Vector4[];
  124577. faceColors?: Color4[];
  124578. updatable?: boolean;
  124579. sideOrientation?: number;
  124580. frontUVs?: Vector4;
  124581. backUVs?: Vector4;
  124582. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124583. /**
  124584. * Creates an extruded polygon mesh, with depth in the Y direction.
  124585. * * 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)
  124586. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124587. * @param name defines the name of the mesh
  124588. * @param options defines the options used to create the mesh
  124589. * @param scene defines the hosting scene
  124590. * @param earcutInjection can be used to inject your own earcut reference
  124591. * @returns the polygon mesh
  124592. */
  124593. static ExtrudePolygon(name: string, options: {
  124594. shape: Vector3[];
  124595. holes?: Vector3[][];
  124596. depth?: number;
  124597. faceUV?: Vector4[];
  124598. faceColors?: Color4[];
  124599. updatable?: boolean;
  124600. sideOrientation?: number;
  124601. frontUVs?: Vector4;
  124602. backUVs?: Vector4;
  124603. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124604. }
  124605. }
  124606. declare module BABYLON {
  124607. /**
  124608. * Class containing static functions to help procedurally build meshes
  124609. */
  124610. export class LatheBuilder {
  124611. /**
  124612. * Creates lathe mesh.
  124613. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124614. * * 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
  124615. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124616. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124617. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124618. * * 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
  124619. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124620. * * 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
  124621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124625. * @param name defines the name of the mesh
  124626. * @param options defines the options used to create the mesh
  124627. * @param scene defines the hosting scene
  124628. * @returns the lathe mesh
  124629. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124630. */
  124631. static CreateLathe(name: string, options: {
  124632. shape: Vector3[];
  124633. radius?: number;
  124634. tessellation?: number;
  124635. clip?: number;
  124636. arc?: number;
  124637. closed?: boolean;
  124638. updatable?: boolean;
  124639. sideOrientation?: number;
  124640. frontUVs?: Vector4;
  124641. backUVs?: Vector4;
  124642. cap?: number;
  124643. invertUV?: boolean;
  124644. }, scene?: Nullable<Scene>): Mesh;
  124645. }
  124646. }
  124647. declare module BABYLON {
  124648. /**
  124649. * Class containing static functions to help procedurally build meshes
  124650. */
  124651. export class TiledPlaneBuilder {
  124652. /**
  124653. * Creates a tiled plane mesh
  124654. * * The parameter `pattern` will, depending on value, do nothing or
  124655. * * * flip (reflect about central vertical) alternate tiles across and up
  124656. * * * flip every tile on alternate rows
  124657. * * * rotate (180 degs) alternate tiles across and up
  124658. * * * rotate every tile on alternate rows
  124659. * * * flip and rotate alternate tiles across and up
  124660. * * * flip and rotate every tile on alternate rows
  124661. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  124662. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  124663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124665. * * 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)
  124666. * * 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)
  124667. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124668. * @param name defines the name of the mesh
  124669. * @param options defines the options used to create the mesh
  124670. * @param scene defines the hosting scene
  124671. * @returns the box mesh
  124672. */
  124673. static CreateTiledPlane(name: string, options: {
  124674. pattern?: number;
  124675. tileSize?: number;
  124676. tileWidth?: number;
  124677. tileHeight?: number;
  124678. size?: number;
  124679. width?: number;
  124680. height?: number;
  124681. alignHorizontal?: number;
  124682. alignVertical?: number;
  124683. sideOrientation?: number;
  124684. frontUVs?: Vector4;
  124685. backUVs?: Vector4;
  124686. updatable?: boolean;
  124687. }, scene?: Nullable<Scene>): Mesh;
  124688. }
  124689. }
  124690. declare module BABYLON {
  124691. /**
  124692. * Class containing static functions to help procedurally build meshes
  124693. */
  124694. export class TubeBuilder {
  124695. /**
  124696. * Creates a tube mesh.
  124697. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124698. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124699. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124700. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124701. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124702. * * 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)
  124703. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124704. * * 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
  124705. * * 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
  124706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124710. * @param name defines the name of the mesh
  124711. * @param options defines the options used to create the mesh
  124712. * @param scene defines the hosting scene
  124713. * @returns the tube mesh
  124714. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124715. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124716. */
  124717. static CreateTube(name: string, options: {
  124718. path: Vector3[];
  124719. radius?: number;
  124720. tessellation?: number;
  124721. radiusFunction?: {
  124722. (i: number, distance: number): number;
  124723. };
  124724. cap?: number;
  124725. arc?: number;
  124726. updatable?: boolean;
  124727. sideOrientation?: number;
  124728. frontUVs?: Vector4;
  124729. backUVs?: Vector4;
  124730. instance?: Mesh;
  124731. invertUV?: boolean;
  124732. }, scene?: Nullable<Scene>): Mesh;
  124733. }
  124734. }
  124735. declare module BABYLON {
  124736. /**
  124737. * Class containing static functions to help procedurally build meshes
  124738. */
  124739. export class IcoSphereBuilder {
  124740. /**
  124741. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124742. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124743. * * 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`)
  124744. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124745. * * 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
  124746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124749. * @param name defines the name of the mesh
  124750. * @param options defines the options used to create the mesh
  124751. * @param scene defines the hosting scene
  124752. * @returns the icosahedron mesh
  124753. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124754. */
  124755. static CreateIcoSphere(name: string, options: {
  124756. radius?: number;
  124757. radiusX?: number;
  124758. radiusY?: number;
  124759. radiusZ?: number;
  124760. flat?: boolean;
  124761. subdivisions?: number;
  124762. sideOrientation?: number;
  124763. frontUVs?: Vector4;
  124764. backUVs?: Vector4;
  124765. updatable?: boolean;
  124766. }, scene?: Nullable<Scene>): Mesh;
  124767. }
  124768. }
  124769. declare module BABYLON {
  124770. /**
  124771. * Class containing static functions to help procedurally build meshes
  124772. */
  124773. export class DecalBuilder {
  124774. /**
  124775. * Creates a decal mesh.
  124776. * 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
  124777. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124778. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124779. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124780. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124781. * @param name defines the name of the mesh
  124782. * @param sourceMesh defines the mesh where the decal must be applied
  124783. * @param options defines the options used to create the mesh
  124784. * @param scene defines the hosting scene
  124785. * @returns the decal mesh
  124786. * @see https://doc.babylonjs.com/how_to/decals
  124787. */
  124788. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124789. position?: Vector3;
  124790. normal?: Vector3;
  124791. size?: Vector3;
  124792. angle?: number;
  124793. }): Mesh;
  124794. }
  124795. }
  124796. declare module BABYLON {
  124797. /**
  124798. * Class containing static functions to help procedurally build meshes
  124799. */
  124800. export class MeshBuilder {
  124801. /**
  124802. * Creates a box mesh
  124803. * * The parameter `size` sets the size (float) of each box side (default 1)
  124804. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  124805. * * 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)
  124806. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124810. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124811. * @param name defines the name of the mesh
  124812. * @param options defines the options used to create the mesh
  124813. * @param scene defines the hosting scene
  124814. * @returns the box mesh
  124815. */
  124816. static CreateBox(name: string, options: {
  124817. size?: number;
  124818. width?: number;
  124819. height?: number;
  124820. depth?: number;
  124821. faceUV?: Vector4[];
  124822. faceColors?: Color4[];
  124823. sideOrientation?: number;
  124824. frontUVs?: Vector4;
  124825. backUVs?: Vector4;
  124826. updatable?: boolean;
  124827. }, scene?: Nullable<Scene>): Mesh;
  124828. /**
  124829. * Creates a tiled box mesh
  124830. * * faceTiles sets the pattern, tile size and number of tiles for a face
  124831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124832. * @param name defines the name of the mesh
  124833. * @param options defines the options used to create the mesh
  124834. * @param scene defines the hosting scene
  124835. * @returns the tiled box mesh
  124836. */
  124837. static CreateTiledBox(name: string, options: {
  124838. pattern?: number;
  124839. size?: number;
  124840. width?: number;
  124841. height?: number;
  124842. depth: number;
  124843. tileSize?: number;
  124844. tileWidth?: number;
  124845. tileHeight?: number;
  124846. faceUV?: Vector4[];
  124847. faceColors?: Color4[];
  124848. alignHorizontal?: number;
  124849. alignVertical?: number;
  124850. sideOrientation?: number;
  124851. updatable?: boolean;
  124852. }, scene?: Nullable<Scene>): Mesh;
  124853. /**
  124854. * Creates a sphere mesh
  124855. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124856. * * 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`)
  124857. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124858. * * 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
  124859. * * 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)
  124860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124863. * @param name defines the name of the mesh
  124864. * @param options defines the options used to create the mesh
  124865. * @param scene defines the hosting scene
  124866. * @returns the sphere mesh
  124867. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124868. */
  124869. static CreateSphere(name: string, options: {
  124870. segments?: number;
  124871. diameter?: number;
  124872. diameterX?: number;
  124873. diameterY?: number;
  124874. diameterZ?: number;
  124875. arc?: number;
  124876. slice?: number;
  124877. sideOrientation?: number;
  124878. frontUVs?: Vector4;
  124879. backUVs?: Vector4;
  124880. updatable?: boolean;
  124881. }, scene?: Nullable<Scene>): Mesh;
  124882. /**
  124883. * Creates a plane polygonal mesh. By default, this is a disc
  124884. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  124885. * * 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
  124886. * * 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
  124887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124890. * @param name defines the name of the mesh
  124891. * @param options defines the options used to create the mesh
  124892. * @param scene defines the hosting scene
  124893. * @returns the plane polygonal mesh
  124894. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  124895. */
  124896. static CreateDisc(name: string, options: {
  124897. radius?: number;
  124898. tessellation?: number;
  124899. arc?: number;
  124900. updatable?: boolean;
  124901. sideOrientation?: number;
  124902. frontUVs?: Vector4;
  124903. backUVs?: Vector4;
  124904. }, scene?: Nullable<Scene>): Mesh;
  124905. /**
  124906. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124907. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124908. * * 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`)
  124909. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124910. * * 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
  124911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124914. * @param name defines the name of the mesh
  124915. * @param options defines the options used to create the mesh
  124916. * @param scene defines the hosting scene
  124917. * @returns the icosahedron mesh
  124918. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124919. */
  124920. static CreateIcoSphere(name: string, options: {
  124921. radius?: number;
  124922. radiusX?: number;
  124923. radiusY?: number;
  124924. radiusZ?: number;
  124925. flat?: boolean;
  124926. subdivisions?: number;
  124927. sideOrientation?: number;
  124928. frontUVs?: Vector4;
  124929. backUVs?: Vector4;
  124930. updatable?: boolean;
  124931. }, scene?: Nullable<Scene>): Mesh;
  124932. /**
  124933. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124934. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124935. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124936. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124937. * * 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
  124938. * * 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
  124939. * * 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
  124940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124942. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124943. * * 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
  124944. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124945. * * 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
  124946. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124948. * @param name defines the name of the mesh
  124949. * @param options defines the options used to create the mesh
  124950. * @param scene defines the hosting scene
  124951. * @returns the ribbon mesh
  124952. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124953. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124954. */
  124955. static CreateRibbon(name: string, options: {
  124956. pathArray: Vector3[][];
  124957. closeArray?: boolean;
  124958. closePath?: boolean;
  124959. offset?: number;
  124960. updatable?: boolean;
  124961. sideOrientation?: number;
  124962. frontUVs?: Vector4;
  124963. backUVs?: Vector4;
  124964. instance?: Mesh;
  124965. invertUV?: boolean;
  124966. uvs?: Vector2[];
  124967. colors?: Color4[];
  124968. }, scene?: Nullable<Scene>): Mesh;
  124969. /**
  124970. * Creates a cylinder or a cone mesh
  124971. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124972. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124973. * * 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.
  124974. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124975. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124976. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124977. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124978. * * 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).
  124979. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124980. * * 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).
  124981. * * 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
  124982. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124983. * * 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
  124984. * * 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.
  124985. * * If `enclose` is false, a ring surface is one element.
  124986. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124987. * * 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
  124988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124991. * @param name defines the name of the mesh
  124992. * @param options defines the options used to create the mesh
  124993. * @param scene defines the hosting scene
  124994. * @returns the cylinder mesh
  124995. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124996. */
  124997. static CreateCylinder(name: string, options: {
  124998. height?: number;
  124999. diameterTop?: number;
  125000. diameterBottom?: number;
  125001. diameter?: number;
  125002. tessellation?: number;
  125003. subdivisions?: number;
  125004. arc?: number;
  125005. faceColors?: Color4[];
  125006. faceUV?: Vector4[];
  125007. updatable?: boolean;
  125008. hasRings?: boolean;
  125009. enclose?: boolean;
  125010. cap?: number;
  125011. sideOrientation?: number;
  125012. frontUVs?: Vector4;
  125013. backUVs?: Vector4;
  125014. }, scene?: Nullable<Scene>): Mesh;
  125015. /**
  125016. * Creates a torus mesh
  125017. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125018. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125019. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125023. * @param name defines the name of the mesh
  125024. * @param options defines the options used to create the mesh
  125025. * @param scene defines the hosting scene
  125026. * @returns the torus mesh
  125027. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125028. */
  125029. static CreateTorus(name: string, options: {
  125030. diameter?: number;
  125031. thickness?: number;
  125032. tessellation?: number;
  125033. updatable?: boolean;
  125034. sideOrientation?: number;
  125035. frontUVs?: Vector4;
  125036. backUVs?: Vector4;
  125037. }, scene?: Nullable<Scene>): Mesh;
  125038. /**
  125039. * Creates a torus knot mesh
  125040. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125041. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125042. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125043. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125047. * @param name defines the name of the mesh
  125048. * @param options defines the options used to create the mesh
  125049. * @param scene defines the hosting scene
  125050. * @returns the torus knot mesh
  125051. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125052. */
  125053. static CreateTorusKnot(name: string, options: {
  125054. radius?: number;
  125055. tube?: number;
  125056. radialSegments?: number;
  125057. tubularSegments?: number;
  125058. p?: number;
  125059. q?: number;
  125060. updatable?: boolean;
  125061. sideOrientation?: number;
  125062. frontUVs?: Vector4;
  125063. backUVs?: Vector4;
  125064. }, scene?: Nullable<Scene>): Mesh;
  125065. /**
  125066. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125067. * * 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
  125068. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125069. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125070. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125071. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125072. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125073. * * 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
  125074. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125077. * @param name defines the name of the new line system
  125078. * @param options defines the options used to create the line system
  125079. * @param scene defines the hosting scene
  125080. * @returns a new line system mesh
  125081. */
  125082. static CreateLineSystem(name: string, options: {
  125083. lines: Vector3[][];
  125084. updatable?: boolean;
  125085. instance?: Nullable<LinesMesh>;
  125086. colors?: Nullable<Color4[][]>;
  125087. useVertexAlpha?: boolean;
  125088. }, scene: Nullable<Scene>): LinesMesh;
  125089. /**
  125090. * Creates a line mesh
  125091. * 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
  125092. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125093. * * The parameter `points` is an array successive Vector3
  125094. * * 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
  125095. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125096. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125097. * * When updating an instance, remember that only point positions can change, not the number of points
  125098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125100. * @param name defines the name of the new line system
  125101. * @param options defines the options used to create the line system
  125102. * @param scene defines the hosting scene
  125103. * @returns a new line mesh
  125104. */
  125105. static CreateLines(name: string, options: {
  125106. points: Vector3[];
  125107. updatable?: boolean;
  125108. instance?: Nullable<LinesMesh>;
  125109. colors?: Color4[];
  125110. useVertexAlpha?: boolean;
  125111. }, scene?: Nullable<Scene>): LinesMesh;
  125112. /**
  125113. * Creates a dashed line mesh
  125114. * * 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
  125115. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125116. * * The parameter `points` is an array successive Vector3
  125117. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125118. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125119. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125120. * * 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
  125121. * * When updating an instance, remember that only point positions can change, not the number of points
  125122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125123. * @param name defines the name of the mesh
  125124. * @param options defines the options used to create the mesh
  125125. * @param scene defines the hosting scene
  125126. * @returns the dashed line mesh
  125127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125128. */
  125129. static CreateDashedLines(name: string, options: {
  125130. points: Vector3[];
  125131. dashSize?: number;
  125132. gapSize?: number;
  125133. dashNb?: number;
  125134. updatable?: boolean;
  125135. instance?: LinesMesh;
  125136. }, scene?: Nullable<Scene>): LinesMesh;
  125137. /**
  125138. * 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.
  125139. * * 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.
  125140. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125141. * * 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.
  125142. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125143. * * 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
  125144. * * 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
  125145. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125150. * @param name defines the name of the mesh
  125151. * @param options defines the options used to create the mesh
  125152. * @param scene defines the hosting scene
  125153. * @returns the extruded shape mesh
  125154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125156. */
  125157. static ExtrudeShape(name: string, options: {
  125158. shape: Vector3[];
  125159. path: Vector3[];
  125160. scale?: number;
  125161. rotation?: number;
  125162. cap?: number;
  125163. updatable?: boolean;
  125164. sideOrientation?: number;
  125165. frontUVs?: Vector4;
  125166. backUVs?: Vector4;
  125167. instance?: Mesh;
  125168. invertUV?: boolean;
  125169. }, scene?: Nullable<Scene>): Mesh;
  125170. /**
  125171. * Creates an custom extruded shape mesh.
  125172. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125173. * * 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.
  125174. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125175. * * 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
  125176. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125177. * * 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
  125178. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125179. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125180. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125181. * * 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
  125182. * * 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
  125183. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125188. * @param name defines the name of the mesh
  125189. * @param options defines the options used to create the mesh
  125190. * @param scene defines the hosting scene
  125191. * @returns the custom extruded shape mesh
  125192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125193. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125195. */
  125196. static ExtrudeShapeCustom(name: string, options: {
  125197. shape: Vector3[];
  125198. path: Vector3[];
  125199. scaleFunction?: any;
  125200. rotationFunction?: any;
  125201. ribbonCloseArray?: boolean;
  125202. ribbonClosePath?: boolean;
  125203. cap?: number;
  125204. updatable?: boolean;
  125205. sideOrientation?: number;
  125206. frontUVs?: Vector4;
  125207. backUVs?: Vector4;
  125208. instance?: Mesh;
  125209. invertUV?: boolean;
  125210. }, scene?: Nullable<Scene>): Mesh;
  125211. /**
  125212. * Creates lathe mesh.
  125213. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125214. * * 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
  125215. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125216. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125217. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125218. * * 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
  125219. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125220. * * 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
  125221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125223. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125225. * @param name defines the name of the mesh
  125226. * @param options defines the options used to create the mesh
  125227. * @param scene defines the hosting scene
  125228. * @returns the lathe mesh
  125229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125230. */
  125231. static CreateLathe(name: string, options: {
  125232. shape: Vector3[];
  125233. radius?: number;
  125234. tessellation?: number;
  125235. clip?: number;
  125236. arc?: number;
  125237. closed?: boolean;
  125238. updatable?: boolean;
  125239. sideOrientation?: number;
  125240. frontUVs?: Vector4;
  125241. backUVs?: Vector4;
  125242. cap?: number;
  125243. invertUV?: boolean;
  125244. }, scene?: Nullable<Scene>): Mesh;
  125245. /**
  125246. * Creates a tiled plane mesh
  125247. * * You can set a limited pattern arrangement with the tiles
  125248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125251. * @param name defines the name of the mesh
  125252. * @param options defines the options used to create the mesh
  125253. * @param scene defines the hosting scene
  125254. * @returns the plane mesh
  125255. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125256. */
  125257. static CreateTiledPlane(name: string, options: {
  125258. pattern?: number;
  125259. tileSize?: number;
  125260. tileWidth?: number;
  125261. tileHeight?: number;
  125262. size?: number;
  125263. width?: number;
  125264. height?: number;
  125265. alignHorizontal?: number;
  125266. alignVertical?: number;
  125267. sideOrientation?: number;
  125268. frontUVs?: Vector4;
  125269. backUVs?: Vector4;
  125270. updatable?: boolean;
  125271. }, scene?: Nullable<Scene>): Mesh;
  125272. /**
  125273. * Creates a plane mesh
  125274. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125275. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125276. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125280. * @param name defines the name of the mesh
  125281. * @param options defines the options used to create the mesh
  125282. * @param scene defines the hosting scene
  125283. * @returns the plane mesh
  125284. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125285. */
  125286. static CreatePlane(name: string, options: {
  125287. size?: number;
  125288. width?: number;
  125289. height?: number;
  125290. sideOrientation?: number;
  125291. frontUVs?: Vector4;
  125292. backUVs?: Vector4;
  125293. updatable?: boolean;
  125294. sourcePlane?: Plane;
  125295. }, scene?: Nullable<Scene>): Mesh;
  125296. /**
  125297. * Creates a ground mesh
  125298. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125299. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125301. * @param name defines the name of the mesh
  125302. * @param options defines the options used to create the mesh
  125303. * @param scene defines the hosting scene
  125304. * @returns the ground mesh
  125305. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125306. */
  125307. static CreateGround(name: string, options: {
  125308. width?: number;
  125309. height?: number;
  125310. subdivisions?: number;
  125311. subdivisionsX?: number;
  125312. subdivisionsY?: number;
  125313. updatable?: boolean;
  125314. }, scene?: Nullable<Scene>): Mesh;
  125315. /**
  125316. * Creates a tiled ground mesh
  125317. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125318. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125319. * * 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
  125320. * * 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
  125321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125322. * @param name defines the name of the mesh
  125323. * @param options defines the options used to create the mesh
  125324. * @param scene defines the hosting scene
  125325. * @returns the tiled ground mesh
  125326. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125327. */
  125328. static CreateTiledGround(name: string, options: {
  125329. xmin: number;
  125330. zmin: number;
  125331. xmax: number;
  125332. zmax: number;
  125333. subdivisions?: {
  125334. w: number;
  125335. h: number;
  125336. };
  125337. precision?: {
  125338. w: number;
  125339. h: number;
  125340. };
  125341. updatable?: boolean;
  125342. }, scene?: Nullable<Scene>): Mesh;
  125343. /**
  125344. * Creates a ground mesh from a height map
  125345. * * The parameter `url` sets the URL of the height map image resource.
  125346. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125347. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125348. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125349. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125350. * * 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.
  125351. * * 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).
  125352. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125354. * @param name defines the name of the mesh
  125355. * @param url defines the url to the height map
  125356. * @param options defines the options used to create the mesh
  125357. * @param scene defines the hosting scene
  125358. * @returns the ground mesh
  125359. * @see https://doc.babylonjs.com/babylon101/height_map
  125360. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125361. */
  125362. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125363. width?: number;
  125364. height?: number;
  125365. subdivisions?: number;
  125366. minHeight?: number;
  125367. maxHeight?: number;
  125368. colorFilter?: Color3;
  125369. alphaFilter?: number;
  125370. updatable?: boolean;
  125371. onReady?: (mesh: GroundMesh) => void;
  125372. }, scene?: Nullable<Scene>): GroundMesh;
  125373. /**
  125374. * Creates a polygon mesh
  125375. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125376. * * 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
  125377. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125380. * * Remember you can only change the shape positions, not their number when updating a polygon
  125381. * @param name defines the name of the mesh
  125382. * @param options defines the options used to create the mesh
  125383. * @param scene defines the hosting scene
  125384. * @param earcutInjection can be used to inject your own earcut reference
  125385. * @returns the polygon mesh
  125386. */
  125387. static CreatePolygon(name: string, options: {
  125388. shape: Vector3[];
  125389. holes?: Vector3[][];
  125390. depth?: number;
  125391. faceUV?: Vector4[];
  125392. faceColors?: Color4[];
  125393. updatable?: boolean;
  125394. sideOrientation?: number;
  125395. frontUVs?: Vector4;
  125396. backUVs?: Vector4;
  125397. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125398. /**
  125399. * Creates an extruded polygon mesh, with depth in the Y direction.
  125400. * * 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)
  125401. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125402. * @param name defines the name of the mesh
  125403. * @param options defines the options used to create the mesh
  125404. * @param scene defines the hosting scene
  125405. * @param earcutInjection can be used to inject your own earcut reference
  125406. * @returns the polygon mesh
  125407. */
  125408. static ExtrudePolygon(name: string, options: {
  125409. shape: Vector3[];
  125410. holes?: Vector3[][];
  125411. depth?: number;
  125412. faceUV?: Vector4[];
  125413. faceColors?: Color4[];
  125414. updatable?: boolean;
  125415. sideOrientation?: number;
  125416. frontUVs?: Vector4;
  125417. backUVs?: Vector4;
  125418. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125419. /**
  125420. * Creates a tube mesh.
  125421. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125422. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125423. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125424. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125425. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125426. * * 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)
  125427. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125428. * * 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
  125429. * * 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
  125430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125432. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125434. * @param name defines the name of the mesh
  125435. * @param options defines the options used to create the mesh
  125436. * @param scene defines the hosting scene
  125437. * @returns the tube mesh
  125438. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125439. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125440. */
  125441. static CreateTube(name: string, options: {
  125442. path: Vector3[];
  125443. radius?: number;
  125444. tessellation?: number;
  125445. radiusFunction?: {
  125446. (i: number, distance: number): number;
  125447. };
  125448. cap?: number;
  125449. arc?: number;
  125450. updatable?: boolean;
  125451. sideOrientation?: number;
  125452. frontUVs?: Vector4;
  125453. backUVs?: Vector4;
  125454. instance?: Mesh;
  125455. invertUV?: boolean;
  125456. }, scene?: Nullable<Scene>): Mesh;
  125457. /**
  125458. * Creates a polyhedron mesh
  125459. * * 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
  125460. * * The parameter `size` (positive float, default 1) sets the polygon size
  125461. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125462. * * 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`
  125463. * * 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
  125464. * * 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)`)
  125465. * * 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
  125466. * * 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
  125467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125470. * @param name defines the name of the mesh
  125471. * @param options defines the options used to create the mesh
  125472. * @param scene defines the hosting scene
  125473. * @returns the polyhedron mesh
  125474. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125475. */
  125476. static CreatePolyhedron(name: string, options: {
  125477. type?: number;
  125478. size?: number;
  125479. sizeX?: number;
  125480. sizeY?: number;
  125481. sizeZ?: number;
  125482. custom?: any;
  125483. faceUV?: Vector4[];
  125484. faceColors?: Color4[];
  125485. flat?: boolean;
  125486. updatable?: boolean;
  125487. sideOrientation?: number;
  125488. frontUVs?: Vector4;
  125489. backUVs?: Vector4;
  125490. }, scene?: Nullable<Scene>): Mesh;
  125491. /**
  125492. * Creates a decal mesh.
  125493. * 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
  125494. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125495. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125496. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125497. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125498. * @param name defines the name of the mesh
  125499. * @param sourceMesh defines the mesh where the decal must be applied
  125500. * @param options defines the options used to create the mesh
  125501. * @param scene defines the hosting scene
  125502. * @returns the decal mesh
  125503. * @see https://doc.babylonjs.com/how_to/decals
  125504. */
  125505. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125506. position?: Vector3;
  125507. normal?: Vector3;
  125508. size?: Vector3;
  125509. angle?: number;
  125510. }): Mesh;
  125511. }
  125512. }
  125513. declare module BABYLON {
  125514. /**
  125515. * A simplifier interface for future simplification implementations
  125516. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125517. */
  125518. export interface ISimplifier {
  125519. /**
  125520. * Simplification of a given mesh according to the given settings.
  125521. * Since this requires computation, it is assumed that the function runs async.
  125522. * @param settings The settings of the simplification, including quality and distance
  125523. * @param successCallback A callback that will be called after the mesh was simplified.
  125524. * @param errorCallback in case of an error, this callback will be called. optional.
  125525. */
  125526. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  125527. }
  125528. /**
  125529. * Expected simplification settings.
  125530. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  125531. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125532. */
  125533. export interface ISimplificationSettings {
  125534. /**
  125535. * Gets or sets the expected quality
  125536. */
  125537. quality: number;
  125538. /**
  125539. * Gets or sets the distance when this optimized version should be used
  125540. */
  125541. distance: number;
  125542. /**
  125543. * Gets an already optimized mesh
  125544. */
  125545. optimizeMesh?: boolean;
  125546. }
  125547. /**
  125548. * Class used to specify simplification options
  125549. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125550. */
  125551. export class SimplificationSettings implements ISimplificationSettings {
  125552. /** expected quality */
  125553. quality: number;
  125554. /** distance when this optimized version should be used */
  125555. distance: number;
  125556. /** already optimized mesh */
  125557. optimizeMesh?: boolean | undefined;
  125558. /**
  125559. * Creates a SimplificationSettings
  125560. * @param quality expected quality
  125561. * @param distance distance when this optimized version should be used
  125562. * @param optimizeMesh already optimized mesh
  125563. */
  125564. constructor(
  125565. /** expected quality */
  125566. quality: number,
  125567. /** distance when this optimized version should be used */
  125568. distance: number,
  125569. /** already optimized mesh */
  125570. optimizeMesh?: boolean | undefined);
  125571. }
  125572. /**
  125573. * Interface used to define a simplification task
  125574. */
  125575. export interface ISimplificationTask {
  125576. /**
  125577. * Array of settings
  125578. */
  125579. settings: Array<ISimplificationSettings>;
  125580. /**
  125581. * Simplification type
  125582. */
  125583. simplificationType: SimplificationType;
  125584. /**
  125585. * Mesh to simplify
  125586. */
  125587. mesh: Mesh;
  125588. /**
  125589. * Callback called on success
  125590. */
  125591. successCallback?: () => void;
  125592. /**
  125593. * Defines if parallel processing can be used
  125594. */
  125595. parallelProcessing: boolean;
  125596. }
  125597. /**
  125598. * Queue used to order the simplification tasks
  125599. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125600. */
  125601. export class SimplificationQueue {
  125602. private _simplificationArray;
  125603. /**
  125604. * Gets a boolean indicating that the process is still running
  125605. */
  125606. running: boolean;
  125607. /**
  125608. * Creates a new queue
  125609. */
  125610. constructor();
  125611. /**
  125612. * Adds a new simplification task
  125613. * @param task defines a task to add
  125614. */
  125615. addTask(task: ISimplificationTask): void;
  125616. /**
  125617. * Execute next task
  125618. */
  125619. executeNext(): void;
  125620. /**
  125621. * Execute a simplification task
  125622. * @param task defines the task to run
  125623. */
  125624. runSimplification(task: ISimplificationTask): void;
  125625. private getSimplifier;
  125626. }
  125627. /**
  125628. * The implemented types of simplification
  125629. * At the moment only Quadratic Error Decimation is implemented
  125630. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125631. */
  125632. export enum SimplificationType {
  125633. /** Quadratic error decimation */
  125634. QUADRATIC = 0
  125635. }
  125636. }
  125637. declare module BABYLON {
  125638. interface Scene {
  125639. /** @hidden (Backing field) */
  125640. _simplificationQueue: SimplificationQueue;
  125641. /**
  125642. * Gets or sets the simplification queue attached to the scene
  125643. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125644. */
  125645. simplificationQueue: SimplificationQueue;
  125646. }
  125647. interface Mesh {
  125648. /**
  125649. * Simplify the mesh according to the given array of settings.
  125650. * Function will return immediately and will simplify async
  125651. * @param settings a collection of simplification settings
  125652. * @param parallelProcessing should all levels calculate parallel or one after the other
  125653. * @param simplificationType the type of simplification to run
  125654. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  125655. * @returns the current mesh
  125656. */
  125657. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  125658. }
  125659. /**
  125660. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  125661. * created in a scene
  125662. */
  125663. export class SimplicationQueueSceneComponent implements ISceneComponent {
  125664. /**
  125665. * The component name helpfull to identify the component in the list of scene components.
  125666. */
  125667. readonly name: string;
  125668. /**
  125669. * The scene the component belongs to.
  125670. */
  125671. scene: Scene;
  125672. /**
  125673. * Creates a new instance of the component for the given scene
  125674. * @param scene Defines the scene to register the component in
  125675. */
  125676. constructor(scene: Scene);
  125677. /**
  125678. * Registers the component in a given scene
  125679. */
  125680. register(): void;
  125681. /**
  125682. * Rebuilds the elements related to this component in case of
  125683. * context lost for instance.
  125684. */
  125685. rebuild(): void;
  125686. /**
  125687. * Disposes the component and the associated ressources
  125688. */
  125689. dispose(): void;
  125690. private _beforeCameraUpdate;
  125691. }
  125692. }
  125693. declare module BABYLON {
  125694. /**
  125695. * Navigation plugin interface to add navigation constrained by a navigation mesh
  125696. */
  125697. export interface INavigationEnginePlugin {
  125698. /**
  125699. * plugin name
  125700. */
  125701. name: string;
  125702. /**
  125703. * Creates a navigation mesh
  125704. * @param meshes array of all the geometry used to compute the navigatio mesh
  125705. * @param parameters bunch of parameters used to filter geometry
  125706. */
  125707. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125708. /**
  125709. * Create a navigation mesh debug mesh
  125710. * @param scene is where the mesh will be added
  125711. * @returns debug display mesh
  125712. */
  125713. createDebugNavMesh(scene: Scene): Mesh;
  125714. /**
  125715. * Get a navigation mesh constrained position, closest to the parameter position
  125716. * @param position world position
  125717. * @returns the closest point to position constrained by the navigation mesh
  125718. */
  125719. getClosestPoint(position: Vector3): Vector3;
  125720. /**
  125721. * Get a navigation mesh constrained position, within a particular radius
  125722. * @param position world position
  125723. * @param maxRadius the maximum distance to the constrained world position
  125724. * @returns the closest point to position constrained by the navigation mesh
  125725. */
  125726. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125727. /**
  125728. * Compute the final position from a segment made of destination-position
  125729. * @param position world position
  125730. * @param destination world position
  125731. * @returns the resulting point along the navmesh
  125732. */
  125733. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125734. /**
  125735. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125736. * @param start world position
  125737. * @param end world position
  125738. * @returns array containing world position composing the path
  125739. */
  125740. computePath(start: Vector3, end: Vector3): Vector3[];
  125741. /**
  125742. * If this plugin is supported
  125743. * @returns true if plugin is supported
  125744. */
  125745. isSupported(): boolean;
  125746. /**
  125747. * Create a new Crowd so you can add agents
  125748. * @param maxAgents the maximum agent count in the crowd
  125749. * @param maxAgentRadius the maximum radius an agent can have
  125750. * @param scene to attach the crowd to
  125751. * @returns the crowd you can add agents to
  125752. */
  125753. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125754. /**
  125755. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125756. * The queries will try to find a solution within those bounds
  125757. * default is (1,1,1)
  125758. * @param extent x,y,z value that define the extent around the queries point of reference
  125759. */
  125760. setDefaultQueryExtent(extent: Vector3): void;
  125761. /**
  125762. * Get the Bounding box extent specified by setDefaultQueryExtent
  125763. * @returns the box extent values
  125764. */
  125765. getDefaultQueryExtent(): Vector3;
  125766. /**
  125767. * Release all resources
  125768. */
  125769. dispose(): void;
  125770. }
  125771. /**
  125772. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  125773. */
  125774. export interface ICrowd {
  125775. /**
  125776. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125777. * You can attach anything to that node. The node position is updated in the scene update tick.
  125778. * @param pos world position that will be constrained by the navigation mesh
  125779. * @param parameters agent parameters
  125780. * @param transform hooked to the agent that will be update by the scene
  125781. * @returns agent index
  125782. */
  125783. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125784. /**
  125785. * Returns the agent position in world space
  125786. * @param index agent index returned by addAgent
  125787. * @returns world space position
  125788. */
  125789. getAgentPosition(index: number): Vector3;
  125790. /**
  125791. * Gets the agent velocity in world space
  125792. * @param index agent index returned by addAgent
  125793. * @returns world space velocity
  125794. */
  125795. getAgentVelocity(index: number): Vector3;
  125796. /**
  125797. * remove a particular agent previously created
  125798. * @param index agent index returned by addAgent
  125799. */
  125800. removeAgent(index: number): void;
  125801. /**
  125802. * get the list of all agents attached to this crowd
  125803. * @returns list of agent indices
  125804. */
  125805. getAgents(): number[];
  125806. /**
  125807. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125808. * @param deltaTime in seconds
  125809. */
  125810. update(deltaTime: number): void;
  125811. /**
  125812. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125813. * @param index agent index returned by addAgent
  125814. * @param destination targeted world position
  125815. */
  125816. agentGoto(index: number, destination: Vector3): void;
  125817. /**
  125818. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125819. * The queries will try to find a solution within those bounds
  125820. * default is (1,1,1)
  125821. * @param extent x,y,z value that define the extent around the queries point of reference
  125822. */
  125823. setDefaultQueryExtent(extent: Vector3): void;
  125824. /**
  125825. * Get the Bounding box extent specified by setDefaultQueryExtent
  125826. * @returns the box extent values
  125827. */
  125828. getDefaultQueryExtent(): Vector3;
  125829. /**
  125830. * Release all resources
  125831. */
  125832. dispose(): void;
  125833. }
  125834. /**
  125835. * Configures an agent
  125836. */
  125837. export interface IAgentParameters {
  125838. /**
  125839. * Agent radius. [Limit: >= 0]
  125840. */
  125841. radius: number;
  125842. /**
  125843. * Agent height. [Limit: > 0]
  125844. */
  125845. height: number;
  125846. /**
  125847. * Maximum allowed acceleration. [Limit: >= 0]
  125848. */
  125849. maxAcceleration: number;
  125850. /**
  125851. * Maximum allowed speed. [Limit: >= 0]
  125852. */
  125853. maxSpeed: number;
  125854. /**
  125855. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  125856. */
  125857. collisionQueryRange: number;
  125858. /**
  125859. * The path visibility optimization range. [Limit: > 0]
  125860. */
  125861. pathOptimizationRange: number;
  125862. /**
  125863. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  125864. */
  125865. separationWeight: number;
  125866. }
  125867. /**
  125868. * Configures the navigation mesh creation
  125869. */
  125870. export interface INavMeshParameters {
  125871. /**
  125872. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  125873. */
  125874. cs: number;
  125875. /**
  125876. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  125877. */
  125878. ch: number;
  125879. /**
  125880. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  125881. */
  125882. walkableSlopeAngle: number;
  125883. /**
  125884. * Minimum floor to 'ceiling' height that will still allow the floor area to
  125885. * be considered walkable. [Limit: >= 3] [Units: vx]
  125886. */
  125887. walkableHeight: number;
  125888. /**
  125889. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  125890. */
  125891. walkableClimb: number;
  125892. /**
  125893. * The distance to erode/shrink the walkable area of the heightfield away from
  125894. * obstructions. [Limit: >=0] [Units: vx]
  125895. */
  125896. walkableRadius: number;
  125897. /**
  125898. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  125899. */
  125900. maxEdgeLen: number;
  125901. /**
  125902. * The maximum distance a simplfied contour's border edges should deviate
  125903. * the original raw contour. [Limit: >=0] [Units: vx]
  125904. */
  125905. maxSimplificationError: number;
  125906. /**
  125907. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  125908. */
  125909. minRegionArea: number;
  125910. /**
  125911. * Any regions with a span count smaller than this value will, if possible,
  125912. * be merged with larger regions. [Limit: >=0] [Units: vx]
  125913. */
  125914. mergeRegionArea: number;
  125915. /**
  125916. * The maximum number of vertices allowed for polygons generated during the
  125917. * contour to polygon conversion process. [Limit: >= 3]
  125918. */
  125919. maxVertsPerPoly: number;
  125920. /**
  125921. * Sets the sampling distance to use when generating the detail mesh.
  125922. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  125923. */
  125924. detailSampleDist: number;
  125925. /**
  125926. * The maximum distance the detail mesh surface should deviate from heightfield
  125927. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  125928. */
  125929. detailSampleMaxError: number;
  125930. }
  125931. }
  125932. declare module BABYLON {
  125933. /**
  125934. * RecastJS navigation plugin
  125935. */
  125936. export class RecastJSPlugin implements INavigationEnginePlugin {
  125937. /**
  125938. * Reference to the Recast library
  125939. */
  125940. bjsRECAST: any;
  125941. /**
  125942. * plugin name
  125943. */
  125944. name: string;
  125945. /**
  125946. * the first navmesh created. We might extend this to support multiple navmeshes
  125947. */
  125948. navMesh: any;
  125949. /**
  125950. * Initializes the recastJS plugin
  125951. * @param recastInjection can be used to inject your own recast reference
  125952. */
  125953. constructor(recastInjection?: any);
  125954. /**
  125955. * Creates a navigation mesh
  125956. * @param meshes array of all the geometry used to compute the navigatio mesh
  125957. * @param parameters bunch of parameters used to filter geometry
  125958. */
  125959. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125960. /**
  125961. * Create a navigation mesh debug mesh
  125962. * @param scene is where the mesh will be added
  125963. * @returns debug display mesh
  125964. */
  125965. createDebugNavMesh(scene: Scene): Mesh;
  125966. /**
  125967. * Get a navigation mesh constrained position, closest to the parameter position
  125968. * @param position world position
  125969. * @returns the closest point to position constrained by the navigation mesh
  125970. */
  125971. getClosestPoint(position: Vector3): Vector3;
  125972. /**
  125973. * Get a navigation mesh constrained position, within a particular radius
  125974. * @param position world position
  125975. * @param maxRadius the maximum distance to the constrained world position
  125976. * @returns the closest point to position constrained by the navigation mesh
  125977. */
  125978. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125979. /**
  125980. * Compute the final position from a segment made of destination-position
  125981. * @param position world position
  125982. * @param destination world position
  125983. * @returns the resulting point along the navmesh
  125984. */
  125985. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125986. /**
  125987. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125988. * @param start world position
  125989. * @param end world position
  125990. * @returns array containing world position composing the path
  125991. */
  125992. computePath(start: Vector3, end: Vector3): Vector3[];
  125993. /**
  125994. * Create a new Crowd so you can add agents
  125995. * @param maxAgents the maximum agent count in the crowd
  125996. * @param maxAgentRadius the maximum radius an agent can have
  125997. * @param scene to attach the crowd to
  125998. * @returns the crowd you can add agents to
  125999. */
  126000. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126001. /**
  126002. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126003. * The queries will try to find a solution within those bounds
  126004. * default is (1,1,1)
  126005. * @param extent x,y,z value that define the extent around the queries point of reference
  126006. */
  126007. setDefaultQueryExtent(extent: Vector3): void;
  126008. /**
  126009. * Get the Bounding box extent specified by setDefaultQueryExtent
  126010. * @returns the box extent values
  126011. */
  126012. getDefaultQueryExtent(): Vector3;
  126013. /**
  126014. * Disposes
  126015. */
  126016. dispose(): void;
  126017. /**
  126018. * If this plugin is supported
  126019. * @returns true if plugin is supported
  126020. */
  126021. isSupported(): boolean;
  126022. }
  126023. /**
  126024. * Recast detour crowd implementation
  126025. */
  126026. export class RecastJSCrowd implements ICrowd {
  126027. /**
  126028. * Recast/detour plugin
  126029. */
  126030. bjsRECASTPlugin: RecastJSPlugin;
  126031. /**
  126032. * Link to the detour crowd
  126033. */
  126034. recastCrowd: any;
  126035. /**
  126036. * One transform per agent
  126037. */
  126038. transforms: TransformNode[];
  126039. /**
  126040. * All agents created
  126041. */
  126042. agents: number[];
  126043. /**
  126044. * Link to the scene is kept to unregister the crowd from the scene
  126045. */
  126046. private _scene;
  126047. /**
  126048. * Observer for crowd updates
  126049. */
  126050. private _onBeforeAnimationsObserver;
  126051. /**
  126052. * Constructor
  126053. * @param plugin recastJS plugin
  126054. * @param maxAgents the maximum agent count in the crowd
  126055. * @param maxAgentRadius the maximum radius an agent can have
  126056. * @param scene to attach the crowd to
  126057. * @returns the crowd you can add agents to
  126058. */
  126059. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126060. /**
  126061. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126062. * You can attach anything to that node. The node position is updated in the scene update tick.
  126063. * @param pos world position that will be constrained by the navigation mesh
  126064. * @param parameters agent parameters
  126065. * @param transform hooked to the agent that will be update by the scene
  126066. * @returns agent index
  126067. */
  126068. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126069. /**
  126070. * Returns the agent position in world space
  126071. * @param index agent index returned by addAgent
  126072. * @returns world space position
  126073. */
  126074. getAgentPosition(index: number): Vector3;
  126075. /**
  126076. * Returns the agent velocity in world space
  126077. * @param index agent index returned by addAgent
  126078. * @returns world space velocity
  126079. */
  126080. getAgentVelocity(index: number): Vector3;
  126081. /**
  126082. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126083. * @param index agent index returned by addAgent
  126084. * @param destination targeted world position
  126085. */
  126086. agentGoto(index: number, destination: Vector3): void;
  126087. /**
  126088. * remove a particular agent previously created
  126089. * @param index agent index returned by addAgent
  126090. */
  126091. removeAgent(index: number): void;
  126092. /**
  126093. * get the list of all agents attached to this crowd
  126094. * @returns list of agent indices
  126095. */
  126096. getAgents(): number[];
  126097. /**
  126098. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126099. * @param deltaTime in seconds
  126100. */
  126101. update(deltaTime: number): void;
  126102. /**
  126103. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126104. * The queries will try to find a solution within those bounds
  126105. * default is (1,1,1)
  126106. * @param extent x,y,z value that define the extent around the queries point of reference
  126107. */
  126108. setDefaultQueryExtent(extent: Vector3): void;
  126109. /**
  126110. * Get the Bounding box extent specified by setDefaultQueryExtent
  126111. * @returns the box extent values
  126112. */
  126113. getDefaultQueryExtent(): Vector3;
  126114. /**
  126115. * Release all resources
  126116. */
  126117. dispose(): void;
  126118. }
  126119. }
  126120. declare module BABYLON {
  126121. /**
  126122. * Class used to enable access to IndexedDB
  126123. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126124. */
  126125. export class Database implements IOfflineProvider {
  126126. private _callbackManifestChecked;
  126127. private _currentSceneUrl;
  126128. private _db;
  126129. private _enableSceneOffline;
  126130. private _enableTexturesOffline;
  126131. private _manifestVersionFound;
  126132. private _mustUpdateRessources;
  126133. private _hasReachedQuota;
  126134. private _isSupported;
  126135. private _idbFactory;
  126136. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126137. private static IsUASupportingBlobStorage;
  126138. /**
  126139. * Gets a boolean indicating if Database storate is enabled (off by default)
  126140. */
  126141. static IDBStorageEnabled: boolean;
  126142. /**
  126143. * Gets a boolean indicating if scene must be saved in the database
  126144. */
  126145. readonly enableSceneOffline: boolean;
  126146. /**
  126147. * Gets a boolean indicating if textures must be saved in the database
  126148. */
  126149. readonly enableTexturesOffline: boolean;
  126150. /**
  126151. * Creates a new Database
  126152. * @param urlToScene defines the url to load the scene
  126153. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126154. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126155. */
  126156. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126157. private static _ParseURL;
  126158. private static _ReturnFullUrlLocation;
  126159. private _checkManifestFile;
  126160. /**
  126161. * Open the database and make it available
  126162. * @param successCallback defines the callback to call on success
  126163. * @param errorCallback defines the callback to call on error
  126164. */
  126165. open(successCallback: () => void, errorCallback: () => void): void;
  126166. /**
  126167. * Loads an image from the database
  126168. * @param url defines the url to load from
  126169. * @param image defines the target DOM image
  126170. */
  126171. loadImage(url: string, image: HTMLImageElement): void;
  126172. private _loadImageFromDBAsync;
  126173. private _saveImageIntoDBAsync;
  126174. private _checkVersionFromDB;
  126175. private _loadVersionFromDBAsync;
  126176. private _saveVersionIntoDBAsync;
  126177. /**
  126178. * Loads a file from database
  126179. * @param url defines the URL to load from
  126180. * @param sceneLoaded defines a callback to call on success
  126181. * @param progressCallBack defines a callback to call when progress changed
  126182. * @param errorCallback defines a callback to call on error
  126183. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126184. */
  126185. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126186. private _loadFileAsync;
  126187. private _saveFileAsync;
  126188. /**
  126189. * Validates if xhr data is correct
  126190. * @param xhr defines the request to validate
  126191. * @param dataType defines the expected data type
  126192. * @returns true if data is correct
  126193. */
  126194. private static _ValidateXHRData;
  126195. }
  126196. }
  126197. declare module BABYLON {
  126198. /** @hidden */
  126199. export var gpuUpdateParticlesPixelShader: {
  126200. name: string;
  126201. shader: string;
  126202. };
  126203. }
  126204. declare module BABYLON {
  126205. /** @hidden */
  126206. export var gpuUpdateParticlesVertexShader: {
  126207. name: string;
  126208. shader: string;
  126209. };
  126210. }
  126211. declare module BABYLON {
  126212. /** @hidden */
  126213. export var clipPlaneFragmentDeclaration2: {
  126214. name: string;
  126215. shader: string;
  126216. };
  126217. }
  126218. declare module BABYLON {
  126219. /** @hidden */
  126220. export var gpuRenderParticlesPixelShader: {
  126221. name: string;
  126222. shader: string;
  126223. };
  126224. }
  126225. declare module BABYLON {
  126226. /** @hidden */
  126227. export var clipPlaneVertexDeclaration2: {
  126228. name: string;
  126229. shader: string;
  126230. };
  126231. }
  126232. declare module BABYLON {
  126233. /** @hidden */
  126234. export var gpuRenderParticlesVertexShader: {
  126235. name: string;
  126236. shader: string;
  126237. };
  126238. }
  126239. declare module BABYLON {
  126240. /**
  126241. * This represents a GPU particle system in Babylon
  126242. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126243. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126244. */
  126245. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126246. /**
  126247. * The layer mask we are rendering the particles through.
  126248. */
  126249. layerMask: number;
  126250. private _capacity;
  126251. private _activeCount;
  126252. private _currentActiveCount;
  126253. private _accumulatedCount;
  126254. private _renderEffect;
  126255. private _updateEffect;
  126256. private _buffer0;
  126257. private _buffer1;
  126258. private _spriteBuffer;
  126259. private _updateVAO;
  126260. private _renderVAO;
  126261. private _targetIndex;
  126262. private _sourceBuffer;
  126263. private _targetBuffer;
  126264. private _engine;
  126265. private _currentRenderId;
  126266. private _started;
  126267. private _stopped;
  126268. private _timeDelta;
  126269. private _randomTexture;
  126270. private _randomTexture2;
  126271. private _attributesStrideSize;
  126272. private _updateEffectOptions;
  126273. private _randomTextureSize;
  126274. private _actualFrame;
  126275. private readonly _rawTextureWidth;
  126276. /**
  126277. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  126278. */
  126279. static readonly IsSupported: boolean;
  126280. /**
  126281. * An event triggered when the system is disposed.
  126282. */
  126283. onDisposeObservable: Observable<GPUParticleSystem>;
  126284. /**
  126285. * Gets the maximum number of particles active at the same time.
  126286. * @returns The max number of active particles.
  126287. */
  126288. getCapacity(): number;
  126289. /**
  126290. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  126291. * to override the particles.
  126292. */
  126293. forceDepthWrite: boolean;
  126294. /**
  126295. * Gets or set the number of active particles
  126296. */
  126297. activeParticleCount: number;
  126298. private _preWarmDone;
  126299. /**
  126300. * Is this system ready to be used/rendered
  126301. * @return true if the system is ready
  126302. */
  126303. isReady(): boolean;
  126304. /**
  126305. * Gets if the system has been started. (Note: this will still be true after stop is called)
  126306. * @returns True if it has been started, otherwise false.
  126307. */
  126308. isStarted(): boolean;
  126309. /**
  126310. * Starts the particle system and begins to emit
  126311. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  126312. */
  126313. start(delay?: number): void;
  126314. /**
  126315. * Stops the particle system.
  126316. */
  126317. stop(): void;
  126318. /**
  126319. * Remove all active particles
  126320. */
  126321. reset(): void;
  126322. /**
  126323. * Returns the string "GPUParticleSystem"
  126324. * @returns a string containing the class name
  126325. */
  126326. getClassName(): string;
  126327. private _colorGradientsTexture;
  126328. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  126329. /**
  126330. * Adds a new color gradient
  126331. * @param gradient defines the gradient to use (between 0 and 1)
  126332. * @param color1 defines the color to affect to the specified gradient
  126333. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  126334. * @returns the current particle system
  126335. */
  126336. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  126337. /**
  126338. * Remove a specific color gradient
  126339. * @param gradient defines the gradient to remove
  126340. * @returns the current particle system
  126341. */
  126342. removeColorGradient(gradient: number): GPUParticleSystem;
  126343. private _angularSpeedGradientsTexture;
  126344. private _sizeGradientsTexture;
  126345. private _velocityGradientsTexture;
  126346. private _limitVelocityGradientsTexture;
  126347. private _dragGradientsTexture;
  126348. private _addFactorGradient;
  126349. /**
  126350. * Adds a new size gradient
  126351. * @param gradient defines the gradient to use (between 0 and 1)
  126352. * @param factor defines the size factor to affect to the specified gradient
  126353. * @returns the current particle system
  126354. */
  126355. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  126356. /**
  126357. * Remove a specific size gradient
  126358. * @param gradient defines the gradient to remove
  126359. * @returns the current particle system
  126360. */
  126361. removeSizeGradient(gradient: number): GPUParticleSystem;
  126362. /**
  126363. * Adds a new angular speed gradient
  126364. * @param gradient defines the gradient to use (between 0 and 1)
  126365. * @param factor defines the angular speed to affect to the specified gradient
  126366. * @returns the current particle system
  126367. */
  126368. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  126369. /**
  126370. * Remove a specific angular speed gradient
  126371. * @param gradient defines the gradient to remove
  126372. * @returns the current particle system
  126373. */
  126374. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  126375. /**
  126376. * Adds a new velocity gradient
  126377. * @param gradient defines the gradient to use (between 0 and 1)
  126378. * @param factor defines the velocity to affect to the specified gradient
  126379. * @returns the current particle system
  126380. */
  126381. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126382. /**
  126383. * Remove a specific velocity gradient
  126384. * @param gradient defines the gradient to remove
  126385. * @returns the current particle system
  126386. */
  126387. removeVelocityGradient(gradient: number): GPUParticleSystem;
  126388. /**
  126389. * Adds a new limit velocity gradient
  126390. * @param gradient defines the gradient to use (between 0 and 1)
  126391. * @param factor defines the limit velocity value to affect to the specified gradient
  126392. * @returns the current particle system
  126393. */
  126394. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126395. /**
  126396. * Remove a specific limit velocity gradient
  126397. * @param gradient defines the gradient to remove
  126398. * @returns the current particle system
  126399. */
  126400. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  126401. /**
  126402. * Adds a new drag gradient
  126403. * @param gradient defines the gradient to use (between 0 and 1)
  126404. * @param factor defines the drag value to affect to the specified gradient
  126405. * @returns the current particle system
  126406. */
  126407. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  126408. /**
  126409. * Remove a specific drag gradient
  126410. * @param gradient defines the gradient to remove
  126411. * @returns the current particle system
  126412. */
  126413. removeDragGradient(gradient: number): GPUParticleSystem;
  126414. /**
  126415. * Not supported by GPUParticleSystem
  126416. * @param gradient defines the gradient to use (between 0 and 1)
  126417. * @param factor defines the emit rate value to affect to the specified gradient
  126418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126419. * @returns the current particle system
  126420. */
  126421. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126422. /**
  126423. * Not supported by GPUParticleSystem
  126424. * @param gradient defines the gradient to remove
  126425. * @returns the current particle system
  126426. */
  126427. removeEmitRateGradient(gradient: number): IParticleSystem;
  126428. /**
  126429. * Not supported by GPUParticleSystem
  126430. * @param gradient defines the gradient to use (between 0 and 1)
  126431. * @param factor defines the start size value to affect to the specified gradient
  126432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126433. * @returns the current particle system
  126434. */
  126435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126436. /**
  126437. * Not supported by GPUParticleSystem
  126438. * @param gradient defines the gradient to remove
  126439. * @returns the current particle system
  126440. */
  126441. removeStartSizeGradient(gradient: number): IParticleSystem;
  126442. /**
  126443. * Not supported by GPUParticleSystem
  126444. * @param gradient defines the gradient to use (between 0 and 1)
  126445. * @param min defines the color remap minimal range
  126446. * @param max defines the color remap maximal range
  126447. * @returns the current particle system
  126448. */
  126449. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126450. /**
  126451. * Not supported by GPUParticleSystem
  126452. * @param gradient defines the gradient to remove
  126453. * @returns the current particle system
  126454. */
  126455. removeColorRemapGradient(): IParticleSystem;
  126456. /**
  126457. * Not supported by GPUParticleSystem
  126458. * @param gradient defines the gradient to use (between 0 and 1)
  126459. * @param min defines the alpha remap minimal range
  126460. * @param max defines the alpha remap maximal range
  126461. * @returns the current particle system
  126462. */
  126463. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126464. /**
  126465. * Not supported by GPUParticleSystem
  126466. * @param gradient defines the gradient to remove
  126467. * @returns the current particle system
  126468. */
  126469. removeAlphaRemapGradient(): IParticleSystem;
  126470. /**
  126471. * Not supported by GPUParticleSystem
  126472. * @param gradient defines the gradient to use (between 0 and 1)
  126473. * @param color defines the color to affect to the specified gradient
  126474. * @returns the current particle system
  126475. */
  126476. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  126477. /**
  126478. * Not supported by GPUParticleSystem
  126479. * @param gradient defines the gradient to remove
  126480. * @returns the current particle system
  126481. */
  126482. removeRampGradient(): IParticleSystem;
  126483. /**
  126484. * Not supported by GPUParticleSystem
  126485. * @returns the list of ramp gradients
  126486. */
  126487. getRampGradients(): Nullable<Array<Color3Gradient>>;
  126488. /**
  126489. * Not supported by GPUParticleSystem
  126490. * Gets or sets a boolean indicating that ramp gradients must be used
  126491. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  126492. */
  126493. useRampGradients: boolean;
  126494. /**
  126495. * Not supported by GPUParticleSystem
  126496. * @param gradient defines the gradient to use (between 0 and 1)
  126497. * @param factor defines the life time factor to affect to the specified gradient
  126498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126499. * @returns the current particle system
  126500. */
  126501. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126502. /**
  126503. * Not supported by GPUParticleSystem
  126504. * @param gradient defines the gradient to remove
  126505. * @returns the current particle system
  126506. */
  126507. removeLifeTimeGradient(gradient: number): IParticleSystem;
  126508. /**
  126509. * Instantiates a GPU particle system.
  126510. * 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.
  126511. * @param name The name of the particle system
  126512. * @param options The options used to create the system
  126513. * @param scene The scene the particle system belongs to
  126514. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  126515. */
  126516. constructor(name: string, options: Partial<{
  126517. capacity: number;
  126518. randomTextureSize: number;
  126519. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  126520. protected _reset(): void;
  126521. private _createUpdateVAO;
  126522. private _createRenderVAO;
  126523. private _initialize;
  126524. /** @hidden */
  126525. _recreateUpdateEffect(): void;
  126526. /** @hidden */
  126527. _recreateRenderEffect(): void;
  126528. /**
  126529. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  126530. * @param preWarm defines if we are in the pre-warmimg phase
  126531. */
  126532. animate(preWarm?: boolean): void;
  126533. private _createFactorGradientTexture;
  126534. private _createSizeGradientTexture;
  126535. private _createAngularSpeedGradientTexture;
  126536. private _createVelocityGradientTexture;
  126537. private _createLimitVelocityGradientTexture;
  126538. private _createDragGradientTexture;
  126539. private _createColorGradientTexture;
  126540. /**
  126541. * Renders the particle system in its current state
  126542. * @param preWarm defines if the system should only update the particles but not render them
  126543. * @returns the current number of particles
  126544. */
  126545. render(preWarm?: boolean): number;
  126546. /**
  126547. * Rebuilds the particle system
  126548. */
  126549. rebuild(): void;
  126550. private _releaseBuffers;
  126551. private _releaseVAOs;
  126552. /**
  126553. * Disposes the particle system and free the associated resources
  126554. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  126555. */
  126556. dispose(disposeTexture?: boolean): void;
  126557. /**
  126558. * Clones the particle system.
  126559. * @param name The name of the cloned object
  126560. * @param newEmitter The new emitter to use
  126561. * @returns the cloned particle system
  126562. */
  126563. clone(name: string, newEmitter: any): GPUParticleSystem;
  126564. /**
  126565. * Serializes the particle system to a JSON object.
  126566. * @returns the JSON object
  126567. */
  126568. serialize(): any;
  126569. /**
  126570. * Parses a JSON object to create a GPU particle system.
  126571. * @param parsedParticleSystem The JSON object to parse
  126572. * @param scene The scene to create the particle system in
  126573. * @param rootUrl The root url to use to load external dependencies like texture
  126574. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  126575. * @returns the parsed GPU particle system
  126576. */
  126577. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  126578. }
  126579. }
  126580. declare module BABYLON {
  126581. /**
  126582. * Represents a set of particle systems working together to create a specific effect
  126583. */
  126584. export class ParticleSystemSet implements IDisposable {
  126585. /**
  126586. * Gets or sets base Assets URL
  126587. */
  126588. static BaseAssetsUrl: string;
  126589. private _emitterCreationOptions;
  126590. private _emitterNode;
  126591. /**
  126592. * Gets the particle system list
  126593. */
  126594. systems: IParticleSystem[];
  126595. /**
  126596. * Gets the emitter node used with this set
  126597. */
  126598. readonly emitterNode: Nullable<TransformNode>;
  126599. /**
  126600. * Creates a new emitter mesh as a sphere
  126601. * @param options defines the options used to create the sphere
  126602. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  126603. * @param scene defines the hosting scene
  126604. */
  126605. setEmitterAsSphere(options: {
  126606. diameter: number;
  126607. segments: number;
  126608. color: Color3;
  126609. }, renderingGroupId: number, scene: Scene): void;
  126610. /**
  126611. * Starts all particle systems of the set
  126612. * @param emitter defines an optional mesh to use as emitter for the particle systems
  126613. */
  126614. start(emitter?: AbstractMesh): void;
  126615. /**
  126616. * Release all associated resources
  126617. */
  126618. dispose(): void;
  126619. /**
  126620. * Serialize the set into a JSON compatible object
  126621. * @returns a JSON compatible representation of the set
  126622. */
  126623. serialize(): any;
  126624. /**
  126625. * Parse a new ParticleSystemSet from a serialized source
  126626. * @param data defines a JSON compatible representation of the set
  126627. * @param scene defines the hosting scene
  126628. * @param gpu defines if we want GPU particles or CPU particles
  126629. * @returns a new ParticleSystemSet
  126630. */
  126631. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  126632. }
  126633. }
  126634. declare module BABYLON {
  126635. /**
  126636. * This class is made for on one-liner static method to help creating particle system set.
  126637. */
  126638. export class ParticleHelper {
  126639. /**
  126640. * Gets or sets base Assets URL
  126641. */
  126642. static BaseAssetsUrl: string;
  126643. /**
  126644. * Create a default particle system that you can tweak
  126645. * @param emitter defines the emitter to use
  126646. * @param capacity defines the system capacity (default is 500 particles)
  126647. * @param scene defines the hosting scene
  126648. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  126649. * @returns the new Particle system
  126650. */
  126651. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  126652. /**
  126653. * This is the main static method (one-liner) of this helper to create different particle systems
  126654. * @param type This string represents the type to the particle system to create
  126655. * @param scene The scene where the particle system should live
  126656. * @param gpu If the system will use gpu
  126657. * @returns the ParticleSystemSet created
  126658. */
  126659. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  126660. /**
  126661. * Static function used to export a particle system to a ParticleSystemSet variable.
  126662. * Please note that the emitter shape is not exported
  126663. * @param systems defines the particle systems to export
  126664. * @returns the created particle system set
  126665. */
  126666. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  126667. }
  126668. }
  126669. declare module BABYLON {
  126670. interface Engine {
  126671. /**
  126672. * Create an effect to use with particle systems.
  126673. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  126674. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  126675. * @param uniformsNames defines a list of attribute names
  126676. * @param samplers defines an array of string used to represent textures
  126677. * @param defines defines the string containing the defines to use to compile the shaders
  126678. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  126679. * @param onCompiled defines a function to call when the effect creation is successful
  126680. * @param onError defines a function to call when the effect creation has failed
  126681. * @returns the new Effect
  126682. */
  126683. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  126684. }
  126685. interface Mesh {
  126686. /**
  126687. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  126688. * @returns an array of IParticleSystem
  126689. */
  126690. getEmittedParticleSystems(): IParticleSystem[];
  126691. /**
  126692. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  126693. * @returns an array of IParticleSystem
  126694. */
  126695. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  126696. }
  126697. /**
  126698. * @hidden
  126699. */
  126700. export var _IDoNeedToBeInTheBuild: number;
  126701. }
  126702. declare module BABYLON {
  126703. /** Defines the 4 color options */
  126704. export enum PointColor {
  126705. /** color value */
  126706. Color = 2,
  126707. /** uv value */
  126708. UV = 1,
  126709. /** random value */
  126710. Random = 0,
  126711. /** stated value */
  126712. Stated = 3
  126713. }
  126714. /**
  126715. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  126716. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  126717. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  126718. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  126719. *
  126720. * Full documentation here : TO BE ENTERED
  126721. */
  126722. export class PointsCloudSystem implements IDisposable {
  126723. /**
  126724. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  126725. * Example : var p = SPS.particles[i];
  126726. */
  126727. particles: CloudPoint[];
  126728. /**
  126729. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  126730. */
  126731. nbParticles: number;
  126732. /**
  126733. * This a counter for your own usage. It's not set by any SPS functions.
  126734. */
  126735. counter: number;
  126736. /**
  126737. * The PCS name. This name is also given to the underlying mesh.
  126738. */
  126739. name: string;
  126740. /**
  126741. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  126742. */
  126743. mesh: Mesh;
  126744. /**
  126745. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  126746. * Please read :
  126747. */
  126748. vars: any;
  126749. /**
  126750. * @hidden
  126751. */
  126752. _size: number;
  126753. private _scene;
  126754. private _promises;
  126755. private _positions;
  126756. private _indices;
  126757. private _normals;
  126758. private _colors;
  126759. private _uvs;
  126760. private _indices32;
  126761. private _positions32;
  126762. private _colors32;
  126763. private _uvs32;
  126764. private _updatable;
  126765. private _isVisibilityBoxLocked;
  126766. private _alwaysVisible;
  126767. private _groups;
  126768. private _groupCounter;
  126769. private _computeParticleColor;
  126770. private _computeParticleTexture;
  126771. private _computeParticleRotation;
  126772. private _computeBoundingBox;
  126773. private _isReady;
  126774. /**
  126775. * Creates a PCS (Points Cloud System) object
  126776. * @param name (String) is the PCS name, this will be the underlying mesh name
  126777. * @param pointSize (number) is the size for each point
  126778. * @param scene (Scene) is the scene in which the PCS is added
  126779. * @param options defines the options of the PCS e.g.
  126780. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  126781. */
  126782. constructor(name: string, pointSize: number, scene: Scene, options?: {
  126783. updatable?: boolean;
  126784. });
  126785. /**
  126786. * Builds the PCS underlying mesh. Returns a standard Mesh.
  126787. * If no points were added to the PCS, the returned mesh is just a single point.
  126788. * @returns a promise for the created mesh
  126789. */
  126790. buildMeshAsync(): Promise<Mesh>;
  126791. /**
  126792. * @hidden
  126793. */
  126794. private _buildMesh;
  126795. private _addParticle;
  126796. private _randomUnitVector;
  126797. private _getColorIndicesForCoord;
  126798. private _setPointsColorOrUV;
  126799. private _colorFromTexture;
  126800. private _calculateDensity;
  126801. /**
  126802. * Adds points to the PCS in random positions within a unit sphere
  126803. * @param nb (positive integer) the number of particles to be created from this model
  126804. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  126805. * @returns the number of groups in the system
  126806. */
  126807. addPoints(nb: number, pointFunction?: any): number;
  126808. /**
  126809. * Adds points to the PCS from the surface of the model shape
  126810. * @param mesh is any Mesh object that will be used as a surface model for the points
  126811. * @param nb (positive integer) the number of particles to be created from this model
  126812. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  126813. * @param color (color3) to be used when colorWith is stated
  126814. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126815. * @returns the number of groups in the system
  126816. */
  126817. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126818. /**
  126819. * Adds points to the PCS inside the model shape
  126820. * @param mesh is any Mesh object that will be used as a surface model for the points
  126821. * @param nb (positive integer) the number of particles to be created from this model
  126822. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  126823. * @param color (color4) to be used when colorWith is stated
  126824. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126825. * @returns the number of groups in the system
  126826. */
  126827. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126828. /**
  126829. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  126830. * This method calls `updateParticle()` for each particle of the SPS.
  126831. * For an animated SPS, it is usually called within the render loop.
  126832. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  126833. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  126834. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  126835. * @returns the PCS.
  126836. */
  126837. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  126838. /**
  126839. * Disposes the PCS.
  126840. */
  126841. dispose(): void;
  126842. /**
  126843. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  126844. * doc :
  126845. * @returns the PCS.
  126846. */
  126847. refreshVisibleSize(): PointsCloudSystem;
  126848. /**
  126849. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  126850. * @param size the size (float) of the visibility box
  126851. * note : this doesn't lock the PCS mesh bounding box.
  126852. * doc :
  126853. */
  126854. setVisibilityBox(size: number): void;
  126855. /**
  126856. * Gets whether the PCS is always visible or not
  126857. * doc :
  126858. */
  126859. /**
  126860. * Sets the PCS as always visible or not
  126861. * doc :
  126862. */
  126863. isAlwaysVisible: boolean;
  126864. /**
  126865. * Tells to `setParticles()` to compute the particle rotations or not
  126866. * Default value : false. The PCS is faster when it's set to false
  126867. * Note : particle rotations are only applied to parent particles
  126868. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  126869. */
  126870. computeParticleRotation: boolean;
  126871. /**
  126872. * Tells to `setParticles()` to compute the particle colors or not.
  126873. * Default value : true. The PCS is faster when it's set to false.
  126874. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126875. */
  126876. /**
  126877. * Gets if `setParticles()` computes the particle colors or not.
  126878. * Default value : false. The PCS is faster when it's set to false.
  126879. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126880. */
  126881. computeParticleColor: boolean;
  126882. /**
  126883. * Gets if `setParticles()` computes the particle textures or not.
  126884. * Default value : false. The PCS is faster when it's set to false.
  126885. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  126886. */
  126887. computeParticleTexture: boolean;
  126888. /**
  126889. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  126890. */
  126891. /**
  126892. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  126893. */
  126894. computeBoundingBox: boolean;
  126895. /**
  126896. * This function does nothing. It may be overwritten to set all the particle first values.
  126897. * The PCS doesn't call this function, you may have to call it by your own.
  126898. * doc :
  126899. */
  126900. initParticles(): void;
  126901. /**
  126902. * This function does nothing. It may be overwritten to recycle a particle
  126903. * The PCS doesn't call this function, you can to call it
  126904. * doc :
  126905. * @param particle The particle to recycle
  126906. * @returns the recycled particle
  126907. */
  126908. recycleParticle(particle: CloudPoint): CloudPoint;
  126909. /**
  126910. * Updates a particle : this function should be overwritten by the user.
  126911. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  126912. * doc :
  126913. * @example : just set a particle position or velocity and recycle conditions
  126914. * @param particle The particle to update
  126915. * @returns the updated particle
  126916. */
  126917. updateParticle(particle: CloudPoint): CloudPoint;
  126918. /**
  126919. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  126920. * This does nothing and may be overwritten by the user.
  126921. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126922. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126923. * @param update the boolean update value actually passed to setParticles()
  126924. */
  126925. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126926. /**
  126927. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  126928. * This will be passed three parameters.
  126929. * This does nothing and may be overwritten by the user.
  126930. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126931. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126932. * @param update the boolean update value actually passed to setParticles()
  126933. */
  126934. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126935. }
  126936. }
  126937. declare module BABYLON {
  126938. /**
  126939. * Represents one particle of a points cloud system.
  126940. */
  126941. export class CloudPoint {
  126942. /**
  126943. * particle global index
  126944. */
  126945. idx: number;
  126946. /**
  126947. * The color of the particle
  126948. */
  126949. color: Nullable<Color4>;
  126950. /**
  126951. * The world space position of the particle.
  126952. */
  126953. position: Vector3;
  126954. /**
  126955. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  126956. */
  126957. rotation: Vector3;
  126958. /**
  126959. * The world space rotation quaternion of the particle.
  126960. */
  126961. rotationQuaternion: Nullable<Quaternion>;
  126962. /**
  126963. * The uv of the particle.
  126964. */
  126965. uv: Nullable<Vector2>;
  126966. /**
  126967. * The current speed of the particle.
  126968. */
  126969. velocity: Vector3;
  126970. /**
  126971. * The pivot point in the particle local space.
  126972. */
  126973. pivot: Vector3;
  126974. /**
  126975. * Must the particle be translated from its pivot point in its local space ?
  126976. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  126977. * Default : false
  126978. */
  126979. translateFromPivot: boolean;
  126980. /**
  126981. * Index of this particle in the global "positions" array (Internal use)
  126982. * @hidden
  126983. */
  126984. _pos: number;
  126985. /**
  126986. * @hidden Index of this particle in the global "indices" array (Internal use)
  126987. */
  126988. _ind: number;
  126989. /**
  126990. * Group this particle belongs to
  126991. */
  126992. _group: PointsGroup;
  126993. /**
  126994. * Group id of this particle
  126995. */
  126996. groupId: number;
  126997. /**
  126998. * Index of the particle in its group id (Internal use)
  126999. */
  127000. idxInGroup: number;
  127001. /**
  127002. * @hidden Particle BoundingInfo object (Internal use)
  127003. */
  127004. _boundingInfo: BoundingInfo;
  127005. /**
  127006. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127007. */
  127008. _pcs: PointsCloudSystem;
  127009. /**
  127010. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127011. */
  127012. _stillInvisible: boolean;
  127013. /**
  127014. * @hidden Last computed particle rotation matrix
  127015. */
  127016. _rotationMatrix: number[];
  127017. /**
  127018. * Parent particle Id, if any.
  127019. * Default null.
  127020. */
  127021. parentId: Nullable<number>;
  127022. /**
  127023. * @hidden Internal global position in the PCS.
  127024. */
  127025. _globalPosition: Vector3;
  127026. /**
  127027. * Creates a Point Cloud object.
  127028. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127029. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127030. * @param group (PointsGroup) is the group the particle belongs to
  127031. * @param groupId (integer) is the group identifier in the PCS.
  127032. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127033. * @param pcs defines the PCS it is associated to
  127034. */
  127035. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127036. /**
  127037. * get point size
  127038. */
  127039. /**
  127040. * Set point size
  127041. */
  127042. size: Vector3;
  127043. /**
  127044. * Legacy support, changed quaternion to rotationQuaternion
  127045. */
  127046. /**
  127047. * Legacy support, changed quaternion to rotationQuaternion
  127048. */
  127049. quaternion: Nullable<Quaternion>;
  127050. /**
  127051. * Returns a boolean. True if the particle intersects a mesh, else false
  127052. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127053. * @param target is the object (point or mesh) what the intersection is computed against
  127054. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127055. * @returns true if it intersects
  127056. */
  127057. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127058. /**
  127059. * get the rotation matrix of the particle
  127060. * @hidden
  127061. */
  127062. getRotationMatrix(m: Matrix): void;
  127063. }
  127064. /**
  127065. * Represents a group of points in a points cloud system
  127066. * * PCS internal tool, don't use it manually.
  127067. */
  127068. export class PointsGroup {
  127069. /**
  127070. * The group id
  127071. * @hidden
  127072. */
  127073. groupID: number;
  127074. /**
  127075. * image data for group (internal use)
  127076. * @hidden
  127077. */
  127078. _groupImageData: Nullable<ArrayBufferView>;
  127079. /**
  127080. * Image Width (internal use)
  127081. * @hidden
  127082. */
  127083. _groupImgWidth: number;
  127084. /**
  127085. * Image Height (internal use)
  127086. * @hidden
  127087. */
  127088. _groupImgHeight: number;
  127089. /**
  127090. * Custom position function (internal use)
  127091. * @hidden
  127092. */
  127093. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127094. /**
  127095. * density per facet for surface points
  127096. * @hidden
  127097. */
  127098. _groupDensity: number[];
  127099. /**
  127100. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127101. * PCS internal tool, don't use it manually.
  127102. * @hidden
  127103. */
  127104. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127105. }
  127106. }
  127107. declare module BABYLON {
  127108. interface Scene {
  127109. /** @hidden (Backing field) */
  127110. _physicsEngine: Nullable<IPhysicsEngine>;
  127111. /**
  127112. * Gets the current physics engine
  127113. * @returns a IPhysicsEngine or null if none attached
  127114. */
  127115. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127116. /**
  127117. * Enables physics to the current scene
  127118. * @param gravity defines the scene's gravity for the physics engine
  127119. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127120. * @return a boolean indicating if the physics engine was initialized
  127121. */
  127122. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127123. /**
  127124. * Disables and disposes the physics engine associated with the scene
  127125. */
  127126. disablePhysicsEngine(): void;
  127127. /**
  127128. * Gets a boolean indicating if there is an active physics engine
  127129. * @returns a boolean indicating if there is an active physics engine
  127130. */
  127131. isPhysicsEnabled(): boolean;
  127132. /**
  127133. * Deletes a physics compound impostor
  127134. * @param compound defines the compound to delete
  127135. */
  127136. deleteCompoundImpostor(compound: any): void;
  127137. /**
  127138. * An event triggered when physic simulation is about to be run
  127139. */
  127140. onBeforePhysicsObservable: Observable<Scene>;
  127141. /**
  127142. * An event triggered when physic simulation has been done
  127143. */
  127144. onAfterPhysicsObservable: Observable<Scene>;
  127145. }
  127146. interface AbstractMesh {
  127147. /** @hidden */
  127148. _physicsImpostor: Nullable<PhysicsImpostor>;
  127149. /**
  127150. * Gets or sets impostor used for physic simulation
  127151. * @see http://doc.babylonjs.com/features/physics_engine
  127152. */
  127153. physicsImpostor: Nullable<PhysicsImpostor>;
  127154. /**
  127155. * Gets the current physics impostor
  127156. * @see http://doc.babylonjs.com/features/physics_engine
  127157. * @returns a physics impostor or null
  127158. */
  127159. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127160. /** Apply a physic impulse to the mesh
  127161. * @param force defines the force to apply
  127162. * @param contactPoint defines where to apply the force
  127163. * @returns the current mesh
  127164. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127165. */
  127166. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127167. /**
  127168. * Creates a physic joint between two meshes
  127169. * @param otherMesh defines the other mesh to use
  127170. * @param pivot1 defines the pivot to use on this mesh
  127171. * @param pivot2 defines the pivot to use on the other mesh
  127172. * @param options defines additional options (can be plugin dependent)
  127173. * @returns the current mesh
  127174. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127175. */
  127176. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127177. /** @hidden */
  127178. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127179. }
  127180. /**
  127181. * Defines the physics engine scene component responsible to manage a physics engine
  127182. */
  127183. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127184. /**
  127185. * The component name helpful to identify the component in the list of scene components.
  127186. */
  127187. readonly name: string;
  127188. /**
  127189. * The scene the component belongs to.
  127190. */
  127191. scene: Scene;
  127192. /**
  127193. * Creates a new instance of the component for the given scene
  127194. * @param scene Defines the scene to register the component in
  127195. */
  127196. constructor(scene: Scene);
  127197. /**
  127198. * Registers the component in a given scene
  127199. */
  127200. register(): void;
  127201. /**
  127202. * Rebuilds the elements related to this component in case of
  127203. * context lost for instance.
  127204. */
  127205. rebuild(): void;
  127206. /**
  127207. * Disposes the component and the associated ressources
  127208. */
  127209. dispose(): void;
  127210. }
  127211. }
  127212. declare module BABYLON {
  127213. /**
  127214. * A helper for physics simulations
  127215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127216. */
  127217. export class PhysicsHelper {
  127218. private _scene;
  127219. private _physicsEngine;
  127220. /**
  127221. * Initializes the Physics helper
  127222. * @param scene Babylon.js scene
  127223. */
  127224. constructor(scene: Scene);
  127225. /**
  127226. * Applies a radial explosion impulse
  127227. * @param origin the origin of the explosion
  127228. * @param radiusOrEventOptions the radius or the options of radial explosion
  127229. * @param strength the explosion strength
  127230. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127231. * @returns A physics radial explosion event, or null
  127232. */
  127233. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127234. /**
  127235. * Applies a radial explosion force
  127236. * @param origin the origin of the explosion
  127237. * @param radiusOrEventOptions the radius or the options of radial explosion
  127238. * @param strength the explosion strength
  127239. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127240. * @returns A physics radial explosion event, or null
  127241. */
  127242. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127243. /**
  127244. * Creates a gravitational field
  127245. * @param origin the origin of the explosion
  127246. * @param radiusOrEventOptions the radius or the options of radial explosion
  127247. * @param strength the explosion strength
  127248. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127249. * @returns A physics gravitational field event, or null
  127250. */
  127251. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127252. /**
  127253. * Creates a physics updraft event
  127254. * @param origin the origin of the updraft
  127255. * @param radiusOrEventOptions the radius or the options of the updraft
  127256. * @param strength the strength of the updraft
  127257. * @param height the height of the updraft
  127258. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127259. * @returns A physics updraft event, or null
  127260. */
  127261. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127262. /**
  127263. * Creates a physics vortex event
  127264. * @param origin the of the vortex
  127265. * @param radiusOrEventOptions the radius or the options of the vortex
  127266. * @param strength the strength of the vortex
  127267. * @param height the height of the vortex
  127268. * @returns a Physics vortex event, or null
  127269. * A physics vortex event or null
  127270. */
  127271. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127272. }
  127273. /**
  127274. * Represents a physics radial explosion event
  127275. */
  127276. class PhysicsRadialExplosionEvent {
  127277. private _scene;
  127278. private _options;
  127279. private _sphere;
  127280. private _dataFetched;
  127281. /**
  127282. * Initializes a radial explosioin event
  127283. * @param _scene BabylonJS scene
  127284. * @param _options The options for the vortex event
  127285. */
  127286. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  127287. /**
  127288. * Returns the data related to the radial explosion event (sphere).
  127289. * @returns The radial explosion event data
  127290. */
  127291. getData(): PhysicsRadialExplosionEventData;
  127292. /**
  127293. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  127294. * @param impostor A physics imposter
  127295. * @param origin the origin of the explosion
  127296. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  127297. */
  127298. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  127299. /**
  127300. * Triggers affecterd impostors callbacks
  127301. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  127302. */
  127303. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  127304. /**
  127305. * Disposes the sphere.
  127306. * @param force Specifies if the sphere should be disposed by force
  127307. */
  127308. dispose(force?: boolean): void;
  127309. /*** Helpers ***/
  127310. private _prepareSphere;
  127311. private _intersectsWithSphere;
  127312. }
  127313. /**
  127314. * Represents a gravitational field event
  127315. */
  127316. class PhysicsGravitationalFieldEvent {
  127317. private _physicsHelper;
  127318. private _scene;
  127319. private _origin;
  127320. private _options;
  127321. private _tickCallback;
  127322. private _sphere;
  127323. private _dataFetched;
  127324. /**
  127325. * Initializes the physics gravitational field event
  127326. * @param _physicsHelper A physics helper
  127327. * @param _scene BabylonJS scene
  127328. * @param _origin The origin position of the gravitational field event
  127329. * @param _options The options for the vortex event
  127330. */
  127331. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  127332. /**
  127333. * Returns the data related to the gravitational field event (sphere).
  127334. * @returns A gravitational field event
  127335. */
  127336. getData(): PhysicsGravitationalFieldEventData;
  127337. /**
  127338. * Enables the gravitational field.
  127339. */
  127340. enable(): void;
  127341. /**
  127342. * Disables the gravitational field.
  127343. */
  127344. disable(): void;
  127345. /**
  127346. * Disposes the sphere.
  127347. * @param force The force to dispose from the gravitational field event
  127348. */
  127349. dispose(force?: boolean): void;
  127350. private _tick;
  127351. }
  127352. /**
  127353. * Represents a physics updraft event
  127354. */
  127355. class PhysicsUpdraftEvent {
  127356. private _scene;
  127357. private _origin;
  127358. private _options;
  127359. private _physicsEngine;
  127360. private _originTop;
  127361. private _originDirection;
  127362. private _tickCallback;
  127363. private _cylinder;
  127364. private _cylinderPosition;
  127365. private _dataFetched;
  127366. /**
  127367. * Initializes the physics updraft event
  127368. * @param _scene BabylonJS scene
  127369. * @param _origin The origin position of the updraft
  127370. * @param _options The options for the updraft event
  127371. */
  127372. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  127373. /**
  127374. * Returns the data related to the updraft event (cylinder).
  127375. * @returns A physics updraft event
  127376. */
  127377. getData(): PhysicsUpdraftEventData;
  127378. /**
  127379. * Enables the updraft.
  127380. */
  127381. enable(): void;
  127382. /**
  127383. * Disables the updraft.
  127384. */
  127385. disable(): void;
  127386. /**
  127387. * Disposes the cylinder.
  127388. * @param force Specifies if the updraft should be disposed by force
  127389. */
  127390. dispose(force?: boolean): void;
  127391. private getImpostorHitData;
  127392. private _tick;
  127393. /*** Helpers ***/
  127394. private _prepareCylinder;
  127395. private _intersectsWithCylinder;
  127396. }
  127397. /**
  127398. * Represents a physics vortex event
  127399. */
  127400. class PhysicsVortexEvent {
  127401. private _scene;
  127402. private _origin;
  127403. private _options;
  127404. private _physicsEngine;
  127405. private _originTop;
  127406. private _tickCallback;
  127407. private _cylinder;
  127408. private _cylinderPosition;
  127409. private _dataFetched;
  127410. /**
  127411. * Initializes the physics vortex event
  127412. * @param _scene The BabylonJS scene
  127413. * @param _origin The origin position of the vortex
  127414. * @param _options The options for the vortex event
  127415. */
  127416. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  127417. /**
  127418. * Returns the data related to the vortex event (cylinder).
  127419. * @returns The physics vortex event data
  127420. */
  127421. getData(): PhysicsVortexEventData;
  127422. /**
  127423. * Enables the vortex.
  127424. */
  127425. enable(): void;
  127426. /**
  127427. * Disables the cortex.
  127428. */
  127429. disable(): void;
  127430. /**
  127431. * Disposes the sphere.
  127432. * @param force
  127433. */
  127434. dispose(force?: boolean): void;
  127435. private getImpostorHitData;
  127436. private _tick;
  127437. /*** Helpers ***/
  127438. private _prepareCylinder;
  127439. private _intersectsWithCylinder;
  127440. }
  127441. /**
  127442. * Options fot the radial explosion event
  127443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127444. */
  127445. export class PhysicsRadialExplosionEventOptions {
  127446. /**
  127447. * The radius of the sphere for the radial explosion.
  127448. */
  127449. radius: number;
  127450. /**
  127451. * The strenth of the explosion.
  127452. */
  127453. strength: number;
  127454. /**
  127455. * The strenght of the force in correspondence to the distance of the affected object
  127456. */
  127457. falloff: PhysicsRadialImpulseFalloff;
  127458. /**
  127459. * Sphere options for the radial explosion.
  127460. */
  127461. sphere: {
  127462. segments: number;
  127463. diameter: number;
  127464. };
  127465. /**
  127466. * Sphere options for the radial explosion.
  127467. */
  127468. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  127469. }
  127470. /**
  127471. * Options fot the updraft event
  127472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127473. */
  127474. export class PhysicsUpdraftEventOptions {
  127475. /**
  127476. * The radius of the cylinder for the vortex
  127477. */
  127478. radius: number;
  127479. /**
  127480. * The strenth of the updraft.
  127481. */
  127482. strength: number;
  127483. /**
  127484. * The height of the cylinder for the updraft.
  127485. */
  127486. height: number;
  127487. /**
  127488. * The mode for the the updraft.
  127489. */
  127490. updraftMode: PhysicsUpdraftMode;
  127491. }
  127492. /**
  127493. * Options fot the vortex event
  127494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127495. */
  127496. export class PhysicsVortexEventOptions {
  127497. /**
  127498. * The radius of the cylinder for the vortex
  127499. */
  127500. radius: number;
  127501. /**
  127502. * The strenth of the vortex.
  127503. */
  127504. strength: number;
  127505. /**
  127506. * The height of the cylinder for the vortex.
  127507. */
  127508. height: number;
  127509. /**
  127510. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  127511. */
  127512. centripetalForceThreshold: number;
  127513. /**
  127514. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  127515. */
  127516. centripetalForceMultiplier: number;
  127517. /**
  127518. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  127519. */
  127520. centrifugalForceMultiplier: number;
  127521. /**
  127522. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  127523. */
  127524. updraftForceMultiplier: number;
  127525. }
  127526. /**
  127527. * The strenght of the force in correspondence to the distance of the affected object
  127528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127529. */
  127530. export enum PhysicsRadialImpulseFalloff {
  127531. /** Defines that impulse is constant in strength across it's whole radius */
  127532. Constant = 0,
  127533. /** Defines that impulse gets weaker if it's further from the origin */
  127534. Linear = 1
  127535. }
  127536. /**
  127537. * The strength of the force in correspondence to the distance of the affected object
  127538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127539. */
  127540. export enum PhysicsUpdraftMode {
  127541. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  127542. Center = 0,
  127543. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  127544. Perpendicular = 1
  127545. }
  127546. /**
  127547. * Interface for a physics hit data
  127548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127549. */
  127550. export interface PhysicsHitData {
  127551. /**
  127552. * The force applied at the contact point
  127553. */
  127554. force: Vector3;
  127555. /**
  127556. * The contact point
  127557. */
  127558. contactPoint: Vector3;
  127559. /**
  127560. * The distance from the origin to the contact point
  127561. */
  127562. distanceFromOrigin: number;
  127563. }
  127564. /**
  127565. * Interface for radial explosion event data
  127566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127567. */
  127568. export interface PhysicsRadialExplosionEventData {
  127569. /**
  127570. * A sphere used for the radial explosion event
  127571. */
  127572. sphere: Mesh;
  127573. }
  127574. /**
  127575. * Interface for gravitational field event data
  127576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127577. */
  127578. export interface PhysicsGravitationalFieldEventData {
  127579. /**
  127580. * A sphere mesh used for the gravitational field event
  127581. */
  127582. sphere: Mesh;
  127583. }
  127584. /**
  127585. * Interface for updraft event data
  127586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127587. */
  127588. export interface PhysicsUpdraftEventData {
  127589. /**
  127590. * A cylinder used for the updraft event
  127591. */
  127592. cylinder: Mesh;
  127593. }
  127594. /**
  127595. * Interface for vortex event data
  127596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127597. */
  127598. export interface PhysicsVortexEventData {
  127599. /**
  127600. * A cylinder used for the vortex event
  127601. */
  127602. cylinder: Mesh;
  127603. }
  127604. /**
  127605. * Interface for an affected physics impostor
  127606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127607. */
  127608. export interface PhysicsAffectedImpostorWithData {
  127609. /**
  127610. * The impostor affected by the effect
  127611. */
  127612. impostor: PhysicsImpostor;
  127613. /**
  127614. * The data about the hit/horce from the explosion
  127615. */
  127616. hitData: PhysicsHitData;
  127617. }
  127618. }
  127619. declare module BABYLON {
  127620. /** @hidden */
  127621. export var blackAndWhitePixelShader: {
  127622. name: string;
  127623. shader: string;
  127624. };
  127625. }
  127626. declare module BABYLON {
  127627. /**
  127628. * Post process used to render in black and white
  127629. */
  127630. export class BlackAndWhitePostProcess extends PostProcess {
  127631. /**
  127632. * Linear about to convert he result to black and white (default: 1)
  127633. */
  127634. degree: number;
  127635. /**
  127636. * Creates a black and white post process
  127637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  127638. * @param name The name of the effect.
  127639. * @param options The required width/height ratio to downsize to before computing the render pass.
  127640. * @param camera The camera to apply the render pass to.
  127641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127642. * @param engine The engine which the post process will be applied. (default: current engine)
  127643. * @param reusable If the post process can be reused on the same frame. (default: false)
  127644. */
  127645. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127646. }
  127647. }
  127648. declare module BABYLON {
  127649. /**
  127650. * This represents a set of one or more post processes in Babylon.
  127651. * A post process can be used to apply a shader to a texture after it is rendered.
  127652. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127653. */
  127654. export class PostProcessRenderEffect {
  127655. private _postProcesses;
  127656. private _getPostProcesses;
  127657. private _singleInstance;
  127658. private _cameras;
  127659. private _indicesForCamera;
  127660. /**
  127661. * Name of the effect
  127662. * @hidden
  127663. */
  127664. _name: string;
  127665. /**
  127666. * Instantiates a post process render effect.
  127667. * A post process can be used to apply a shader to a texture after it is rendered.
  127668. * @param engine The engine the effect is tied to
  127669. * @param name The name of the effect
  127670. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  127671. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  127672. */
  127673. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  127674. /**
  127675. * Checks if all the post processes in the effect are supported.
  127676. */
  127677. readonly isSupported: boolean;
  127678. /**
  127679. * Updates the current state of the effect
  127680. * @hidden
  127681. */
  127682. _update(): void;
  127683. /**
  127684. * Attaches the effect on cameras
  127685. * @param cameras The camera to attach to.
  127686. * @hidden
  127687. */
  127688. _attachCameras(cameras: Camera): void;
  127689. /**
  127690. * Attaches the effect on cameras
  127691. * @param cameras The camera to attach to.
  127692. * @hidden
  127693. */
  127694. _attachCameras(cameras: Camera[]): void;
  127695. /**
  127696. * Detaches the effect on cameras
  127697. * @param cameras The camera to detatch from.
  127698. * @hidden
  127699. */
  127700. _detachCameras(cameras: Camera): void;
  127701. /**
  127702. * Detatches the effect on cameras
  127703. * @param cameras The camera to detatch from.
  127704. * @hidden
  127705. */
  127706. _detachCameras(cameras: Camera[]): void;
  127707. /**
  127708. * Enables the effect on given cameras
  127709. * @param cameras The camera to enable.
  127710. * @hidden
  127711. */
  127712. _enable(cameras: Camera): void;
  127713. /**
  127714. * Enables the effect on given cameras
  127715. * @param cameras The camera to enable.
  127716. * @hidden
  127717. */
  127718. _enable(cameras: Nullable<Camera[]>): void;
  127719. /**
  127720. * Disables the effect on the given cameras
  127721. * @param cameras The camera to disable.
  127722. * @hidden
  127723. */
  127724. _disable(cameras: Camera): void;
  127725. /**
  127726. * Disables the effect on the given cameras
  127727. * @param cameras The camera to disable.
  127728. * @hidden
  127729. */
  127730. _disable(cameras: Nullable<Camera[]>): void;
  127731. /**
  127732. * Gets a list of the post processes contained in the effect.
  127733. * @param camera The camera to get the post processes on.
  127734. * @returns The list of the post processes in the effect.
  127735. */
  127736. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  127737. }
  127738. }
  127739. declare module BABYLON {
  127740. /** @hidden */
  127741. export var extractHighlightsPixelShader: {
  127742. name: string;
  127743. shader: string;
  127744. };
  127745. }
  127746. declare module BABYLON {
  127747. /**
  127748. * 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.
  127749. */
  127750. export class ExtractHighlightsPostProcess extends PostProcess {
  127751. /**
  127752. * The luminance threshold, pixels below this value will be set to black.
  127753. */
  127754. threshold: number;
  127755. /** @hidden */
  127756. _exposure: number;
  127757. /**
  127758. * Post process which has the input texture to be used when performing highlight extraction
  127759. * @hidden
  127760. */
  127761. _inputPostProcess: Nullable<PostProcess>;
  127762. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127763. }
  127764. }
  127765. declare module BABYLON {
  127766. /** @hidden */
  127767. export var bloomMergePixelShader: {
  127768. name: string;
  127769. shader: string;
  127770. };
  127771. }
  127772. declare module BABYLON {
  127773. /**
  127774. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127775. */
  127776. export class BloomMergePostProcess extends PostProcess {
  127777. /** Weight of the bloom to be added to the original input. */
  127778. weight: number;
  127779. /**
  127780. * Creates a new instance of @see BloomMergePostProcess
  127781. * @param name The name of the effect.
  127782. * @param originalFromInput Post process which's input will be used for the merge.
  127783. * @param blurred Blurred highlights post process which's output will be used.
  127784. * @param weight Weight of the bloom to be added to the original input.
  127785. * @param options The required width/height ratio to downsize to before computing the render pass.
  127786. * @param camera The camera to apply the render pass to.
  127787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127788. * @param engine The engine which the post process will be applied. (default: current engine)
  127789. * @param reusable If the post process can be reused on the same frame. (default: false)
  127790. * @param textureType Type of textures used when performing the post process. (default: 0)
  127791. * @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)
  127792. */
  127793. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  127794. /** Weight of the bloom to be added to the original input. */
  127795. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127796. }
  127797. }
  127798. declare module BABYLON {
  127799. /**
  127800. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  127801. */
  127802. export class BloomEffect extends PostProcessRenderEffect {
  127803. private bloomScale;
  127804. /**
  127805. * @hidden Internal
  127806. */
  127807. _effects: Array<PostProcess>;
  127808. /**
  127809. * @hidden Internal
  127810. */
  127811. _downscale: ExtractHighlightsPostProcess;
  127812. private _blurX;
  127813. private _blurY;
  127814. private _merge;
  127815. /**
  127816. * The luminance threshold to find bright areas of the image to bloom.
  127817. */
  127818. threshold: number;
  127819. /**
  127820. * The strength of the bloom.
  127821. */
  127822. weight: number;
  127823. /**
  127824. * Specifies the size of the bloom blur kernel, relative to the final output size
  127825. */
  127826. kernel: number;
  127827. /**
  127828. * Creates a new instance of @see BloomEffect
  127829. * @param scene The scene the effect belongs to.
  127830. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  127831. * @param bloomKernel The size of the kernel to be used when applying the blur.
  127832. * @param bloomWeight The the strength of bloom.
  127833. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127834. * @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)
  127835. */
  127836. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  127837. /**
  127838. * Disposes each of the internal effects for a given camera.
  127839. * @param camera The camera to dispose the effect on.
  127840. */
  127841. disposeEffects(camera: Camera): void;
  127842. /**
  127843. * @hidden Internal
  127844. */
  127845. _updateEffects(): void;
  127846. /**
  127847. * Internal
  127848. * @returns if all the contained post processes are ready.
  127849. * @hidden
  127850. */
  127851. _isReady(): boolean;
  127852. }
  127853. }
  127854. declare module BABYLON {
  127855. /** @hidden */
  127856. export var chromaticAberrationPixelShader: {
  127857. name: string;
  127858. shader: string;
  127859. };
  127860. }
  127861. declare module BABYLON {
  127862. /**
  127863. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  127864. */
  127865. export class ChromaticAberrationPostProcess extends PostProcess {
  127866. /**
  127867. * The amount of seperation of rgb channels (default: 30)
  127868. */
  127869. aberrationAmount: number;
  127870. /**
  127871. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  127872. */
  127873. radialIntensity: number;
  127874. /**
  127875. * 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))
  127876. */
  127877. direction: Vector2;
  127878. /**
  127879. * 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))
  127880. */
  127881. centerPosition: Vector2;
  127882. /**
  127883. * Creates a new instance ChromaticAberrationPostProcess
  127884. * @param name The name of the effect.
  127885. * @param screenWidth The width of the screen to apply the effect on.
  127886. * @param screenHeight The height of the screen to apply the effect on.
  127887. * @param options The required width/height ratio to downsize to before computing the render pass.
  127888. * @param camera The camera to apply the render pass to.
  127889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127890. * @param engine The engine which the post process will be applied. (default: current engine)
  127891. * @param reusable If the post process can be reused on the same frame. (default: false)
  127892. * @param textureType Type of textures used when performing the post process. (default: 0)
  127893. * @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)
  127894. */
  127895. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127896. }
  127897. }
  127898. declare module BABYLON {
  127899. /** @hidden */
  127900. export var circleOfConfusionPixelShader: {
  127901. name: string;
  127902. shader: string;
  127903. };
  127904. }
  127905. declare module BABYLON {
  127906. /**
  127907. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  127908. */
  127909. export class CircleOfConfusionPostProcess extends PostProcess {
  127910. /**
  127911. * 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.
  127912. */
  127913. lensSize: number;
  127914. /**
  127915. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127916. */
  127917. fStop: number;
  127918. /**
  127919. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127920. */
  127921. focusDistance: number;
  127922. /**
  127923. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  127924. */
  127925. focalLength: number;
  127926. private _depthTexture;
  127927. /**
  127928. * Creates a new instance CircleOfConfusionPostProcess
  127929. * @param name The name of the effect.
  127930. * @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.
  127931. * @param options The required width/height ratio to downsize to before computing the render pass.
  127932. * @param camera The camera to apply the render pass to.
  127933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127934. * @param engine The engine which the post process will be applied. (default: current engine)
  127935. * @param reusable If the post process can be reused on the same frame. (default: false)
  127936. * @param textureType Type of textures used when performing the post process. (default: 0)
  127937. * @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)
  127938. */
  127939. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127940. /**
  127941. * 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.
  127942. */
  127943. depthTexture: RenderTargetTexture;
  127944. }
  127945. }
  127946. declare module BABYLON {
  127947. /** @hidden */
  127948. export var colorCorrectionPixelShader: {
  127949. name: string;
  127950. shader: string;
  127951. };
  127952. }
  127953. declare module BABYLON {
  127954. /**
  127955. *
  127956. * This post-process allows the modification of rendered colors by using
  127957. * a 'look-up table' (LUT). This effect is also called Color Grading.
  127958. *
  127959. * The object needs to be provided an url to a texture containing the color
  127960. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  127961. * Use an image editing software to tweak the LUT to match your needs.
  127962. *
  127963. * For an example of a color LUT, see here:
  127964. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  127965. * For explanations on color grading, see here:
  127966. * @see http://udn.epicgames.com/Three/ColorGrading.html
  127967. *
  127968. */
  127969. export class ColorCorrectionPostProcess extends PostProcess {
  127970. private _colorTableTexture;
  127971. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127972. }
  127973. }
  127974. declare module BABYLON {
  127975. /** @hidden */
  127976. export var convolutionPixelShader: {
  127977. name: string;
  127978. shader: string;
  127979. };
  127980. }
  127981. declare module BABYLON {
  127982. /**
  127983. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  127984. * input texture to perform effects such as edge detection or sharpening
  127985. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127986. */
  127987. export class ConvolutionPostProcess extends PostProcess {
  127988. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127989. kernel: number[];
  127990. /**
  127991. * Creates a new instance ConvolutionPostProcess
  127992. * @param name The name of the effect.
  127993. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  127994. * @param options The required width/height ratio to downsize to before computing the render pass.
  127995. * @param camera The camera to apply the render pass to.
  127996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127997. * @param engine The engine which the post process will be applied. (default: current engine)
  127998. * @param reusable If the post process can be reused on the same frame. (default: false)
  127999. * @param textureType Type of textures used when performing the post process. (default: 0)
  128000. */
  128001. constructor(name: string,
  128002. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128003. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128004. /**
  128005. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128006. */
  128007. static EdgeDetect0Kernel: number[];
  128008. /**
  128009. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128010. */
  128011. static EdgeDetect1Kernel: number[];
  128012. /**
  128013. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128014. */
  128015. static EdgeDetect2Kernel: number[];
  128016. /**
  128017. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128018. */
  128019. static SharpenKernel: number[];
  128020. /**
  128021. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128022. */
  128023. static EmbossKernel: number[];
  128024. /**
  128025. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128026. */
  128027. static GaussianKernel: number[];
  128028. }
  128029. }
  128030. declare module BABYLON {
  128031. /**
  128032. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128033. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128034. * based on samples that have a large difference in distance than the center pixel.
  128035. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128036. */
  128037. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128038. direction: Vector2;
  128039. /**
  128040. * Creates a new instance CircleOfConfusionPostProcess
  128041. * @param name The name of the effect.
  128042. * @param scene The scene the effect belongs to.
  128043. * @param direction The direction the blur should be applied.
  128044. * @param kernel The size of the kernel used to blur.
  128045. * @param options The required width/height ratio to downsize to before computing the render pass.
  128046. * @param camera The camera to apply the render pass to.
  128047. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128048. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128050. * @param engine The engine which the post process will be applied. (default: current engine)
  128051. * @param reusable If the post process can be reused on the same frame. (default: false)
  128052. * @param textureType Type of textures used when performing the post process. (default: 0)
  128053. * @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)
  128054. */
  128055. 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);
  128056. }
  128057. }
  128058. declare module BABYLON {
  128059. /** @hidden */
  128060. export var depthOfFieldMergePixelShader: {
  128061. name: string;
  128062. shader: string;
  128063. };
  128064. }
  128065. declare module BABYLON {
  128066. /**
  128067. * Options to be set when merging outputs from the default pipeline.
  128068. */
  128069. export class DepthOfFieldMergePostProcessOptions {
  128070. /**
  128071. * The original image to merge on top of
  128072. */
  128073. originalFromInput: PostProcess;
  128074. /**
  128075. * Parameters to perform the merge of the depth of field effect
  128076. */
  128077. depthOfField?: {
  128078. circleOfConfusion: PostProcess;
  128079. blurSteps: Array<PostProcess>;
  128080. };
  128081. /**
  128082. * Parameters to perform the merge of bloom effect
  128083. */
  128084. bloom?: {
  128085. blurred: PostProcess;
  128086. weight: number;
  128087. };
  128088. }
  128089. /**
  128090. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128091. */
  128092. export class DepthOfFieldMergePostProcess extends PostProcess {
  128093. private blurSteps;
  128094. /**
  128095. * Creates a new instance of DepthOfFieldMergePostProcess
  128096. * @param name The name of the effect.
  128097. * @param originalFromInput Post process which's input will be used for the merge.
  128098. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128099. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128100. * @param options The required width/height ratio to downsize to before computing the render pass.
  128101. * @param camera The camera to apply the render pass to.
  128102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128103. * @param engine The engine which the post process will be applied. (default: current engine)
  128104. * @param reusable If the post process can be reused on the same frame. (default: false)
  128105. * @param textureType Type of textures used when performing the post process. (default: 0)
  128106. * @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)
  128107. */
  128108. 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);
  128109. /**
  128110. * Updates the effect with the current post process compile time values and recompiles the shader.
  128111. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128112. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128113. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128114. * @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
  128115. * @param onCompiled Called when the shader has been compiled.
  128116. * @param onError Called if there is an error when compiling a shader.
  128117. */
  128118. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128119. }
  128120. }
  128121. declare module BABYLON {
  128122. /**
  128123. * Specifies the level of max blur that should be applied when using the depth of field effect
  128124. */
  128125. export enum DepthOfFieldEffectBlurLevel {
  128126. /**
  128127. * Subtle blur
  128128. */
  128129. Low = 0,
  128130. /**
  128131. * Medium blur
  128132. */
  128133. Medium = 1,
  128134. /**
  128135. * Large blur
  128136. */
  128137. High = 2
  128138. }
  128139. /**
  128140. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128141. */
  128142. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128143. private _circleOfConfusion;
  128144. /**
  128145. * @hidden Internal, blurs from high to low
  128146. */
  128147. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128148. private _depthOfFieldBlurY;
  128149. private _dofMerge;
  128150. /**
  128151. * @hidden Internal post processes in depth of field effect
  128152. */
  128153. _effects: Array<PostProcess>;
  128154. /**
  128155. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128156. */
  128157. focalLength: number;
  128158. /**
  128159. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128160. */
  128161. fStop: number;
  128162. /**
  128163. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128164. */
  128165. focusDistance: number;
  128166. /**
  128167. * 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.
  128168. */
  128169. lensSize: number;
  128170. /**
  128171. * Creates a new instance DepthOfFieldEffect
  128172. * @param scene The scene the effect belongs to.
  128173. * @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.
  128174. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128175. * @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)
  128176. */
  128177. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128178. /**
  128179. * Get the current class name of the current effet
  128180. * @returns "DepthOfFieldEffect"
  128181. */
  128182. getClassName(): string;
  128183. /**
  128184. * 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.
  128185. */
  128186. depthTexture: RenderTargetTexture;
  128187. /**
  128188. * Disposes each of the internal effects for a given camera.
  128189. * @param camera The camera to dispose the effect on.
  128190. */
  128191. disposeEffects(camera: Camera): void;
  128192. /**
  128193. * @hidden Internal
  128194. */
  128195. _updateEffects(): void;
  128196. /**
  128197. * Internal
  128198. * @returns if all the contained post processes are ready.
  128199. * @hidden
  128200. */
  128201. _isReady(): boolean;
  128202. }
  128203. }
  128204. declare module BABYLON {
  128205. /** @hidden */
  128206. export var displayPassPixelShader: {
  128207. name: string;
  128208. shader: string;
  128209. };
  128210. }
  128211. declare module BABYLON {
  128212. /**
  128213. * DisplayPassPostProcess which produces an output the same as it's input
  128214. */
  128215. export class DisplayPassPostProcess extends PostProcess {
  128216. /**
  128217. * Creates the DisplayPassPostProcess
  128218. * @param name The name of the effect.
  128219. * @param options The required width/height ratio to downsize to before computing the render pass.
  128220. * @param camera The camera to apply the render pass to.
  128221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128222. * @param engine The engine which the post process will be applied. (default: current engine)
  128223. * @param reusable If the post process can be reused on the same frame. (default: false)
  128224. */
  128225. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128226. }
  128227. }
  128228. declare module BABYLON {
  128229. /** @hidden */
  128230. export var filterPixelShader: {
  128231. name: string;
  128232. shader: string;
  128233. };
  128234. }
  128235. declare module BABYLON {
  128236. /**
  128237. * Applies a kernel filter to the image
  128238. */
  128239. export class FilterPostProcess extends PostProcess {
  128240. /** The matrix to be applied to the image */
  128241. kernelMatrix: Matrix;
  128242. /**
  128243. *
  128244. * @param name The name of the effect.
  128245. * @param kernelMatrix The matrix to be applied to the image
  128246. * @param options The required width/height ratio to downsize to before computing the render pass.
  128247. * @param camera The camera to apply the render pass to.
  128248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128249. * @param engine The engine which the post process will be applied. (default: current engine)
  128250. * @param reusable If the post process can be reused on the same frame. (default: false)
  128251. */
  128252. constructor(name: string,
  128253. /** The matrix to be applied to the image */
  128254. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128255. }
  128256. }
  128257. declare module BABYLON {
  128258. /** @hidden */
  128259. export var fxaaPixelShader: {
  128260. name: string;
  128261. shader: string;
  128262. };
  128263. }
  128264. declare module BABYLON {
  128265. /** @hidden */
  128266. export var fxaaVertexShader: {
  128267. name: string;
  128268. shader: string;
  128269. };
  128270. }
  128271. declare module BABYLON {
  128272. /**
  128273. * Fxaa post process
  128274. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  128275. */
  128276. export class FxaaPostProcess extends PostProcess {
  128277. /** @hidden */
  128278. texelWidth: number;
  128279. /** @hidden */
  128280. texelHeight: number;
  128281. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128282. private _getDefines;
  128283. }
  128284. }
  128285. declare module BABYLON {
  128286. /** @hidden */
  128287. export var grainPixelShader: {
  128288. name: string;
  128289. shader: string;
  128290. };
  128291. }
  128292. declare module BABYLON {
  128293. /**
  128294. * The GrainPostProcess adds noise to the image at mid luminance levels
  128295. */
  128296. export class GrainPostProcess extends PostProcess {
  128297. /**
  128298. * The intensity of the grain added (default: 30)
  128299. */
  128300. intensity: number;
  128301. /**
  128302. * If the grain should be randomized on every frame
  128303. */
  128304. animated: boolean;
  128305. /**
  128306. * Creates a new instance of @see GrainPostProcess
  128307. * @param name The name of the effect.
  128308. * @param options The required width/height ratio to downsize to before computing the render pass.
  128309. * @param camera The camera to apply the render pass to.
  128310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128311. * @param engine The engine which the post process will be applied. (default: current engine)
  128312. * @param reusable If the post process can be reused on the same frame. (default: false)
  128313. * @param textureType Type of textures used when performing the post process. (default: 0)
  128314. * @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)
  128315. */
  128316. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128317. }
  128318. }
  128319. declare module BABYLON {
  128320. /** @hidden */
  128321. export var highlightsPixelShader: {
  128322. name: string;
  128323. shader: string;
  128324. };
  128325. }
  128326. declare module BABYLON {
  128327. /**
  128328. * Extracts highlights from the image
  128329. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128330. */
  128331. export class HighlightsPostProcess extends PostProcess {
  128332. /**
  128333. * Extracts highlights from the image
  128334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128335. * @param name The name of the effect.
  128336. * @param options The required width/height ratio to downsize to before computing the render pass.
  128337. * @param camera The camera to apply the render pass to.
  128338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128339. * @param engine The engine which the post process will be applied. (default: current engine)
  128340. * @param reusable If the post process can be reused on the same frame. (default: false)
  128341. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  128342. */
  128343. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128344. }
  128345. }
  128346. declare module BABYLON {
  128347. /** @hidden */
  128348. export var mrtFragmentDeclaration: {
  128349. name: string;
  128350. shader: string;
  128351. };
  128352. }
  128353. declare module BABYLON {
  128354. /** @hidden */
  128355. export var geometryPixelShader: {
  128356. name: string;
  128357. shader: string;
  128358. };
  128359. }
  128360. declare module BABYLON {
  128361. /** @hidden */
  128362. export var geometryVertexShader: {
  128363. name: string;
  128364. shader: string;
  128365. };
  128366. }
  128367. declare module BABYLON {
  128368. /** @hidden */
  128369. interface ISavedTransformationMatrix {
  128370. world: Matrix;
  128371. viewProjection: Matrix;
  128372. }
  128373. /**
  128374. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  128375. */
  128376. export class GeometryBufferRenderer {
  128377. /**
  128378. * Constant used to retrieve the position texture index in the G-Buffer textures array
  128379. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  128380. */
  128381. static readonly POSITION_TEXTURE_TYPE: number;
  128382. /**
  128383. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  128384. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  128385. */
  128386. static readonly VELOCITY_TEXTURE_TYPE: number;
  128387. /**
  128388. * Dictionary used to store the previous transformation matrices of each rendered mesh
  128389. * in order to compute objects velocities when enableVelocity is set to "true"
  128390. * @hidden
  128391. */
  128392. _previousTransformationMatrices: {
  128393. [index: number]: ISavedTransformationMatrix;
  128394. };
  128395. /**
  128396. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  128397. * in order to compute objects velocities when enableVelocity is set to "true"
  128398. * @hidden
  128399. */
  128400. _previousBonesTransformationMatrices: {
  128401. [index: number]: Float32Array;
  128402. };
  128403. /**
  128404. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  128405. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  128406. */
  128407. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  128408. private _scene;
  128409. private _multiRenderTarget;
  128410. private _ratio;
  128411. private _enablePosition;
  128412. private _enableVelocity;
  128413. private _positionIndex;
  128414. private _velocityIndex;
  128415. protected _effect: Effect;
  128416. protected _cachedDefines: string;
  128417. /**
  128418. * Set the render list (meshes to be rendered) used in the G buffer.
  128419. */
  128420. renderList: Mesh[];
  128421. /**
  128422. * Gets wether or not G buffer are supported by the running hardware.
  128423. * This requires draw buffer supports
  128424. */
  128425. readonly isSupported: boolean;
  128426. /**
  128427. * Returns the index of the given texture type in the G-Buffer textures array
  128428. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  128429. * @returns the index of the given texture type in the G-Buffer textures array
  128430. */
  128431. getTextureIndex(textureType: number): number;
  128432. /**
  128433. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  128434. */
  128435. /**
  128436. * Sets whether or not objects positions are enabled for the G buffer.
  128437. */
  128438. enablePosition: boolean;
  128439. /**
  128440. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  128441. */
  128442. /**
  128443. * Sets wether or not objects velocities are enabled for the G buffer.
  128444. */
  128445. enableVelocity: boolean;
  128446. /**
  128447. * Gets the scene associated with the buffer.
  128448. */
  128449. readonly scene: Scene;
  128450. /**
  128451. * Gets the ratio used by the buffer during its creation.
  128452. * How big is the buffer related to the main canvas.
  128453. */
  128454. readonly ratio: number;
  128455. /** @hidden */
  128456. static _SceneComponentInitialization: (scene: Scene) => void;
  128457. /**
  128458. * Creates a new G Buffer for the scene
  128459. * @param scene The scene the buffer belongs to
  128460. * @param ratio How big is the buffer related to the main canvas.
  128461. */
  128462. constructor(scene: Scene, ratio?: number);
  128463. /**
  128464. * Checks wether everything is ready to render a submesh to the G buffer.
  128465. * @param subMesh the submesh to check readiness for
  128466. * @param useInstances is the mesh drawn using instance or not
  128467. * @returns true if ready otherwise false
  128468. */
  128469. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128470. /**
  128471. * Gets the current underlying G Buffer.
  128472. * @returns the buffer
  128473. */
  128474. getGBuffer(): MultiRenderTarget;
  128475. /**
  128476. * Gets the number of samples used to render the buffer (anti aliasing).
  128477. */
  128478. /**
  128479. * Sets the number of samples used to render the buffer (anti aliasing).
  128480. */
  128481. samples: number;
  128482. /**
  128483. * Disposes the renderer and frees up associated resources.
  128484. */
  128485. dispose(): void;
  128486. protected _createRenderTargets(): void;
  128487. private _copyBonesTransformationMatrices;
  128488. }
  128489. }
  128490. declare module BABYLON {
  128491. interface Scene {
  128492. /** @hidden (Backing field) */
  128493. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128494. /**
  128495. * Gets or Sets the current geometry buffer associated to the scene.
  128496. */
  128497. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128498. /**
  128499. * Enables a GeometryBufferRender and associates it with the scene
  128500. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  128501. * @returns the GeometryBufferRenderer
  128502. */
  128503. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  128504. /**
  128505. * Disables the GeometryBufferRender associated with the scene
  128506. */
  128507. disableGeometryBufferRenderer(): void;
  128508. }
  128509. /**
  128510. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  128511. * in several rendering techniques.
  128512. */
  128513. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  128514. /**
  128515. * The component name helpful to identify the component in the list of scene components.
  128516. */
  128517. readonly name: string;
  128518. /**
  128519. * The scene the component belongs to.
  128520. */
  128521. scene: Scene;
  128522. /**
  128523. * Creates a new instance of the component for the given scene
  128524. * @param scene Defines the scene to register the component in
  128525. */
  128526. constructor(scene: Scene);
  128527. /**
  128528. * Registers the component in a given scene
  128529. */
  128530. register(): void;
  128531. /**
  128532. * Rebuilds the elements related to this component in case of
  128533. * context lost for instance.
  128534. */
  128535. rebuild(): void;
  128536. /**
  128537. * Disposes the component and the associated ressources
  128538. */
  128539. dispose(): void;
  128540. private _gatherRenderTargets;
  128541. }
  128542. }
  128543. declare module BABYLON {
  128544. /** @hidden */
  128545. export var motionBlurPixelShader: {
  128546. name: string;
  128547. shader: string;
  128548. };
  128549. }
  128550. declare module BABYLON {
  128551. /**
  128552. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  128553. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  128554. * As an example, all you have to do is to create the post-process:
  128555. * var mb = new BABYLON.MotionBlurPostProcess(
  128556. * 'mb', // The name of the effect.
  128557. * scene, // The scene containing the objects to blur according to their velocity.
  128558. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  128559. * camera // The camera to apply the render pass to.
  128560. * );
  128561. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  128562. */
  128563. export class MotionBlurPostProcess extends PostProcess {
  128564. /**
  128565. * Defines how much the image is blurred by the movement. Default value is equal to 1
  128566. */
  128567. motionStrength: number;
  128568. /**
  128569. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  128570. */
  128571. /**
  128572. * Sets the number of iterations to be used for motion blur quality
  128573. */
  128574. motionBlurSamples: number;
  128575. private _motionBlurSamples;
  128576. private _geometryBufferRenderer;
  128577. /**
  128578. * Creates a new instance MotionBlurPostProcess
  128579. * @param name The name of the effect.
  128580. * @param scene The scene containing the objects to blur according to their velocity.
  128581. * @param options The required width/height ratio to downsize to before computing the render pass.
  128582. * @param camera The camera to apply the render pass to.
  128583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128584. * @param engine The engine which the post process will be applied. (default: current engine)
  128585. * @param reusable If the post process can be reused on the same frame. (default: false)
  128586. * @param textureType Type of textures used when performing the post process. (default: 0)
  128587. * @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)
  128588. */
  128589. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128590. /**
  128591. * Excludes the given skinned mesh from computing bones velocities.
  128592. * 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.
  128593. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  128594. */
  128595. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128596. /**
  128597. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  128598. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  128599. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  128600. */
  128601. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128602. /**
  128603. * Disposes the post process.
  128604. * @param camera The camera to dispose the post process on.
  128605. */
  128606. dispose(camera?: Camera): void;
  128607. }
  128608. }
  128609. declare module BABYLON {
  128610. /** @hidden */
  128611. export var refractionPixelShader: {
  128612. name: string;
  128613. shader: string;
  128614. };
  128615. }
  128616. declare module BABYLON {
  128617. /**
  128618. * Post process which applies a refractin texture
  128619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128620. */
  128621. export class RefractionPostProcess extends PostProcess {
  128622. /** the base color of the refraction (used to taint the rendering) */
  128623. color: Color3;
  128624. /** simulated refraction depth */
  128625. depth: number;
  128626. /** the coefficient of the base color (0 to remove base color tainting) */
  128627. colorLevel: number;
  128628. private _refTexture;
  128629. private _ownRefractionTexture;
  128630. /**
  128631. * Gets or sets the refraction texture
  128632. * Please note that you are responsible for disposing the texture if you set it manually
  128633. */
  128634. refractionTexture: Texture;
  128635. /**
  128636. * Initializes the RefractionPostProcess
  128637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128638. * @param name The name of the effect.
  128639. * @param refractionTextureUrl Url of the refraction texture to use
  128640. * @param color the base color of the refraction (used to taint the rendering)
  128641. * @param depth simulated refraction depth
  128642. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  128643. * @param camera The camera to apply the render pass to.
  128644. * @param options The required width/height ratio to downsize to before computing the render pass.
  128645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128646. * @param engine The engine which the post process will be applied. (default: current engine)
  128647. * @param reusable If the post process can be reused on the same frame. (default: false)
  128648. */
  128649. constructor(name: string, refractionTextureUrl: string,
  128650. /** the base color of the refraction (used to taint the rendering) */
  128651. color: Color3,
  128652. /** simulated refraction depth */
  128653. depth: number,
  128654. /** the coefficient of the base color (0 to remove base color tainting) */
  128655. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128656. /**
  128657. * Disposes of the post process
  128658. * @param camera Camera to dispose post process on
  128659. */
  128660. dispose(camera: Camera): void;
  128661. }
  128662. }
  128663. declare module BABYLON {
  128664. /** @hidden */
  128665. export var sharpenPixelShader: {
  128666. name: string;
  128667. shader: string;
  128668. };
  128669. }
  128670. declare module BABYLON {
  128671. /**
  128672. * The SharpenPostProcess applies a sharpen kernel to every pixel
  128673. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128674. */
  128675. export class SharpenPostProcess extends PostProcess {
  128676. /**
  128677. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  128678. */
  128679. colorAmount: number;
  128680. /**
  128681. * How much sharpness should be applied (default: 0.3)
  128682. */
  128683. edgeAmount: number;
  128684. /**
  128685. * Creates a new instance ConvolutionPostProcess
  128686. * @param name The name of the effect.
  128687. * @param options The required width/height ratio to downsize to before computing the render pass.
  128688. * @param camera The camera to apply the render pass to.
  128689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128690. * @param engine The engine which the post process will be applied. (default: current engine)
  128691. * @param reusable If the post process can be reused on the same frame. (default: false)
  128692. * @param textureType Type of textures used when performing the post process. (default: 0)
  128693. * @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)
  128694. */
  128695. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128696. }
  128697. }
  128698. declare module BABYLON {
  128699. /**
  128700. * PostProcessRenderPipeline
  128701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128702. */
  128703. export class PostProcessRenderPipeline {
  128704. private engine;
  128705. private _renderEffects;
  128706. private _renderEffectsForIsolatedPass;
  128707. /**
  128708. * List of inspectable custom properties (used by the Inspector)
  128709. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  128710. */
  128711. inspectableCustomProperties: IInspectable[];
  128712. /**
  128713. * @hidden
  128714. */
  128715. protected _cameras: Camera[];
  128716. /** @hidden */
  128717. _name: string;
  128718. /**
  128719. * Gets pipeline name
  128720. */
  128721. readonly name: string;
  128722. /** Gets the list of attached cameras */
  128723. readonly cameras: Camera[];
  128724. /**
  128725. * Initializes a PostProcessRenderPipeline
  128726. * @param engine engine to add the pipeline to
  128727. * @param name name of the pipeline
  128728. */
  128729. constructor(engine: Engine, name: string);
  128730. /**
  128731. * Gets the class name
  128732. * @returns "PostProcessRenderPipeline"
  128733. */
  128734. getClassName(): string;
  128735. /**
  128736. * If all the render effects in the pipeline are supported
  128737. */
  128738. readonly isSupported: boolean;
  128739. /**
  128740. * Adds an effect to the pipeline
  128741. * @param renderEffect the effect to add
  128742. */
  128743. addEffect(renderEffect: PostProcessRenderEffect): void;
  128744. /** @hidden */
  128745. _rebuild(): void;
  128746. /** @hidden */
  128747. _enableEffect(renderEffectName: string, cameras: Camera): void;
  128748. /** @hidden */
  128749. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  128750. /** @hidden */
  128751. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  128752. /** @hidden */
  128753. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  128754. /** @hidden */
  128755. _attachCameras(cameras: Camera, unique: boolean): void;
  128756. /** @hidden */
  128757. _attachCameras(cameras: Camera[], unique: boolean): void;
  128758. /** @hidden */
  128759. _detachCameras(cameras: Camera): void;
  128760. /** @hidden */
  128761. _detachCameras(cameras: Nullable<Camera[]>): void;
  128762. /** @hidden */
  128763. _update(): void;
  128764. /** @hidden */
  128765. _reset(): void;
  128766. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  128767. /**
  128768. * Disposes of the pipeline
  128769. */
  128770. dispose(): void;
  128771. }
  128772. }
  128773. declare module BABYLON {
  128774. /**
  128775. * PostProcessRenderPipelineManager class
  128776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128777. */
  128778. export class PostProcessRenderPipelineManager {
  128779. private _renderPipelines;
  128780. /**
  128781. * Initializes a PostProcessRenderPipelineManager
  128782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128783. */
  128784. constructor();
  128785. /**
  128786. * Gets the list of supported render pipelines
  128787. */
  128788. readonly supportedPipelines: PostProcessRenderPipeline[];
  128789. /**
  128790. * Adds a pipeline to the manager
  128791. * @param renderPipeline The pipeline to add
  128792. */
  128793. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  128794. /**
  128795. * Attaches a camera to the pipeline
  128796. * @param renderPipelineName The name of the pipeline to attach to
  128797. * @param cameras the camera to attach
  128798. * @param unique if the camera can be attached multiple times to the pipeline
  128799. */
  128800. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  128801. /**
  128802. * Detaches a camera from the pipeline
  128803. * @param renderPipelineName The name of the pipeline to detach from
  128804. * @param cameras the camera to detach
  128805. */
  128806. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  128807. /**
  128808. * Enables an effect by name on a pipeline
  128809. * @param renderPipelineName the name of the pipeline to enable the effect in
  128810. * @param renderEffectName the name of the effect to enable
  128811. * @param cameras the cameras that the effect should be enabled on
  128812. */
  128813. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128814. /**
  128815. * Disables an effect by name on a pipeline
  128816. * @param renderPipelineName the name of the pipeline to disable the effect in
  128817. * @param renderEffectName the name of the effect to disable
  128818. * @param cameras the cameras that the effect should be disabled on
  128819. */
  128820. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128821. /**
  128822. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  128823. */
  128824. update(): void;
  128825. /** @hidden */
  128826. _rebuild(): void;
  128827. /**
  128828. * Disposes of the manager and pipelines
  128829. */
  128830. dispose(): void;
  128831. }
  128832. }
  128833. declare module BABYLON {
  128834. interface Scene {
  128835. /** @hidden (Backing field) */
  128836. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128837. /**
  128838. * Gets the postprocess render pipeline manager
  128839. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128840. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128841. */
  128842. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128843. }
  128844. /**
  128845. * Defines the Render Pipeline scene component responsible to rendering pipelines
  128846. */
  128847. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  128848. /**
  128849. * The component name helpfull to identify the component in the list of scene components.
  128850. */
  128851. readonly name: string;
  128852. /**
  128853. * The scene the component belongs to.
  128854. */
  128855. scene: Scene;
  128856. /**
  128857. * Creates a new instance of the component for the given scene
  128858. * @param scene Defines the scene to register the component in
  128859. */
  128860. constructor(scene: Scene);
  128861. /**
  128862. * Registers the component in a given scene
  128863. */
  128864. register(): void;
  128865. /**
  128866. * Rebuilds the elements related to this component in case of
  128867. * context lost for instance.
  128868. */
  128869. rebuild(): void;
  128870. /**
  128871. * Disposes the component and the associated ressources
  128872. */
  128873. dispose(): void;
  128874. private _gatherRenderTargets;
  128875. }
  128876. }
  128877. declare module BABYLON {
  128878. /**
  128879. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  128880. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128881. */
  128882. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128883. private _scene;
  128884. private _camerasToBeAttached;
  128885. /**
  128886. * ID of the sharpen post process,
  128887. */
  128888. private readonly SharpenPostProcessId;
  128889. /**
  128890. * @ignore
  128891. * ID of the image processing post process;
  128892. */
  128893. readonly ImageProcessingPostProcessId: string;
  128894. /**
  128895. * @ignore
  128896. * ID of the Fast Approximate Anti-Aliasing post process;
  128897. */
  128898. readonly FxaaPostProcessId: string;
  128899. /**
  128900. * ID of the chromatic aberration post process,
  128901. */
  128902. private readonly ChromaticAberrationPostProcessId;
  128903. /**
  128904. * ID of the grain post process
  128905. */
  128906. private readonly GrainPostProcessId;
  128907. /**
  128908. * Sharpen post process which will apply a sharpen convolution to enhance edges
  128909. */
  128910. sharpen: SharpenPostProcess;
  128911. private _sharpenEffect;
  128912. private bloom;
  128913. /**
  128914. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  128915. */
  128916. depthOfField: DepthOfFieldEffect;
  128917. /**
  128918. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128919. */
  128920. fxaa: FxaaPostProcess;
  128921. /**
  128922. * Image post processing pass used to perform operations such as tone mapping or color grading.
  128923. */
  128924. imageProcessing: ImageProcessingPostProcess;
  128925. /**
  128926. * Chromatic aberration post process which will shift rgb colors in the image
  128927. */
  128928. chromaticAberration: ChromaticAberrationPostProcess;
  128929. private _chromaticAberrationEffect;
  128930. /**
  128931. * Grain post process which add noise to the image
  128932. */
  128933. grain: GrainPostProcess;
  128934. private _grainEffect;
  128935. /**
  128936. * Glow post process which adds a glow to emissive areas of the image
  128937. */
  128938. private _glowLayer;
  128939. /**
  128940. * Animations which can be used to tweak settings over a period of time
  128941. */
  128942. animations: Animation[];
  128943. private _imageProcessingConfigurationObserver;
  128944. private _sharpenEnabled;
  128945. private _bloomEnabled;
  128946. private _depthOfFieldEnabled;
  128947. private _depthOfFieldBlurLevel;
  128948. private _fxaaEnabled;
  128949. private _imageProcessingEnabled;
  128950. private _defaultPipelineTextureType;
  128951. private _bloomScale;
  128952. private _chromaticAberrationEnabled;
  128953. private _grainEnabled;
  128954. private _buildAllowed;
  128955. /**
  128956. * Gets active scene
  128957. */
  128958. readonly scene: Scene;
  128959. /**
  128960. * Enable or disable the sharpen process from the pipeline
  128961. */
  128962. sharpenEnabled: boolean;
  128963. private _resizeObserver;
  128964. private _hardwareScaleLevel;
  128965. private _bloomKernel;
  128966. /**
  128967. * Specifies the size of the bloom blur kernel, relative to the final output size
  128968. */
  128969. bloomKernel: number;
  128970. /**
  128971. * Specifies the weight of the bloom in the final rendering
  128972. */
  128973. private _bloomWeight;
  128974. /**
  128975. * Specifies the luma threshold for the area that will be blurred by the bloom
  128976. */
  128977. private _bloomThreshold;
  128978. private _hdr;
  128979. /**
  128980. * The strength of the bloom.
  128981. */
  128982. bloomWeight: number;
  128983. /**
  128984. * The strength of the bloom.
  128985. */
  128986. bloomThreshold: number;
  128987. /**
  128988. * The scale of the bloom, lower value will provide better performance.
  128989. */
  128990. bloomScale: number;
  128991. /**
  128992. * Enable or disable the bloom from the pipeline
  128993. */
  128994. bloomEnabled: boolean;
  128995. private _rebuildBloom;
  128996. /**
  128997. * If the depth of field is enabled.
  128998. */
  128999. depthOfFieldEnabled: boolean;
  129000. /**
  129001. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129002. */
  129003. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129004. /**
  129005. * If the anti aliasing is enabled.
  129006. */
  129007. fxaaEnabled: boolean;
  129008. private _samples;
  129009. /**
  129010. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129011. */
  129012. samples: number;
  129013. /**
  129014. * If image processing is enabled.
  129015. */
  129016. imageProcessingEnabled: boolean;
  129017. /**
  129018. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129019. */
  129020. glowLayerEnabled: boolean;
  129021. /**
  129022. * Gets the glow layer (or null if not defined)
  129023. */
  129024. readonly glowLayer: Nullable<GlowLayer>;
  129025. /**
  129026. * Enable or disable the chromaticAberration process from the pipeline
  129027. */
  129028. chromaticAberrationEnabled: boolean;
  129029. /**
  129030. * Enable or disable the grain process from the pipeline
  129031. */
  129032. grainEnabled: boolean;
  129033. /**
  129034. * @constructor
  129035. * @param name - The rendering pipeline name (default: "")
  129036. * @param hdr - If high dynamic range textures should be used (default: true)
  129037. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129038. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129039. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129040. */
  129041. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129042. /**
  129043. * Get the class name
  129044. * @returns "DefaultRenderingPipeline"
  129045. */
  129046. getClassName(): string;
  129047. /**
  129048. * Force the compilation of the entire pipeline.
  129049. */
  129050. prepare(): void;
  129051. private _hasCleared;
  129052. private _prevPostProcess;
  129053. private _prevPrevPostProcess;
  129054. private _setAutoClearAndTextureSharing;
  129055. private _depthOfFieldSceneObserver;
  129056. private _buildPipeline;
  129057. private _disposePostProcesses;
  129058. /**
  129059. * Adds a camera to the pipeline
  129060. * @param camera the camera to be added
  129061. */
  129062. addCamera(camera: Camera): void;
  129063. /**
  129064. * Removes a camera from the pipeline
  129065. * @param camera the camera to remove
  129066. */
  129067. removeCamera(camera: Camera): void;
  129068. /**
  129069. * Dispose of the pipeline and stop all post processes
  129070. */
  129071. dispose(): void;
  129072. /**
  129073. * Serialize the rendering pipeline (Used when exporting)
  129074. * @returns the serialized object
  129075. */
  129076. serialize(): any;
  129077. /**
  129078. * Parse the serialized pipeline
  129079. * @param source Source pipeline.
  129080. * @param scene The scene to load the pipeline to.
  129081. * @param rootUrl The URL of the serialized pipeline.
  129082. * @returns An instantiated pipeline from the serialized object.
  129083. */
  129084. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129085. }
  129086. }
  129087. declare module BABYLON {
  129088. /** @hidden */
  129089. export var lensHighlightsPixelShader: {
  129090. name: string;
  129091. shader: string;
  129092. };
  129093. }
  129094. declare module BABYLON {
  129095. /** @hidden */
  129096. export var depthOfFieldPixelShader: {
  129097. name: string;
  129098. shader: string;
  129099. };
  129100. }
  129101. declare module BABYLON {
  129102. /**
  129103. * BABYLON.JS Chromatic Aberration GLSL Shader
  129104. * Author: Olivier Guyot
  129105. * Separates very slightly R, G and B colors on the edges of the screen
  129106. * Inspired by Francois Tarlier & Martins Upitis
  129107. */
  129108. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129109. /**
  129110. * @ignore
  129111. * The chromatic aberration PostProcess id in the pipeline
  129112. */
  129113. LensChromaticAberrationEffect: string;
  129114. /**
  129115. * @ignore
  129116. * The highlights enhancing PostProcess id in the pipeline
  129117. */
  129118. HighlightsEnhancingEffect: string;
  129119. /**
  129120. * @ignore
  129121. * The depth-of-field PostProcess id in the pipeline
  129122. */
  129123. LensDepthOfFieldEffect: string;
  129124. private _scene;
  129125. private _depthTexture;
  129126. private _grainTexture;
  129127. private _chromaticAberrationPostProcess;
  129128. private _highlightsPostProcess;
  129129. private _depthOfFieldPostProcess;
  129130. private _edgeBlur;
  129131. private _grainAmount;
  129132. private _chromaticAberration;
  129133. private _distortion;
  129134. private _highlightsGain;
  129135. private _highlightsThreshold;
  129136. private _dofDistance;
  129137. private _dofAperture;
  129138. private _dofDarken;
  129139. private _dofPentagon;
  129140. private _blurNoise;
  129141. /**
  129142. * @constructor
  129143. *
  129144. * Effect parameters are as follow:
  129145. * {
  129146. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129147. * edge_blur: number; // from 0 to x (1 for realism)
  129148. * distortion: number; // from 0 to x (1 for realism)
  129149. * grain_amount: number; // from 0 to 1
  129150. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129151. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129152. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129153. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129154. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129155. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129156. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129157. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129158. * }
  129159. * Note: if an effect parameter is unset, effect is disabled
  129160. *
  129161. * @param name The rendering pipeline name
  129162. * @param parameters - An object containing all parameters (see above)
  129163. * @param scene The scene linked to this pipeline
  129164. * @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)
  129165. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129166. */
  129167. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129168. /**
  129169. * Get the class name
  129170. * @returns "LensRenderingPipeline"
  129171. */
  129172. getClassName(): string;
  129173. /**
  129174. * Gets associated scene
  129175. */
  129176. readonly scene: Scene;
  129177. /**
  129178. * Gets or sets the edge blur
  129179. */
  129180. edgeBlur: number;
  129181. /**
  129182. * Gets or sets the grain amount
  129183. */
  129184. grainAmount: number;
  129185. /**
  129186. * Gets or sets the chromatic aberration amount
  129187. */
  129188. chromaticAberration: number;
  129189. /**
  129190. * Gets or sets the depth of field aperture
  129191. */
  129192. dofAperture: number;
  129193. /**
  129194. * Gets or sets the edge distortion
  129195. */
  129196. edgeDistortion: number;
  129197. /**
  129198. * Gets or sets the depth of field distortion
  129199. */
  129200. dofDistortion: number;
  129201. /**
  129202. * Gets or sets the darken out of focus amount
  129203. */
  129204. darkenOutOfFocus: number;
  129205. /**
  129206. * Gets or sets a boolean indicating if blur noise is enabled
  129207. */
  129208. blurNoise: boolean;
  129209. /**
  129210. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129211. */
  129212. pentagonBokeh: boolean;
  129213. /**
  129214. * Gets or sets the highlight grain amount
  129215. */
  129216. highlightsGain: number;
  129217. /**
  129218. * Gets or sets the highlight threshold
  129219. */
  129220. highlightsThreshold: number;
  129221. /**
  129222. * Sets the amount of blur at the edges
  129223. * @param amount blur amount
  129224. */
  129225. setEdgeBlur(amount: number): void;
  129226. /**
  129227. * Sets edge blur to 0
  129228. */
  129229. disableEdgeBlur(): void;
  129230. /**
  129231. * Sets the amout of grain
  129232. * @param amount Amount of grain
  129233. */
  129234. setGrainAmount(amount: number): void;
  129235. /**
  129236. * Set grain amount to 0
  129237. */
  129238. disableGrain(): void;
  129239. /**
  129240. * Sets the chromatic aberration amount
  129241. * @param amount amount of chromatic aberration
  129242. */
  129243. setChromaticAberration(amount: number): void;
  129244. /**
  129245. * Sets chromatic aberration amount to 0
  129246. */
  129247. disableChromaticAberration(): void;
  129248. /**
  129249. * Sets the EdgeDistortion amount
  129250. * @param amount amount of EdgeDistortion
  129251. */
  129252. setEdgeDistortion(amount: number): void;
  129253. /**
  129254. * Sets edge distortion to 0
  129255. */
  129256. disableEdgeDistortion(): void;
  129257. /**
  129258. * Sets the FocusDistance amount
  129259. * @param amount amount of FocusDistance
  129260. */
  129261. setFocusDistance(amount: number): void;
  129262. /**
  129263. * Disables depth of field
  129264. */
  129265. disableDepthOfField(): void;
  129266. /**
  129267. * Sets the Aperture amount
  129268. * @param amount amount of Aperture
  129269. */
  129270. setAperture(amount: number): void;
  129271. /**
  129272. * Sets the DarkenOutOfFocus amount
  129273. * @param amount amount of DarkenOutOfFocus
  129274. */
  129275. setDarkenOutOfFocus(amount: number): void;
  129276. private _pentagonBokehIsEnabled;
  129277. /**
  129278. * Creates a pentagon bokeh effect
  129279. */
  129280. enablePentagonBokeh(): void;
  129281. /**
  129282. * Disables the pentagon bokeh effect
  129283. */
  129284. disablePentagonBokeh(): void;
  129285. /**
  129286. * Enables noise blur
  129287. */
  129288. enableNoiseBlur(): void;
  129289. /**
  129290. * Disables noise blur
  129291. */
  129292. disableNoiseBlur(): void;
  129293. /**
  129294. * Sets the HighlightsGain amount
  129295. * @param amount amount of HighlightsGain
  129296. */
  129297. setHighlightsGain(amount: number): void;
  129298. /**
  129299. * Sets the HighlightsThreshold amount
  129300. * @param amount amount of HighlightsThreshold
  129301. */
  129302. setHighlightsThreshold(amount: number): void;
  129303. /**
  129304. * Disables highlights
  129305. */
  129306. disableHighlights(): void;
  129307. /**
  129308. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  129309. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  129310. */
  129311. dispose(disableDepthRender?: boolean): void;
  129312. private _createChromaticAberrationPostProcess;
  129313. private _createHighlightsPostProcess;
  129314. private _createDepthOfFieldPostProcess;
  129315. private _createGrainTexture;
  129316. }
  129317. }
  129318. declare module BABYLON {
  129319. /** @hidden */
  129320. export var ssao2PixelShader: {
  129321. name: string;
  129322. shader: string;
  129323. };
  129324. }
  129325. declare module BABYLON {
  129326. /** @hidden */
  129327. export var ssaoCombinePixelShader: {
  129328. name: string;
  129329. shader: string;
  129330. };
  129331. }
  129332. declare module BABYLON {
  129333. /**
  129334. * Render pipeline to produce ssao effect
  129335. */
  129336. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  129337. /**
  129338. * @ignore
  129339. * The PassPostProcess id in the pipeline that contains the original scene color
  129340. */
  129341. SSAOOriginalSceneColorEffect: string;
  129342. /**
  129343. * @ignore
  129344. * The SSAO PostProcess id in the pipeline
  129345. */
  129346. SSAORenderEffect: string;
  129347. /**
  129348. * @ignore
  129349. * The horizontal blur PostProcess id in the pipeline
  129350. */
  129351. SSAOBlurHRenderEffect: string;
  129352. /**
  129353. * @ignore
  129354. * The vertical blur PostProcess id in the pipeline
  129355. */
  129356. SSAOBlurVRenderEffect: string;
  129357. /**
  129358. * @ignore
  129359. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129360. */
  129361. SSAOCombineRenderEffect: string;
  129362. /**
  129363. * The output strength of the SSAO post-process. Default value is 1.0.
  129364. */
  129365. totalStrength: number;
  129366. /**
  129367. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  129368. */
  129369. maxZ: number;
  129370. /**
  129371. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  129372. */
  129373. minZAspect: number;
  129374. private _samples;
  129375. /**
  129376. * Number of samples used for the SSAO calculations. Default value is 8
  129377. */
  129378. samples: number;
  129379. private _textureSamples;
  129380. /**
  129381. * Number of samples to use for antialiasing
  129382. */
  129383. textureSamples: number;
  129384. /**
  129385. * Ratio object used for SSAO ratio and blur ratio
  129386. */
  129387. private _ratio;
  129388. /**
  129389. * Dynamically generated sphere sampler.
  129390. */
  129391. private _sampleSphere;
  129392. /**
  129393. * Blur filter offsets
  129394. */
  129395. private _samplerOffsets;
  129396. private _expensiveBlur;
  129397. /**
  129398. * If bilateral blur should be used
  129399. */
  129400. expensiveBlur: boolean;
  129401. /**
  129402. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  129403. */
  129404. radius: number;
  129405. /**
  129406. * The base color of the SSAO post-process
  129407. * The final result is "base + ssao" between [0, 1]
  129408. */
  129409. base: number;
  129410. /**
  129411. * Support test.
  129412. */
  129413. static readonly IsSupported: boolean;
  129414. private _scene;
  129415. private _depthTexture;
  129416. private _normalTexture;
  129417. private _randomTexture;
  129418. private _originalColorPostProcess;
  129419. private _ssaoPostProcess;
  129420. private _blurHPostProcess;
  129421. private _blurVPostProcess;
  129422. private _ssaoCombinePostProcess;
  129423. private _firstUpdate;
  129424. /**
  129425. * Gets active scene
  129426. */
  129427. readonly scene: Scene;
  129428. /**
  129429. * @constructor
  129430. * @param name The rendering pipeline name
  129431. * @param scene The scene linked to this pipeline
  129432. * @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 }
  129433. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129434. */
  129435. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129436. /**
  129437. * Get the class name
  129438. * @returns "SSAO2RenderingPipeline"
  129439. */
  129440. getClassName(): string;
  129441. /**
  129442. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129443. */
  129444. dispose(disableGeometryBufferRenderer?: boolean): void;
  129445. private _createBlurPostProcess;
  129446. /** @hidden */
  129447. _rebuild(): void;
  129448. private _bits;
  129449. private _radicalInverse_VdC;
  129450. private _hammersley;
  129451. private _hemisphereSample_uniform;
  129452. private _generateHemisphere;
  129453. private _createSSAOPostProcess;
  129454. private _createSSAOCombinePostProcess;
  129455. private _createRandomTexture;
  129456. /**
  129457. * Serialize the rendering pipeline (Used when exporting)
  129458. * @returns the serialized object
  129459. */
  129460. serialize(): any;
  129461. /**
  129462. * Parse the serialized pipeline
  129463. * @param source Source pipeline.
  129464. * @param scene The scene to load the pipeline to.
  129465. * @param rootUrl The URL of the serialized pipeline.
  129466. * @returns An instantiated pipeline from the serialized object.
  129467. */
  129468. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  129469. }
  129470. }
  129471. declare module BABYLON {
  129472. /** @hidden */
  129473. export var ssaoPixelShader: {
  129474. name: string;
  129475. shader: string;
  129476. };
  129477. }
  129478. declare module BABYLON {
  129479. /**
  129480. * Render pipeline to produce ssao effect
  129481. */
  129482. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  129483. /**
  129484. * @ignore
  129485. * The PassPostProcess id in the pipeline that contains the original scene color
  129486. */
  129487. SSAOOriginalSceneColorEffect: string;
  129488. /**
  129489. * @ignore
  129490. * The SSAO PostProcess id in the pipeline
  129491. */
  129492. SSAORenderEffect: string;
  129493. /**
  129494. * @ignore
  129495. * The horizontal blur PostProcess id in the pipeline
  129496. */
  129497. SSAOBlurHRenderEffect: string;
  129498. /**
  129499. * @ignore
  129500. * The vertical blur PostProcess id in the pipeline
  129501. */
  129502. SSAOBlurVRenderEffect: string;
  129503. /**
  129504. * @ignore
  129505. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129506. */
  129507. SSAOCombineRenderEffect: string;
  129508. /**
  129509. * The output strength of the SSAO post-process. Default value is 1.0.
  129510. */
  129511. totalStrength: number;
  129512. /**
  129513. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  129514. */
  129515. radius: number;
  129516. /**
  129517. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  129518. * Must not be equal to fallOff and superior to fallOff.
  129519. * Default value is 0.0075
  129520. */
  129521. area: number;
  129522. /**
  129523. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  129524. * Must not be equal to area and inferior to area.
  129525. * Default value is 0.000001
  129526. */
  129527. fallOff: number;
  129528. /**
  129529. * The base color of the SSAO post-process
  129530. * The final result is "base + ssao" between [0, 1]
  129531. */
  129532. base: number;
  129533. private _scene;
  129534. private _depthTexture;
  129535. private _randomTexture;
  129536. private _originalColorPostProcess;
  129537. private _ssaoPostProcess;
  129538. private _blurHPostProcess;
  129539. private _blurVPostProcess;
  129540. private _ssaoCombinePostProcess;
  129541. private _firstUpdate;
  129542. /**
  129543. * Gets active scene
  129544. */
  129545. readonly scene: Scene;
  129546. /**
  129547. * @constructor
  129548. * @param name - The rendering pipeline name
  129549. * @param scene - The scene linked to this pipeline
  129550. * @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 }
  129551. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  129552. */
  129553. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129554. /**
  129555. * Get the class name
  129556. * @returns "SSAORenderingPipeline"
  129557. */
  129558. getClassName(): string;
  129559. /**
  129560. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129561. */
  129562. dispose(disableDepthRender?: boolean): void;
  129563. private _createBlurPostProcess;
  129564. /** @hidden */
  129565. _rebuild(): void;
  129566. private _createSSAOPostProcess;
  129567. private _createSSAOCombinePostProcess;
  129568. private _createRandomTexture;
  129569. }
  129570. }
  129571. declare module BABYLON {
  129572. /** @hidden */
  129573. export var standardPixelShader: {
  129574. name: string;
  129575. shader: string;
  129576. };
  129577. }
  129578. declare module BABYLON {
  129579. /**
  129580. * Standard rendering pipeline
  129581. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129582. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  129583. */
  129584. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129585. /**
  129586. * Public members
  129587. */
  129588. /**
  129589. * Post-process which contains the original scene color before the pipeline applies all the effects
  129590. */
  129591. originalPostProcess: Nullable<PostProcess>;
  129592. /**
  129593. * Post-process used to down scale an image x4
  129594. */
  129595. downSampleX4PostProcess: Nullable<PostProcess>;
  129596. /**
  129597. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  129598. */
  129599. brightPassPostProcess: Nullable<PostProcess>;
  129600. /**
  129601. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  129602. */
  129603. blurHPostProcesses: PostProcess[];
  129604. /**
  129605. * Post-process array storing all the vertical blur post-processes used by the pipeline
  129606. */
  129607. blurVPostProcesses: PostProcess[];
  129608. /**
  129609. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  129610. */
  129611. textureAdderPostProcess: Nullable<PostProcess>;
  129612. /**
  129613. * Post-process used to create volumetric lighting effect
  129614. */
  129615. volumetricLightPostProcess: Nullable<PostProcess>;
  129616. /**
  129617. * Post-process used to smooth the previous volumetric light post-process on the X axis
  129618. */
  129619. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  129620. /**
  129621. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  129622. */
  129623. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  129624. /**
  129625. * Post-process used to merge the volumetric light effect and the real scene color
  129626. */
  129627. volumetricLightMergePostProces: Nullable<PostProcess>;
  129628. /**
  129629. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  129630. */
  129631. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  129632. /**
  129633. * Base post-process used to calculate the average luminance of the final image for HDR
  129634. */
  129635. luminancePostProcess: Nullable<PostProcess>;
  129636. /**
  129637. * Post-processes used to create down sample post-processes in order to get
  129638. * the average luminance of the final image for HDR
  129639. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  129640. */
  129641. luminanceDownSamplePostProcesses: PostProcess[];
  129642. /**
  129643. * Post-process used to create a HDR effect (light adaptation)
  129644. */
  129645. hdrPostProcess: Nullable<PostProcess>;
  129646. /**
  129647. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  129648. */
  129649. textureAdderFinalPostProcess: Nullable<PostProcess>;
  129650. /**
  129651. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  129652. */
  129653. lensFlareFinalPostProcess: Nullable<PostProcess>;
  129654. /**
  129655. * Post-process used to merge the final HDR post-process and the real scene color
  129656. */
  129657. hdrFinalPostProcess: Nullable<PostProcess>;
  129658. /**
  129659. * Post-process used to create a lens flare effect
  129660. */
  129661. lensFlarePostProcess: Nullable<PostProcess>;
  129662. /**
  129663. * Post-process that merges the result of the lens flare post-process and the real scene color
  129664. */
  129665. lensFlareComposePostProcess: Nullable<PostProcess>;
  129666. /**
  129667. * Post-process used to create a motion blur effect
  129668. */
  129669. motionBlurPostProcess: Nullable<PostProcess>;
  129670. /**
  129671. * Post-process used to create a depth of field effect
  129672. */
  129673. depthOfFieldPostProcess: Nullable<PostProcess>;
  129674. /**
  129675. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129676. */
  129677. fxaaPostProcess: Nullable<FxaaPostProcess>;
  129678. /**
  129679. * Represents the brightness threshold in order to configure the illuminated surfaces
  129680. */
  129681. brightThreshold: number;
  129682. /**
  129683. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  129684. */
  129685. blurWidth: number;
  129686. /**
  129687. * Sets if the blur for highlighted surfaces must be only horizontal
  129688. */
  129689. horizontalBlur: boolean;
  129690. /**
  129691. * Gets the overall exposure used by the pipeline
  129692. */
  129693. /**
  129694. * Sets the overall exposure used by the pipeline
  129695. */
  129696. exposure: number;
  129697. /**
  129698. * Texture used typically to simulate "dirty" on camera lens
  129699. */
  129700. lensTexture: Nullable<Texture>;
  129701. /**
  129702. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  129703. */
  129704. volumetricLightCoefficient: number;
  129705. /**
  129706. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  129707. */
  129708. volumetricLightPower: number;
  129709. /**
  129710. * Used the set the blur intensity to smooth the volumetric lights
  129711. */
  129712. volumetricLightBlurScale: number;
  129713. /**
  129714. * Light (spot or directional) used to generate the volumetric lights rays
  129715. * The source light must have a shadow generate so the pipeline can get its
  129716. * depth map
  129717. */
  129718. sourceLight: Nullable<SpotLight | DirectionalLight>;
  129719. /**
  129720. * For eye adaptation, represents the minimum luminance the eye can see
  129721. */
  129722. hdrMinimumLuminance: number;
  129723. /**
  129724. * For eye adaptation, represents the decrease luminance speed
  129725. */
  129726. hdrDecreaseRate: number;
  129727. /**
  129728. * For eye adaptation, represents the increase luminance speed
  129729. */
  129730. hdrIncreaseRate: number;
  129731. /**
  129732. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129733. */
  129734. /**
  129735. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129736. */
  129737. hdrAutoExposure: boolean;
  129738. /**
  129739. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  129740. */
  129741. lensColorTexture: Nullable<Texture>;
  129742. /**
  129743. * The overall strengh for the lens flare effect
  129744. */
  129745. lensFlareStrength: number;
  129746. /**
  129747. * Dispersion coefficient for lens flare ghosts
  129748. */
  129749. lensFlareGhostDispersal: number;
  129750. /**
  129751. * Main lens flare halo width
  129752. */
  129753. lensFlareHaloWidth: number;
  129754. /**
  129755. * Based on the lens distortion effect, defines how much the lens flare result
  129756. * is distorted
  129757. */
  129758. lensFlareDistortionStrength: number;
  129759. /**
  129760. * Configures the blur intensity used for for lens flare (halo)
  129761. */
  129762. lensFlareBlurWidth: number;
  129763. /**
  129764. * Lens star texture must be used to simulate rays on the flares and is available
  129765. * in the documentation
  129766. */
  129767. lensStarTexture: Nullable<Texture>;
  129768. /**
  129769. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  129770. * flare effect by taking account of the dirt texture
  129771. */
  129772. lensFlareDirtTexture: Nullable<Texture>;
  129773. /**
  129774. * Represents the focal length for the depth of field effect
  129775. */
  129776. depthOfFieldDistance: number;
  129777. /**
  129778. * Represents the blur intensity for the blurred part of the depth of field effect
  129779. */
  129780. depthOfFieldBlurWidth: number;
  129781. /**
  129782. * Gets how much the image is blurred by the movement while using the motion blur post-process
  129783. */
  129784. /**
  129785. * Sets how much the image is blurred by the movement while using the motion blur post-process
  129786. */
  129787. motionStrength: number;
  129788. /**
  129789. * Gets wether or not the motion blur post-process is object based or screen based.
  129790. */
  129791. /**
  129792. * Sets wether or not the motion blur post-process should be object based or screen based
  129793. */
  129794. objectBasedMotionBlur: boolean;
  129795. /**
  129796. * List of animations for the pipeline (IAnimatable implementation)
  129797. */
  129798. animations: Animation[];
  129799. /**
  129800. * Private members
  129801. */
  129802. private _scene;
  129803. private _currentDepthOfFieldSource;
  129804. private _basePostProcess;
  129805. private _fixedExposure;
  129806. private _currentExposure;
  129807. private _hdrAutoExposure;
  129808. private _hdrCurrentLuminance;
  129809. private _motionStrength;
  129810. private _isObjectBasedMotionBlur;
  129811. private _floatTextureType;
  129812. private _camerasToBeAttached;
  129813. private _ratio;
  129814. private _bloomEnabled;
  129815. private _depthOfFieldEnabled;
  129816. private _vlsEnabled;
  129817. private _lensFlareEnabled;
  129818. private _hdrEnabled;
  129819. private _motionBlurEnabled;
  129820. private _fxaaEnabled;
  129821. private _motionBlurSamples;
  129822. private _volumetricLightStepsCount;
  129823. private _samples;
  129824. /**
  129825. * @ignore
  129826. * Specifies if the bloom pipeline is enabled
  129827. */
  129828. BloomEnabled: boolean;
  129829. /**
  129830. * @ignore
  129831. * Specifies if the depth of field pipeline is enabed
  129832. */
  129833. DepthOfFieldEnabled: boolean;
  129834. /**
  129835. * @ignore
  129836. * Specifies if the lens flare pipeline is enabed
  129837. */
  129838. LensFlareEnabled: boolean;
  129839. /**
  129840. * @ignore
  129841. * Specifies if the HDR pipeline is enabled
  129842. */
  129843. HDREnabled: boolean;
  129844. /**
  129845. * @ignore
  129846. * Specifies if the volumetric lights scattering effect is enabled
  129847. */
  129848. VLSEnabled: boolean;
  129849. /**
  129850. * @ignore
  129851. * Specifies if the motion blur effect is enabled
  129852. */
  129853. MotionBlurEnabled: boolean;
  129854. /**
  129855. * Specifies if anti-aliasing is enabled
  129856. */
  129857. fxaaEnabled: boolean;
  129858. /**
  129859. * Specifies the number of steps used to calculate the volumetric lights
  129860. * Typically in interval [50, 200]
  129861. */
  129862. volumetricLightStepsCount: number;
  129863. /**
  129864. * Specifies the number of samples used for the motion blur effect
  129865. * Typically in interval [16, 64]
  129866. */
  129867. motionBlurSamples: number;
  129868. /**
  129869. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129870. */
  129871. samples: number;
  129872. /**
  129873. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129874. * @constructor
  129875. * @param name The rendering pipeline name
  129876. * @param scene The scene linked to this pipeline
  129877. * @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)
  129878. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  129879. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129880. */
  129881. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  129882. private _buildPipeline;
  129883. private _createDownSampleX4PostProcess;
  129884. private _createBrightPassPostProcess;
  129885. private _createBlurPostProcesses;
  129886. private _createTextureAdderPostProcess;
  129887. private _createVolumetricLightPostProcess;
  129888. private _createLuminancePostProcesses;
  129889. private _createHdrPostProcess;
  129890. private _createLensFlarePostProcess;
  129891. private _createDepthOfFieldPostProcess;
  129892. private _createMotionBlurPostProcess;
  129893. private _getDepthTexture;
  129894. private _disposePostProcesses;
  129895. /**
  129896. * Dispose of the pipeline and stop all post processes
  129897. */
  129898. dispose(): void;
  129899. /**
  129900. * Serialize the rendering pipeline (Used when exporting)
  129901. * @returns the serialized object
  129902. */
  129903. serialize(): any;
  129904. /**
  129905. * Parse the serialized pipeline
  129906. * @param source Source pipeline.
  129907. * @param scene The scene to load the pipeline to.
  129908. * @param rootUrl The URL of the serialized pipeline.
  129909. * @returns An instantiated pipeline from the serialized object.
  129910. */
  129911. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  129912. /**
  129913. * Luminance steps
  129914. */
  129915. static LuminanceSteps: number;
  129916. }
  129917. }
  129918. declare module BABYLON {
  129919. /** @hidden */
  129920. export var tonemapPixelShader: {
  129921. name: string;
  129922. shader: string;
  129923. };
  129924. }
  129925. declare module BABYLON {
  129926. /** Defines operator used for tonemapping */
  129927. export enum TonemappingOperator {
  129928. /** Hable */
  129929. Hable = 0,
  129930. /** Reinhard */
  129931. Reinhard = 1,
  129932. /** HejiDawson */
  129933. HejiDawson = 2,
  129934. /** Photographic */
  129935. Photographic = 3
  129936. }
  129937. /**
  129938. * Defines a post process to apply tone mapping
  129939. */
  129940. export class TonemapPostProcess extends PostProcess {
  129941. private _operator;
  129942. /** Defines the required exposure adjustement */
  129943. exposureAdjustment: number;
  129944. /**
  129945. * Creates a new TonemapPostProcess
  129946. * @param name defines the name of the postprocess
  129947. * @param _operator defines the operator to use
  129948. * @param exposureAdjustment defines the required exposure adjustement
  129949. * @param camera defines the camera to use (can be null)
  129950. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  129951. * @param engine defines the hosting engine (can be ignore if camera is set)
  129952. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129953. */
  129954. constructor(name: string, _operator: TonemappingOperator,
  129955. /** Defines the required exposure adjustement */
  129956. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  129957. }
  129958. }
  129959. declare module BABYLON {
  129960. /** @hidden */
  129961. export var depthVertexShader: {
  129962. name: string;
  129963. shader: string;
  129964. };
  129965. }
  129966. declare module BABYLON {
  129967. /** @hidden */
  129968. export var volumetricLightScatteringPixelShader: {
  129969. name: string;
  129970. shader: string;
  129971. };
  129972. }
  129973. declare module BABYLON {
  129974. /** @hidden */
  129975. export var volumetricLightScatteringPassVertexShader: {
  129976. name: string;
  129977. shader: string;
  129978. };
  129979. }
  129980. declare module BABYLON {
  129981. /** @hidden */
  129982. export var volumetricLightScatteringPassPixelShader: {
  129983. name: string;
  129984. shader: string;
  129985. };
  129986. }
  129987. declare module BABYLON {
  129988. /**
  129989. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  129990. */
  129991. export class VolumetricLightScatteringPostProcess extends PostProcess {
  129992. private _volumetricLightScatteringPass;
  129993. private _volumetricLightScatteringRTT;
  129994. private _viewPort;
  129995. private _screenCoordinates;
  129996. private _cachedDefines;
  129997. /**
  129998. * If not undefined, the mesh position is computed from the attached node position
  129999. */
  130000. attachedNode: {
  130001. position: Vector3;
  130002. };
  130003. /**
  130004. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130005. */
  130006. customMeshPosition: Vector3;
  130007. /**
  130008. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130009. */
  130010. useCustomMeshPosition: boolean;
  130011. /**
  130012. * If the post-process should inverse the light scattering direction
  130013. */
  130014. invert: boolean;
  130015. /**
  130016. * The internal mesh used by the post-process
  130017. */
  130018. mesh: Mesh;
  130019. /**
  130020. * @hidden
  130021. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130022. */
  130023. useDiffuseColor: boolean;
  130024. /**
  130025. * Array containing the excluded meshes not rendered in the internal pass
  130026. */
  130027. excludedMeshes: AbstractMesh[];
  130028. /**
  130029. * Controls the overall intensity of the post-process
  130030. */
  130031. exposure: number;
  130032. /**
  130033. * Dissipates each sample's contribution in range [0, 1]
  130034. */
  130035. decay: number;
  130036. /**
  130037. * Controls the overall intensity of each sample
  130038. */
  130039. weight: number;
  130040. /**
  130041. * Controls the density of each sample
  130042. */
  130043. density: number;
  130044. /**
  130045. * @constructor
  130046. * @param name The post-process name
  130047. * @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)
  130048. * @param camera The camera that the post-process will be attached to
  130049. * @param mesh The mesh used to create the light scattering
  130050. * @param samples The post-process quality, default 100
  130051. * @param samplingModeThe post-process filtering mode
  130052. * @param engine The babylon engine
  130053. * @param reusable If the post-process is reusable
  130054. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130055. */
  130056. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130057. /**
  130058. * Returns the string "VolumetricLightScatteringPostProcess"
  130059. * @returns "VolumetricLightScatteringPostProcess"
  130060. */
  130061. getClassName(): string;
  130062. private _isReady;
  130063. /**
  130064. * Sets the new light position for light scattering effect
  130065. * @param position The new custom light position
  130066. */
  130067. setCustomMeshPosition(position: Vector3): void;
  130068. /**
  130069. * Returns the light position for light scattering effect
  130070. * @return Vector3 The custom light position
  130071. */
  130072. getCustomMeshPosition(): Vector3;
  130073. /**
  130074. * Disposes the internal assets and detaches the post-process from the camera
  130075. */
  130076. dispose(camera: Camera): void;
  130077. /**
  130078. * Returns the render target texture used by the post-process
  130079. * @return the render target texture used by the post-process
  130080. */
  130081. getPass(): RenderTargetTexture;
  130082. private _meshExcluded;
  130083. private _createPass;
  130084. private _updateMeshScreenCoordinates;
  130085. /**
  130086. * Creates a default mesh for the Volumeric Light Scattering post-process
  130087. * @param name The mesh name
  130088. * @param scene The scene where to create the mesh
  130089. * @return the default mesh
  130090. */
  130091. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130092. }
  130093. }
  130094. declare module BABYLON {
  130095. interface Scene {
  130096. /** @hidden (Backing field) */
  130097. _boundingBoxRenderer: BoundingBoxRenderer;
  130098. /** @hidden (Backing field) */
  130099. _forceShowBoundingBoxes: boolean;
  130100. /**
  130101. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130102. */
  130103. forceShowBoundingBoxes: boolean;
  130104. /**
  130105. * Gets the bounding box renderer associated with the scene
  130106. * @returns a BoundingBoxRenderer
  130107. */
  130108. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130109. }
  130110. interface AbstractMesh {
  130111. /** @hidden (Backing field) */
  130112. _showBoundingBox: boolean;
  130113. /**
  130114. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130115. */
  130116. showBoundingBox: boolean;
  130117. }
  130118. /**
  130119. * Component responsible of rendering the bounding box of the meshes in a scene.
  130120. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130121. */
  130122. export class BoundingBoxRenderer implements ISceneComponent {
  130123. /**
  130124. * The component name helpfull to identify the component in the list of scene components.
  130125. */
  130126. readonly name: string;
  130127. /**
  130128. * The scene the component belongs to.
  130129. */
  130130. scene: Scene;
  130131. /**
  130132. * Color of the bounding box lines placed in front of an object
  130133. */
  130134. frontColor: Color3;
  130135. /**
  130136. * Color of the bounding box lines placed behind an object
  130137. */
  130138. backColor: Color3;
  130139. /**
  130140. * Defines if the renderer should show the back lines or not
  130141. */
  130142. showBackLines: boolean;
  130143. /**
  130144. * @hidden
  130145. */
  130146. renderList: SmartArray<BoundingBox>;
  130147. private _colorShader;
  130148. private _vertexBuffers;
  130149. private _indexBuffer;
  130150. private _fillIndexBuffer;
  130151. private _fillIndexData;
  130152. /**
  130153. * Instantiates a new bounding box renderer in a scene.
  130154. * @param scene the scene the renderer renders in
  130155. */
  130156. constructor(scene: Scene);
  130157. /**
  130158. * Registers the component in a given scene
  130159. */
  130160. register(): void;
  130161. private _evaluateSubMesh;
  130162. private _activeMesh;
  130163. private _prepareRessources;
  130164. private _createIndexBuffer;
  130165. /**
  130166. * Rebuilds the elements related to this component in case of
  130167. * context lost for instance.
  130168. */
  130169. rebuild(): void;
  130170. /**
  130171. * @hidden
  130172. */
  130173. reset(): void;
  130174. /**
  130175. * Render the bounding boxes of a specific rendering group
  130176. * @param renderingGroupId defines the rendering group to render
  130177. */
  130178. render(renderingGroupId: number): void;
  130179. /**
  130180. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130181. * @param mesh Define the mesh to render the occlusion bounding box for
  130182. */
  130183. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130184. /**
  130185. * Dispose and release the resources attached to this renderer.
  130186. */
  130187. dispose(): void;
  130188. }
  130189. }
  130190. declare module BABYLON {
  130191. /** @hidden */
  130192. export var depthPixelShader: {
  130193. name: string;
  130194. shader: string;
  130195. };
  130196. }
  130197. declare module BABYLON {
  130198. /**
  130199. * This represents a depth renderer in Babylon.
  130200. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130201. */
  130202. export class DepthRenderer {
  130203. private _scene;
  130204. private _depthMap;
  130205. private _effect;
  130206. private readonly _storeNonLinearDepth;
  130207. private readonly _clearColor;
  130208. /** Get if the depth renderer is using packed depth or not */
  130209. readonly isPacked: boolean;
  130210. private _cachedDefines;
  130211. private _camera;
  130212. /**
  130213. * Specifiess that the depth renderer will only be used within
  130214. * the camera it is created for.
  130215. * This can help forcing its rendering during the camera processing.
  130216. */
  130217. useOnlyInActiveCamera: boolean;
  130218. /** @hidden */
  130219. static _SceneComponentInitialization: (scene: Scene) => void;
  130220. /**
  130221. * Instantiates a depth renderer
  130222. * @param scene The scene the renderer belongs to
  130223. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130224. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130225. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130226. */
  130227. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130228. /**
  130229. * Creates the depth rendering effect and checks if the effect is ready.
  130230. * @param subMesh The submesh to be used to render the depth map of
  130231. * @param useInstances If multiple world instances should be used
  130232. * @returns if the depth renderer is ready to render the depth map
  130233. */
  130234. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130235. /**
  130236. * Gets the texture which the depth map will be written to.
  130237. * @returns The depth map texture
  130238. */
  130239. getDepthMap(): RenderTargetTexture;
  130240. /**
  130241. * Disposes of the depth renderer.
  130242. */
  130243. dispose(): void;
  130244. }
  130245. }
  130246. declare module BABYLON {
  130247. interface Scene {
  130248. /** @hidden (Backing field) */
  130249. _depthRenderer: {
  130250. [id: string]: DepthRenderer;
  130251. };
  130252. /**
  130253. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130254. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130255. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130256. * @returns the created depth renderer
  130257. */
  130258. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130259. /**
  130260. * Disables a depth renderer for a given camera
  130261. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130262. */
  130263. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130264. }
  130265. /**
  130266. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130267. * in several rendering techniques.
  130268. */
  130269. export class DepthRendererSceneComponent implements ISceneComponent {
  130270. /**
  130271. * The component name helpfull to identify the component in the list of scene components.
  130272. */
  130273. readonly name: string;
  130274. /**
  130275. * The scene the component belongs to.
  130276. */
  130277. scene: Scene;
  130278. /**
  130279. * Creates a new instance of the component for the given scene
  130280. * @param scene Defines the scene to register the component in
  130281. */
  130282. constructor(scene: Scene);
  130283. /**
  130284. * Registers the component in a given scene
  130285. */
  130286. register(): void;
  130287. /**
  130288. * Rebuilds the elements related to this component in case of
  130289. * context lost for instance.
  130290. */
  130291. rebuild(): void;
  130292. /**
  130293. * Disposes the component and the associated ressources
  130294. */
  130295. dispose(): void;
  130296. private _gatherRenderTargets;
  130297. private _gatherActiveCameraRenderTargets;
  130298. }
  130299. }
  130300. declare module BABYLON {
  130301. /** @hidden */
  130302. export var outlinePixelShader: {
  130303. name: string;
  130304. shader: string;
  130305. };
  130306. }
  130307. declare module BABYLON {
  130308. /** @hidden */
  130309. export var outlineVertexShader: {
  130310. name: string;
  130311. shader: string;
  130312. };
  130313. }
  130314. declare module BABYLON {
  130315. interface Scene {
  130316. /** @hidden */
  130317. _outlineRenderer: OutlineRenderer;
  130318. /**
  130319. * Gets the outline renderer associated with the scene
  130320. * @returns a OutlineRenderer
  130321. */
  130322. getOutlineRenderer(): OutlineRenderer;
  130323. }
  130324. interface AbstractMesh {
  130325. /** @hidden (Backing field) */
  130326. _renderOutline: boolean;
  130327. /**
  130328. * Gets or sets a boolean indicating if the outline must be rendered as well
  130329. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  130330. */
  130331. renderOutline: boolean;
  130332. /** @hidden (Backing field) */
  130333. _renderOverlay: boolean;
  130334. /**
  130335. * Gets or sets a boolean indicating if the overlay must be rendered as well
  130336. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  130337. */
  130338. renderOverlay: boolean;
  130339. }
  130340. /**
  130341. * This class is responsible to draw bothe outline/overlay of meshes.
  130342. * It should not be used directly but through the available method on mesh.
  130343. */
  130344. export class OutlineRenderer implements ISceneComponent {
  130345. /**
  130346. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130347. */
  130348. private static _StencilReference;
  130349. /**
  130350. * The name of the component. Each component must have a unique name.
  130351. */
  130352. name: string;
  130353. /**
  130354. * The scene the component belongs to.
  130355. */
  130356. scene: Scene;
  130357. /**
  130358. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  130359. */
  130360. zOffset: number;
  130361. private _engine;
  130362. private _effect;
  130363. private _cachedDefines;
  130364. private _savedDepthWrite;
  130365. /**
  130366. * Instantiates a new outline renderer. (There could be only one per scene).
  130367. * @param scene Defines the scene it belongs to
  130368. */
  130369. constructor(scene: Scene);
  130370. /**
  130371. * Register the component to one instance of a scene.
  130372. */
  130373. register(): void;
  130374. /**
  130375. * Rebuilds the elements related to this component in case of
  130376. * context lost for instance.
  130377. */
  130378. rebuild(): void;
  130379. /**
  130380. * Disposes the component and the associated ressources.
  130381. */
  130382. dispose(): void;
  130383. /**
  130384. * Renders the outline in the canvas.
  130385. * @param subMesh Defines the sumesh to render
  130386. * @param batch Defines the batch of meshes in case of instances
  130387. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130388. */
  130389. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  130390. /**
  130391. * Returns whether or not the outline renderer is ready for a given submesh.
  130392. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130393. * @param subMesh Defines the submesh to check readyness for
  130394. * @param useInstances Defines wheter wee are trying to render instances or not
  130395. * @returns true if ready otherwise false
  130396. */
  130397. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130398. private _beforeRenderingMesh;
  130399. private _afterRenderingMesh;
  130400. }
  130401. }
  130402. declare module BABYLON {
  130403. /**
  130404. * Class used to manage multiple sprites of different sizes on the same spritesheet
  130405. * @see http://doc.babylonjs.com/babylon101/sprites
  130406. */
  130407. export class SpritePackedManager extends SpriteManager {
  130408. /** defines the packed manager's name */
  130409. name: string;
  130410. /**
  130411. * Creates a new sprite manager from a packed sprite sheet
  130412. * @param name defines the manager's name
  130413. * @param imgUrl defines the sprite sheet url
  130414. * @param capacity defines the maximum allowed number of sprites
  130415. * @param scene defines the hosting scene
  130416. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  130417. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130418. * @param samplingMode defines the smapling mode to use with spritesheet
  130419. * @param fromPacked set to true; do not alter
  130420. */
  130421. constructor(
  130422. /** defines the packed manager's name */
  130423. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  130424. }
  130425. }
  130426. declare module BABYLON {
  130427. /**
  130428. * Defines the list of states available for a task inside a AssetsManager
  130429. */
  130430. export enum AssetTaskState {
  130431. /**
  130432. * Initialization
  130433. */
  130434. INIT = 0,
  130435. /**
  130436. * Running
  130437. */
  130438. RUNNING = 1,
  130439. /**
  130440. * Done
  130441. */
  130442. DONE = 2,
  130443. /**
  130444. * Error
  130445. */
  130446. ERROR = 3
  130447. }
  130448. /**
  130449. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  130450. */
  130451. export abstract class AbstractAssetTask {
  130452. /**
  130453. * Task name
  130454. */ name: string;
  130455. /**
  130456. * Callback called when the task is successful
  130457. */
  130458. onSuccess: (task: any) => void;
  130459. /**
  130460. * Callback called when the task is not successful
  130461. */
  130462. onError: (task: any, message?: string, exception?: any) => void;
  130463. /**
  130464. * Creates a new AssetsManager
  130465. * @param name defines the name of the task
  130466. */
  130467. constructor(
  130468. /**
  130469. * Task name
  130470. */ name: string);
  130471. private _isCompleted;
  130472. private _taskState;
  130473. private _errorObject;
  130474. /**
  130475. * Get if the task is completed
  130476. */
  130477. readonly isCompleted: boolean;
  130478. /**
  130479. * Gets the current state of the task
  130480. */
  130481. readonly taskState: AssetTaskState;
  130482. /**
  130483. * Gets the current error object (if task is in error)
  130484. */
  130485. readonly errorObject: {
  130486. message?: string;
  130487. exception?: any;
  130488. };
  130489. /**
  130490. * Internal only
  130491. * @hidden
  130492. */
  130493. _setErrorObject(message?: string, exception?: any): void;
  130494. /**
  130495. * Execute the current task
  130496. * @param scene defines the scene where you want your assets to be loaded
  130497. * @param onSuccess is a callback called when the task is successfully executed
  130498. * @param onError is a callback called if an error occurs
  130499. */
  130500. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130501. /**
  130502. * Execute the current task
  130503. * @param scene defines the scene where you want your assets to be loaded
  130504. * @param onSuccess is a callback called when the task is successfully executed
  130505. * @param onError is a callback called if an error occurs
  130506. */
  130507. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130508. /**
  130509. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  130510. * This can be used with failed tasks that have the reason for failure fixed.
  130511. */
  130512. reset(): void;
  130513. private onErrorCallback;
  130514. private onDoneCallback;
  130515. }
  130516. /**
  130517. * Define the interface used by progress events raised during assets loading
  130518. */
  130519. export interface IAssetsProgressEvent {
  130520. /**
  130521. * Defines the number of remaining tasks to process
  130522. */
  130523. remainingCount: number;
  130524. /**
  130525. * Defines the total number of tasks
  130526. */
  130527. totalCount: number;
  130528. /**
  130529. * Defines the task that was just processed
  130530. */
  130531. task: AbstractAssetTask;
  130532. }
  130533. /**
  130534. * Class used to share progress information about assets loading
  130535. */
  130536. export class AssetsProgressEvent implements IAssetsProgressEvent {
  130537. /**
  130538. * Defines the number of remaining tasks to process
  130539. */
  130540. remainingCount: number;
  130541. /**
  130542. * Defines the total number of tasks
  130543. */
  130544. totalCount: number;
  130545. /**
  130546. * Defines the task that was just processed
  130547. */
  130548. task: AbstractAssetTask;
  130549. /**
  130550. * Creates a AssetsProgressEvent
  130551. * @param remainingCount defines the number of remaining tasks to process
  130552. * @param totalCount defines the total number of tasks
  130553. * @param task defines the task that was just processed
  130554. */
  130555. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  130556. }
  130557. /**
  130558. * Define a task used by AssetsManager to load meshes
  130559. */
  130560. export class MeshAssetTask extends AbstractAssetTask {
  130561. /**
  130562. * Defines the name of the task
  130563. */
  130564. name: string;
  130565. /**
  130566. * Defines the list of mesh's names you want to load
  130567. */
  130568. meshesNames: any;
  130569. /**
  130570. * Defines the root url to use as a base to load your meshes and associated resources
  130571. */
  130572. rootUrl: string;
  130573. /**
  130574. * Defines the filename of the scene to load from
  130575. */
  130576. sceneFilename: string;
  130577. /**
  130578. * Gets the list of loaded meshes
  130579. */
  130580. loadedMeshes: Array<AbstractMesh>;
  130581. /**
  130582. * Gets the list of loaded particle systems
  130583. */
  130584. loadedParticleSystems: Array<IParticleSystem>;
  130585. /**
  130586. * Gets the list of loaded skeletons
  130587. */
  130588. loadedSkeletons: Array<Skeleton>;
  130589. /**
  130590. * Gets the list of loaded animation groups
  130591. */
  130592. loadedAnimationGroups: Array<AnimationGroup>;
  130593. /**
  130594. * Callback called when the task is successful
  130595. */
  130596. onSuccess: (task: MeshAssetTask) => void;
  130597. /**
  130598. * Callback called when the task is successful
  130599. */
  130600. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  130601. /**
  130602. * Creates a new MeshAssetTask
  130603. * @param name defines the name of the task
  130604. * @param meshesNames defines the list of mesh's names you want to load
  130605. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  130606. * @param sceneFilename defines the filename of the scene to load from
  130607. */
  130608. constructor(
  130609. /**
  130610. * Defines the name of the task
  130611. */
  130612. name: string,
  130613. /**
  130614. * Defines the list of mesh's names you want to load
  130615. */
  130616. meshesNames: any,
  130617. /**
  130618. * Defines the root url to use as a base to load your meshes and associated resources
  130619. */
  130620. rootUrl: string,
  130621. /**
  130622. * Defines the filename of the scene to load from
  130623. */
  130624. sceneFilename: string);
  130625. /**
  130626. * Execute the current task
  130627. * @param scene defines the scene where you want your assets to be loaded
  130628. * @param onSuccess is a callback called when the task is successfully executed
  130629. * @param onError is a callback called if an error occurs
  130630. */
  130631. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130632. }
  130633. /**
  130634. * Define a task used by AssetsManager to load text content
  130635. */
  130636. export class TextFileAssetTask extends AbstractAssetTask {
  130637. /**
  130638. * Defines the name of the task
  130639. */
  130640. name: string;
  130641. /**
  130642. * Defines the location of the file to load
  130643. */
  130644. url: string;
  130645. /**
  130646. * Gets the loaded text string
  130647. */
  130648. text: string;
  130649. /**
  130650. * Callback called when the task is successful
  130651. */
  130652. onSuccess: (task: TextFileAssetTask) => void;
  130653. /**
  130654. * Callback called when the task is successful
  130655. */
  130656. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  130657. /**
  130658. * Creates a new TextFileAssetTask object
  130659. * @param name defines the name of the task
  130660. * @param url defines the location of the file to load
  130661. */
  130662. constructor(
  130663. /**
  130664. * Defines the name of the task
  130665. */
  130666. name: string,
  130667. /**
  130668. * Defines the location of the file to load
  130669. */
  130670. url: string);
  130671. /**
  130672. * Execute the current task
  130673. * @param scene defines the scene where you want your assets to be loaded
  130674. * @param onSuccess is a callback called when the task is successfully executed
  130675. * @param onError is a callback called if an error occurs
  130676. */
  130677. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130678. }
  130679. /**
  130680. * Define a task used by AssetsManager to load binary data
  130681. */
  130682. export class BinaryFileAssetTask extends AbstractAssetTask {
  130683. /**
  130684. * Defines the name of the task
  130685. */
  130686. name: string;
  130687. /**
  130688. * Defines the location of the file to load
  130689. */
  130690. url: string;
  130691. /**
  130692. * Gets the lodaded data (as an array buffer)
  130693. */
  130694. data: ArrayBuffer;
  130695. /**
  130696. * Callback called when the task is successful
  130697. */
  130698. onSuccess: (task: BinaryFileAssetTask) => void;
  130699. /**
  130700. * Callback called when the task is successful
  130701. */
  130702. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  130703. /**
  130704. * Creates a new BinaryFileAssetTask object
  130705. * @param name defines the name of the new task
  130706. * @param url defines the location of the file to load
  130707. */
  130708. constructor(
  130709. /**
  130710. * Defines the name of the task
  130711. */
  130712. name: string,
  130713. /**
  130714. * Defines the location of the file to load
  130715. */
  130716. url: string);
  130717. /**
  130718. * Execute the current task
  130719. * @param scene defines the scene where you want your assets to be loaded
  130720. * @param onSuccess is a callback called when the task is successfully executed
  130721. * @param onError is a callback called if an error occurs
  130722. */
  130723. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130724. }
  130725. /**
  130726. * Define a task used by AssetsManager to load images
  130727. */
  130728. export class ImageAssetTask extends AbstractAssetTask {
  130729. /**
  130730. * Defines the name of the task
  130731. */
  130732. name: string;
  130733. /**
  130734. * Defines the location of the image to load
  130735. */
  130736. url: string;
  130737. /**
  130738. * Gets the loaded images
  130739. */
  130740. image: HTMLImageElement;
  130741. /**
  130742. * Callback called when the task is successful
  130743. */
  130744. onSuccess: (task: ImageAssetTask) => void;
  130745. /**
  130746. * Callback called when the task is successful
  130747. */
  130748. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  130749. /**
  130750. * Creates a new ImageAssetTask
  130751. * @param name defines the name of the task
  130752. * @param url defines the location of the image to load
  130753. */
  130754. constructor(
  130755. /**
  130756. * Defines the name of the task
  130757. */
  130758. name: string,
  130759. /**
  130760. * Defines the location of the image to load
  130761. */
  130762. url: string);
  130763. /**
  130764. * Execute the current task
  130765. * @param scene defines the scene where you want your assets to be loaded
  130766. * @param onSuccess is a callback called when the task is successfully executed
  130767. * @param onError is a callback called if an error occurs
  130768. */
  130769. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130770. }
  130771. /**
  130772. * Defines the interface used by texture loading tasks
  130773. */
  130774. export interface ITextureAssetTask<TEX extends BaseTexture> {
  130775. /**
  130776. * Gets the loaded texture
  130777. */
  130778. texture: TEX;
  130779. }
  130780. /**
  130781. * Define a task used by AssetsManager to load 2D textures
  130782. */
  130783. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  130784. /**
  130785. * Defines the name of the task
  130786. */
  130787. name: string;
  130788. /**
  130789. * Defines the location of the file to load
  130790. */
  130791. url: string;
  130792. /**
  130793. * Defines if mipmap should not be generated (default is false)
  130794. */
  130795. noMipmap?: boolean | undefined;
  130796. /**
  130797. * Defines if texture must be inverted on Y axis (default is false)
  130798. */
  130799. invertY?: boolean | undefined;
  130800. /**
  130801. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130802. */
  130803. samplingMode: number;
  130804. /**
  130805. * Gets the loaded texture
  130806. */
  130807. texture: Texture;
  130808. /**
  130809. * Callback called when the task is successful
  130810. */
  130811. onSuccess: (task: TextureAssetTask) => void;
  130812. /**
  130813. * Callback called when the task is successful
  130814. */
  130815. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  130816. /**
  130817. * Creates a new TextureAssetTask object
  130818. * @param name defines the name of the task
  130819. * @param url defines the location of the file to load
  130820. * @param noMipmap defines if mipmap should not be generated (default is false)
  130821. * @param invertY defines if texture must be inverted on Y axis (default is false)
  130822. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130823. */
  130824. constructor(
  130825. /**
  130826. * Defines the name of the task
  130827. */
  130828. name: string,
  130829. /**
  130830. * Defines the location of the file to load
  130831. */
  130832. url: string,
  130833. /**
  130834. * Defines if mipmap should not be generated (default is false)
  130835. */
  130836. noMipmap?: boolean | undefined,
  130837. /**
  130838. * Defines if texture must be inverted on Y axis (default is false)
  130839. */
  130840. invertY?: boolean | undefined,
  130841. /**
  130842. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130843. */
  130844. samplingMode?: number);
  130845. /**
  130846. * Execute the current task
  130847. * @param scene defines the scene where you want your assets to be loaded
  130848. * @param onSuccess is a callback called when the task is successfully executed
  130849. * @param onError is a callback called if an error occurs
  130850. */
  130851. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130852. }
  130853. /**
  130854. * Define a task used by AssetsManager to load cube textures
  130855. */
  130856. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  130857. /**
  130858. * Defines the name of the task
  130859. */
  130860. name: string;
  130861. /**
  130862. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130863. */
  130864. url: string;
  130865. /**
  130866. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130867. */
  130868. extensions?: string[] | undefined;
  130869. /**
  130870. * Defines if mipmaps should not be generated (default is false)
  130871. */
  130872. noMipmap?: boolean | undefined;
  130873. /**
  130874. * Defines the explicit list of files (undefined by default)
  130875. */
  130876. files?: string[] | undefined;
  130877. /**
  130878. * Gets the loaded texture
  130879. */
  130880. texture: CubeTexture;
  130881. /**
  130882. * Callback called when the task is successful
  130883. */
  130884. onSuccess: (task: CubeTextureAssetTask) => void;
  130885. /**
  130886. * Callback called when the task is successful
  130887. */
  130888. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  130889. /**
  130890. * Creates a new CubeTextureAssetTask
  130891. * @param name defines the name of the task
  130892. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130893. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130894. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130895. * @param files defines the explicit list of files (undefined by default)
  130896. */
  130897. constructor(
  130898. /**
  130899. * Defines the name of the task
  130900. */
  130901. name: string,
  130902. /**
  130903. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130904. */
  130905. url: string,
  130906. /**
  130907. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130908. */
  130909. extensions?: string[] | undefined,
  130910. /**
  130911. * Defines if mipmaps should not be generated (default is false)
  130912. */
  130913. noMipmap?: boolean | undefined,
  130914. /**
  130915. * Defines the explicit list of files (undefined by default)
  130916. */
  130917. files?: string[] | undefined);
  130918. /**
  130919. * Execute the current task
  130920. * @param scene defines the scene where you want your assets to be loaded
  130921. * @param onSuccess is a callback called when the task is successfully executed
  130922. * @param onError is a callback called if an error occurs
  130923. */
  130924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130925. }
  130926. /**
  130927. * Define a task used by AssetsManager to load HDR cube textures
  130928. */
  130929. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  130930. /**
  130931. * Defines the name of the task
  130932. */
  130933. name: string;
  130934. /**
  130935. * Defines the location of the file to load
  130936. */
  130937. url: string;
  130938. /**
  130939. * Defines the desired size (the more it increases the longer the generation will be)
  130940. */
  130941. size: number;
  130942. /**
  130943. * Defines if mipmaps should not be generated (default is false)
  130944. */
  130945. noMipmap: boolean;
  130946. /**
  130947. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130948. */
  130949. generateHarmonics: boolean;
  130950. /**
  130951. * 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)
  130952. */
  130953. gammaSpace: boolean;
  130954. /**
  130955. * Internal Use Only
  130956. */
  130957. reserved: boolean;
  130958. /**
  130959. * Gets the loaded texture
  130960. */
  130961. texture: HDRCubeTexture;
  130962. /**
  130963. * Callback called when the task is successful
  130964. */
  130965. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  130966. /**
  130967. * Callback called when the task is successful
  130968. */
  130969. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  130970. /**
  130971. * Creates a new HDRCubeTextureAssetTask object
  130972. * @param name defines the name of the task
  130973. * @param url defines the location of the file to load
  130974. * @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.
  130975. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130976. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130977. * @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)
  130978. * @param reserved Internal use only
  130979. */
  130980. constructor(
  130981. /**
  130982. * Defines the name of the task
  130983. */
  130984. name: string,
  130985. /**
  130986. * Defines the location of the file to load
  130987. */
  130988. url: string,
  130989. /**
  130990. * Defines the desired size (the more it increases the longer the generation will be)
  130991. */
  130992. size: number,
  130993. /**
  130994. * Defines if mipmaps should not be generated (default is false)
  130995. */
  130996. noMipmap?: boolean,
  130997. /**
  130998. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130999. */
  131000. generateHarmonics?: boolean,
  131001. /**
  131002. * 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)
  131003. */
  131004. gammaSpace?: boolean,
  131005. /**
  131006. * Internal Use Only
  131007. */
  131008. reserved?: boolean);
  131009. /**
  131010. * Execute the current task
  131011. * @param scene defines the scene where you want your assets to be loaded
  131012. * @param onSuccess is a callback called when the task is successfully executed
  131013. * @param onError is a callback called if an error occurs
  131014. */
  131015. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131016. }
  131017. /**
  131018. * Define a task used by AssetsManager to load Equirectangular cube textures
  131019. */
  131020. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131021. /**
  131022. * Defines the name of the task
  131023. */
  131024. name: string;
  131025. /**
  131026. * Defines the location of the file to load
  131027. */
  131028. url: string;
  131029. /**
  131030. * Defines the desired size (the more it increases the longer the generation will be)
  131031. */
  131032. size: number;
  131033. /**
  131034. * Defines if mipmaps should not be generated (default is false)
  131035. */
  131036. noMipmap: boolean;
  131037. /**
  131038. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131039. * but the standard material would require them in Gamma space) (default is true)
  131040. */
  131041. gammaSpace: boolean;
  131042. /**
  131043. * Gets the loaded texture
  131044. */
  131045. texture: EquiRectangularCubeTexture;
  131046. /**
  131047. * Callback called when the task is successful
  131048. */
  131049. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131050. /**
  131051. * Callback called when the task is successful
  131052. */
  131053. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131054. /**
  131055. * Creates a new EquiRectangularCubeTextureAssetTask object
  131056. * @param name defines the name of the task
  131057. * @param url defines the location of the file to load
  131058. * @param size defines the desired size (the more it increases the longer the generation will be)
  131059. * If the size is omitted this implies you are using a preprocessed cubemap.
  131060. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131061. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131062. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131063. * (default is true)
  131064. */
  131065. constructor(
  131066. /**
  131067. * Defines the name of the task
  131068. */
  131069. name: string,
  131070. /**
  131071. * Defines the location of the file to load
  131072. */
  131073. url: string,
  131074. /**
  131075. * Defines the desired size (the more it increases the longer the generation will be)
  131076. */
  131077. size: number,
  131078. /**
  131079. * Defines if mipmaps should not be generated (default is false)
  131080. */
  131081. noMipmap?: boolean,
  131082. /**
  131083. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131084. * but the standard material would require them in Gamma space) (default is true)
  131085. */
  131086. gammaSpace?: boolean);
  131087. /**
  131088. * Execute the current task
  131089. * @param scene defines the scene where you want your assets to be loaded
  131090. * @param onSuccess is a callback called when the task is successfully executed
  131091. * @param onError is a callback called if an error occurs
  131092. */
  131093. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131094. }
  131095. /**
  131096. * This class can be used to easily import assets into a scene
  131097. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131098. */
  131099. export class AssetsManager {
  131100. private _scene;
  131101. private _isLoading;
  131102. protected _tasks: AbstractAssetTask[];
  131103. protected _waitingTasksCount: number;
  131104. protected _totalTasksCount: number;
  131105. /**
  131106. * Callback called when all tasks are processed
  131107. */
  131108. onFinish: (tasks: AbstractAssetTask[]) => void;
  131109. /**
  131110. * Callback called when a task is successful
  131111. */
  131112. onTaskSuccess: (task: AbstractAssetTask) => void;
  131113. /**
  131114. * Callback called when a task had an error
  131115. */
  131116. onTaskError: (task: AbstractAssetTask) => void;
  131117. /**
  131118. * Callback called when a task is done (whatever the result is)
  131119. */
  131120. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131121. /**
  131122. * Observable called when all tasks are processed
  131123. */
  131124. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131125. /**
  131126. * Observable called when a task had an error
  131127. */
  131128. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131129. /**
  131130. * Observable called when all tasks were executed
  131131. */
  131132. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131133. /**
  131134. * Observable called when a task is done (whatever the result is)
  131135. */
  131136. onProgressObservable: Observable<IAssetsProgressEvent>;
  131137. /**
  131138. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131139. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131140. */
  131141. useDefaultLoadingScreen: boolean;
  131142. /**
  131143. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131144. * when all assets have been downloaded.
  131145. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131146. */
  131147. autoHideLoadingUI: boolean;
  131148. /**
  131149. * Creates a new AssetsManager
  131150. * @param scene defines the scene to work on
  131151. */
  131152. constructor(scene: Scene);
  131153. /**
  131154. * Add a MeshAssetTask to the list of active tasks
  131155. * @param taskName defines the name of the new task
  131156. * @param meshesNames defines the name of meshes to load
  131157. * @param rootUrl defines the root url to use to locate files
  131158. * @param sceneFilename defines the filename of the scene file
  131159. * @returns a new MeshAssetTask object
  131160. */
  131161. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131162. /**
  131163. * Add a TextFileAssetTask to the list of active tasks
  131164. * @param taskName defines the name of the new task
  131165. * @param url defines the url of the file to load
  131166. * @returns a new TextFileAssetTask object
  131167. */
  131168. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131169. /**
  131170. * Add a BinaryFileAssetTask to the list of active tasks
  131171. * @param taskName defines the name of the new task
  131172. * @param url defines the url of the file to load
  131173. * @returns a new BinaryFileAssetTask object
  131174. */
  131175. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131176. /**
  131177. * Add a ImageAssetTask to the list of active tasks
  131178. * @param taskName defines the name of the new task
  131179. * @param url defines the url of the file to load
  131180. * @returns a new ImageAssetTask object
  131181. */
  131182. addImageTask(taskName: string, url: string): ImageAssetTask;
  131183. /**
  131184. * Add a TextureAssetTask to the list of active tasks
  131185. * @param taskName defines the name of the new task
  131186. * @param url defines the url of the file to load
  131187. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131188. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  131189. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131190. * @returns a new TextureAssetTask object
  131191. */
  131192. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  131193. /**
  131194. * Add a CubeTextureAssetTask to the list of active tasks
  131195. * @param taskName defines the name of the new task
  131196. * @param url defines the url of the file to load
  131197. * @param extensions defines the extension to use to load the cube map (can be null)
  131198. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131199. * @param files defines the list of files to load (can be null)
  131200. * @returns a new CubeTextureAssetTask object
  131201. */
  131202. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131203. /**
  131204. *
  131205. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131206. * @param taskName defines the name of the new task
  131207. * @param url defines the url of the file to load
  131208. * @param size defines the size you want for the cubemap (can be null)
  131209. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131210. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131211. * @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)
  131212. * @param reserved Internal use only
  131213. * @returns a new HDRCubeTextureAssetTask object
  131214. */
  131215. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131216. /**
  131217. *
  131218. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131219. * @param taskName defines the name of the new task
  131220. * @param url defines the url of the file to load
  131221. * @param size defines the size you want for the cubemap (can be null)
  131222. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131223. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131224. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131225. * @returns a new EquiRectangularCubeTextureAssetTask object
  131226. */
  131227. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131228. /**
  131229. * Remove a task from the assets manager.
  131230. * @param task the task to remove
  131231. */
  131232. removeTask(task: AbstractAssetTask): void;
  131233. private _decreaseWaitingTasksCount;
  131234. private _runTask;
  131235. /**
  131236. * Reset the AssetsManager and remove all tasks
  131237. * @return the current instance of the AssetsManager
  131238. */
  131239. reset(): AssetsManager;
  131240. /**
  131241. * Start the loading process
  131242. * @return the current instance of the AssetsManager
  131243. */
  131244. load(): AssetsManager;
  131245. /**
  131246. * Start the loading process as an async operation
  131247. * @return a promise returning the list of failed tasks
  131248. */
  131249. loadAsync(): Promise<void>;
  131250. }
  131251. }
  131252. declare module BABYLON {
  131253. /**
  131254. * Wrapper class for promise with external resolve and reject.
  131255. */
  131256. export class Deferred<T> {
  131257. /**
  131258. * The promise associated with this deferred object.
  131259. */
  131260. readonly promise: Promise<T>;
  131261. private _resolve;
  131262. private _reject;
  131263. /**
  131264. * The resolve method of the promise associated with this deferred object.
  131265. */
  131266. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131267. /**
  131268. * The reject method of the promise associated with this deferred object.
  131269. */
  131270. readonly reject: (reason?: any) => void;
  131271. /**
  131272. * Constructor for this deferred object.
  131273. */
  131274. constructor();
  131275. }
  131276. }
  131277. declare module BABYLON {
  131278. /**
  131279. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  131280. */
  131281. export class MeshExploder {
  131282. private _centerMesh;
  131283. private _meshes;
  131284. private _meshesOrigins;
  131285. private _toCenterVectors;
  131286. private _scaledDirection;
  131287. private _newPosition;
  131288. private _centerPosition;
  131289. /**
  131290. * Explodes meshes from a center mesh.
  131291. * @param meshes The meshes to explode.
  131292. * @param centerMesh The mesh to be center of explosion.
  131293. */
  131294. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  131295. private _setCenterMesh;
  131296. /**
  131297. * Get class name
  131298. * @returns "MeshExploder"
  131299. */
  131300. getClassName(): string;
  131301. /**
  131302. * "Exploded meshes"
  131303. * @returns Array of meshes with the centerMesh at index 0.
  131304. */
  131305. getMeshes(): Array<Mesh>;
  131306. /**
  131307. * Explodes meshes giving a specific direction
  131308. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  131309. */
  131310. explode(direction?: number): void;
  131311. }
  131312. }
  131313. declare module BABYLON {
  131314. /**
  131315. * Class used to help managing file picking and drag'n'drop
  131316. */
  131317. export class FilesInput {
  131318. /**
  131319. * List of files ready to be loaded
  131320. */
  131321. static readonly FilesToLoad: {
  131322. [key: string]: File;
  131323. };
  131324. /**
  131325. * Callback called when a file is processed
  131326. */
  131327. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  131328. private _engine;
  131329. private _currentScene;
  131330. private _sceneLoadedCallback;
  131331. private _progressCallback;
  131332. private _additionalRenderLoopLogicCallback;
  131333. private _textureLoadingCallback;
  131334. private _startingProcessingFilesCallback;
  131335. private _onReloadCallback;
  131336. private _errorCallback;
  131337. private _elementToMonitor;
  131338. private _sceneFileToLoad;
  131339. private _filesToLoad;
  131340. /**
  131341. * Creates a new FilesInput
  131342. * @param engine defines the rendering engine
  131343. * @param scene defines the hosting scene
  131344. * @param sceneLoadedCallback callback called when scene is loaded
  131345. * @param progressCallback callback called to track progress
  131346. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  131347. * @param textureLoadingCallback callback called when a texture is loading
  131348. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  131349. * @param onReloadCallback callback called when a reload is requested
  131350. * @param errorCallback callback call if an error occurs
  131351. */
  131352. 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);
  131353. private _dragEnterHandler;
  131354. private _dragOverHandler;
  131355. private _dropHandler;
  131356. /**
  131357. * Calls this function to listen to drag'n'drop events on a specific DOM element
  131358. * @param elementToMonitor defines the DOM element to track
  131359. */
  131360. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  131361. /**
  131362. * Release all associated resources
  131363. */
  131364. dispose(): void;
  131365. private renderFunction;
  131366. private drag;
  131367. private drop;
  131368. private _traverseFolder;
  131369. private _processFiles;
  131370. /**
  131371. * Load files from a drop event
  131372. * @param event defines the drop event to use as source
  131373. */
  131374. loadFiles(event: any): void;
  131375. private _processReload;
  131376. /**
  131377. * Reload the current scene from the loaded files
  131378. */
  131379. reload(): void;
  131380. }
  131381. }
  131382. declare module BABYLON {
  131383. /**
  131384. * Defines the root class used to create scene optimization to use with SceneOptimizer
  131385. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131386. */
  131387. export class SceneOptimization {
  131388. /**
  131389. * Defines the priority of this optimization (0 by default which means first in the list)
  131390. */
  131391. priority: number;
  131392. /**
  131393. * Gets a string describing the action executed by the current optimization
  131394. * @returns description string
  131395. */
  131396. getDescription(): string;
  131397. /**
  131398. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131399. * @param scene defines the current scene where to apply this optimization
  131400. * @param optimizer defines the current optimizer
  131401. * @returns true if everything that can be done was applied
  131402. */
  131403. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131404. /**
  131405. * Creates the SceneOptimization object
  131406. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131407. * @param desc defines the description associated with the optimization
  131408. */
  131409. constructor(
  131410. /**
  131411. * Defines the priority of this optimization (0 by default which means first in the list)
  131412. */
  131413. priority?: number);
  131414. }
  131415. /**
  131416. * Defines an optimization used to reduce the size of render target textures
  131417. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131418. */
  131419. export class TextureOptimization extends SceneOptimization {
  131420. /**
  131421. * Defines the priority of this optimization (0 by default which means first in the list)
  131422. */
  131423. priority: number;
  131424. /**
  131425. * 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
  131426. */
  131427. maximumSize: number;
  131428. /**
  131429. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131430. */
  131431. step: number;
  131432. /**
  131433. * Gets a string describing the action executed by the current optimization
  131434. * @returns description string
  131435. */
  131436. getDescription(): string;
  131437. /**
  131438. * Creates the TextureOptimization object
  131439. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131440. * @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
  131441. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131442. */
  131443. constructor(
  131444. /**
  131445. * Defines the priority of this optimization (0 by default which means first in the list)
  131446. */
  131447. priority?: number,
  131448. /**
  131449. * 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
  131450. */
  131451. maximumSize?: number,
  131452. /**
  131453. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131454. */
  131455. step?: number);
  131456. /**
  131457. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131458. * @param scene defines the current scene where to apply this optimization
  131459. * @param optimizer defines the current optimizer
  131460. * @returns true if everything that can be done was applied
  131461. */
  131462. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131463. }
  131464. /**
  131465. * Defines an optimization used to increase or decrease the rendering resolution
  131466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131467. */
  131468. export class HardwareScalingOptimization extends SceneOptimization {
  131469. /**
  131470. * Defines the priority of this optimization (0 by default which means first in the list)
  131471. */
  131472. priority: number;
  131473. /**
  131474. * Defines the maximum scale to use (2 by default)
  131475. */
  131476. maximumScale: number;
  131477. /**
  131478. * Defines the step to use between two passes (0.5 by default)
  131479. */
  131480. step: number;
  131481. private _currentScale;
  131482. private _directionOffset;
  131483. /**
  131484. * Gets a string describing the action executed by the current optimization
  131485. * @return description string
  131486. */
  131487. getDescription(): string;
  131488. /**
  131489. * Creates the HardwareScalingOptimization object
  131490. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131491. * @param maximumScale defines the maximum scale to use (2 by default)
  131492. * @param step defines the step to use between two passes (0.5 by default)
  131493. */
  131494. constructor(
  131495. /**
  131496. * Defines the priority of this optimization (0 by default which means first in the list)
  131497. */
  131498. priority?: number,
  131499. /**
  131500. * Defines the maximum scale to use (2 by default)
  131501. */
  131502. maximumScale?: number,
  131503. /**
  131504. * Defines the step to use between two passes (0.5 by default)
  131505. */
  131506. step?: number);
  131507. /**
  131508. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131509. * @param scene defines the current scene where to apply this optimization
  131510. * @param optimizer defines the current optimizer
  131511. * @returns true if everything that can be done was applied
  131512. */
  131513. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131514. }
  131515. /**
  131516. * Defines an optimization used to remove shadows
  131517. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131518. */
  131519. export class ShadowsOptimization extends SceneOptimization {
  131520. /**
  131521. * Gets a string describing the action executed by the current optimization
  131522. * @return description string
  131523. */
  131524. getDescription(): string;
  131525. /**
  131526. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131527. * @param scene defines the current scene where to apply this optimization
  131528. * @param optimizer defines the current optimizer
  131529. * @returns true if everything that can be done was applied
  131530. */
  131531. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131532. }
  131533. /**
  131534. * Defines an optimization used to turn post-processes off
  131535. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131536. */
  131537. export class PostProcessesOptimization extends SceneOptimization {
  131538. /**
  131539. * Gets a string describing the action executed by the current optimization
  131540. * @return description string
  131541. */
  131542. getDescription(): string;
  131543. /**
  131544. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131545. * @param scene defines the current scene where to apply this optimization
  131546. * @param optimizer defines the current optimizer
  131547. * @returns true if everything that can be done was applied
  131548. */
  131549. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131550. }
  131551. /**
  131552. * Defines an optimization used to turn lens flares off
  131553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131554. */
  131555. export class LensFlaresOptimization extends SceneOptimization {
  131556. /**
  131557. * Gets a string describing the action executed by the current optimization
  131558. * @return description string
  131559. */
  131560. getDescription(): string;
  131561. /**
  131562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131563. * @param scene defines the current scene where to apply this optimization
  131564. * @param optimizer defines the current optimizer
  131565. * @returns true if everything that can be done was applied
  131566. */
  131567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131568. }
  131569. /**
  131570. * Defines an optimization based on user defined callback.
  131571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131572. */
  131573. export class CustomOptimization extends SceneOptimization {
  131574. /**
  131575. * Callback called to apply the custom optimization.
  131576. */
  131577. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  131578. /**
  131579. * Callback called to get custom description
  131580. */
  131581. onGetDescription: () => string;
  131582. /**
  131583. * Gets a string describing the action executed by the current optimization
  131584. * @returns description string
  131585. */
  131586. getDescription(): string;
  131587. /**
  131588. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131589. * @param scene defines the current scene where to apply this optimization
  131590. * @param optimizer defines the current optimizer
  131591. * @returns true if everything that can be done was applied
  131592. */
  131593. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131594. }
  131595. /**
  131596. * Defines an optimization used to turn particles off
  131597. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131598. */
  131599. export class ParticlesOptimization extends SceneOptimization {
  131600. /**
  131601. * Gets a string describing the action executed by the current optimization
  131602. * @return description string
  131603. */
  131604. getDescription(): string;
  131605. /**
  131606. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131607. * @param scene defines the current scene where to apply this optimization
  131608. * @param optimizer defines the current optimizer
  131609. * @returns true if everything that can be done was applied
  131610. */
  131611. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131612. }
  131613. /**
  131614. * Defines an optimization used to turn render targets off
  131615. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131616. */
  131617. export class RenderTargetsOptimization extends SceneOptimization {
  131618. /**
  131619. * Gets a string describing the action executed by the current optimization
  131620. * @return description string
  131621. */
  131622. getDescription(): string;
  131623. /**
  131624. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131625. * @param scene defines the current scene where to apply this optimization
  131626. * @param optimizer defines the current optimizer
  131627. * @returns true if everything that can be done was applied
  131628. */
  131629. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131630. }
  131631. /**
  131632. * Defines an optimization used to merge meshes with compatible materials
  131633. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131634. */
  131635. export class MergeMeshesOptimization extends SceneOptimization {
  131636. private static _UpdateSelectionTree;
  131637. /**
  131638. * Gets or sets a boolean which defines if optimization octree has to be updated
  131639. */
  131640. /**
  131641. * Gets or sets a boolean which defines if optimization octree has to be updated
  131642. */
  131643. static UpdateSelectionTree: boolean;
  131644. /**
  131645. * Gets a string describing the action executed by the current optimization
  131646. * @return description string
  131647. */
  131648. getDescription(): string;
  131649. private _canBeMerged;
  131650. /**
  131651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131652. * @param scene defines the current scene where to apply this optimization
  131653. * @param optimizer defines the current optimizer
  131654. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  131655. * @returns true if everything that can be done was applied
  131656. */
  131657. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  131658. }
  131659. /**
  131660. * Defines a list of options used by SceneOptimizer
  131661. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131662. */
  131663. export class SceneOptimizerOptions {
  131664. /**
  131665. * Defines the target frame rate to reach (60 by default)
  131666. */
  131667. targetFrameRate: number;
  131668. /**
  131669. * Defines the interval between two checkes (2000ms by default)
  131670. */
  131671. trackerDuration: number;
  131672. /**
  131673. * Gets the list of optimizations to apply
  131674. */
  131675. optimizations: SceneOptimization[];
  131676. /**
  131677. * Creates a new list of options used by SceneOptimizer
  131678. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  131679. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  131680. */
  131681. constructor(
  131682. /**
  131683. * Defines the target frame rate to reach (60 by default)
  131684. */
  131685. targetFrameRate?: number,
  131686. /**
  131687. * Defines the interval between two checkes (2000ms by default)
  131688. */
  131689. trackerDuration?: number);
  131690. /**
  131691. * Add a new optimization
  131692. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  131693. * @returns the current SceneOptimizerOptions
  131694. */
  131695. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  131696. /**
  131697. * Add a new custom optimization
  131698. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  131699. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  131700. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131701. * @returns the current SceneOptimizerOptions
  131702. */
  131703. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  131704. /**
  131705. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  131706. * @param targetFrameRate defines the target frame rate (60 by default)
  131707. * @returns a SceneOptimizerOptions object
  131708. */
  131709. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131710. /**
  131711. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  131712. * @param targetFrameRate defines the target frame rate (60 by default)
  131713. * @returns a SceneOptimizerOptions object
  131714. */
  131715. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131716. /**
  131717. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  131718. * @param targetFrameRate defines the target frame rate (60 by default)
  131719. * @returns a SceneOptimizerOptions object
  131720. */
  131721. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131722. }
  131723. /**
  131724. * Class used to run optimizations in order to reach a target frame rate
  131725. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131726. */
  131727. export class SceneOptimizer implements IDisposable {
  131728. private _isRunning;
  131729. private _options;
  131730. private _scene;
  131731. private _currentPriorityLevel;
  131732. private _targetFrameRate;
  131733. private _trackerDuration;
  131734. private _currentFrameRate;
  131735. private _sceneDisposeObserver;
  131736. private _improvementMode;
  131737. /**
  131738. * Defines an observable called when the optimizer reaches the target frame rate
  131739. */
  131740. onSuccessObservable: Observable<SceneOptimizer>;
  131741. /**
  131742. * Defines an observable called when the optimizer enables an optimization
  131743. */
  131744. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  131745. /**
  131746. * Defines an observable called when the optimizer is not able to reach the target frame rate
  131747. */
  131748. onFailureObservable: Observable<SceneOptimizer>;
  131749. /**
  131750. * Gets a boolean indicating if the optimizer is in improvement mode
  131751. */
  131752. readonly isInImprovementMode: boolean;
  131753. /**
  131754. * Gets the current priority level (0 at start)
  131755. */
  131756. readonly currentPriorityLevel: number;
  131757. /**
  131758. * Gets the current frame rate checked by the SceneOptimizer
  131759. */
  131760. readonly currentFrameRate: number;
  131761. /**
  131762. * Gets or sets the current target frame rate (60 by default)
  131763. */
  131764. /**
  131765. * Gets or sets the current target frame rate (60 by default)
  131766. */
  131767. targetFrameRate: number;
  131768. /**
  131769. * Gets or sets the current interval between two checks (every 2000ms by default)
  131770. */
  131771. /**
  131772. * Gets or sets the current interval between two checks (every 2000ms by default)
  131773. */
  131774. trackerDuration: number;
  131775. /**
  131776. * Gets the list of active optimizations
  131777. */
  131778. readonly optimizations: SceneOptimization[];
  131779. /**
  131780. * Creates a new SceneOptimizer
  131781. * @param scene defines the scene to work on
  131782. * @param options defines the options to use with the SceneOptimizer
  131783. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  131784. * @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)
  131785. */
  131786. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  131787. /**
  131788. * Stops the current optimizer
  131789. */
  131790. stop(): void;
  131791. /**
  131792. * Reset the optimizer to initial step (current priority level = 0)
  131793. */
  131794. reset(): void;
  131795. /**
  131796. * Start the optimizer. By default it will try to reach a specific framerate
  131797. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  131798. */
  131799. start(): void;
  131800. private _checkCurrentState;
  131801. /**
  131802. * Release all resources
  131803. */
  131804. dispose(): void;
  131805. /**
  131806. * Helper function to create a SceneOptimizer with one single line of code
  131807. * @param scene defines the scene to work on
  131808. * @param options defines the options to use with the SceneOptimizer
  131809. * @param onSuccess defines a callback to call on success
  131810. * @param onFailure defines a callback to call on failure
  131811. * @returns the new SceneOptimizer object
  131812. */
  131813. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  131814. }
  131815. }
  131816. declare module BABYLON {
  131817. /**
  131818. * Class used to serialize a scene into a string
  131819. */
  131820. export class SceneSerializer {
  131821. /**
  131822. * Clear cache used by a previous serialization
  131823. */
  131824. static ClearCache(): void;
  131825. /**
  131826. * Serialize a scene into a JSON compatible object
  131827. * @param scene defines the scene to serialize
  131828. * @returns a JSON compatible object
  131829. */
  131830. static Serialize(scene: Scene): any;
  131831. /**
  131832. * Serialize a mesh into a JSON compatible object
  131833. * @param toSerialize defines the mesh to serialize
  131834. * @param withParents defines if parents must be serialized as well
  131835. * @param withChildren defines if children must be serialized as well
  131836. * @returns a JSON compatible object
  131837. */
  131838. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  131839. }
  131840. }
  131841. declare module BABYLON {
  131842. /**
  131843. * Class used to host texture specific utilities
  131844. */
  131845. export class TextureTools {
  131846. /**
  131847. * Uses the GPU to create a copy texture rescaled at a given size
  131848. * @param texture Texture to copy from
  131849. * @param width defines the desired width
  131850. * @param height defines the desired height
  131851. * @param useBilinearMode defines if bilinear mode has to be used
  131852. * @return the generated texture
  131853. */
  131854. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  131855. }
  131856. }
  131857. declare module BABYLON {
  131858. /**
  131859. * This represents the different options available for the video capture.
  131860. */
  131861. export interface VideoRecorderOptions {
  131862. /** Defines the mime type of the video. */
  131863. mimeType: string;
  131864. /** Defines the FPS the video should be recorded at. */
  131865. fps: number;
  131866. /** Defines the chunk size for the recording data. */
  131867. recordChunckSize: number;
  131868. /** The audio tracks to attach to the recording. */
  131869. audioTracks?: MediaStreamTrack[];
  131870. }
  131871. /**
  131872. * This can help with recording videos from BabylonJS.
  131873. * This is based on the available WebRTC functionalities of the browser.
  131874. *
  131875. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  131876. */
  131877. export class VideoRecorder {
  131878. private static readonly _defaultOptions;
  131879. /**
  131880. * Returns whether or not the VideoRecorder is available in your browser.
  131881. * @param engine Defines the Babylon Engine.
  131882. * @returns true if supported otherwise false.
  131883. */
  131884. static IsSupported(engine: Engine): boolean;
  131885. private readonly _options;
  131886. private _canvas;
  131887. private _mediaRecorder;
  131888. private _recordedChunks;
  131889. private _fileName;
  131890. private _resolve;
  131891. private _reject;
  131892. /**
  131893. * True when a recording is already in progress.
  131894. */
  131895. readonly isRecording: boolean;
  131896. /**
  131897. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  131898. * @param engine Defines the BabylonJS Engine you wish to record.
  131899. * @param options Defines options that can be used to customize the capture.
  131900. */
  131901. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  131902. /**
  131903. * Stops the current recording before the default capture timeout passed in the startRecording function.
  131904. */
  131905. stopRecording(): void;
  131906. /**
  131907. * Starts recording the canvas for a max duration specified in parameters.
  131908. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  131909. * If null no automatic download will start and you can rely on the promise to get the data back.
  131910. * @param maxDuration Defines the maximum recording time in seconds.
  131911. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  131912. * @return A promise callback at the end of the recording with the video data in Blob.
  131913. */
  131914. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  131915. /**
  131916. * Releases internal resources used during the recording.
  131917. */
  131918. dispose(): void;
  131919. private _handleDataAvailable;
  131920. private _handleError;
  131921. private _handleStop;
  131922. }
  131923. }
  131924. declare module BABYLON {
  131925. /**
  131926. * Class containing a set of static utilities functions for screenshots
  131927. */
  131928. export class ScreenshotTools {
  131929. /**
  131930. * Captures a screenshot of the current rendering
  131931. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131932. * @param engine defines the rendering engine
  131933. * @param camera defines the source camera
  131934. * @param size This parameter can be set to a single number or to an object with the
  131935. * following (optional) properties: precision, width, height. If a single number is passed,
  131936. * it will be used for both width and height. If an object is passed, the screenshot size
  131937. * will be derived from the parameters. The precision property is a multiplier allowing
  131938. * rendering at a higher or lower resolution
  131939. * @param successCallback defines the callback receives a single parameter which contains the
  131940. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131941. * src parameter of an <img> to display it
  131942. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131943. * Check your browser for supported MIME types
  131944. */
  131945. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  131946. /**
  131947. * Captures a screenshot of the current rendering
  131948. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131949. * @param engine defines the rendering engine
  131950. * @param camera defines the source camera
  131951. * @param size This parameter can be set to a single number or to an object with the
  131952. * following (optional) properties: precision, width, height. If a single number is passed,
  131953. * it will be used for both width and height. If an object is passed, the screenshot size
  131954. * will be derived from the parameters. The precision property is a multiplier allowing
  131955. * rendering at a higher or lower resolution
  131956. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131957. * Check your browser for supported MIME types
  131958. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131959. * to the src parameter of an <img> to display it
  131960. */
  131961. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  131962. /**
  131963. * Generates an image screenshot from the specified camera.
  131964. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131965. * @param engine The engine to use for rendering
  131966. * @param camera The camera to use for rendering
  131967. * @param size This parameter can be set to a single number or to an object with the
  131968. * following (optional) properties: precision, width, height. If a single number is passed,
  131969. * it will be used for both width and height. If an object is passed, the screenshot size
  131970. * will be derived from the parameters. The precision property is a multiplier allowing
  131971. * rendering at a higher or lower resolution
  131972. * @param successCallback The callback receives a single parameter which contains the
  131973. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131974. * src parameter of an <img> to display it
  131975. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131976. * Check your browser for supported MIME types
  131977. * @param samples Texture samples (default: 1)
  131978. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131979. * @param fileName A name for for the downloaded file.
  131980. */
  131981. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  131982. /**
  131983. * Generates an image screenshot from the specified camera.
  131984. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131985. * @param engine The engine to use for rendering
  131986. * @param camera The camera to use for rendering
  131987. * @param size This parameter can be set to a single number or to an object with the
  131988. * following (optional) properties: precision, width, height. If a single number is passed,
  131989. * it will be used for both width and height. If an object is passed, the screenshot size
  131990. * will be derived from the parameters. The precision property is a multiplier allowing
  131991. * rendering at a higher or lower resolution
  131992. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131993. * Check your browser for supported MIME types
  131994. * @param samples Texture samples (default: 1)
  131995. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131996. * @param fileName A name for for the downloaded file.
  131997. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131998. * to the src parameter of an <img> to display it
  131999. */
  132000. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132001. /**
  132002. * Gets height and width for screenshot size
  132003. * @private
  132004. */
  132005. private static _getScreenshotSize;
  132006. }
  132007. }
  132008. declare module BABYLON {
  132009. /**
  132010. * Interface for a data buffer
  132011. */
  132012. export interface IDataBuffer {
  132013. /**
  132014. * Reads bytes from the data buffer.
  132015. * @param byteOffset The byte offset to read
  132016. * @param byteLength The byte length to read
  132017. * @returns A promise that resolves when the bytes are read
  132018. */
  132019. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132020. /**
  132021. * The byte length of the buffer.
  132022. */
  132023. readonly byteLength: number;
  132024. }
  132025. /**
  132026. * Utility class for reading from a data buffer
  132027. */
  132028. export class DataReader {
  132029. /**
  132030. * The data buffer associated with this data reader.
  132031. */
  132032. readonly buffer: IDataBuffer;
  132033. /**
  132034. * The current byte offset from the beginning of the data buffer.
  132035. */
  132036. byteOffset: number;
  132037. private _dataView;
  132038. private _dataByteOffset;
  132039. /**
  132040. * Constructor
  132041. * @param buffer The buffer to read
  132042. */
  132043. constructor(buffer: IDataBuffer);
  132044. /**
  132045. * Loads the given byte length.
  132046. * @param byteLength The byte length to load
  132047. * @returns A promise that resolves when the load is complete
  132048. */
  132049. loadAsync(byteLength: number): Promise<void>;
  132050. /**
  132051. * Read a unsigned 32-bit integer from the currently loaded data range.
  132052. * @returns The 32-bit integer read
  132053. */
  132054. readUint32(): number;
  132055. /**
  132056. * Read a byte array from the currently loaded data range.
  132057. * @param byteLength The byte length to read
  132058. * @returns The byte array read
  132059. */
  132060. readUint8Array(byteLength: number): Uint8Array;
  132061. /**
  132062. * Read a string from the currently loaded data range.
  132063. * @param byteLength The byte length to read
  132064. * @returns The string read
  132065. */
  132066. readString(byteLength: number): string;
  132067. /**
  132068. * Skips the given byte length the currently loaded data range.
  132069. * @param byteLength The byte length to skip
  132070. */
  132071. skipBytes(byteLength: number): void;
  132072. }
  132073. }
  132074. declare module BABYLON {
  132075. /**
  132076. * A cursor which tracks a point on a path
  132077. */
  132078. export class PathCursor {
  132079. private path;
  132080. /**
  132081. * Stores path cursor callbacks for when an onchange event is triggered
  132082. */
  132083. private _onchange;
  132084. /**
  132085. * The value of the path cursor
  132086. */
  132087. value: number;
  132088. /**
  132089. * The animation array of the path cursor
  132090. */
  132091. animations: Animation[];
  132092. /**
  132093. * Initializes the path cursor
  132094. * @param path The path to track
  132095. */
  132096. constructor(path: Path2);
  132097. /**
  132098. * Gets the cursor point on the path
  132099. * @returns A point on the path cursor at the cursor location
  132100. */
  132101. getPoint(): Vector3;
  132102. /**
  132103. * Moves the cursor ahead by the step amount
  132104. * @param step The amount to move the cursor forward
  132105. * @returns This path cursor
  132106. */
  132107. moveAhead(step?: number): PathCursor;
  132108. /**
  132109. * Moves the cursor behind by the step amount
  132110. * @param step The amount to move the cursor back
  132111. * @returns This path cursor
  132112. */
  132113. moveBack(step?: number): PathCursor;
  132114. /**
  132115. * Moves the cursor by the step amount
  132116. * If the step amount is greater than one, an exception is thrown
  132117. * @param step The amount to move the cursor
  132118. * @returns This path cursor
  132119. */
  132120. move(step: number): PathCursor;
  132121. /**
  132122. * Ensures that the value is limited between zero and one
  132123. * @returns This path cursor
  132124. */
  132125. private ensureLimits;
  132126. /**
  132127. * Runs onchange callbacks on change (used by the animation engine)
  132128. * @returns This path cursor
  132129. */
  132130. private raiseOnChange;
  132131. /**
  132132. * Executes a function on change
  132133. * @param f A path cursor onchange callback
  132134. * @returns This path cursor
  132135. */
  132136. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132137. }
  132138. }
  132139. declare module BABYLON {
  132140. /** @hidden */
  132141. export var blurPixelShader: {
  132142. name: string;
  132143. shader: string;
  132144. };
  132145. }
  132146. declare module BABYLON {
  132147. /** @hidden */
  132148. export var pointCloudVertexDeclaration: {
  132149. name: string;
  132150. shader: string;
  132151. };
  132152. }
  132153. // Mixins
  132154. interface Window {
  132155. mozIndexedDB: IDBFactory;
  132156. webkitIndexedDB: IDBFactory;
  132157. msIndexedDB: IDBFactory;
  132158. webkitURL: typeof URL;
  132159. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132160. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132161. WebGLRenderingContext: WebGLRenderingContext;
  132162. MSGesture: MSGesture;
  132163. CANNON: any;
  132164. AudioContext: AudioContext;
  132165. webkitAudioContext: AudioContext;
  132166. PointerEvent: any;
  132167. Math: Math;
  132168. Uint8Array: Uint8ArrayConstructor;
  132169. Float32Array: Float32ArrayConstructor;
  132170. mozURL: typeof URL;
  132171. msURL: typeof URL;
  132172. VRFrameData: any; // WebVR, from specs 1.1
  132173. DracoDecoderModule: any;
  132174. setImmediate(handler: (...args: any[]) => void): number;
  132175. }
  132176. interface HTMLCanvasElement {
  132177. requestPointerLock(): void;
  132178. msRequestPointerLock?(): void;
  132179. mozRequestPointerLock?(): void;
  132180. webkitRequestPointerLock?(): void;
  132181. /** Track wether a record is in progress */
  132182. isRecording: boolean;
  132183. /** Capture Stream method defined by some browsers */
  132184. captureStream(fps?: number): MediaStream;
  132185. }
  132186. interface CanvasRenderingContext2D {
  132187. msImageSmoothingEnabled: boolean;
  132188. }
  132189. interface MouseEvent {
  132190. mozMovementX: number;
  132191. mozMovementY: number;
  132192. webkitMovementX: number;
  132193. webkitMovementY: number;
  132194. msMovementX: number;
  132195. msMovementY: number;
  132196. }
  132197. interface Navigator {
  132198. mozGetVRDevices: (any: any) => any;
  132199. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132200. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132201. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132202. webkitGetGamepads(): Gamepad[];
  132203. msGetGamepads(): Gamepad[];
  132204. webkitGamepads(): Gamepad[];
  132205. }
  132206. interface HTMLVideoElement {
  132207. mozSrcObject: any;
  132208. }
  132209. interface Math {
  132210. fround(x: number): number;
  132211. imul(a: number, b: number): number;
  132212. }
  132213. interface WebGLRenderingContext {
  132214. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132215. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132216. vertexAttribDivisor(index: number, divisor: number): void;
  132217. createVertexArray(): any;
  132218. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132219. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132220. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132221. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132222. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132223. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132224. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132225. // Queries
  132226. createQuery(): WebGLQuery;
  132227. deleteQuery(query: WebGLQuery): void;
  132228. beginQuery(target: number, query: WebGLQuery): void;
  132229. endQuery(target: number): void;
  132230. getQueryParameter(query: WebGLQuery, pname: number): any;
  132231. getQuery(target: number, pname: number): any;
  132232. MAX_SAMPLES: number;
  132233. RGBA8: number;
  132234. READ_FRAMEBUFFER: number;
  132235. DRAW_FRAMEBUFFER: number;
  132236. UNIFORM_BUFFER: number;
  132237. HALF_FLOAT_OES: number;
  132238. RGBA16F: number;
  132239. RGBA32F: number;
  132240. R32F: number;
  132241. RG32F: number;
  132242. RGB32F: number;
  132243. R16F: number;
  132244. RG16F: number;
  132245. RGB16F: number;
  132246. RED: number;
  132247. RG: number;
  132248. R8: number;
  132249. RG8: number;
  132250. UNSIGNED_INT_24_8: number;
  132251. DEPTH24_STENCIL8: number;
  132252. MIN: number;
  132253. MAX: number;
  132254. /* Multiple Render Targets */
  132255. drawBuffers(buffers: number[]): void;
  132256. readBuffer(src: number): void;
  132257. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132258. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132259. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132260. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132261. // Occlusion Query
  132262. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132263. ANY_SAMPLES_PASSED: number;
  132264. QUERY_RESULT_AVAILABLE: number;
  132265. QUERY_RESULT: number;
  132266. }
  132267. interface WebGLProgram {
  132268. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132269. }
  132270. interface EXT_disjoint_timer_query {
  132271. QUERY_COUNTER_BITS_EXT: number;
  132272. TIME_ELAPSED_EXT: number;
  132273. TIMESTAMP_EXT: number;
  132274. GPU_DISJOINT_EXT: number;
  132275. QUERY_RESULT_EXT: number;
  132276. QUERY_RESULT_AVAILABLE_EXT: number;
  132277. queryCounterEXT(query: WebGLQuery, target: number): void;
  132278. createQueryEXT(): WebGLQuery;
  132279. beginQueryEXT(target: number, query: WebGLQuery): void;
  132280. endQueryEXT(target: number): void;
  132281. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  132282. deleteQueryEXT(query: WebGLQuery): void;
  132283. }
  132284. interface WebGLUniformLocation {
  132285. _currentState: any;
  132286. }
  132287. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  132288. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  132289. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  132290. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132291. interface WebGLRenderingContext {
  132292. readonly RASTERIZER_DISCARD: number;
  132293. readonly DEPTH_COMPONENT24: number;
  132294. readonly TEXTURE_3D: number;
  132295. readonly TEXTURE_2D_ARRAY: number;
  132296. readonly TEXTURE_COMPARE_FUNC: number;
  132297. readonly TEXTURE_COMPARE_MODE: number;
  132298. readonly COMPARE_REF_TO_TEXTURE: number;
  132299. readonly TEXTURE_WRAP_R: number;
  132300. readonly HALF_FLOAT: number;
  132301. readonly RGB8: number;
  132302. readonly RED_INTEGER: number;
  132303. readonly RG_INTEGER: number;
  132304. readonly RGB_INTEGER: number;
  132305. readonly RGBA_INTEGER: number;
  132306. readonly R8_SNORM: number;
  132307. readonly RG8_SNORM: number;
  132308. readonly RGB8_SNORM: number;
  132309. readonly RGBA8_SNORM: number;
  132310. readonly R8I: number;
  132311. readonly RG8I: number;
  132312. readonly RGB8I: number;
  132313. readonly RGBA8I: number;
  132314. readonly R8UI: number;
  132315. readonly RG8UI: number;
  132316. readonly RGB8UI: number;
  132317. readonly RGBA8UI: number;
  132318. readonly R16I: number;
  132319. readonly RG16I: number;
  132320. readonly RGB16I: number;
  132321. readonly RGBA16I: number;
  132322. readonly R16UI: number;
  132323. readonly RG16UI: number;
  132324. readonly RGB16UI: number;
  132325. readonly RGBA16UI: number;
  132326. readonly R32I: number;
  132327. readonly RG32I: number;
  132328. readonly RGB32I: number;
  132329. readonly RGBA32I: number;
  132330. readonly R32UI: number;
  132331. readonly RG32UI: number;
  132332. readonly RGB32UI: number;
  132333. readonly RGBA32UI: number;
  132334. readonly RGB10_A2UI: number;
  132335. readonly R11F_G11F_B10F: number;
  132336. readonly RGB9_E5: number;
  132337. readonly RGB10_A2: number;
  132338. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  132339. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  132340. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  132341. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  132342. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  132343. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  132344. 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;
  132345. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  132346. readonly TRANSFORM_FEEDBACK: number;
  132347. readonly INTERLEAVED_ATTRIBS: number;
  132348. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  132349. createTransformFeedback(): WebGLTransformFeedback;
  132350. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  132351. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  132352. beginTransformFeedback(primitiveMode: number): void;
  132353. endTransformFeedback(): void;
  132354. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  132355. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132356. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132357. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132358. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  132359. }
  132360. interface ImageBitmap {
  132361. readonly width: number;
  132362. readonly height: number;
  132363. close(): void;
  132364. }
  132365. interface WebGLQuery extends WebGLObject {
  132366. }
  132367. declare var WebGLQuery: {
  132368. prototype: WebGLQuery;
  132369. new(): WebGLQuery;
  132370. };
  132371. interface WebGLSampler extends WebGLObject {
  132372. }
  132373. declare var WebGLSampler: {
  132374. prototype: WebGLSampler;
  132375. new(): WebGLSampler;
  132376. };
  132377. interface WebGLSync extends WebGLObject {
  132378. }
  132379. declare var WebGLSync: {
  132380. prototype: WebGLSync;
  132381. new(): WebGLSync;
  132382. };
  132383. interface WebGLTransformFeedback extends WebGLObject {
  132384. }
  132385. declare var WebGLTransformFeedback: {
  132386. prototype: WebGLTransformFeedback;
  132387. new(): WebGLTransformFeedback;
  132388. };
  132389. interface WebGLVertexArrayObject extends WebGLObject {
  132390. }
  132391. declare var WebGLVertexArrayObject: {
  132392. prototype: WebGLVertexArrayObject;
  132393. new(): WebGLVertexArrayObject;
  132394. };
  132395. // Type definitions for WebVR API
  132396. // Project: https://w3c.github.io/webvr/
  132397. // Definitions by: six a <https://github.com/lostfictions>
  132398. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132399. interface VRDisplay extends EventTarget {
  132400. /**
  132401. * Dictionary of capabilities describing the VRDisplay.
  132402. */
  132403. readonly capabilities: VRDisplayCapabilities;
  132404. /**
  132405. * z-depth defining the far plane of the eye view frustum
  132406. * enables mapping of values in the render target depth
  132407. * attachment to scene coordinates. Initially set to 10000.0.
  132408. */
  132409. depthFar: number;
  132410. /**
  132411. * z-depth defining the near plane of the eye view frustum
  132412. * enables mapping of values in the render target depth
  132413. * attachment to scene coordinates. Initially set to 0.01.
  132414. */
  132415. depthNear: number;
  132416. /**
  132417. * An identifier for this distinct VRDisplay. Used as an
  132418. * association point in the Gamepad API.
  132419. */
  132420. readonly displayId: number;
  132421. /**
  132422. * A display name, a user-readable name identifying it.
  132423. */
  132424. readonly displayName: string;
  132425. readonly isConnected: boolean;
  132426. readonly isPresenting: boolean;
  132427. /**
  132428. * If this VRDisplay supports room-scale experiences, the optional
  132429. * stage attribute contains details on the room-scale parameters.
  132430. */
  132431. readonly stageParameters: VRStageParameters | null;
  132432. /**
  132433. * Passing the value returned by `requestAnimationFrame` to
  132434. * `cancelAnimationFrame` will unregister the callback.
  132435. * @param handle Define the hanle of the request to cancel
  132436. */
  132437. cancelAnimationFrame(handle: number): void;
  132438. /**
  132439. * Stops presenting to the VRDisplay.
  132440. * @returns a promise to know when it stopped
  132441. */
  132442. exitPresent(): Promise<void>;
  132443. /**
  132444. * Return the current VREyeParameters for the given eye.
  132445. * @param whichEye Define the eye we want the parameter for
  132446. * @returns the eye parameters
  132447. */
  132448. getEyeParameters(whichEye: string): VREyeParameters;
  132449. /**
  132450. * Populates the passed VRFrameData with the information required to render
  132451. * the current frame.
  132452. * @param frameData Define the data structure to populate
  132453. * @returns true if ok otherwise false
  132454. */
  132455. getFrameData(frameData: VRFrameData): boolean;
  132456. /**
  132457. * Get the layers currently being presented.
  132458. * @returns the list of VR layers
  132459. */
  132460. getLayers(): VRLayer[];
  132461. /**
  132462. * Return a VRPose containing the future predicted pose of the VRDisplay
  132463. * when the current frame will be presented. The value returned will not
  132464. * change until JavaScript has returned control to the browser.
  132465. *
  132466. * The VRPose will contain the position, orientation, velocity,
  132467. * and acceleration of each of these properties.
  132468. * @returns the pose object
  132469. */
  132470. getPose(): VRPose;
  132471. /**
  132472. * Return the current instantaneous pose of the VRDisplay, with no
  132473. * prediction applied.
  132474. * @returns the current instantaneous pose
  132475. */
  132476. getImmediatePose(): VRPose;
  132477. /**
  132478. * The callback passed to `requestAnimationFrame` will be called
  132479. * any time a new frame should be rendered. When the VRDisplay is
  132480. * presenting the callback will be called at the native refresh
  132481. * rate of the HMD. When not presenting this function acts
  132482. * identically to how window.requestAnimationFrame acts. Content should
  132483. * make no assumptions of frame rate or vsync behavior as the HMD runs
  132484. * asynchronously from other displays and at differing refresh rates.
  132485. * @param callback Define the eaction to run next frame
  132486. * @returns the request handle it
  132487. */
  132488. requestAnimationFrame(callback: FrameRequestCallback): number;
  132489. /**
  132490. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  132491. * Repeat calls while already presenting will update the VRLayers being displayed.
  132492. * @param layers Define the list of layer to present
  132493. * @returns a promise to know when the request has been fulfilled
  132494. */
  132495. requestPresent(layers: VRLayer[]): Promise<void>;
  132496. /**
  132497. * Reset the pose for this display, treating its current position and
  132498. * orientation as the "origin/zero" values. VRPose.position,
  132499. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  132500. * updated when calling resetPose(). This should be called in only
  132501. * sitting-space experiences.
  132502. */
  132503. resetPose(): void;
  132504. /**
  132505. * The VRLayer provided to the VRDisplay will be captured and presented
  132506. * in the HMD. Calling this function has the same effect on the source
  132507. * canvas as any other operation that uses its source image, and canvases
  132508. * created without preserveDrawingBuffer set to true will be cleared.
  132509. * @param pose Define the pose to submit
  132510. */
  132511. submitFrame(pose?: VRPose): void;
  132512. }
  132513. declare var VRDisplay: {
  132514. prototype: VRDisplay;
  132515. new(): VRDisplay;
  132516. };
  132517. interface VRLayer {
  132518. leftBounds?: number[] | Float32Array | null;
  132519. rightBounds?: number[] | Float32Array | null;
  132520. source?: HTMLCanvasElement | null;
  132521. }
  132522. interface VRDisplayCapabilities {
  132523. readonly canPresent: boolean;
  132524. readonly hasExternalDisplay: boolean;
  132525. readonly hasOrientation: boolean;
  132526. readonly hasPosition: boolean;
  132527. readonly maxLayers: number;
  132528. }
  132529. interface VREyeParameters {
  132530. /** @deprecated */
  132531. readonly fieldOfView: VRFieldOfView;
  132532. readonly offset: Float32Array;
  132533. readonly renderHeight: number;
  132534. readonly renderWidth: number;
  132535. }
  132536. interface VRFieldOfView {
  132537. readonly downDegrees: number;
  132538. readonly leftDegrees: number;
  132539. readonly rightDegrees: number;
  132540. readonly upDegrees: number;
  132541. }
  132542. interface VRFrameData {
  132543. readonly leftProjectionMatrix: Float32Array;
  132544. readonly leftViewMatrix: Float32Array;
  132545. readonly pose: VRPose;
  132546. readonly rightProjectionMatrix: Float32Array;
  132547. readonly rightViewMatrix: Float32Array;
  132548. readonly timestamp: number;
  132549. }
  132550. interface VRPose {
  132551. readonly angularAcceleration: Float32Array | null;
  132552. readonly angularVelocity: Float32Array | null;
  132553. readonly linearAcceleration: Float32Array | null;
  132554. readonly linearVelocity: Float32Array | null;
  132555. readonly orientation: Float32Array | null;
  132556. readonly position: Float32Array | null;
  132557. readonly timestamp: number;
  132558. }
  132559. interface VRStageParameters {
  132560. sittingToStandingTransform?: Float32Array;
  132561. sizeX?: number;
  132562. sizeY?: number;
  132563. }
  132564. interface Navigator {
  132565. getVRDisplays(): Promise<VRDisplay[]>;
  132566. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  132567. }
  132568. interface Window {
  132569. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  132570. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  132571. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  132572. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132573. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132574. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  132575. }
  132576. interface Gamepad {
  132577. readonly displayId: number;
  132578. }
  132579. type XRSessionMode =
  132580. | "inline"
  132581. | "immersive-vr"
  132582. | "immersive-ar";
  132583. type XRReferenceSpaceType =
  132584. | "viewer"
  132585. | "local"
  132586. | "local-floor"
  132587. | "bounded-floor"
  132588. | "unbounded";
  132589. type XREnvironmentBlendMode =
  132590. | "opaque"
  132591. | "additive"
  132592. | "alpha-blend";
  132593. type XRVisibilityState =
  132594. | "visible"
  132595. | "visible-blurred"
  132596. | "hidden";
  132597. type XRHandedness =
  132598. | "none"
  132599. | "left"
  132600. | "right";
  132601. type XRTargetRayMode =
  132602. | "gaze"
  132603. | "tracked-pointer"
  132604. | "screen";
  132605. type XREye =
  132606. | "none"
  132607. | "left"
  132608. | "right";
  132609. interface XRSpace extends EventTarget {
  132610. }
  132611. interface XRRenderState {
  132612. depthNear?: number;
  132613. depthFar?: number;
  132614. inlineVerticalFieldOfView?: number;
  132615. baseLayer?: XRWebGLLayer;
  132616. }
  132617. interface XRInputSource {
  132618. handedness: XRHandedness;
  132619. targetRayMode: XRTargetRayMode;
  132620. targetRaySpace: XRSpace;
  132621. gripSpace: XRSpace | undefined;
  132622. gamepad: Gamepad | undefined;
  132623. profiles: Array<string>;
  132624. }
  132625. interface XRSession {
  132626. addEventListener: Function;
  132627. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132628. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  132629. requestAnimationFrame: Function;
  132630. end(): Promise<void>;
  132631. renderState: XRRenderState;
  132632. inputSources: Array<XRInputSource>;
  132633. }
  132634. interface XRReferenceSpace extends XRSpace {
  132635. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  132636. onreset: any;
  132637. }
  132638. interface XRFrame {
  132639. session: XRSession;
  132640. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  132641. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  132642. }
  132643. interface XRViewerPose extends XRPose {
  132644. views: Array<XRView>;
  132645. }
  132646. interface XRPose {
  132647. transform: XRRigidTransform;
  132648. emulatedPosition: boolean;
  132649. }
  132650. declare var XRWebGLLayer: {
  132651. prototype: XRWebGLLayer;
  132652. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  132653. };
  132654. interface XRWebGLLayer {
  132655. framebuffer: WebGLFramebuffer;
  132656. framebufferWidth: number;
  132657. framebufferHeight: number;
  132658. getViewport: Function;
  132659. }
  132660. interface XRRigidTransform {
  132661. position: DOMPointReadOnly;
  132662. orientation: DOMPointReadOnly;
  132663. matrix: Float32Array;
  132664. inverse: XRRigidTransform;
  132665. }
  132666. interface XRView {
  132667. eye: XREye;
  132668. projectionMatrix: Float32Array;
  132669. transform: XRRigidTransform;
  132670. }
  132671. interface XRInputSourceChangeEvent {
  132672. session: XRSession;
  132673. removed: Array<XRInputSource>;
  132674. added: Array<XRInputSource>;
  132675. }